use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class BoundFilterBenchmark method setup.
@Setup
public void setup() throws IOException {
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 BitmapIndexColumnPartSupplier(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 BitmapIndexSelector() {
@Override
public Indexed<String> getDimensionValues(String dimension) {
return dictionary;
}
@Override
public int getNumRows() {
throw new UnsupportedOperationException();
}
@Override
public BitmapFactory getBitmapFactory() {
return bitmapFactory;
}
@Override
public ImmutableBitmap getBitmapIndex(String dimension, String value) {
return bitmapIndex.getBitmap(bitmapIndex.getIndex(value));
}
@Override
public BitmapIndex getBitmapIndex(String dimension) {
return bitmapIndex;
}
@Override
public ImmutableRTree getSpatialIndex(String dimension) {
throw new UnsupportedOperationException();
}
};
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class Point method makeBitmap.
private static MutableBitmap makeBitmap(int entry, BitmapFactory bitmapFactory) {
MutableBitmap retVal = bitmapFactory.makeEmptyMutableBitmap();
retVal.add(entry);
return retVal;
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testToArray.
@Test
public void testToArray() throws IllegalAccessException, InstantiationException {
for (Class<? extends MutableBitmap> clazz : clazzes) {
Exception e = null;
MutableBitmap wrappedBitmap = clazz.newInstance();
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Set<Integer> set = Sets.newHashSet((Integer[]) integerSet.toArray());
Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
}
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testSize.
@Test
public void testSize() throws IllegalAccessException, InstantiationException {
for (Class<? extends MutableBitmap> clazz : clazzes) {
MutableBitmap wrappedBitmap = clazz.newInstance();
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Set<Integer> set = IntSetTestUtility.getSetBits();
Assert.assertEquals(set.size(), integerSet.size());
}
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class TestIntegerSet method testRetainAll.
@Test
public void testRetainAll() throws IllegalAccessException, InstantiationException {
for (Class<? extends MutableBitmap> clazz : clazzes) {
MutableBitmap wrappedBitmap = clazz.newInstance();
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Set<Integer> set = IntSetTestUtility.getSetBits();
set.remove(1);
set.add(9999);
boolean threwError = false;
try {
integerSet.retainAll(set);
} catch (UnsupportedOperationException ex) {
threwError = true;
}
Assert.assertTrue(threwError);
}
}
Aggregations