Search in sources :

Example 31 with MutableBitmap

use of org.apache.druid.collections.bitmap.MutableBitmap in project druid by druid-io.

the class IncrementalIndexAdapter method getBitmapValues.

@Override
public BitmapValues getBitmapValues(String dimension, int index) {
    DimensionAccessor accessor = accessors.get(dimension);
    if (accessor == null) {
        return BitmapValues.EMPTY;
    }
    ColumnCapabilities capabilities = accessor.dimensionDesc.getCapabilities();
    DimensionIndexer indexer = accessor.dimensionDesc.getIndexer();
    if (!capabilities.hasBitmapIndexes()) {
        return BitmapValues.EMPTY;
    }
    final int id = (Integer) indexer.getUnsortedEncodedValueFromSorted(index);
    if (id < 0 || id >= indexer.getCardinality()) {
        return BitmapValues.EMPTY;
    }
    MutableBitmap bitmapIndex = accessor.invertedIndexes[id];
    if (bitmapIndex == null) {
        return BitmapValues.EMPTY;
    }
    return new MutableBitmapValues(bitmapIndex);
}
Also used : DimensionIndexer(org.apache.druid.segment.DimensionIndexer) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) ColumnCapabilities(org.apache.druid.segment.column.ColumnCapabilities)

Example 32 with MutableBitmap

use of org.apache.druid.collections.bitmap.MutableBitmap in project druid by druid-io.

the class BitmapCreationBenchmark method testLinearAdditionDescending.

@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 1000)
@Test
public void testLinearAdditionDescending() {
    MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
    for (int i = NUM_BITS - 1; i >= 0; --i) {
        mutableBitmap.add(i);
    }
    Assert.assertEquals(NUM_BITS, mutableBitmap.size());
}
Also used : MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 33 with MutableBitmap

use of org.apache.druid.collections.bitmap.MutableBitmap in project druid by druid-io.

the class BitmapCreationBenchmark method testRandomAddition.

@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 10)
@Test
public void testRandomAddition() {
    MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
    for (int i : randIndex) {
        mutableBitmap.add(i);
    }
    Assert.assertEquals(NUM_BITS, mutableBitmap.size());
}
Also used : MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Aggregations

MutableBitmap (org.apache.druid.collections.bitmap.MutableBitmap)33 Test (org.junit.Test)15 BitmapFactory (org.apache.druid.collections.bitmap.BitmapFactory)8 ImmutableBitmap (org.apache.druid.collections.bitmap.ImmutableBitmap)7 RoaringBitmapFactory (org.apache.druid.collections.bitmap.RoaringBitmapFactory)6 Setup (org.openjdk.jmh.annotations.Setup)6 ArrayList (java.util.ArrayList)4 ConciseBitmapFactory (org.apache.druid.collections.bitmap.ConciseBitmapFactory)4 BitmapIndex (org.apache.druid.segment.column.BitmapIndex)4 BitmapSerdeFactory (org.apache.druid.segment.data.BitmapSerdeFactory)4 Benchmark (org.openjdk.jmh.annotations.Benchmark)4 BenchmarkOptions (com.carrotsearch.junitbenchmarks.BenchmarkOptions)3 Function (com.google.common.base.Function)3 List (java.util.List)3 Random (java.util.Random)3 TimeUnit (java.util.concurrent.TimeUnit)3 NullHandling (org.apache.druid.common.config.NullHandling)3 IAE (org.apache.druid.java.util.common.IAE)3 RoaringBitmapSerdeFactory (org.apache.druid.segment.data.RoaringBitmapSerdeFactory)3 StringBitmapIndexColumnPartSupplier (org.apache.druid.segment.serde.StringBitmapIndexColumnPartSupplier)3