Search in sources :

Example 16 with MutableBitmap

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

the class LikeFilterBenchmark method setup.

@Setup
public void setup() {
    step = (END_INT - START_INT) / cardinality;
    final BitmapFactory bitmapFactory = new RoaringBitmapFactory();
    final BitmapSerdeFactory serdeFactory = new RoaringBitmapSerdeFactory(null);
    final List<Integer> ints = generateInts();
    final GenericIndexed<String> dictionary = GenericIndexed.fromIterable(FluentIterable.from(ints).transform(new Function<Integer, String>() {

        @Override
        public String apply(Integer i) {
            return i.toString();
        }
    }), GenericIndexed.STRING_STRATEGY);
    final BitmapIndex bitmapIndex = new StringBitmapIndexColumnPartSupplier(bitmapFactory, GenericIndexed.fromIterable(FluentIterable.from(ints).transform(new Function<Integer, ImmutableBitmap>() {

        @Override
        public ImmutableBitmap apply(Integer i) {
            final MutableBitmap mutableBitmap = bitmapFactory.makeEmptyMutableBitmap();
            mutableBitmap.add((i - START_INT) / step);
            return bitmapFactory.makeImmutableBitmap(mutableBitmap);
        }
    }), serdeFactory.getObjectStrategy()), dictionary).get();
    selector = new MockBitmapIndexSelector(dictionary, bitmapFactory, bitmapIndex);
}
Also used : StringBitmapIndexColumnPartSupplier(org.apache.druid.segment.serde.StringBitmapIndexColumnPartSupplier) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) BitmapIndex(org.apache.druid.segment.column.BitmapIndex) Function(com.google.common.base.Function) RoaringBitmapSerdeFactory(org.apache.druid.segment.data.RoaringBitmapSerdeFactory) BitmapFactory(org.apache.druid.collections.bitmap.BitmapFactory) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) RoaringBitmapSerdeFactory(org.apache.druid.segment.data.RoaringBitmapSerdeFactory) BitmapSerdeFactory(org.apache.druid.segment.data.BitmapSerdeFactory) Setup(org.openjdk.jmh.annotations.Setup)

Example 17 with MutableBitmap

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

the class BoundFilterBenchmark method setup.

@Setup
public void setup() {
    step = (END_INT - START_INT) / cardinality;
    final BitmapFactory bitmapFactory = new RoaringBitmapFactory();
    final BitmapSerdeFactory serdeFactory = new RoaringBitmapSerdeFactory(null);
    final List<Integer> ints = generateInts();
    final GenericIndexed<String> dictionary = GenericIndexed.fromIterable(FluentIterable.from(ints).transform(i -> i.toString()), GenericIndexed.STRING_STRATEGY);
    final BitmapIndex bitmapIndex = new StringBitmapIndexColumnPartSupplier(bitmapFactory, GenericIndexed.fromIterable(FluentIterable.from(ints).transform(new Function<Integer, ImmutableBitmap>() {

        @Override
        public ImmutableBitmap apply(Integer i) {
            final MutableBitmap mutableBitmap = bitmapFactory.makeEmptyMutableBitmap();
            mutableBitmap.add((i - START_INT) / step);
            return bitmapFactory.makeImmutableBitmap(mutableBitmap);
        }
    }), serdeFactory.getObjectStrategy()), dictionary).get();
    selector = new MockBitmapIndexSelector(dictionary, bitmapFactory, bitmapIndex);
}
Also used : BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Measurement(org.openjdk.jmh.annotations.Measurement) Scope(org.openjdk.jmh.annotations.Scope) BitmapIndex(org.apache.druid.segment.column.BitmapIndex) ImmutableBitmap(org.apache.druid.collections.bitmap.ImmutableBitmap) Warmup(org.openjdk.jmh.annotations.Warmup) ArrayList(java.util.ArrayList) StringBitmapIndexColumnPartSupplier(org.apache.druid.segment.serde.StringBitmapIndexColumnPartSupplier) FluentIterable(com.google.common.collect.FluentIterable) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) BitmapFactory(org.apache.druid.collections.bitmap.BitmapFactory) StringComparators(org.apache.druid.query.ordering.StringComparators) GenericIndexed(org.apache.druid.segment.data.GenericIndexed) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) RoaringBitmapSerdeFactory(org.apache.druid.segment.data.RoaringBitmapSerdeFactory) Setup(org.openjdk.jmh.annotations.Setup) Function(com.google.common.base.Function) Mode(org.openjdk.jmh.annotations.Mode) Param(org.openjdk.jmh.annotations.Param) State(org.openjdk.jmh.annotations.State) Benchmark(org.openjdk.jmh.annotations.Benchmark) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) TimeUnit(java.util.concurrent.TimeUnit) BitmapSerdeFactory(org.apache.druid.segment.data.BitmapSerdeFactory) List(java.util.List) NullHandling(org.apache.druid.common.config.NullHandling) BoundFilter(org.apache.druid.segment.filter.BoundFilter) Fork(org.openjdk.jmh.annotations.Fork) Preconditions(com.google.common.base.Preconditions) ConciseSetUtils(org.apache.druid.extendedset.intset.ConciseSetUtils) BitmapIndexSelector(org.apache.druid.query.filter.BitmapIndexSelector) StringBitmapIndexColumnPartSupplier(org.apache.druid.segment.serde.StringBitmapIndexColumnPartSupplier) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) BitmapIndex(org.apache.druid.segment.column.BitmapIndex) Function(com.google.common.base.Function) RoaringBitmapSerdeFactory(org.apache.druid.segment.data.RoaringBitmapSerdeFactory) BitmapFactory(org.apache.druid.collections.bitmap.BitmapFactory) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) RoaringBitmapSerdeFactory(org.apache.druid.segment.data.RoaringBitmapSerdeFactory) BitmapSerdeFactory(org.apache.druid.segment.data.BitmapSerdeFactory) Setup(org.openjdk.jmh.annotations.Setup)

