use of io.druid.collections.bitmap.ImmutableBitmap 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.ImmutableBitmap in project druid by druid-io.
the class OrFilter method makeMatcher.
@Override
public ValueMatcher makeMatcher(BitmapIndexSelector selector, ColumnSelectorFactory columnSelectorFactory, RowOffsetMatcherFactory rowOffsetMatcherFactory) {
final List<ValueMatcher> matchers = new ArrayList<>();
final List<ImmutableBitmap> bitmaps = new ArrayList<>();
for (Filter filter : filters) {
if (filter.supportsBitmapIndex(selector)) {
bitmaps.add(filter.getBitmapIndex(selector));
} else {
ValueMatcher matcher = filter.makeMatcher(columnSelectorFactory);
matchers.add(matcher);
}
}
if (bitmaps.size() > 0) {
ImmutableBitmap combinedBitmap = selector.getBitmapFactory().union(bitmaps);
ValueMatcher offsetMatcher = rowOffsetMatcherFactory.makeRowOffsetMatcher(combinedBitmap);
matchers.add(0, offsetMatcher);
}
return new ValueMatcher() {
@Override
public boolean matches() {
for (ValueMatcher valueMatcher : matchers) {
if (valueMatcher.matches()) {
return true;
}
}
return false;
}
};
}
use of io.druid.collections.bitmap.ImmutableBitmap in project druid by druid-io.
the class AndFilter method getBitmapIndex.
public static ImmutableBitmap getBitmapIndex(BitmapIndexSelector selector, List<Filter> filters) {
if (filters.size() == 1) {
return filters.get(0).getBitmapIndex(selector);
}
final List<ImmutableBitmap> bitmaps = Lists.newArrayListWithCapacity(filters.size());
for (final Filter filter : filters) {
Preconditions.checkArgument(filter.supportsBitmapIndex(selector), "Filter[%s] does not support bitmap index", filter);
final ImmutableBitmap bitmapIndex = filter.getBitmapIndex(selector);
if (bitmapIndex.isEmpty()) {
// Short-circuit.
return Filters.allFalse(selector);
}
bitmaps.add(bitmapIndex);
}
return selector.getBitmapFactory().intersection(bitmaps);
}
use of io.druid.collections.bitmap.ImmutableBitmap in project druid by druid-io.
the class AndFilter method makeMatcher.
@Override
public ValueMatcher makeMatcher(BitmapIndexSelector selector, ColumnSelectorFactory columnSelectorFactory, RowOffsetMatcherFactory rowOffsetMatcherFactory) {
final List<ValueMatcher> matchers = new ArrayList<>();
final List<ImmutableBitmap> bitmaps = new ArrayList<>();
for (Filter filter : filters) {
if (filter.supportsBitmapIndex(selector)) {
bitmaps.add(filter.getBitmapIndex(selector));
} else {
ValueMatcher matcher = filter.makeMatcher(columnSelectorFactory);
matchers.add(matcher);
}
}
if (bitmaps.size() > 0) {
ImmutableBitmap combinedBitmap = selector.getBitmapFactory().intersection(bitmaps);
ValueMatcher offsetMatcher = rowOffsetMatcherFactory.makeRowOffsetMatcher(combinedBitmap);
matchers.add(0, offsetMatcher);
}
return new ValueMatcher() {
@Override
public boolean matches() {
for (ValueMatcher valueMatcher : matchers) {
if (!valueMatcher.matches()) {
return false;
}
}
return true;
}
};
}
use of io.druid.collections.bitmap.ImmutableBitmap in project druid by druid-io.
the class LikeFilterBenchmark method matchRegexPrefix.
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void matchRegexPrefix(Blackhole blackhole) {
final ImmutableBitmap bitmapIndex = REGEX_PREFIX.getBitmapIndex(selector);
blackhole.consume(bitmapIndex);
}
Aggregations