use of org.roaringbitmap.RoaringBitmap in project RoaringBitmap by RoaringBitmap.
the class TestRoaring64NavigableMap method testDefaultBehaviorLikeRoaring.
// Ensure the ordering behavior with default constructors is the same between RoaringBitmap and
// Roaring64NavigableMap. Typically ensures longs are managed as unsigned longs
@Test
public void testDefaultBehaviorLikeRoaring() {
Roaring64NavigableMap longBitmap = newDefaultCtor();
RoaringBitmap bitmap = new RoaringBitmap();
longBitmap.addLong(-1);
bitmap.add(-1);
longBitmap.addLong(1);
bitmap.add(1);
int[] bitmapAsIntArray = bitmap.toArray();
long[] longBitmapAsArray = longBitmap.toArray();
// The array seems equivalent, but beware one represents unsigned integers while the others
// holds unsigned longs: -1 have a different meaning
Assert.assertArrayEquals(bitmapAsIntArray, Ints.toArray(Longs.asList(longBitmapAsArray)));
Assert.assertArrayEquals(Longs.toArray(Ints.asList(bitmapAsIntArray)), longBitmapAsArray);
long[] bitmapAsLongArray = new long[bitmapAsIntArray.length];
for (int i = 0; i < bitmapAsIntArray.length; i++) {
bitmapAsLongArray[i] = Util.toUnsignedLong(bitmapAsIntArray[i]);
}
}
use of org.roaringbitmap.RoaringBitmap in project RoaringBitmap by RoaringBitmap.
the class VeryLargeBitmap method main.
public static void main(String[] args) {
RoaringBitmap rb = new RoaringBitmap();
// the biggest bitmap we can create
rb.add(0L, 1L << 32);
System.out.println("memory usage: " + rb.getSizeInBytes() * 1.0 / (1L << 32) + " byte per value");
if (rb.getLongCardinality() != (1L << 32))
throw new RuntimeException("bug!");
}
use of org.roaringbitmap.RoaringBitmap in project RoaringBitmap by RoaringBitmap.
the class RoaringBitmapBenchmark method inplace_and.
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public RoaringBitmap inplace_and() {
RoaringBitmap b1 = bitmap1.clone();
b1.and(bitmap2);
return b1;
}
use of org.roaringbitmap.RoaringBitmap in project RoaringBitmap by RoaringBitmap.
the class RoaringBitmapBenchmark method setup.
@Setup
public void setup() {
bitmap1 = new RoaringBitmap();
bitmap2 = new RoaringBitmap();
int k = 1 << 16;
for (int i = 0; i < 10000; ++i) {
bitmap1.add(i * k);
bitmap2.add(i * k);
}
}
use of org.roaringbitmap.RoaringBitmap in project RoaringBitmap by RoaringBitmap.
the class RoaringBitmapBenchmark method setup.
@Setup
public void setup() {
bitmap1 = new RoaringBitmap();
bitmap2 = new RoaringBitmap();
int k = 1 << 16;
for (int i = 0; i < 10000; ++i) {
bitmap1.add(2 * i * k);
bitmap2.add(2 * i * k + 1);
}
}
Aggregations