Search in sources :

Example 21 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;
    int i = 0;
    for (; i < 10000; ++i) {
        bitmap1.add(i * k);
    }
    for (; i < 10050; ++i) {
        bitmap2.add(i * k);
        bitmap1.add(i * k + 13);
    }
    for (; i < 20000; ++i) {
        bitmap2.add(i * k);
    }
    bitmap1.add(i * k);
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap) Setup(org.openjdk.jmh.annotations.Setup)

Example 22 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 23 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)

Example 24 with RoaringBitmap

use of org.roaringbitmap.RoaringBitmap in project RoaringBitmap by RoaringBitmap.

the class RoaringBitmapBenchmark method inplace_andNot.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public RoaringBitmap inplace_andNot() {
    RoaringBitmap b1 = bitmap1.clone();
    b1.andNot(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 25 with RoaringBitmap

use of org.roaringbitmap.RoaringBitmap in project RoaringBitmap by RoaringBitmap.

the class Basic method main.

public static void main(String[] args) {
    RoaringBitmap rr = RoaringBitmap.bitmapOf(1, 2, 3, 1000);
    RoaringBitmap rr2 = new RoaringBitmap();
    rr2.add(4000L, 4255L);
    // new bitmap
    RoaringBitmap rror = RoaringBitmap.or(rr, rr2);
    // in-place computation
    rr.or(rr2);
    // true
    boolean equals = rror.equals(rr);
    if (!equals)
        throw new RuntimeException("bug");
    // number of values stored?
    long cardinality = rr.getLongCardinality();
    System.out.println(cardinality);
    // a "forEach" is faster than this loop, but a loop is possible:
    for (int i : rr) {
        System.out.println(i);
    }
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap)

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