use of org.apache.druid.collections.bitmap.BitmapFactory in project druid by druid-io.
the class LinearGutmanSplitStrategyTest method testPickSeeds.
@Test
public void testPickSeeds() {
BitmapFactory bf = new ConciseBitmapFactory();
LinearGutmanSplitStrategy strategy = new LinearGutmanSplitStrategy(0, 50, bf);
Node node = new Node(new float[2], new float[2], true, bf);
node.addChild(new Point(new float[] { 3, 7 }, 1, bf));
node.addChild(new Point(new float[] { 1, 6 }, 1, bf));
node.addChild(new Point(new float[] { 9, 8 }, 1, bf));
node.addChild(new Point(new float[] { 2, 5 }, 1, bf));
node.addChild(new Point(new float[] { 4, 4 }, 1, bf));
node.enclose();
Node[] groups = strategy.split(node);
Assert.assertEquals(groups[0].getMinCoordinates()[0], 1.0f);
Assert.assertEquals(groups[0].getMinCoordinates()[1], 4.0f);
Assert.assertEquals(groups[1].getMinCoordinates()[0], 9.0f);
Assert.assertEquals(groups[1].getMinCoordinates()[1], 8.0f);
}
use of org.apache.druid.collections.bitmap.BitmapFactory in project druid by druid-io.
the class LinearGutmanSplitStrategyTest method testNumChildrenSize.
@Test
public void testNumChildrenSize() {
BitmapFactory bf = new ConciseBitmapFactory();
RTree tree = new RTree(2, new LinearGutmanSplitStrategy(0, 50, bf), bf);
Random rand = ThreadLocalRandom.current();
for (int i = 0; i < 100; i++) {
tree.insert(new float[] { rand.nextFloat(), rand.nextFloat() }, i);
}
Assert.assertTrue(getNumPoints(tree.getRoot()) >= tree.getSize());
}
use of org.apache.druid.collections.bitmap.BitmapFactory in project druid by druid-io.
the class UniformBitmapBenchmark method setup.
@Setup(Level.Trial)
public void setup() throws IOException {
final int[] knownTrue = new int[minIntersect];
for (int i = 0; i < knownTrue.length; ++i) {
knownTrue[i] = RANDOM.nextInt(bitmapLength);
}
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();
for (int k = 0; k < bitmapLength; ++k) {
if (RANDOM.nextDouble() < density) {
mutableBitmap.add(k);
}
}
for (int k : knownTrue) {
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);
}
use of org.apache.druid.collections.bitmap.BitmapFactory 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.BitmapFactory 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);
}
Aggregations