Search in sources :

Example 16 with RoaringBitmapFactory

use of org.apache.druid.collections.bitmap.RoaringBitmapFactory 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 RoaringBitmapFactory

use of org.apache.druid.collections.bitmap.RoaringBitmapFactory 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 RoaringBitmapFactory

use of org.apache.druid.collections.bitmap.RoaringBitmapFactory 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 RoaringBitmapFactory

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

the class RangeBitmapBenchmark method setup.

@Setup(Level.Trial)
public void setup() throws IOException {
    switch(type) {
        case "concise":
            bitmapFactory = new ConciseBitmapFactory();
            break;
        case "roaring":
            bitmapFactory = new RoaringBitmapFactory();
            break;
        default:
            throw new IAE("Unknown bitmap type[%s]", type);
    }
    bitmaps = new ArrayList<>(numBitmaps);
    for (int i = 0; i < numBitmaps; ++i) {
        final MutableBitmap mutableBitmap = bitmapFactory.makeEmptyMutableBitmap();
        int k = 0;
        boolean fill = true;
        while (k < bitmapLength) {
            int runLength = (int) (bitmapLength * density) + RANDOM.nextInt((int) (bitmapLength * density));
            for (int j = k; fill && j < bitmapLength && j < k + runLength; ++j) {
                mutableBitmap.add(j);
            }
            k += runLength;
            fill = !fill;
        }
        for (k = bitmapLength / 2; k < bitmapLength / 2 + minIntersect; ++k) {
            mutableBitmap.add(k);
        }
        bitmaps.add(BitmapBenchmarkUtils.toOffheap(bitmapFactory.makeImmutableBitmap(mutableBitmap)));
    }
    final long totalSizeBytes = bitmaps.stream().mapToLong(bitmap -> bitmap.toBytes().length).sum();
    BitmapBenchmarkUtils.printSizeStats(type, density, bitmaps.size(), totalSizeBytes);
}
Also used : BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Measurement(org.openjdk.jmh.annotations.Measurement) Blackhole(org.openjdk.jmh.infra.Blackhole) Scope(org.openjdk.jmh.annotations.Scope) Random(java.util.Random) ImmutableBitmap(org.apache.druid.collections.bitmap.ImmutableBitmap) Warmup(org.openjdk.jmh.annotations.Warmup) ArrayList(java.util.ArrayList) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) BitmapFactory(org.apache.druid.collections.bitmap.BitmapFactory) IAE(org.apache.druid.java.util.common.IAE) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) Setup(org.openjdk.jmh.annotations.Setup) Mode(org.openjdk.jmh.annotations.Mode) Param(org.openjdk.jmh.annotations.Param) IOException(java.io.IOException) State(org.openjdk.jmh.annotations.State) ConciseBitmapFactory(org.apache.druid.collections.bitmap.ConciseBitmapFactory) Benchmark(org.openjdk.jmh.annotations.Benchmark) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) NullHandling(org.apache.druid.common.config.NullHandling) Level(org.openjdk.jmh.annotations.Level) Fork(org.openjdk.jmh.annotations.Fork) ConciseBitmapFactory(org.apache.druid.collections.bitmap.ConciseBitmapFactory) MutableBitmap(org.apache.druid.collections.bitmap.MutableBitmap) IAE(org.apache.druid.java.util.common.IAE) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) Setup(org.openjdk.jmh.annotations.Setup)

Example 20 with RoaringBitmapFactory

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

the class ImmutableRTreeTest method testEmptyRoaringBitmap.

@Test
public void testEmptyRoaringBitmap() {
    BitmapFactory bf = new RoaringBitmapFactory();
    RTree tree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, bf), bf);
    tree.insert(new float[] { 0.0f, 0.0f }, bf.makeEmptyMutableBitmap());
    ImmutableRTree searchTree = ImmutableRTree.newImmutableFromMutable(tree);
    Iterable<ImmutableBitmap> points = searchTree.search(new RadiusBound(new float[] { 0.0f, 0.0f }, 5));
    ImmutableBitmap finalSet = bf.union(points);
    Assert.assertEquals(finalSet.size(), 0);
    Assert.assertTrue(finalSet.isEmpty());
}
Also used : RadiusBound(org.apache.druid.collections.spatial.search.RadiusBound) ImmutableBitmap(org.apache.druid.collections.bitmap.ImmutableBitmap) BitmapFactory(org.apache.druid.collections.bitmap.BitmapFactory) ConciseBitmapFactory(org.apache.druid.collections.bitmap.ConciseBitmapFactory) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) LinearGutmanSplitStrategy(org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy) RoaringBitmapFactory(org.apache.druid.collections.bitmap.RoaringBitmapFactory) Test(org.junit.Test)

Aggregations

RoaringBitmapFactory (org.apache.druid.collections.bitmap.RoaringBitmapFactory)26 BitmapFactory (org.apache.druid.collections.bitmap.BitmapFactory)20 Test (org.junit.Test)18 ConciseBitmapFactory (org.apache.druid.collections.bitmap.ConciseBitmapFactory)16 ImmutableBitmap (org.apache.druid.collections.bitmap.ImmutableBitmap)14 LinearGutmanSplitStrategy (org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy)10 Random (java.util.Random)8 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)7 IntIterator (org.roaringbitmap.IntIterator)7 MutableBitmap (org.apache.druid.collections.bitmap.MutableBitmap)6 BitmapIndex (org.apache.druid.segment.column.BitmapIndex)6 Setup (org.openjdk.jmh.annotations.Setup)6 File (java.io.File)5 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)5 RadiusBound (org.apache.druid.collections.spatial.search.RadiusBound)5 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)5 IncrementalIndexTest (org.apache.druid.segment.data.IncrementalIndexTest)5 IncrementalIndex (org.apache.druid.segment.incremental.IncrementalIndex)5 IncrementalIndexAdapter (org.apache.druid.segment.incremental.IncrementalIndexAdapter)5 OnheapIncrementalIndex (org.apache.druid.segment.incremental.OnheapIncrementalIndex)5