Hi Team,
While testing RangeBitmap, I recently came across several problems that I wanted to let you know about.
RangeBitmap works fine if the data has all been inserted in advance. However, when I try to add additional values to the appender after building the range bitmap, RangeBitmap displays some unexpected results. It demonstrates that RangeBitamp cannot presently fully support insert operations.
It is also possible that I misunderstood how the RangeBitmap class methods worked, which would explain why the outcome was unexpected.
I would like to ask how to correctly insert new values after the appender calls the build() method.
My test file is as follows:
--------------------------------------------------------------------------------------------------------------------------
import org.roaringbitmap.RangeBitmap;
import org.roaringbitmap.RoaringBitmap;
public class RangeBitmapTest {
public static void printRoaringBitmap(String bitmapInfo, RoaringBitmap RBM){
System.out.printf("\n" + bitmapInfo + " roaring bitmap values: ");
for(int i : RBM) { System.out.printf("%d ", i); }
}
public static void main(String[] args) throws InterruptedException {
System.out.printf("--------Range Bitmap Experiments1--------");
RangeBitmap.Appender appender1 = RangeBitmap.appender(5_000L);
appender1.add(1L);
appender1.add(2L);
RangeBitmap oldRangeBitmap = appender1.build();
RoaringBitmap oldlte5Test = oldRangeBitmap.lte(5);
printRoaringBitmap("lte5 old", oldlte5Test);
// insert more numbers
appender1.add(3L);
appender1.add(4L);
appender1.add(5L);
RangeBitmap newRangeBitmap = appender1.build();
RoaringBitmap newLte5Test = newRangeBitmap.lte(5);
printRoaringBitmap("lte5 new", newLte5Test);
RoaringBitmap newGte3Test = newRangeBitmap.gte(3);
printRoaringBitmap("gte3 new", newGte3Test);
RoaringBitmap newGte4Test = newRangeBitmap.gte(4);
printRoaringBitmap("gte4 new", newGte4Test);
System.out.printf("\n--------Range Bitmap Experiments2--------");
RangeBitmap.Appender appender2 = RangeBitmap.appender(5_000L);
for(long i = 1; i < 6; i++){
appender2.add(i);
}
RangeBitmap test2RangeBitmap = appender2.build();
RoaringBitmap gte4 = test2RangeBitmap.gte(4);
printRoaringBitmap("gte4 ", gte4);
RoaringBitmap lte5 = test2RangeBitmap.lte(5);
printRoaringBitmap("lte5 ", lte5);
}
}
--------------------------------------------------------------------------------------------------------------------------
These are the output results:
--------Range Bitmap Experiments1--------
lte5 old roaring bitmap values: 0 1
lte5 new roaring bitmap values: 0 1
gte3 new roaring bitmap values: 2 3 4
gte4 new roaring bitmap values: 2 3 4
--------Range Bitmap Experiments2--------
gte4 roaring bitmap values: 3 4
lte5 roaring bitmap values: 0 1 2 3 4
Process finished with exit code 0