Repository navigation
Add roaring_bitmap_word_range_to_bitset - #907
Merged
Merged
Conversation
Member
|
Because range comes beforehand, from the name of the function I wouldn't expect the range to also be in units of words. |
Member
Author
|
Renamed to |
Writes the values of a range of the bitmap, given in 64-bit words, as a bitset. Bitset containers are copied, array and run containers set only the bits in the range, so the cost depends on the range and not on the size of the bitmap.
…bitset The new name says that the range is in units of 64-bit words.
lemire
force-pushed
the
range-to-words
branch
from
October 16, 2026 00:10
44e8c36 to
df3470a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
roaring_bitmap_word_range_to_bitset(r, first_word, n_words, words), which writes the values from64 * first_wordto64 * (first_word + n_words)(excluded) as a bitset: value64 * (first_word + k) + isets bitiofwords[k]. Alln_wordswords are written, so the caller does not need to zero them.Unlike
roaring_bitmap_to_bitset, which converts the whole bitmap, the cost depends only on the range: the containers before the range are skipped with a binary search, bitset containers are copied withmemcpy, and array and run containers set only the bits in the range (binary search for the first value or run, then clipped ranges).This is useful when a bitmap stands for a bit string of which an application reads windows (for example, a few bytes at a given offset, or a block of words to scan for the first zero bit), where iterating over the values is much slower on dense data.
Test:
test_word_range_to_bitsetintoplevel_unit.cchecks the output againstroaring_bitmap_containson a bitmap with array, bitset and run containers, including partial containers, chunk boundaries, the end of the 32-bit range, empty ranges and an empty bitmap, and checks that no word outside the output is written. All tests pass with sanitizers and with C23.