Skip to content

BitvecFlags: bitvec container with dynamic mmap flags storage - #6990

Merged
timvisee merged 10 commits into
devfrom
bitvec-flags
Aug 7, 2025
Merged

timvisee merged 10 commits into
devfrom
bitvec-flags

Conversation

@coszio

@coszio coszio commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

This PR extracts the BufferedDynamicFlags logic into its own structure, which buffers writes and can only write to disk manually.

To handle reads, two new structures have been created:

  • RoaringFlags: uses the BufferedDynamicFlags as storage only, and keeps a RoaringBitmap in memory for reads.
  • BitvecFlags: same BufferedDynamicFlags storage, but with a BitVec in memory for reads.

This enables the flexibility of choosing the in-memory structure. For example, vector storages need a reference to a bitslice, which can only be provided by BitvecFlags. On the other hand, null index benefits from lower memory overhead and does not need a bitslice explicitly.

@coszio
coszio requested review from generall and timvisee August 6, 2025 18:47
@coderabbitai

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Comment thread lib/segment/src/common/bitvec_flags.rs Resolved
Comment thread lib/segment/src/common/roaring_flags.rs Resolved
coderabbitai[bot]

This comment was marked as resolved.

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

I carefully checked the way we handle the length of structures here, as it's important for reliable iterators. While there's a bit of indirection there, everything looks sound.

Comment thread lib/segment/src/common/bitvec_flags.rs Resolved
@timvisee timvisee self-assigned this Aug 7, 2025
@timvisee
timvisee merged commit 6344ab8 into dev Aug 7, 2025
@timvisee
timvisee deleted the bitvec-flags branch August 7, 2025 09:30
timvisee added a commit that referenced this pull request Aug 11, 2025
* separate flags buffering and in-memory container

* new bitvec flags

* fmt

* clippy

* make BufferedDynamicFlags public to crate only

* clear cache after loading

* clippyyy

* improve comment

* Use resize with a constant to eliminate a hot closure

* Add comment on why we take subslice of bitslice

---------

Co-authored-by: timvisee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants