use of org.apache.druid.query.filter.DruidFloatPredicate in project druid by druid-io.
the class FloatVectorValueMatcher method makeMatcher.
@Override
public VectorValueMatcher makeMatcher(final DruidPredicateFactory predicateFactory) {
final DruidFloatPredicate predicate = predicateFactory.makeFloatPredicate();
return new BaseVectorValueMatcher(selector) {
final VectorMatch match = VectorMatch.wrap(new int[selector.getMaxVectorSize()]);
@Override
public ReadableVectorMatch match(final ReadableVectorMatch mask) {
final float[] vector = selector.getFloatVector();
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.applyFloat(vector[rowNum])) {
selection[numRows++] = rowNum;
}
}
match.setSelectionSize(numRows);
assert match.isValid(mask);
return match;
}
};
}
use of org.apache.druid.query.filter.DruidFloatPredicate 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);
}
};
}
Aggregations