Search in sources :

Example 16 with RoaringBitmap

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]);
    }
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap) Test(org.junit.Test)

Example 17 with RoaringBitmap

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!");
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap)

Example 18 with RoaringBitmap

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;
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 19 with RoaringBitmap

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);
    }
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap) Setup(org.openjdk.jmh.annotations.Setup)

Example 20 with RoaringBitmap

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);
    }
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

RoaringBitmap (org.roaringbitmap.RoaringBitmap)85 Benchmark (org.openjdk.jmh.annotations.Benchmark)14 Test (org.junit.jupiter.api.Test)10 Test (org.junit.Test)9 DataOutputStream (java.io.DataOutputStream)8 MutableRoaringBitmap (org.roaringbitmap.buffer.MutableRoaringBitmap)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 DataInputStream (java.io.DataInputStream)7 IOException (java.io.IOException)7 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteBuffer (java.nio.ByteBuffer)6 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)6 BitmapDataProvider (org.roaringbitmap.BitmapDataProvider)6 ByteString (com.google.protobuf.ByteString)5 Setup (org.openjdk.jmh.annotations.Setup)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 FasterList (jcog.list.FasterList)4 Term (nars.term.Term)4 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)4