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 UseIndexesStrategy method makeTimeFilteredBitmap.
static ImmutableBitmap makeTimeFilteredBitmap(final QueryableIndex index, final Segment segment, final Filter filter, final Interval interval) {
final BitmapFactory bitmapFactory = index.getBitmapFactoryForDimensions();
final ImmutableBitmap baseFilter;
if (filter == null) {
baseFilter = null;
} else {
final BitmapIndexSelector selector = new ColumnSelectorBitmapIndexSelector(index.getBitmapFactoryForDimensions(), VirtualColumns.EMPTY, index);
Preconditions.checkArgument(filter.supportsBitmapIndex(selector), "filter[%s] should support bitmap", filter);
baseFilter = filter.getBitmapIndex(selector);
}
final ImmutableBitmap timeFilteredBitmap;
if (!interval.contains(segment.getDataInterval())) {
final MutableBitmap timeBitmap = bitmapFactory.makeEmptyMutableBitmap();
final Column timeColumn = index.getColumn(Column.TIME_COLUMN_NAME);
try (final GenericColumn timeValues = timeColumn.getGenericColumn()) {
int startIndex = Math.max(0, getStartIndexOfTime(timeValues, interval.getStartMillis(), true));
int endIndex = Math.min(timeValues.length() - 1, getStartIndexOfTime(timeValues, interval.getEndMillis(), false));
for (int i = startIndex; i <= endIndex; i++) {
timeBitmap.add(i);
}
final ImmutableBitmap finalTimeBitmap = bitmapFactory.makeImmutableBitmap(timeBitmap);
timeFilteredBitmap = (baseFilter == null) ? finalTimeBitmap : finalTimeBitmap.intersection(baseFilter);
}
} else {
timeFilteredBitmap = baseFilter;
}
return timeFilteredBitmap;
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class BitmapOffset method getReverseBitmapOffsetIterator.
public static IntIterator getReverseBitmapOffsetIterator(ImmutableBitmap bitmapIndex) {
ImmutableBitmap roaringBitmap = bitmapIndex;
if (!(bitmapIndex instanceof WrappedImmutableRoaringBitmap)) {
final MutableBitmap bitmap = ROARING_BITMAP_FACTORY.makeEmptyMutableBitmap();
final IntIterator iterator = bitmapIndex.iterator();
while (iterator.hasNext()) {
bitmap.add(iterator.next());
}
roaringBitmap = ROARING_BITMAP_FACTORY.makeImmutableBitmap(bitmap);
}
return ((WrappedImmutableRoaringBitmap) roaringBitmap).getBitmap().getReverseIntIterator();
}
use of io.druid.collections.bitmap.MutableBitmap in project druid by druid-io.
the class LikeFilterBenchmark 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 DimensionPredicateFilterBenchmark method setup.
@Setup
public void setup() throws IOException {
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);
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();
}
};
}
Aggregations