Search in sources :

Example 1 with ImmutableConciseSet

use of org.apache.druid.extendedset.intset.ImmutableConciseSet in project druid by druid-io.

the class BitmapOperationTestBase method testConciseUnion.

@Test
public void testConciseUnion() {
    ImmutableConciseSet union = ImmutableConciseSet.union(CONCISE);
    Assert.assertEquals(unionCount, union.size());
}
Also used : ImmutableConciseSet(org.apache.druid.extendedset.intset.ImmutableConciseSet) Test(org.junit.Test)

Example 2 with ImmutableConciseSet

use of org.apache.druid.extendedset.intset.ImmutableConciseSet in project druid by druid-io.

the class BitmapOperationTestBase method makeOffheapConcise.

protected static ImmutableConciseSet makeOffheapConcise(ImmutableConciseSet concise) {
    final byte[] bytes = concise.toBytes();
    totalConciseBytes += bytes.length;
    conciseCount++;
    final ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length).put(bytes);
    buf.rewind();
    return new ImmutableConciseSet(buf.asIntBuffer());
}
Also used : ImmutableConciseSet(org.apache.druid.extendedset.intset.ImmutableConciseSet) ByteBuffer(java.nio.ByteBuffer)

Example 3 with ImmutableConciseSet

use of org.apache.druid.extendedset.intset.ImmutableConciseSet in project druid by druid-io.

the class WrappedImmutableConciseBitmap method intersection.

@Override
public ImmutableBitmap intersection(ImmutableBitmap otherBitmap) {
    WrappedImmutableConciseBitmap other = (WrappedImmutableConciseBitmap) otherBitmap;
    ImmutableConciseSet unwrappedOtherBitmap = other.bitmap;
    return new WrappedImmutableConciseBitmap(ImmutableConciseSet.intersection(bitmap, unwrappedOtherBitmap));
}
Also used : ImmutableConciseSet(org.apache.druid.extendedset.intset.ImmutableConciseSet)

Example 4 with ImmutableConciseSet

use of org.apache.druid.extendedset.intset.ImmutableConciseSet in project druid by druid-io.

the class ConciseComplementBenchmark method uncompressed.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void uncompressed(Blackhole blackhole) {
    final ImmutableConciseSet set = ImmutableConciseSet.complement(null, emptyRows);
    blackhole.consume(set);
    assert (emptyRows == set.size());
}
Also used : ImmutableConciseSet(org.apache.druid.extendedset.intset.ImmutableConciseSet) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 5 with ImmutableConciseSet

use of org.apache.druid.extendedset.intset.ImmutableConciseSet in project druid by druid-io.

the class BitmapBenchmarkUtils method toOffheap.

public static ImmutableBitmap toOffheap(ImmutableBitmap bitmap) throws IOException {
    if (bitmap instanceof WrappedImmutableConciseBitmap) {
        final WrappedImmutableConciseBitmap conciseBitmap = (WrappedImmutableConciseBitmap) bitmap;
        final byte[] bytes = conciseBitmap.getBitmap().toBytes();
        final ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length).put(bytes);
        buf.rewind();
        return new WrappedImmutableConciseBitmap(new ImmutableConciseSet(buf.asIntBuffer()));
    } else if (bitmap instanceof WrappedImmutableRoaringBitmap) {
        final WrappedImmutableRoaringBitmap roaringBitmap = (WrappedImmutableRoaringBitmap) bitmap;
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        roaringBitmap.getBitmap().serialize(new DataOutputStream(out));
        final byte[] bytes = out.toByteArray();
        final ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length);
        buf.put(bytes);
        buf.rewind();
        return new WrappedImmutableRoaringBitmap(new ImmutableRoaringBitmap(buf.asReadOnlyBuffer()));
    } else {
        throw new IAE("Unsupported bitmap type [%s]", bitmap.getClass().getSimpleName());
    }
}
Also used : ImmutableConciseSet(org.apache.druid.extendedset.intset.ImmutableConciseSet) WrappedImmutableConciseBitmap(org.apache.druid.collections.bitmap.WrappedImmutableConciseBitmap) DataOutputStream(java.io.DataOutputStream) WrappedImmutableRoaringBitmap(org.apache.druid.collections.bitmap.WrappedImmutableRoaringBitmap) ImmutableRoaringBitmap(org.roaringbitmap.buffer.ImmutableRoaringBitmap) WrappedImmutableRoaringBitmap(org.apache.druid.collections.bitmap.WrappedImmutableRoaringBitmap) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IAE(org.apache.druid.java.util.common.IAE) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ImmutableConciseSet (org.apache.druid.extendedset.intset.ImmutableConciseSet)6 ByteBuffer (java.nio.ByteBuffer)2 Test (org.junit.Test)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 WrappedImmutableConciseBitmap (org.apache.druid.collections.bitmap.WrappedImmutableConciseBitmap)1 WrappedImmutableRoaringBitmap (org.apache.druid.collections.bitmap.WrappedImmutableRoaringBitmap)1 IAE (org.apache.druid.java.util.common.IAE)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)1 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)1 ImmutableRoaringBitmap (org.roaringbitmap.buffer.ImmutableRoaringBitmap)1