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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations