use of org.apache.druid.query.filter.DruidDoublePredicate 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.DruidDoublePredicate in project druid by druid-io.
the class DoubleVectorValueMatcher method makeMatcher.
@Override
public VectorValueMatcher makeMatcher(final DruidPredicateFactory predicateFactory) {
final DruidDoublePredicate predicate = predicateFactory.makeDoublePredicate();
return new BaseVectorValueMatcher(selector) {
final VectorMatch match = VectorMatch.wrap(new int[selector.getMaxVectorSize()]);
@Override
public ReadableVectorMatch match(final ReadableVectorMatch mask) {
final double[] vector = selector.getDoubleVector();
final int[] selection = match.getSelection();
final boolean[] nulls = selector.getNullVector();
final boolean hasNulls = canHaveNulls && nulls != null;
int numRows = 0;
for (int i = 0; i < mask.getSelectionSize(); i++) {
final int rowNum = mask.getSelection()[i];
if (hasNulls && nulls[rowNum]) {
if (predicate.applyNull()) {
selection[numRows++] = rowNum;
}
} else if (predicate.applyDouble(vector[rowNum])) {
selection[numRows++] = rowNum;
}
}
match.setSelectionSize(numRows);
assert match.isValid(mask);
return match;
}
};
}
Aggregations