roaring-rs: The `insert_range` method does not properly handle boundary condition
Progress
- Switch inner parameters to RangeBounds
- insert_range
- remove_range
- Fix boundary condition in insert_range/remove_range
- Add more tests
Experiments
#[test]
fn insert_range_multi() {
let mut bitmap = RoaringBitmap::new();
bitmap.insert_range(0..((1_u64 << 16) + 1));
println!("{:?}", bitmap);
}
#[test]
fn insert_multi() {
let mut bitmap = RoaringBitmap::new();
for i in 0..((1 << 16) + 1) {
bitmap.insert(i);
}
println!("{:?}", bitmap);
}
#[test]
fn insert_range_single() {
let mut bitmap = RoaringBitmap::new();
bitmap.insert_range(0..(1_u64 << 16));
println!("{:?}", bitmap); // would panic here
}
#[test]
fn insert_single() {
let mut bitmap = RoaringBitmap::new();
for i in 0..(1 << 16) {
bitmap.insert(i);
}
println!("{:?}", bitmap);
}
single partition insertion
After insert 0…(1_u64 << 16) to the bitmap, we expect only one container(bitmap), whose key is 0, exists in the bitmap.
But actually we got:

multiply partition insertion
After insert 0…((1_u64 << 16) + 1) to the bitmap, we expect one container(bitmap), whose key is 0, followed by a container(array), whose key is 1.
But we got:

About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (21 by maintainers)
Commits related to this issue
- [#113][#5] Rework Bitmap::{insert_range,remove_range} and Treemap::remove_range to accept `RangeBounds`; Fix boundary issue; — committed to RoaringBitmap/roaring-rs by oliverdding 3 years ago
- [#113][#5] Rework Bitmap::{insert_range,remove_range} and Treemap::remove_range to accept `RangeBounds`; Fix boundary issue; — committed to not-jan/roaring-rs by oliverdding 3 years ago
Hi @Kerollmops . I got it.
And now I have done all the tasks and created another PR now.
Thanks for your patience 😊
That sounds great 🙋♂️
Thanks for your patience and excellent works.