Skip to content

Core: Optimize RoaringPositionBitmap.setRange with native range API#15791

Open
Baunsgaard wants to merge 2 commits intoapache:mainfrom
Baunsgaard:optimize-setrange-roaring-bitmap
Open

Core: Optimize RoaringPositionBitmap.setRange with native range API#15791
Baunsgaard wants to merge 2 commits intoapache:mainfrom
Baunsgaard:optimize-setrange-roaring-bitmap

Conversation

@Baunsgaard
Copy link
Copy Markdown
Contributor

Replace the per-position loop in RoaringPositionBitmap.setRange() with RoaringBitmap.add(long, long) bulk range insertion.

The new implementation splits the 64-bit range at key boundaries and delegates each segment to the native API, which operates at the container level internally. This also eliminates per-position validation and bitmap array growth checks.

Replace the O(n) per-position loop in setRange() with native
RoaringBitmap.add(long, long) bulk range insertion. The new
implementation splits 64-bit ranges at key boundaries and delegates
to the native range add API, reducing cost from O(range_size) to
O(containers_touched) and eliminating per-position validation and
bitmap allocation checks.
…y ranges

Add tests that verify every position in a range via contains() for
both the same-key and cross-key code paths. Strengthen the empty
range test to cover start == end and start > end cases with
cardinality and contains() assertions.
@github-actions github-actions bot added the core label Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant