Search in sources :

Example 1 with DruidFloatPredicate

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;
        }
    };
}
Also used : DruidFloatPredicate(org.apache.druid.query.filter.DruidFloatPredicate)

Example 2 with DruidFloatPredicate

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);
        }
    };
}
Also used : DruidFloatPredicate(org.apache.druid.query.filter.DruidFloatPredicate) ValueMatcher(org.apache.druid.query.filter.ValueMatcher) RuntimeShapeInspector(org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector)

Aggregations

DruidFloatPredicate (org.apache.druid.query.filter.DruidFloatPredicate)2 ValueMatcher (org.apache.druid.query.filter.ValueMatcher)1 RuntimeShapeInspector (org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector)1