Search in sources :

Example 1 with RoaringBitmap

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

the class RoaringBitmapAggregatorTest method shouldCloneInputBitmapWhenAggregating.

@Test
public void shouldCloneInputBitmapWhenAggregating() {
    // Given
    final RoaringBitmapAggregator roaringBitmapAggregator = new RoaringBitmapAggregator();
    roaringBitmapAggregator.init();
    final RoaringBitmap bitmap = mock(RoaringBitmap.class);
    final RoaringBitmap clonedBitmap = mock(RoaringBitmap.class);
    given(bitmap.clone()).willReturn(clonedBitmap);
    // When
    roaringBitmapAggregator._aggregate(bitmap);
    // Then
    assertSame(clonedBitmap, roaringBitmapAggregator.state()[0]);
    assertNotSame(bitmap, roaringBitmapAggregator.state()[0]);
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap) Test(org.junit.Test)

Example 2 with RoaringBitmap

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

the class FilterUtil method prepareExcludeFilterMembers.

private static List<Integer> prepareExcludeFilterMembers(Dictionary forwardDictionary, List<Integer> includeSurrogates) throws FilterUnsupportedException {
    DictionaryChunksWrapper dictionaryWrapper;
    RoaringBitmap bitMapOfSurrogates = RoaringBitmap.bitmapOf(ArrayUtils.toPrimitive(includeSurrogates.toArray(new Integer[includeSurrogates.size()])));
    dictionaryWrapper = forwardDictionary.getDictionaryChunks();
    List<Integer> excludeFilterList = new ArrayList<Integer>(includeSurrogates.size());
    int surrogateCount = 0;
    while (dictionaryWrapper.hasNext()) {
        dictionaryWrapper.next();
        ++surrogateCount;
        if (!bitMapOfSurrogates.contains(surrogateCount)) {
            excludeFilterList.add(surrogateCount);
        }
    }
    return excludeFilterList;
}
Also used : DictionaryChunksWrapper(org.apache.carbondata.core.cache.dictionary.DictionaryChunksWrapper) ArrayList(java.util.ArrayList) RoaringBitmap(org.roaringbitmap.RoaringBitmap)

Example 3 with RoaringBitmap

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

the class RunContainerRealDataBenchmarkRunOptimize method serializeToBAOSFromClonePreOpti.

@Benchmark
public int serializeToBAOSFromClonePreOpti(BenchmarkState benchmarkState) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    for (int i = 0; i < benchmarkState.rc.size(); i++) {
        RoaringBitmap bitmap = benchmarkState.rc.get(i).clone();
        bitmap.serialize(dos);
    }
    dos.flush();
    return bos.size();
}
Also used : DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RoaringBitmap(org.roaringbitmap.RoaringBitmap) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 4 with RoaringBitmap

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

the class RunContainerRealDataBenchmarkRunOptimize method cloneAndrunOptimize.

@Benchmark
public int cloneAndrunOptimize(BenchmarkState benchmarkState) {
    int total = 0;
    for (int i = 0; i < benchmarkState.ac.size(); i++) {
        RoaringBitmap bitmap = benchmarkState.ac.get(i).clone();
        bitmap.runOptimize();
        total += bitmap.getCardinality();
    }
    return total;
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 5 with RoaringBitmap

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

the class RunContainerRealDataBenchmarkRunOptimize method serializeToBAOSFromClone.

@Benchmark
public int serializeToBAOSFromClone(BenchmarkState benchmarkState) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    for (int i = 0; i < benchmarkState.ac.size(); i++) {
        RoaringBitmap bitmap = benchmarkState.ac.get(i).clone();
        bitmap.serialize(dos);
    }
    dos.flush();
    return bos.size();
}
Also used : DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RoaringBitmap(org.roaringbitmap.RoaringBitmap) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

RoaringBitmap (org.roaringbitmap.RoaringBitmap)81 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 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)6 BitmapDataProvider (org.roaringbitmap.BitmapDataProvider)6 ByteString (com.google.protobuf.ByteString)5 ByteBuffer (java.nio.ByteBuffer)5 Setup (org.openjdk.jmh.annotations.Setup)5 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 FasterList (jcog.list.FasterList)4 Term (nars.term.Term)4