Example 18 with MutableBitmap

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

the class DimensionPredicateFilterBenchmark method setup.

@Setup
public void setup() {
    final BitmapFactory bitmapFactory = new RoaringBitmapFactory();
    final BitmapSerdeFactory serdeFactory = new RoaringBitmapSerdeFactory(null);
    final List<Integer> ints = generateInts();
    final GenericIndexed<String> dictionary = GenericIndexed.fromIterable(FluentIterable.from(ints).transform(new Function<Integer, String>() {

        @Override
        public String apply(Integer i) {
            return i.toString();
        }
    }), GenericIndexed.STRING_STRATEGY);
    final BitmapIndex bitmapIndex = new StringBitmapIndexColumnPartSupplier(bitmapFactory, GenericIndexed.fromIterable(FluentIterable.from(ints).transform(new Function<Integer, ImmutableBitmap>() {

        @Override
        public ImmutableBitmap apply(Integer i) {
            final MutableBitmap mutableBitmap = bitmapFactory.makeEmptyMutableBitmap();
            mutableBitmap.add(i - START_INT);
            return bitmapFactory.makeImmutableBitmap(mutableBitmap);
        }
    }), serdeFactory.getObjectStrategy()), dictionary).get();
    selector = new MockBitmapIndexSelector(dictionary, bitmapFactory, bitmapIndex);
}
Also used : StringBitmapIndexColumnPartSupplier(org.apache.druid.segment.serde.StringBitmapIndexColumnPartSupplier) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) BitmapIndex(org.apache.druid.segment.column.BitmapIndex) Function(com.google.common.base.Function) RoaringBitmapSerdeFactory(org.apache.druid.segment.data.RoaringBitmapSerdeFactory) BitmapFactory(org.apache.druid.collections.bitmap.BitmapFactory) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) RoaringBitmapSerdeFactory(org.apache.druid.segment.data.RoaringBitmapSerdeFactory) BitmapSerdeFactory(org.apache.druid.segment.data.BitmapSerdeFactory) Setup(org.openjdk.jmh.annotations.Setup)

Example 19 with MutableBitmap

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

the class BitmapIterationBenchmark method constructAndIter.

/**
 * Benchmark of cumulative cost of construction of an immutable bitmap and then iterating over it. This is a pattern
 * from realtime nodes, see {@link org.apache.druid.segment.StringDimensionIndexer#fillBitmapsFromUnsortedEncodedKeyComponent}.
 * However this benchmark is yet approximate and to be improved to better reflect actual workloads of realtime nodes.
 */
@Benchmark
public int constructAndIter(ConstructAndIterState state) {
    int dataSize = state.dataSize;
    int[] data = state.data;
    MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
    for (int i = 0; i < dataSize; i++) {
        mutableBitmap.add(data[i]);
    }
    ImmutableBitmap bitmap = factory.makeImmutableBitmap(mutableBitmap);
    return iter(bitmap);
}
Also used : ImmutableBitmap(org.apache.druid.collections.bitmap.ImmutableBitmap) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 20 with MutableBitmap

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

the class BitmapIterationBenchmark method makeBitmap.

private ImmutableBitmap makeBitmap(double prob) {
    MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
    Random random = ThreadLocalRandom.current();
    for (int bit = 0; bit < size; bit++) {
        if (random.nextDouble() < prob) {
            mutableBitmap.add(bit);
        }
    }
    return factory.makeImmutableBitmap(mutableBitmap);
}
Also used : Random(java.util.Random) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap)

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