use of org.apache.druid.query.filter.ValueMatcher in project druid by druid-io.
the class DimensionSelectorUtils method makeNonDictionaryEncodedValueMatcherGeneric.
private static ValueMatcher makeNonDictionaryEncodedValueMatcherGeneric(final DimensionSelector selector, final Predicate<String> predicate) {
final boolean matchNull = predicate.apply(null);
return new ValueMatcher() {
@Override
public boolean matches() {
final IndexedInts row = selector.getRow();
final int size = row.size();
if (size == 0) {
// null should match empty rows in multi-value columns
return matchNull;
} else {
for (int i = 0; i < size; ++i) {
if (predicate.apply(selector.lookupName(row.get(i)))) {
return true;
}
}
return false;
}
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
inspector.visit("selector", selector);
inspector.visit("predicate", predicate);
}
};
}
use of org.apache.druid.query.filter.ValueMatcher in project druid by druid-io.
the class ValueMatchers method makeFloatValueMatcher.
/**
* Creates a predicate-based {@link ValueMatcher} for a float-typed selector.
*
* @param selector column selector
* @param predicateFactory predicate to match
*/
public static ValueMatcher makeFloatValueMatcher(final BaseFloatColumnValueSelector selector, final DruidPredicateFactory predicateFactory) {
final DruidFloatPredicate predicate = predicateFactory.makeFloatPredicate();
return new ValueMatcher() {
@Override
public boolean matches() {
if (selector.isNull()) {
return predicate.applyNull();
}
return predicate.applyFloat(selector.getFloat());
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
inspector.visit("selector", selector);
inspector.visit("predicate", predicate);
}
};
}
use of org.apache.druid.query.filter.ValueMatcher in project druid by druid-io.
the class ValueMatchers method makeDoubleValueMatcher.
/**
* Creates a predicate-based {@link ValueMatcher} for a double-typed selector.
*
* @param selector column selector
* @param predicateFactory predicate to match
*/
public static ValueMatcher makeDoubleValueMatcher(final BaseDoubleColumnValueSelector selector, final DruidPredicateFactory predicateFactory) {
final DruidDoublePredicate predicate = predicateFactory.makeDoublePredicate();
return new ValueMatcher() {
@Override
public boolean matches() {
if (selector.isNull()) {
return predicate.applyNull();
}
return predicate.applyDouble(selector.getDouble());
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
inspector.visit("selector", selector);
inspector.visit("predicate", predicate);
}
};
}
use of org.apache.druid.query.filter.ValueMatcher in project druid by druid-io.
the class ValueMatchers method makeLongValueMatcher.
public static ValueMatcher makeLongValueMatcher(final BaseLongColumnValueSelector selector, final DruidPredicateFactory predicateFactory) {
final DruidLongPredicate predicate = predicateFactory.makeLongPredicate();
return new ValueMatcher() {
@Override
public boolean matches() {
if (selector.isNull()) {
return predicate.applyNull();
}
return predicate.applyLong(selector.getLong());
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
inspector.visit("selector", selector);
inspector.visit("predicate", predicate);
}
};
}
use of org.apache.druid.query.filter.ValueMatcher 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 makeMatcher(matchers.toArray(BooleanFilter.EMPTY_VALUE_MATCHER_ARRAY));
}
Aggregations