Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Moving" parts of a RoaringBitmap #276

Open
llogiq opened this issue May 23, 2024 · 2 comments
Open

"Moving" parts of a RoaringBitmap #276

llogiq opened this issue May 23, 2024 · 2 comments
Labels

Comments

@llogiq
Copy link
Contributor

llogiq commented May 23, 2024

Let's say I have a RoaringBitmap with the values 0, 1, 32, 35 and 70. Now I want to reduce all values > 6 and < 40 by, say, 2. Is there a thing I'm overlooking or would I have to remove and recreate the values via from_sorted_iter?

@Kerollmops
Copy link
Member

Kerollmops commented May 28, 2024

Hey @llogiq 👋

Happy to see you there. Unfortunately, there is no direct operation to do the following. What I would do is create a second bitmap with numbers in between 7 (> 6) and 39 (<40), do an intersection to get the real numbers. Do the increment by 2 by by iterating on this subset and creating a new bitmap (yes, again). Using the RoaringBitmap::remove_range method to delete the range of values in between 7 and 39 then do the union with the previously shifted bitmap (using the BitOrAssign operator).

What are we Missing to be Efficient?

  • A way to split a bitmap when doing an operation:
    fn extract_range(&self, impl Range) -> RoaringBitmap.
  • A way to do different, simple, operations on a bitmap in-place:
    fn increment_all(&mut self, n: usize) -> u64.
  • Or a way to directly do that on the bitmap itself:
    fn increment_range(&mut self, r: impl Range, n: usize) -> u64.

@llogiq
Copy link
Contributor Author

llogiq commented May 28, 2024

Yeah, I guess having RoaringBitmap::{in, de}crement_range functions would probably get the most bang for the buck, and could also easily be SIMD-optimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants