Skip to content

Commit

Permalink
Add document for bitmap with empty segment and smaller than 1KiB segm…
Browse files Browse the repository at this point in the history
…ent (#234)

* Add document for bitmap with empty segment and smaller than 1KiB segment

* Update community/data-structure-on-rocksdb.md

* Update community/data-structure-on-rocksdb.md

Co-authored-by: Twice <[email protected]>

---------

Co-authored-by: Twice <[email protected]>
  • Loading branch information
mapleFU and PragmaTwice authored Jul 23, 2024
1 parent f1350d8 commit 53bf83c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions community/data-structure-on-rocksdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ key|version|index => | fragment |

When the user requests to get it of position P, Kvrocks would first fetch the metadata with bitmap's key and calculate the index of the fragment with bit position, then fetch the bitmap fragment with composed key and find the bit in fragment offset. For example, `getbit bitmap 8193`, the fragment index is `1` (8193/8192) and subkey is `bitmap|1|1024` (when the version is 1, and fragment index is `1`, kvrocks will use `1 * 1024` as the index key), then fetch the subkey from RocksDB and check if the bit of offset `1`(8193%8192) is set or not.

A nonexistent segment means all bits are 0 in this segment. The bitmap design is very efficient when the bitmap is sparse. Besides, a segment could be less than 1KiB, and the "padding" bits are always regarded as 0.

## SortedInt

SortedInt is a set with members being type int and sorted in ascending order:
Expand Down

0 comments on commit 53bf83c

Please sign in to comment.