diff --git a/processing/src/main/java/org/apache/druid/math/expr/ApplyFunction.java b/processing/src/main/java/org/apache/druid/math/expr/ApplyFunction.java index 9f5bbffcc21..6403f2b28c0 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/ApplyFunction.java +++ b/processing/src/main/java/org/apache/druid/math/expr/ApplyFunction.java @@ -57,9 +57,9 @@ public interface ApplyFunction extends NamedFunction /** * Builds a 'vectorized' function expression processor, that can build vectorized processors for its input values - * using {@link Expr#buildVectorized}, for use in vectorized query engines. + * using {@link Expr#asVectorProcessor}, for use in vectorized query engines. * - * @see Expr#buildVectorized(Expr.VectorInputBindingInspector) + * @see Expr#asVectorProcessor(Expr.VectorInputBindingInspector) * @see Function#asVectorProcessor(Expr.VectorInputBindingInspector, List) */ default ExprVectorProcessor asVectorProcessor( diff --git a/processing/src/main/java/org/apache/druid/math/expr/BinaryLogicalOperatorExpr.java b/processing/src/main/java/org/apache/druid/math/expr/BinaryLogicalOperatorExpr.java index 7b991ca13ab..de1de837818 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/BinaryLogicalOperatorExpr.java +++ b/processing/src/main/java/org/apache/druid/math/expr/BinaryLogicalOperatorExpr.java @@ -70,7 +70,7 @@ class BinLtExpr extends BinaryBooleanOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorComparisonProcessors.lessThan(inspector, left, right); } @@ -116,7 +116,7 @@ class BinLeqExpr extends BinaryBooleanOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorComparisonProcessors.lessThanOrEqual(inspector, left, right); } @@ -162,7 +162,7 @@ class BinGtExpr extends BinaryBooleanOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorComparisonProcessors.greaterThan(inspector, left, right); } @@ -208,7 +208,7 @@ class BinGeqExpr extends BinaryBooleanOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorComparisonProcessors.greaterThanOrEqual(inspector, left, right); } @@ -253,7 +253,7 @@ class BinEqExpr extends BinaryBooleanOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorComparisonProcessors.equal(inspector, left, right); } @@ -298,7 +298,7 @@ class BinNeqExpr extends BinaryBooleanOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorComparisonProcessors.notEqual(inspector, left, right); } @@ -331,7 +331,9 @@ class BinAndExpr extends BinaryOpExprBase return ExprEval.ofLongBoolean(false); } ExprEval rightVal; - if (NullHandling.sqlCompatible() || Types.is(leftVal.type(), ExprType.STRING)) { + // null values can (but not always) appear as string typed + // so type isn't necessarily string unless value is non-null + if (NullHandling.sqlCompatible() || (Types.is(leftVal.type(), ExprType.STRING))) { // true/null, null/true, null/null -> null // false/null, null/false -> false if (leftVal.value() == null) { @@ -362,7 +364,7 @@ class BinAndExpr extends BinaryOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorProcessors.and(inspector, left, right); } @@ -405,7 +407,9 @@ class BinOrExpr extends BinaryOpExprBase } final ExprEval rightVal; - if (NullHandling.sqlCompatible() || Types.is(leftVal.type(), ExprType.STRING)) { + // null values can (but not always) appear as string typed + // so type isn't necessarily string unless value is non-null + if (NullHandling.sqlCompatible() || (Types.is(leftVal.type(), ExprType.STRING))) { // true/null, null/true -> true // false/null, null/false, null/null -> null if (leftVal.value() == null) { @@ -438,7 +442,7 @@ class BinOrExpr extends BinaryOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorProcessors.or(inspector, left, right); } diff --git a/processing/src/main/java/org/apache/druid/math/expr/BinaryMathOperatorExpr.java b/processing/src/main/java/org/apache/druid/math/expr/BinaryMathOperatorExpr.java index c8a4ce636eb..17160c24bae 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/BinaryMathOperatorExpr.java +++ b/processing/src/main/java/org/apache/druid/math/expr/BinaryMathOperatorExpr.java @@ -70,7 +70,7 @@ final class BinPlusExpr extends BinaryEvalOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { ExpressionType type = ExpressionTypeConversion.operator( left.getOutputType(inspector), @@ -116,7 +116,7 @@ final class BinMinusExpr extends BinaryEvalOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorMathProcessors.minus(inspector, left, right); } @@ -155,7 +155,7 @@ final class BinMulExpr extends BinaryEvalOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorMathProcessors.multiply(inspector, left, right); } @@ -194,7 +194,7 @@ final class BinDivExpr extends BinaryEvalOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorMathProcessors.divide(inspector, left, right); } @@ -233,7 +233,7 @@ class BinPowExpr extends BinaryEvalOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorMathProcessors.power(inspector, left, right); } @@ -272,7 +272,7 @@ class BinModuloExpr extends BinaryEvalOpExprBase } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorMathProcessors.modulo(inspector, left, right); } diff --git a/processing/src/main/java/org/apache/druid/math/expr/ConstantExpr.java b/processing/src/main/java/org/apache/druid/math/expr/ConstantExpr.java index d9a40f82d17..ff4cedbecbb 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/ConstantExpr.java +++ b/processing/src/main/java/org/apache/druid/math/expr/ConstantExpr.java @@ -175,7 +175,7 @@ class LongExpr extends ConstantExpr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorProcessors.constant(value, inspector.getMaxVectorSize()); } @@ -214,7 +214,7 @@ class NullLongExpr extends ConstantExpr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorProcessors.constant((Long) null, inspector.getMaxVectorSize()); } @@ -258,7 +258,7 @@ class DoubleExpr extends ConstantExpr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorProcessors.constant(value, inspector.getMaxVectorSize()); } @@ -297,7 +297,7 @@ class NullDoubleExpr extends ConstantExpr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorProcessors.constant((Double) null, inspector.getMaxVectorSize()); } @@ -341,7 +341,7 @@ class StringExpr extends ConstantExpr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorProcessors.constant(value, inspector.getMaxVectorSize()); } diff --git a/processing/src/main/java/org/apache/druid/math/expr/Expr.java b/processing/src/main/java/org/apache/druid/math/expr/Expr.java index 00f16df892a..9844a0526bf 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/Expr.java +++ b/processing/src/main/java/org/apache/druid/math/expr/Expr.java @@ -164,7 +164,7 @@ public interface Expr extends Cacheable /** * Check if an expression can be 'vectorized', for a given set of inputs. If this method returns true, - * {@link #buildVectorized} is expected to produce a {@link ExprVectorProcessor} which can evaluate values in batches + * {@link #asVectorProcessor} is expected to produce a {@link ExprVectorProcessor} which can evaluate values in batches * to use with vectorized query engines. * * @param inspector @@ -180,7 +180,7 @@ public interface Expr extends Cacheable * * @param inspector */ - default ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + default ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { throw Exprs.cannotVectorize(this); } @@ -345,7 +345,7 @@ public interface Expr extends Cacheable } /** - * {@link InputBindingInspector} + vectorizations stuff for {@link #buildVectorized} + * {@link InputBindingInspector} + vectorizations stuff for {@link #asVectorProcessor} */ interface VectorInputBindingInspector extends InputBindingInspector { diff --git a/processing/src/main/java/org/apache/druid/math/expr/ExprEval.java b/processing/src/main/java/org/apache/druid/math/expr/ExprEval.java index f06618a23a5..6e4e142b428 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/ExprEval.java +++ b/processing/src/main/java/org/apache/druid/math/expr/ExprEval.java @@ -109,14 +109,14 @@ public abstract class ExprEval int offset = position; switch (type.getType()) { case LONG: - if (eval.isNumericNull()) { + if (eval.value() == null) { TypeStrategies.writeNull(buffer, offset); } else { TypeStrategies.writeNotNullNullableLong(buffer, offset, eval.asLong()); } break; case DOUBLE: - if (eval.isNumericNull()) { + if (eval.value() == null) { TypeStrategies.writeNull(buffer, offset); } else { TypeStrategies.writeNotNullNullableDouble(buffer, offset, eval.asDouble()); @@ -163,14 +163,14 @@ public abstract class ExprEval Object[] array = new Object[val.size()]; int i = 0; for (Object o : val) { - array[i++] = o == null ? null : ExprEval.ofType(ExpressionType.LONG, o).value(); + array[i++] = o != null ? ExprEval.ofType(ExpressionType.LONG, o).value() : null; } return new NonnullPair<>(ExpressionType.LONG_ARRAY, array); } else if (coercedType == Float.class || coercedType == Double.class) { Object[] array = new Object[val.size()]; int i = 0; for (Object o : val) { - array[i++] = ExprEval.ofType(ExpressionType.DOUBLE, o).value(); + array[i++] = o != null ? ExprEval.ofType(ExpressionType.DOUBLE, o).value() : null; } return new NonnullPair<>(ExpressionType.DOUBLE_ARRAY, array); } else if (coercedType == Object.class) { @@ -205,7 +205,7 @@ public abstract class ExprEval Object[] array = new Object[val.size()]; int i = 0; for (Object o : val) { - array[i++] = o == null ? null : ExprEval.ofType(ExpressionType.STRING, o).value(); + array[i++] = o != null ? ExprEval.ofType(ExpressionType.STRING, o).value() : null; } return new NonnullPair<>(ExpressionType.STRING_ARRAY, array); } @@ -345,7 +345,6 @@ public abstract class ExprEval @Deprecated public static ExprEval ofBoolean(boolean value, ExprType type) { - assert !ExpressionProcessing.useStrictBooleans(); switch (type) { case DOUBLE: return ExprEval.of(Evals.asDouble(value)); @@ -398,7 +397,7 @@ public abstract class ExprEval final Long[] inputArray = (Long[]) val; final Object[] array = new Object[inputArray.length]; for (int i = 0; i < inputArray.length; i++) { - array[i] = inputArray[i] != null ? inputArray[i] : NullHandling.defaultLongValue(); + array[i] = inputArray[i]; } return new ArrayExprEval(ExpressionType.LONG_ARRAY, array); } @@ -414,7 +413,7 @@ public abstract class ExprEval final Integer[] inputArray = (Integer[]) val; final Object[] array = new Object[inputArray.length]; for (int i = 0; i < inputArray.length; i++) { - array[i] = inputArray[i] != null ? inputArray[i].longValue() : NullHandling.defaultLongValue(); + array[i] = inputArray[i] != null ? inputArray[i].longValue() : null; } return new ArrayExprEval(ExpressionType.LONG_ARRAY, array); } @@ -430,7 +429,7 @@ public abstract class ExprEval final Double[] inputArray = (Double[]) val; final Object[] array = new Object[inputArray.length]; for (int i = 0; i < inputArray.length; i++) { - array[i] = inputArray[i] != null ? inputArray[i] : NullHandling.defaultDoubleValue(); + array[i] = inputArray[i] != null ? inputArray[i] : null; } return new ArrayExprEval(ExpressionType.DOUBLE_ARRAY, array); } @@ -446,7 +445,7 @@ public abstract class ExprEval final Float[] inputArray = (Float[]) val; final Object[] array = new Object[inputArray.length]; for (int i = 0; i < inputArray.length; i++) { - array[i] = inputArray[i] != null ? inputArray[i].doubleValue() : NullHandling.defaultDoubleValue(); + array[i] = inputArray[i] != null ? inputArray[i].doubleValue() : null; } return new ArrayExprEval(ExpressionType.DOUBLE_ARRAY, array); } @@ -561,7 +560,6 @@ public abstract class ExprEval if (bytes != null) { TypeStrategy strategy = type.getStrategy(); - assert strategy != null; ByteBuffer bb = ByteBuffer.wrap(bytes); return ofComplex(type, strategy.read(bb)); } @@ -653,6 +651,12 @@ public abstract class ExprEval return value; } + @Nullable + public T valueOrDefault() + { + return value; + } + void cacheStringValue(@Nullable String value) { stringValue = value; @@ -662,7 +666,6 @@ public abstract class ExprEval @Nullable String getCachedStringValue() { - assert stringValueCached; return stringValue; } @@ -743,25 +746,34 @@ public abstract class ExprEval @Override public final int asInt() { + if (value == null) { + return 0; + } return value.intValue(); } @Override public final long asLong() { + if (value == null) { + return 0L; + } return value.longValue(); } @Override public final double asDouble() { + if (value == null) { + return 0.0; + } return value.doubleValue(); } @Override public boolean isNumericNull() { - return value == null; + return NullHandling.sqlCompatible() && value == null; } } @@ -771,7 +783,7 @@ public abstract class ExprEval private DoubleExprEval(@Nullable Number value) { - super(value == null ? NullHandling.defaultDoubleValue() : (Double) value.doubleValue()); + super(value == null ? null : value.doubleValue()); } @Override @@ -780,6 +792,15 @@ public abstract class ExprEval return ExpressionType.DOUBLE; } + @Override + public Number valueOrDefault() + { + if (value == null) { + return NullHandling.defaultDoubleValue(); + } + return value; + } + @Override public final boolean asBoolean() { @@ -823,7 +844,7 @@ public abstract class ExprEval @Override public Expr toExpr() { - if (isNumericNull()) { + if (value == null) { return new NullDoubleExpr(); } return new DoubleExpr(value.doubleValue()); @@ -836,7 +857,7 @@ public abstract class ExprEval private LongExprEval(@Nullable Number value) { - super(value == null ? NullHandling.defaultLongValue() : (Long) value.longValue()); + super(value == null ? null : value.longValue()); } @Override @@ -845,6 +866,15 @@ public abstract class ExprEval return ExpressionType.LONG; } + @Override + public Number valueOrDefault() + { + if (value == null) { + return NullHandling.defaultLongValue(); + } + return value; + } + @Override public final boolean asBoolean() { @@ -888,7 +918,7 @@ public abstract class ExprEval @Override public Expr toExpr() { - if (isNumericNull()) { + if (value == null) { return new NullLongExpr(); } return new LongExpr(value.longValue()); @@ -974,7 +1004,6 @@ public abstract class ExprEval { Number number = computeNumber(); if (number == null) { - assert NullHandling.replaceWithDefault(); return 0; } return number.intValue(); @@ -984,7 +1013,6 @@ public abstract class ExprEval { Number number = computeNumber(); if (number == null) { - assert NullHandling.replaceWithDefault(); return 0L; } return number.longValue(); @@ -994,7 +1022,6 @@ public abstract class ExprEval { Number number = computeNumber(); if (number == null) { - assert NullHandling.replaceWithDefault(); return 0.0d; } return number.doubleValue(); @@ -1042,11 +1069,16 @@ public abstract class ExprEval case STRING: return this; case ARRAY: + final Number number = computeNumber(); switch (castTo.getElementType().getType()) { case DOUBLE: - return ExprEval.ofDoubleArray(value == null ? null : new Object[] {computeDouble()}); + return ExprEval.ofDoubleArray( + value == null ? null : new Object[] {number == null ? null : number.doubleValue()} + ); case LONG: - return ExprEval.ofLongArray(value == null ? null : new Object[] {computeLong()}); + return ExprEval.ofLongArray( + value == null ? null : new Object[] {number == null ? null : number.longValue()} + ); case STRING: return ExprEval.ofStringArray(value == null ? null : new Object[] {value}); } @@ -1131,7 +1163,6 @@ public abstract class ExprEval scalar = computeNumber((String) getScalarValue()); } if (scalar == null) { - assert NullHandling.replaceWithDefault(); return 0; } return scalar.intValue(); @@ -1150,7 +1181,6 @@ public abstract class ExprEval scalar = computeNumber((String) getScalarValue()); } if (scalar == null) { - assert NullHandling.replaceWithDefault(); return 0; } return scalar.longValue(); @@ -1169,7 +1199,6 @@ public abstract class ExprEval scalar = computeNumber((String) getScalarValue()); } if (scalar == null) { - assert NullHandling.replaceWithDefault(); return 0.0; } return scalar.doubleValue(); @@ -1184,7 +1213,6 @@ public abstract class ExprEval if (arrayType.getElementType().isNumeric()) { Number scalarValue = (Number) getScalarValue(); if (scalarValue == null) { - assert NullHandling.replaceWithDefault(); return false; } return Evals.asBoolean(scalarValue.longValue()); @@ -1257,7 +1285,6 @@ public abstract class ExprEval @Nullable protected Object getScalarValue() { - assert value != null && value.length == 1; return value[0]; } } diff --git a/processing/src/main/java/org/apache/druid/math/expr/Function.java b/processing/src/main/java/org/apache/druid/math/expr/Function.java index 1763e18ef80..70cd0f8f278 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/Function.java +++ b/processing/src/main/java/org/apache/druid/math/expr/Function.java @@ -131,9 +131,9 @@ public interface Function extends NamedFunction /** * Builds a 'vectorized' function expression processor, that can build vectorized processors for its input values - * using {@link Expr#buildVectorized}, for use in vectorized query engines. + * using {@link Expr#asVectorProcessor}, for use in vectorized query engines. * - * @see Expr#buildVectorized(Expr.VectorInputBindingInspector) + * @see Expr#asVectorProcessor(Expr.VectorInputBindingInspector) * @see ApplyFunction#asVectorProcessor(Expr.VectorInputBindingInspector, Expr, List) */ default ExprVectorProcessor asVectorProcessor(Expr.VectorInputBindingInspector inspector, List args) @@ -1176,7 +1176,7 @@ public interface Function extends NamedFunction { if (y == 0) { if (x != 0) { - return ExprEval.ofLong(NullHandling.defaultLongValue()); + return ExprEval.ofLong(null); } return ExprEval.ofLong(0); } @@ -1188,7 +1188,7 @@ public interface Function extends NamedFunction { if (y == 0 || Double.isNaN(y)) { if (x != 0) { - return ExprEval.ofDouble(NullHandling.defaultDoubleValue()); + return ExprEval.ofDouble(null); } return ExprEval.ofDouble(0); } @@ -2014,7 +2014,7 @@ public interface Function extends NamedFunction public ExprVectorProcessor asVectorProcessor(Expr.VectorInputBindingInspector inspector, List args) { return CastToTypeVectorProcessor.cast( - args.get(0).buildVectorized(inspector), + args.get(0).asVectorProcessor(inspector), ExpressionType.fromString(StringUtils.toUpperCase(args.get(1).getLiteralValue().toString())) ); } @@ -2384,7 +2384,7 @@ public interface Function extends NamedFunction public ExprEval apply(List args, Expr.ObjectBinding bindings) { final String arg = args.get(0).eval(bindings).asString(); - return arg == null ? ExprEval.ofLong(NullHandling.defaultLongValue()) : ExprEval.of(arg.length()); + return arg == null ? ExprEval.ofLong(null) : ExprEval.of(arg.length()); } @Override diff --git a/processing/src/main/java/org/apache/druid/math/expr/FunctionalExpr.java b/processing/src/main/java/org/apache/druid/math/expr/FunctionalExpr.java index 5d0aee9d392..3eef9c7bacb 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/FunctionalExpr.java +++ b/processing/src/main/java/org/apache/druid/math/expr/FunctionalExpr.java @@ -90,9 +90,9 @@ class LambdaExpr implements Expr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { - return expr.buildVectorized(inspector); + return expr.asVectorProcessor(inspector); } @Override @@ -190,7 +190,7 @@ class FunctionExpr implements Expr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return function.asVectorProcessor(inspector, args); } @@ -313,7 +313,7 @@ class ApplyFunctionExpr implements Expr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return function.asVectorProcessor(inspector, lambdaExpr, argsExpr); } diff --git a/processing/src/main/java/org/apache/druid/math/expr/IdentifierExpr.java b/processing/src/main/java/org/apache/druid/math/expr/IdentifierExpr.java index 63b5535f844..1fb2b249909 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/IdentifierExpr.java +++ b/processing/src/main/java/org/apache/druid/math/expr/IdentifierExpr.java @@ -147,7 +147,7 @@ class IdentifierExpr implements Expr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorProcessors.identifier(inspector, binding); } diff --git a/processing/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java b/processing/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java index 6e559d8ee08..d260f0b887d 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java +++ b/processing/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java @@ -147,7 +147,7 @@ class UnaryMinusExpr extends UnaryExpr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorMathProcessors.negate(inspector, expr); } @@ -203,7 +203,7 @@ class UnaryNotExpr extends UnaryExpr } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { return VectorProcessors.not(inspector, expr); } diff --git a/processing/src/main/java/org/apache/druid/math/expr/vector/ExprEvalVector.java b/processing/src/main/java/org/apache/druid/math/expr/vector/ExprEvalVector.java index 723b34f12c2..f723ada4f7a 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/vector/ExprEvalVector.java +++ b/processing/src/main/java/org/apache/druid/math/expr/vector/ExprEvalVector.java @@ -19,11 +19,9 @@ package org.apache.druid.math.expr.vector; -import org.apache.druid.common.config.NullHandling; import org.apache.druid.math.expr.ExpressionType; import javax.annotation.Nullable; -import java.lang.reflect.Array; /** * Result of {@link ExprVectorProcessor#evalVector} which wraps the actual evaluated results of the operation over the @@ -48,15 +46,6 @@ public abstract class ExprEvalVector return values; } - @Nullable - public Object get(int index) - { - if (nulls == null || NullHandling.replaceWithDefault() || !nulls[index]) { - return Array.get(values, index); - } - return null; - } - @Nullable public boolean[] getNullVector() { diff --git a/processing/src/main/java/org/apache/druid/math/expr/vector/LongOutObjectsInFunctionVectorProcessor.java b/processing/src/main/java/org/apache/druid/math/expr/vector/LongOutObjectsInFunctionVectorProcessor.java index de34db9afd4..a99342928fb 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/vector/LongOutObjectsInFunctionVectorProcessor.java +++ b/processing/src/main/java/org/apache/druid/math/expr/vector/LongOutObjectsInFunctionVectorProcessor.java @@ -19,6 +19,7 @@ package org.apache.druid.math.expr.vector; +import org.apache.druid.common.config.NullHandling; import org.apache.druid.math.expr.ExpressionType; import javax.annotation.Nullable; @@ -52,7 +53,7 @@ public abstract class LongOutObjectsInFunctionVectorProcessor final Long outVal = processValue(in1[i], in2[i]); if (outVal == null) { outValues[i] = 0L; - outNulls[i] = true; + outNulls[i] = NullHandling.sqlCompatible(); } else { outValues[i] = outVal; outNulls[i] = false; @@ -63,7 +64,7 @@ public abstract class LongOutObjectsInFunctionVectorProcessor void processNull(int i) { outValues[i] = 0L; - outNulls[i] = true; + outNulls[i] = NullHandling.sqlCompatible(); } @Override diff --git a/processing/src/main/java/org/apache/druid/math/expr/vector/VectorComparisonProcessors.java b/processing/src/main/java/org/apache/druid/math/expr/vector/VectorComparisonProcessors.java index decfd9b3d49..a132c0ee672 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/vector/VectorComparisonProcessors.java +++ b/processing/src/main/java/org/apache/druid/math/expr/vector/VectorComparisonProcessors.java @@ -137,8 +137,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -151,8 +151,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -163,8 +163,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -175,8 +175,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -187,8 +187,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -205,8 +205,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -219,8 +219,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -231,8 +231,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -243,8 +243,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -255,8 +255,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -281,8 +281,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -295,8 +295,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -307,8 +307,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -319,8 +319,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -331,8 +331,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -349,8 +349,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -363,8 +363,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -375,8 +375,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -387,8 +387,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -399,8 +399,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -425,8 +425,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -441,8 +441,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -453,8 +453,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -465,8 +465,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -477,8 +477,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -495,8 +495,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -511,8 +511,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -523,8 +523,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -535,8 +535,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -547,8 +547,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -573,8 +573,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -589,8 +589,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -601,8 +601,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -613,8 +613,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -625,8 +625,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -643,8 +643,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -659,8 +659,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -671,8 +671,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -683,8 +683,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -695,8 +695,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -721,8 +721,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -737,8 +737,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -749,8 +749,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -761,8 +761,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -773,8 +773,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -791,8 +791,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -807,8 +807,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -819,8 +819,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -831,8 +831,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -843,8 +843,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -869,8 +869,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -885,8 +885,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -897,8 +897,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -909,8 +909,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -921,8 +921,8 @@ public class VectorComparisonProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -939,8 +939,8 @@ public class VectorComparisonProcessors left, right, () -> new LongOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -955,8 +955,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -967,8 +967,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -979,8 +979,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -991,8 +991,8 @@ public class VectorComparisonProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { diff --git a/processing/src/main/java/org/apache/druid/math/expr/vector/VectorMathProcessors.java b/processing/src/main/java/org/apache/druid/math/expr/vector/VectorMathProcessors.java index 4499be2f31f..b45764e935e 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/vector/VectorMathProcessors.java +++ b/processing/src/main/java/org/apache/druid/math/expr/vector/VectorMathProcessors.java @@ -266,8 +266,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -278,8 +278,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -290,8 +290,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -302,8 +302,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -323,8 +323,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -335,8 +335,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -347,8 +347,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -359,8 +359,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -380,8 +380,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -392,8 +392,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -404,8 +404,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -416,8 +416,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -437,8 +437,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -449,8 +449,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -461,8 +461,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -473,8 +473,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -494,8 +494,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -506,8 +506,8 @@ public class VectorMathProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -518,8 +518,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -530,8 +530,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -551,8 +551,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -563,8 +563,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -575,8 +575,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -587,8 +587,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -607,7 +607,7 @@ public class VectorMathProcessors inspector, arg, () -> new LongOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -618,7 +618,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -638,8 +638,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -650,8 +650,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -662,8 +662,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -674,8 +674,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -700,8 +700,8 @@ public class VectorMathProcessors if ((Types.is(leftType, ExprType.LONG) && Types.isNullOr(rightType, ExprType.LONG)) || (leftType == null && Types.is(rightType, ExprType.LONG))) { processor = new DoubleOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -726,8 +726,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -738,8 +738,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -750,8 +750,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -762,8 +762,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -783,8 +783,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -795,8 +795,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -807,8 +807,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -819,8 +819,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -840,8 +840,8 @@ public class VectorMathProcessors left, right, () -> new DoubleOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -852,8 +852,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -864,8 +864,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -876,8 +876,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -897,8 +897,8 @@ public class VectorMathProcessors left, right, () -> new DoubleOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -909,8 +909,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -921,8 +921,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -933,8 +933,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -954,8 +954,8 @@ public class VectorMathProcessors left, right, () -> new DoubleOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -966,8 +966,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -978,8 +978,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -990,8 +990,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1011,8 +1011,8 @@ public class VectorMathProcessors left, right, () -> new DoubleOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1023,8 +1023,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1035,8 +1035,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1047,8 +1047,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1068,8 +1068,8 @@ public class VectorMathProcessors left, right, () -> new DoubleOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1080,8 +1080,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1092,8 +1092,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1104,8 +1104,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1125,8 +1125,8 @@ public class VectorMathProcessors left, right, () -> new DoubleOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1137,8 +1137,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1149,8 +1149,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1161,8 +1161,8 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1181,7 +1181,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1192,7 +1192,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1211,7 +1211,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1222,7 +1222,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1241,7 +1241,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1252,7 +1252,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1271,7 +1271,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1282,7 +1282,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1301,7 +1301,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1312,7 +1312,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1331,7 +1331,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1342,7 +1342,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1361,7 +1361,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1372,7 +1372,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1391,7 +1391,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1402,7 +1402,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1421,7 +1421,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1432,7 +1432,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1451,7 +1451,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1462,7 +1462,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1481,7 +1481,7 @@ public class VectorMathProcessors inspector, arg, () -> new LongOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1492,7 +1492,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1511,7 +1511,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1522,7 +1522,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1541,7 +1541,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1552,7 +1552,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1571,7 +1571,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1582,7 +1582,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1601,7 +1601,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1612,7 +1612,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1631,7 +1631,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1642,7 +1642,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1661,7 +1661,7 @@ public class VectorMathProcessors inspector, arg, () -> new LongOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1672,7 +1672,7 @@ public class VectorMathProcessors } }, () -> new LongOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1691,7 +1691,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1702,7 +1702,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1721,7 +1721,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1732,7 +1732,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1751,7 +1751,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1762,7 +1762,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1781,7 +1781,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1792,7 +1792,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1811,7 +1811,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1822,7 +1822,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1841,7 +1841,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1852,7 +1852,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1871,7 +1871,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1882,7 +1882,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1901,7 +1901,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1912,7 +1912,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1931,7 +1931,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1942,7 +1942,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1961,7 +1961,7 @@ public class VectorMathProcessors inspector, arg, () -> new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1972,7 +1972,7 @@ public class VectorMathProcessors } }, () -> new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -1991,7 +1991,7 @@ public class VectorMathProcessors inspector, arg, () -> new LongOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2002,7 +2002,7 @@ public class VectorMathProcessors } }, () -> new LongOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2025,7 +2025,7 @@ public class VectorMathProcessors ExprVectorProcessor processor = null; if (Types.is(inputType, ExprType.LONG)) { processor = new LongOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2037,7 +2037,7 @@ public class VectorMathProcessors }; } else if (Types.is(inputType, ExprType.DOUBLE)) { processor = new LongOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2064,7 +2064,7 @@ public class VectorMathProcessors ExprVectorProcessor processor = null; if (Types.is(inputType, ExprType.LONG)) { processor = new DoubleOutLongInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2076,7 +2076,7 @@ public class VectorMathProcessors }; } else if (Types.is(inputType, ExprType.DOUBLE)) { processor = new DoubleOutDoubleInFunctionVectorValueProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2100,8 +2100,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2112,8 +2112,8 @@ public class VectorMathProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2124,8 +2124,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2136,8 +2136,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2157,8 +2157,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2169,8 +2169,8 @@ public class VectorMathProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2181,8 +2181,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2193,8 +2193,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2214,8 +2214,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2226,8 +2226,8 @@ public class VectorMathProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2238,8 +2238,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2250,8 +2250,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2275,8 +2275,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2287,8 +2287,8 @@ public class VectorMathProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2299,8 +2299,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2311,8 +2311,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2336,8 +2336,8 @@ public class VectorMathProcessors left, right, () -> new LongOutLongsInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2348,8 +2348,8 @@ public class VectorMathProcessors } }, () -> new LongOutLongDoubleInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2360,8 +2360,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoubleLongInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { @@ -2372,8 +2372,8 @@ public class VectorMathProcessors } }, () -> new LongOutDoublesInFunctionVectorValueProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize() ) { diff --git a/processing/src/main/java/org/apache/druid/math/expr/vector/VectorProcessors.java b/processing/src/main/java/org/apache/druid/math/expr/vector/VectorProcessors.java index e23e03eef38..2fb3591ddfc 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/vector/VectorProcessors.java +++ b/processing/src/main/java/org/apache/druid/math/expr/vector/VectorProcessors.java @@ -55,7 +55,7 @@ public class VectorProcessors // if type is null, it means the input is all nulls if (leftType == null) { - return right.buildVectorized(inspector); + return right.asVectorProcessor(inspector); } Preconditions.checkArgument( @@ -80,6 +80,11 @@ public class VectorProcessors return (ExprVectorProcessor) processor; } + /** + * Creates an {@link ExprVectorProcessor} that creates a {@link ExprEvalVector} for a constant {@link String} value. + * + * @see org.apache.druid.math.expr.ConstantExpr + */ public static ExprVectorProcessor constant(@Nullable String constant, int maxVectorSize) { final Object[] strings = new Object[maxVectorSize]; @@ -101,13 +106,18 @@ public class VectorProcessors }; } + /** + * Creates an {@link ExprVectorProcessor} that creates a {@link ExprEvalVector} for a constant {@link Double} value. + * + * @see org.apache.druid.math.expr.ConstantExpr + */ public static ExprVectorProcessor constant(@Nullable Double constant, int maxVectorSize) { final double[] doubles = new double[maxVectorSize]; final boolean[] nulls; if (constant == null) { nulls = new boolean[maxVectorSize]; - Arrays.fill(nulls, true); + Arrays.fill(nulls, NullHandling.sqlCompatible()); } else { nulls = null; Arrays.fill(doubles, constant); @@ -129,13 +139,18 @@ public class VectorProcessors }; } + /** + * Creates an {@link ExprVectorProcessor} that creates a {@link ExprEvalVector} for a constant {@link Long} value. + * + * @see org.apache.druid.math.expr.ConstantExpr + */ public static ExprVectorProcessor constant(@Nullable Long constant, int maxVectorSize) { final long[] longs = new long[maxVectorSize]; final boolean[] nulls; if (constant == null) { nulls = new boolean[maxVectorSize]; - Arrays.fill(nulls, true); + Arrays.fill(nulls, NullHandling.sqlCompatible()); } else { nulls = null; Arrays.fill(longs, constant); @@ -157,6 +172,14 @@ public class VectorProcessors }; } + /** + * Creates an {@link ExprVectorProcessor} that creates a {@link ExprEvalVector} for some expression variable input + * binding, typically for segment column value vectors from a + * {@link org.apache.druid.segment.vector.VectorValueSelector} or + * {@link org.apache.druid.segment.vector.VectorObjectSelector}. + * + * @see org.apache.druid.math.expr.IdentifierExpr + */ public static ExprVectorProcessor identifier(Expr.VectorInputBindingInspector inspector, String binding) { ExpressionType inputType = inspector.getType(binding); @@ -206,10 +229,15 @@ public class VectorProcessors } } + /** + * Creates an {@link ExprVectorProcessor} that will parse a string into a long value given a radix. + * + * @see org.apache.druid.math.expr.Function.ParseLong + */ public static ExprVectorProcessor parseLong(Expr.VectorInputBindingInspector inspector, Expr arg, int radix) { final ExprVectorProcessor processor = new LongOutObjectInFunctionVectorProcessor( - arg.buildVectorized(inspector), + arg.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -242,6 +270,12 @@ public class VectorProcessors return (ExprVectorProcessor) processor; } + /** + * Creates an {@link ExprVectorProcessor} for the 'isnull' function, that produces a "boolean" typed output + * vector (long[]) with values set to 1 if the input value was null or 0 if it was not null. + * + * @see org.apache.druid.math.expr.Function.IsNullFunc + */ public static ExprVectorProcessor isNull(Expr.VectorInputBindingInspector inspector, Expr expr) { @@ -254,7 +288,7 @@ public class VectorProcessors ExprVectorProcessor processor = null; if (Types.is(type, ExprType.STRING)) { - final ExprVectorProcessor input = expr.buildVectorized(inspector); + final ExprVectorProcessor input = expr.asVectorProcessor(inspector); processor = new ExprVectorProcessor() { @Override @@ -281,7 +315,7 @@ public class VectorProcessors } }; } else if (Types.is(type, ExprType.LONG)) { - final ExprVectorProcessor input = expr.buildVectorized(inspector); + final ExprVectorProcessor input = expr.asVectorProcessor(inspector); processor = new ExprVectorProcessor() { @Override @@ -312,7 +346,7 @@ public class VectorProcessors } }; } else if (Types.is(type, ExprType.DOUBLE)) { - final ExprVectorProcessor input = expr.buildVectorized(inspector); + final ExprVectorProcessor input = expr.asVectorProcessor(inspector); processor = new ExprVectorProcessor() { @Override @@ -350,6 +384,12 @@ public class VectorProcessors return (ExprVectorProcessor) processor; } + /** + * Creates an {@link ExprVectorProcessor} for the 'isnotnull' function, that produces a "boolean" typed output + * vector (long[]) with values set to 1 if the input value was not null or 0 if it was null. + * + * @see org.apache.druid.math.expr.Function.IsNotNullFunc + */ public static ExprVectorProcessor isNotNull(Expr.VectorInputBindingInspector inspector, Expr expr) { @@ -362,7 +402,7 @@ public class VectorProcessors ExprVectorProcessor processor = null; if (Types.is(type, ExprType.STRING)) { - final ExprVectorProcessor input = expr.buildVectorized(inspector); + final ExprVectorProcessor input = expr.asVectorProcessor(inspector); processor = new ExprVectorProcessor() { @Override @@ -389,7 +429,7 @@ public class VectorProcessors } }; } else if (Types.is(type, ExprType.LONG)) { - final ExprVectorProcessor input = expr.buildVectorized(inspector); + final ExprVectorProcessor input = expr.asVectorProcessor(inspector); processor = new ExprVectorProcessor() { @Override @@ -420,7 +460,7 @@ public class VectorProcessors } }; } else if (Types.is(type, ExprType.DOUBLE)) { - final ExprVectorProcessor input = expr.buildVectorized(inspector); + final ExprVectorProcessor input = expr.asVectorProcessor(inspector); processor = new ExprVectorProcessor() { @Override @@ -458,6 +498,12 @@ public class VectorProcessors return (ExprVectorProcessor) processor; } + /** + * Creates an {@link ExprVectorProcessor} for the 'nvl' function, that will return the first argument value if it is + * not null, else the value of the 2nd argument. + * + * @see org.apache.druid.math.expr.Function.NvlFunc + */ public static ExprVectorProcessor nvl(Expr.VectorInputBindingInspector inspector, Expr left, Expr right) { final int maxVectorSize = inspector.getMaxVectorSize(); @@ -468,8 +514,8 @@ public class VectorProcessors right, () -> new SymmetricalBivariateFunctionVectorProcessor( ExpressionType.LONG, - left.buildVectorized(inspector), - right.buildVectorized(inspector) + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector) ) { final long[] output = new long[maxVectorSize]; @@ -504,8 +550,8 @@ public class VectorProcessors }, () -> new SymmetricalBivariateFunctionVectorProcessor( ExpressionType.DOUBLE, - left.buildVectorized(inspector), - right.buildVectorized(inspector) + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector) ) { final double[] output = new double[maxVectorSize]; @@ -540,8 +586,8 @@ public class VectorProcessors }, () -> new SymmetricalBivariateFunctionVectorProcessor( ExpressionType.STRING, - left.buildVectorized(inspector), - right.buildVectorized(inspector) + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector) ) { final Object[] output = new Object[maxVectorSize]; @@ -567,6 +613,15 @@ public class VectorProcessors ); } + /** + * Creates an {@link ExprVectorProcessor} for the logical 'not' operator, which produces a long typed vector output + * with values set by the following rules: + * false -> true (1) + * null -> null + * true -> false (0) + * + * @see org.apache.druid.math.expr.UnaryNotExpr + */ public static ExprVectorProcessor not(Expr.VectorInputBindingInspector inspector, Expr expr) { final ExpressionType inputType = expr.getOutputType(inspector); @@ -574,7 +629,7 @@ public class VectorProcessors ExprVectorProcessor processor = null; if (Types.is(inputType, ExprType.STRING)) { processor = new LongOutObjectInFunctionVectorProcessor( - expr.buildVectorized(inspector), + expr.asVectorProcessor(inspector), maxVectorSize, ExpressionType.STRING ) @@ -589,7 +644,7 @@ public class VectorProcessors } }; } else if (Types.is(inputType, ExprType.LONG)) { - processor = new LongOutLongInFunctionVectorValueProcessor(expr.buildVectorized(inspector), maxVectorSize) + processor = new LongOutLongInFunctionVectorValueProcessor(expr.asVectorProcessor(inspector), maxVectorSize) { @Override public long apply(long input) @@ -599,7 +654,7 @@ public class VectorProcessors }; } else if (Types.is(inputType, ExprType.DOUBLE)) { if (!ExpressionProcessing.useStrictBooleans()) { - processor = new DoubleOutDoubleInFunctionVectorValueProcessor(expr.buildVectorized(inspector), maxVectorSize) + processor = new DoubleOutDoubleInFunctionVectorValueProcessor(expr.asVectorProcessor(inspector), maxVectorSize) { @Override public double apply(double input) @@ -608,7 +663,7 @@ public class VectorProcessors } }; } else { - processor = new LongOutDoubleInFunctionVectorValueProcessor(expr.buildVectorized(inspector), maxVectorSize) + processor = new LongOutDoubleInFunctionVectorValueProcessor(expr.asVectorProcessor(inspector), maxVectorSize) { @Override public long apply(double input) @@ -624,6 +679,15 @@ public class VectorProcessors return (ExprVectorProcessor) processor; } + /** + * Creates an {@link ExprVectorProcessor} for the logical 'or' operator, which produces a long typed vector output + * with values set by the following rules: + * true/null, null/true -> true (1) + * false/null, null/false, null/null -> null + * false/false -> false (0) + * + * @see org.apache.druid.math.expr.BinOrExpr + */ public static ExprVectorProcessor or(Expr.VectorInputBindingInspector inspector, Expr left, Expr right) { final int maxVectorSize = inspector.getMaxVectorSize(); @@ -633,8 +697,8 @@ public class VectorProcessors right, () -> new SymmetricalBivariateFunctionVectorProcessor( ExpressionType.LONG, - left.buildVectorized(inspector), - right.buildVectorized(inspector) + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector) ) { final long[] output = new long[maxVectorSize]; @@ -657,7 +721,7 @@ public class VectorProcessors if (leftNull) { if (rightNull) { output[i] = 0L; - outputNulls[i] = true; + outputNulls[i] = NullHandling.sqlCompatible(); return; } final boolean bool = Evals.asBoolean(rightInput[i]); @@ -682,8 +746,8 @@ public class VectorProcessors }, () -> new BivariateFunctionVectorProcessor( ExpressionType.LONG, - left.buildVectorized(inspector), - right.buildVectorized(inspector) + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector) ) { final long[] output = new long[maxVectorSize]; @@ -706,7 +770,7 @@ public class VectorProcessors if (leftNull) { if (rightNull) { output[i] = 0; - outputNulls[i] = true; + outputNulls[i] = NullHandling.sqlCompatible(); return; } final boolean bool = Evals.asBoolean(rightInput[i]); @@ -731,8 +795,8 @@ public class VectorProcessors }, () -> new BivariateFunctionVectorProcessor( ExpressionType.LONG, - left.buildVectorized(inspector), - right.buildVectorized(inspector) + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector) ) { final long[] output = new long[maxVectorSize]; @@ -753,7 +817,7 @@ public class VectorProcessors final boolean rightNull = rightInput[i] == null; if (leftNull) { if (rightNull) { - outputNulls[i] = true; + outputNulls[i] = NullHandling.sqlCompatible(); return; } final boolean bool = Evals.asBoolean((String) rightInput[i]); @@ -778,6 +842,15 @@ public class VectorProcessors ); } + /** + * Creates an {@link ExprVectorProcessor} for the logical 'and' operator, which produces a long typed vector output + * with values set by the following rules: + * true/true -> true (1) + * true/null, null/true, null/null -> null + * false/null, null/false -> false (0) + * + * @see org.apache.druid.math.expr.BinAndExpr + */ public static ExprVectorProcessor and(Expr.VectorInputBindingInspector inputTypes, Expr left, Expr right) { final int maxVectorSize = inputTypes.getMaxVectorSize(); @@ -787,8 +860,8 @@ public class VectorProcessors right, () -> new SymmetricalBivariateFunctionVectorProcessor( ExpressionType.LONG, - left.buildVectorized(inputTypes), - right.buildVectorized(inputTypes) + left.asVectorProcessor(inputTypes), + right.asVectorProcessor(inputTypes) ) { final long[] output = new long[maxVectorSize]; @@ -811,7 +884,7 @@ public class VectorProcessors if (leftNull) { if (rightNull) { output[i] = 0L; - outputNulls[i] = true; + outputNulls[i] = NullHandling.sqlCompatible(); return; } final boolean bool = Evals.asBoolean(rightInput[i]); @@ -836,8 +909,8 @@ public class VectorProcessors }, () -> new BivariateFunctionVectorProcessor( ExpressionType.DOUBLE, - left.buildVectorized(inputTypes), - right.buildVectorized(inputTypes) + left.asVectorProcessor(inputTypes), + right.asVectorProcessor(inputTypes) ) { final long[] output = new long[maxVectorSize]; @@ -860,7 +933,7 @@ public class VectorProcessors if (leftNull) { if (rightNull) { output[i] = 0L; - outputNulls[i] = true; + outputNulls[i] = NullHandling.sqlCompatible(); return; } final boolean bool = Evals.asBoolean(rightInput[i]); @@ -885,8 +958,8 @@ public class VectorProcessors }, () -> new BivariateFunctionVectorProcessor( ExpressionType.STRING, - left.buildVectorized(inputTypes), - right.buildVectorized(inputTypes) + left.asVectorProcessor(inputTypes), + right.asVectorProcessor(inputTypes) ) { final long[] output = new long[maxVectorSize]; @@ -907,7 +980,7 @@ public class VectorProcessors final boolean rightNull = rightInput[i] == null; if (leftNull) { if (rightNull) { - outputNulls[i] = true; + outputNulls[i] = NullHandling.sqlCompatible(); return; } final boolean bool = Evals.asBoolean((String) rightInput[i]); @@ -939,6 +1012,11 @@ public class VectorProcessors // No instantiation } + /** + * Basic scaffolding for an 'identifier' {@link ExprVectorProcessor} + * + * @see #identifier + */ abstract static class IdentifierVectorProcessor implements ExprVectorProcessor { private final ExpressionType outputType; diff --git a/processing/src/main/java/org/apache/druid/math/expr/vector/VectorStringProcessors.java b/processing/src/main/java/org/apache/druid/math/expr/vector/VectorStringProcessors.java index 1ffaa2518d3..3326474f42e 100644 --- a/processing/src/main/java/org/apache/druid/math/expr/vector/VectorStringProcessors.java +++ b/processing/src/main/java/org/apache/druid/math/expr/vector/VectorStringProcessors.java @@ -34,8 +34,8 @@ public class VectorStringProcessors final ExprVectorProcessor processor; if (NullHandling.sqlCompatible()) { processor = new ObjectOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -50,8 +50,8 @@ public class VectorStringProcessors }; } else { processor = new ObjectOutObjectsInFunctionVectorProcessor( - left.buildVectorized(inspector), - right.buildVectorized(inspector), + left.asVectorProcessor(inspector), + right.asVectorProcessor(inspector), inspector.getMaxVectorSize(), ExpressionType.STRING ) @@ -73,7 +73,7 @@ public class VectorStringProcessors final ExprVectorProcessor[] inputProcessors = new ExprVectorProcessor[inputs.size()]; for (int i = 0; i < inputs.size(); i++) { inputProcessors[i] = CastToTypeVectorProcessor.cast( - inputs.get(i).buildVectorized(inspector), + inputs.get(i).asVectorProcessor(inspector), ExpressionType.STRING ); } diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorUtil.java b/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorUtil.java index 933b4b454f4..301baf4b967 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorUtil.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorUtil.java @@ -206,7 +206,7 @@ public class AggregatorUtil * Only one of fieldName and fieldExpression should be non-null */ static ColumnValueSelector makeColumnValueSelectorWithFloatDefault( - final ColumnSelectorFactory metricFactory, + final ColumnSelectorFactory columnSelectorFactory, @Nullable final String fieldName, @Nullable final Expr fieldExpression, final float nullValue @@ -216,9 +216,12 @@ public class AggregatorUtil throw new IllegalArgumentException("Only one of fieldName or expression should be non-null"); } if (fieldName != null) { - return metricFactory.makeColumnValueSelector(fieldName); + return columnSelectorFactory.makeColumnValueSelector(fieldName); } else { - final ColumnValueSelector baseSelector = ExpressionSelectors.makeExprEvalSelector(metricFactory, fieldExpression); + final ColumnValueSelector baseSelector = ExpressionSelectors.makeExprEvalSelector( + columnSelectorFactory, + fieldExpression + ); class ExpressionFloatColumnSelector implements FloatColumnSelector { @Override @@ -226,22 +229,22 @@ public class AggregatorUtil { // Although baseSelector.getObject is nullable // exprEval returned from Expression selectors is never null. - final ExprEval exprEval = baseSelector.getObject(); + final ExprEval exprEval = baseSelector.getObject(); return exprEval.isNumericNull() ? nullValue : (float) exprEval.asDouble(); } + @Override + public boolean isNull() + { + final ExprEval exprEval = baseSelector.getObject(); + return exprEval == null || exprEval.isNumericNull(); + } + @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("baseSelector", baseSelector); } - - @Override - public boolean isNull() - { - final ExprEval exprEval = baseSelector.getObject(); - return exprEval == null || exprEval.isNumericNull(); - } } return new ExpressionFloatColumnSelector(); } @@ -250,8 +253,8 @@ public class AggregatorUtil /** * Only one of fieldName and fieldExpression should be non-null */ - static ColumnValueSelector makeColumnValueSelectorWithLongDefault( - final ColumnSelectorFactory metricFactory, + static ColumnValueSelector makeColumnValueSelectorWithLongDefault( + final ColumnSelectorFactory columnSelectorFactory, @Nullable final String fieldName, @Nullable final Expr fieldExpression, final long nullValue @@ -261,30 +264,33 @@ public class AggregatorUtil throw new IllegalArgumentException("Only one of fieldName and fieldExpression should be non-null"); } if (fieldName != null) { - return metricFactory.makeColumnValueSelector(fieldName); + return columnSelectorFactory.makeColumnValueSelector(fieldName); } else { - final ColumnValueSelector baseSelector = ExpressionSelectors.makeExprEvalSelector(metricFactory, fieldExpression); + final ColumnValueSelector baseSelector = ExpressionSelectors.makeExprEvalSelector( + columnSelectorFactory, + fieldExpression + ); class ExpressionLongColumnSelector implements LongColumnSelector { @Override public long getLong() { - final ExprEval exprEval = baseSelector.getObject(); + final ExprEval exprEval = baseSelector.getObject(); return exprEval.isNumericNull() ? nullValue : exprEval.asLong(); } + @Override + public boolean isNull() + { + final ExprEval exprEval = baseSelector.getObject(); + return exprEval == null || exprEval.isNumericNull(); + } + @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("baseSelector", baseSelector); } - - @Override - public boolean isNull() - { - final ExprEval exprEval = baseSelector.getObject(); - return exprEval == null || exprEval.isNumericNull(); - } } return new ExpressionLongColumnSelector(); } @@ -293,8 +299,8 @@ public class AggregatorUtil /** * Only one of fieldName and fieldExpression should be non-null */ - static ColumnValueSelector makeColumnValueSelectorWithDoubleDefault( - final ColumnSelectorFactory metricFactory, + static ColumnValueSelector makeColumnValueSelectorWithDoubleDefault( + final ColumnSelectorFactory columnSelectorFactory, @Nullable final String fieldName, @Nullable final Expr fieldExpression, final double nullValue @@ -304,30 +310,33 @@ public class AggregatorUtil throw new IllegalArgumentException("Only one of fieldName and fieldExpression should be non-null"); } if (fieldName != null) { - return metricFactory.makeColumnValueSelector(fieldName); + return columnSelectorFactory.makeColumnValueSelector(fieldName); } else { - final ColumnValueSelector baseSelector = ExpressionSelectors.makeExprEvalSelector(metricFactory, fieldExpression); + final ColumnValueSelector baseSelector = ExpressionSelectors.makeExprEvalSelector( + columnSelectorFactory, + fieldExpression + ); class ExpressionDoubleColumnSelector implements DoubleColumnSelector { @Override public double getDouble() { - final ExprEval exprEval = baseSelector.getObject(); + final ExprEval exprEval = baseSelector.getObject(); return exprEval.isNumericNull() ? nullValue : exprEval.asDouble(); } + @Override + public boolean isNull() + { + final ExprEval exprEval = baseSelector.getObject(); + return exprEval == null || exprEval.isNumericNull(); + } + @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("baseSelector", baseSelector); } - - @Override - public boolean isNull() - { - final ExprEval exprEval = baseSelector.getObject(); - return exprEval == null || exprEval.isNumericNull(); - } } return new ExpressionDoubleColumnSelector(); } diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregator.java b/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregator.java index c50b7d42e10..5331943575a 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregator.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregator.java @@ -59,7 +59,7 @@ public class ExpressionLambdaAggregator implements Aggregator } } final ExprEval eval = lambda.eval(bindings); - final int estimatedSize = eval.type().getNullableStrategy().estimateSizeBytes(eval.value()); + final int estimatedSize = eval.type().getNullableStrategy().estimateSizeBytes(eval.valueOrDefault()); if (estimatedSize > maxSizeBytes) { throw new ISE( "Exceeded memory usage when aggregating type [%s], size [%s] is larger than max [%s]", @@ -76,7 +76,7 @@ public class ExpressionLambdaAggregator implements Aggregator @Override public Object get() { - return hasValue ? bindings.getAccumulator().value() : null; + return hasValue ? bindings.getAccumulator().valueOrDefault() : null; } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregatorFactory.java index 7629a4708da..df1040c29d2 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregatorFactory.java @@ -346,7 +346,7 @@ public class ExpressionLambdaAggregatorFactory extends AggregatorFactory // arbitrarily assign lhs and rhs to accumulator and aggregator name inputs to re-use combine function return combineExpression.get().eval( combineBindings.get().withBinding(accumulatorId, lhs).withBinding(name, rhs) - ).value(); + ).valueOrDefault(); } @Override @@ -362,7 +362,7 @@ public class ExpressionLambdaAggregatorFactory extends AggregatorFactory Expr finalizeExpr; finalizeExpr = finalizeExpression.get(); if (finalizeExpr != null) { - return finalizeExpr.eval(finalizeBindings.get().withBinding(FINALIZE_IDENTIFIER, object)).value(); + return finalizeExpr.eval(finalizeBindings.get().withBinding(FINALIZE_IDENTIFIER, object)).valueOrDefault(); } return object; } diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregatorInputBindings.java b/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregatorInputBindings.java index 36232ff0c47..b84a8ad3d8a 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregatorInputBindings.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaAggregatorInputBindings.java @@ -53,7 +53,7 @@ public class ExpressionLambdaAggregatorInputBindings implements Expr.ObjectBindi public Object get(String name) { if (accumlatorIdentifier.equals(name)) { - return accumulator.value(); + return accumulator.valueOrDefault(); } return inputBindings.get(name); } diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaBufferAggregator.java b/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaBufferAggregator.java index 5dc9a88d963..3730649953b 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaBufferAggregator.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/ExpressionLambdaBufferAggregator.java @@ -90,7 +90,7 @@ public class ExpressionLambdaBufferAggregator implements BufferAggregator if (isNullUnlessAggregated && (buf.get(position) & NOT_AGGREGATED_BIT) != 0) { return null; } - return ExprEval.deserialize(buf, position, maxSizeBytes, outputType, false).value(); + return ExprEval.deserialize(buf, position, maxSizeBytes, outputType, false).valueOrDefault(); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/post/ExpressionPostAggregator.java b/processing/src/main/java/org/apache/druid/query/aggregation/post/ExpressionPostAggregator.java index 4291a6e40a9..efeb8ed983a 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/post/ExpressionPostAggregator.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/post/ExpressionPostAggregator.java @@ -171,7 +171,7 @@ public class ExpressionPostAggregator implements PostAggregator } ); - return parsed.get().eval(InputBindings.withMap(finalizedValues)).value(); + return parsed.get().eval(InputBindings.withMap(finalizedValues)).valueOrDefault(); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/expression/ExprUtils.java b/processing/src/main/java/org/apache/druid/query/expression/ExprUtils.java index 3a7224f59d5..e2bd808d7b9 100644 --- a/processing/src/main/java/org/apache/druid/query/expression/ExprUtils.java +++ b/processing/src/main/java/org/apache/druid/query/expression/ExprUtils.java @@ -66,7 +66,7 @@ public class ExprUtils origin = null; } else { Chronology chronology = timeZone == null ? ISOChronology.getInstanceUTC() : ISOChronology.getInstance(timeZone); - final Object value = originArg.eval(bindings).value(); + final Object value = originArg.eval(bindings).valueOrDefault(); if (value instanceof String && NullHandling.isNullOrEquivalent((String) value)) { // We get a blank string here, when sql compatible null handling is enabled // and expression contains empty string for for origin diff --git a/processing/src/main/java/org/apache/druid/query/expression/TimestampFloorExprMacro.java b/processing/src/main/java/org/apache/druid/query/expression/TimestampFloorExprMacro.java index dea3604a6d2..5588170f965 100644 --- a/processing/src/main/java/org/apache/druid/query/expression/TimestampFloorExprMacro.java +++ b/processing/src/main/java/org/apache/druid/query/expression/TimestampFloorExprMacro.java @@ -124,11 +124,11 @@ public class TimestampFloorExprMacro implements ExprMacroTable.ExprMacro } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { ExprVectorProcessor processor; processor = new LongOutLongInFunctionVectorValueProcessor( - CastToTypeVectorProcessor.cast(args.get(0).buildVectorized(inspector), ExpressionType.LONG), + CastToTypeVectorProcessor.cast(args.get(0).asVectorProcessor(inspector), ExpressionType.LONG), inspector.getMaxVectorSize() ) { diff --git a/processing/src/main/java/org/apache/druid/query/expression/TimestampShiftExprMacro.java b/processing/src/main/java/org/apache/druid/query/expression/TimestampShiftExprMacro.java index 875ed28a69f..1c38f39700d 100644 --- a/processing/src/main/java/org/apache/druid/query/expression/TimestampShiftExprMacro.java +++ b/processing/src/main/java/org/apache/druid/query/expression/TimestampShiftExprMacro.java @@ -119,11 +119,11 @@ public class TimestampShiftExprMacro implements ExprMacroTable.ExprMacro } @Override - public ExprVectorProcessor buildVectorized(VectorInputBindingInspector inspector) + public ExprVectorProcessor asVectorProcessor(VectorInputBindingInspector inspector) { ExprVectorProcessor processor; processor = new LongOutLongInFunctionVectorValueProcessor( - CastToTypeVectorProcessor.cast(args.get(0).buildVectorized(inspector), ExpressionType.LONG), + CastToTypeVectorProcessor.cast(args.get(0).asVectorProcessor(inspector), ExpressionType.LONG), inspector.getMaxVectorSize() ) { diff --git a/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionSelectors.java b/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionSelectors.java index 86f7172ac73..9f3894cc103 100644 --- a/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionSelectors.java +++ b/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionSelectors.java @@ -110,7 +110,7 @@ public class ExpressionSelectors { // No need for null check on getObject() since baseSelector impls will never return null. ExprEval eval = baseSelector.getObject(); - return eval.value(); + return eval.valueOrDefault(); } @Override @@ -196,14 +196,7 @@ public class ExpressionSelectors Expr expression ) { - return makeExprEvalSelector(columnSelectorFactory, ExpressionPlanner.plan(columnSelectorFactory, expression)); - } - - public static ColumnValueSelector makeExprEvalSelector( - ColumnSelectorFactory columnSelectorFactory, - ExpressionPlan plan - ) - { + ExpressionPlan plan = ExpressionPlanner.plan(columnSelectorFactory, expression); final RowIdSupplier rowIdSupplier = columnSelectorFactory.getRowIdSupplier(); if (plan.is(ExpressionPlan.Trait.SINGLE_INPUT_SCALAR)) { @@ -548,6 +541,6 @@ public class ExpressionSelectors } return Arrays.stream(asArray).collect(Collectors.toList()); } - return eval.value(); + return eval.valueOrDefault(); } } diff --git a/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionVectorSelectors.java b/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionVectorSelectors.java index 77c40b551e1..66ddc2c5f8a 100644 --- a/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionVectorSelectors.java +++ b/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionVectorSelectors.java @@ -79,11 +79,11 @@ public class ExpressionVectorSelectors if (plan.isConstant()) { return ConstantVectorSelectors.vectorValueSelector( factory.getReadableVectorInspector(), - (Number) plan.getExpression().eval(InputBindings.nilBindings()).value() + (Number) plan.getExpression().eval(InputBindings.nilBindings()).valueOrDefault() ); } final Expr.VectorInputBinding bindings = createVectorBindings(plan.getAnalysis(), factory); - final ExprVectorProcessor processor = plan.getExpression().buildVectorized(bindings); + final ExprVectorProcessor processor = plan.getExpression().asVectorProcessor(bindings); return new ExpressionVectorValueSelector(processor, bindings); } @@ -98,12 +98,12 @@ public class ExpressionVectorSelectors if (plan.isConstant()) { return ConstantVectorSelectors.vectorObjectSelector( factory.getReadableVectorInspector(), - plan.getExpression().eval(InputBindings.nilBindings()).value() + plan.getExpression().eval(InputBindings.nilBindings()).valueOrDefault() ); } final Expr.VectorInputBinding bindings = createVectorBindings(plan.getAnalysis(), factory); - final ExprVectorProcessor processor = plan.getExpression().buildVectorized(bindings); + final ExprVectorProcessor processor = plan.getExpression().asVectorProcessor(bindings); return new ExpressionVectorObjectSelector(processor, bindings); } diff --git a/processing/src/main/java/org/apache/druid/segment/virtual/NestedFieldVirtualColumn.java b/processing/src/main/java/org/apache/druid/segment/virtual/NestedFieldVirtualColumn.java index 62cd303bc93..6541e1e79cb 100644 --- a/processing/src/main/java/org/apache/druid/segment/virtual/NestedFieldVirtualColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/virtual/NestedFieldVirtualColumn.java @@ -507,7 +507,7 @@ public class NestedFieldVirtualColumn implements VirtualColumn nullVector = new boolean[objectSelector.getMaxVectorSize()]; } longVector[i] = 0L; - nullVector[i] = true; + nullVector[i] = NullHandling.sqlCompatible(); } else { Long l; if (v instanceof Number) { @@ -525,7 +525,7 @@ public class NestedFieldVirtualColumn implements VirtualColumn nullVector = new boolean[objectSelector.getMaxVectorSize()]; } longVector[i] = 0L; - nullVector[i] = true; + nullVector[i] = NullHandling.sqlCompatible(); } } } @@ -570,7 +570,7 @@ public class NestedFieldVirtualColumn implements VirtualColumn nullVector = new boolean[objectSelector.getMaxVectorSize()]; } doubleVector[i] = 0.0; - nullVector[i] = true; + nullVector[i] = NullHandling.sqlCompatible(); } else { Double d; if (v instanceof Number) { @@ -588,7 +588,7 @@ public class NestedFieldVirtualColumn implements VirtualColumn nullVector = new boolean[objectSelector.getMaxVectorSize()]; } doubleVector[i] = 0.0; - nullVector[i] = true; + nullVector[i] = NullHandling.sqlCompatible(); } } } diff --git a/processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputDeferredEvaluationExpressionDimensionVectorSelector.java b/processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputDeferredEvaluationExpressionDimensionVectorSelector.java index 4b884972946..5a1dd495506 100644 --- a/processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputDeferredEvaluationExpressionDimensionVectorSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputDeferredEvaluationExpressionDimensionVectorSelector.java @@ -62,7 +62,7 @@ public class SingleStringInputDeferredEvaluationExpressionDimensionVectorSelecto } this.selector = selector; this.inputBinding = new StringLookupVectorInputBindings(); - this.stringProcessor = expression.buildVectorized(inputBinding); + this.stringProcessor = expression.asVectorProcessor(inputBinding); } @Override diff --git a/processing/src/test/java/org/apache/druid/math/expr/EvalTest.java b/processing/src/test/java/org/apache/druid/math/expr/EvalTest.java index c3322ba19f7..1d8400f42d5 100644 --- a/processing/src/test/java/org/apache/druid/math/expr/EvalTest.java +++ b/processing/src/test/java/org/apache/druid/math/expr/EvalTest.java @@ -247,18 +247,18 @@ public class EvalTest extends InitializedNullHandlingTest // test casting arrays to scalars assertEquals(1L, ExprEval.ofLongArray(new Long[]{1L}).castTo(ExpressionType.LONG).value()); - assertEquals(NullHandling.defaultLongValue(), ExprEval.ofLongArray(new Long[]{null}).castTo(ExpressionType.LONG).value()); + assertEquals(null, ExprEval.ofLongArray(new Long[]{null}).castTo(ExpressionType.LONG).value()); assertEquals(1.0, ExprEval.ofLongArray(new Long[]{1L}).castTo(ExpressionType.DOUBLE).asDouble(), 0.0); assertEquals("1", ExprEval.ofLongArray(new Long[]{1L}).castTo(ExpressionType.STRING).value()); assertEquals(1.1, ExprEval.ofDoubleArray(new Double[]{1.1}).castTo(ExpressionType.DOUBLE).asDouble(), 0.0); - assertEquals(NullHandling.defaultDoubleValue(), ExprEval.ofDoubleArray(new Double[]{null}).castTo(ExpressionType.DOUBLE).value()); + assertEquals(null, ExprEval.ofDoubleArray(new Double[]{null}).castTo(ExpressionType.DOUBLE).value()); assertEquals(1L, ExprEval.ofDoubleArray(new Double[]{1.1}).castTo(ExpressionType.LONG).value()); assertEquals("1.1", ExprEval.ofDoubleArray(new Double[]{1.1}).castTo(ExpressionType.STRING).value()); assertEquals("foo", ExprEval.ofStringArray(new String[]{"foo"}).castTo(ExpressionType.STRING).value()); - assertEquals(NullHandling.defaultLongValue(), ExprEval.ofStringArray(new String[]{"foo"}).castTo(ExpressionType.LONG).value()); - assertEquals(NullHandling.defaultDoubleValue(), ExprEval.ofStringArray(new String[]{"foo"}).castTo(ExpressionType.DOUBLE).value()); + assertEquals(null, ExprEval.ofStringArray(new String[]{"foo"}).castTo(ExpressionType.LONG).value()); + assertEquals(null, ExprEval.ofStringArray(new String[]{"foo"}).castTo(ExpressionType.DOUBLE).value()); assertEquals("1", ExprEval.ofStringArray(new String[]{"1"}).castTo(ExpressionType.STRING).value()); assertEquals(1L, ExprEval.ofStringArray(new String[]{"1"}).castTo(ExpressionType.LONG).value()); assertEquals(1.0, ExprEval.ofStringArray(new String[]{"1"}).castTo(ExpressionType.DOUBLE).value()); @@ -518,17 +518,18 @@ public class EvalTest extends InitializedNullHandlingTest assertEquals(1L, eval("null || 1", bindings).value()); assertEquals(1L, eval("1 || null", bindings).value()); - assertEquals(NullHandling.defaultLongValue(), eval("null || 0", bindings).value()); - assertEquals(NullHandling.defaultLongValue(), eval("0 || null", bindings).value()); - // null/null is evaluated as string typed - assertEquals(NullHandling.defaultLongValue(), eval("null || null", bindings).value()); + // in sql incompatible mode, null is false, so we return 0 + assertEquals(NullHandling.defaultLongValue(), eval("null || 0", bindings).valueOrDefault()); + assertEquals(NullHandling.defaultLongValue(), eval("0 || null", bindings).valueOrDefault()); + assertEquals(NullHandling.defaultLongValue(), eval("null || null", bindings).valueOrDefault()); - assertEquals(NullHandling.defaultLongValue(), eval("null && 1", bindings).value()); - assertEquals(NullHandling.defaultLongValue(), eval("1 && null", bindings).value()); + // in sql incompatible mode, null is false, so we return 0 + assertEquals(NullHandling.defaultLongValue(), eval("null && 1", bindings).valueOrDefault()); + assertEquals(NullHandling.defaultLongValue(), eval("1 && null", bindings).valueOrDefault()); + assertEquals(NullHandling.defaultLongValue(), eval("null && null", bindings).valueOrDefault()); + // if either side is false, output is false in both modes assertEquals(0L, eval("null && 0", bindings).value()); assertEquals(0L, eval("0 && null", bindings).value()); - // null/null is evaluated as string typed - assertEquals(NullHandling.defaultLongValue(), eval("null && null", bindings).value()); } finally { // reset @@ -707,6 +708,26 @@ public class EvalTest extends InitializedNullHandlingTest } } + @Test + public void testValueOrDefault() + { + ExprEval longNull = ExprEval.ofLong(null); + ExprEval doubleNull = ExprEval.ofDouble(null); + Assert.assertEquals(NullHandling.sqlCompatible(), longNull.isNumericNull()); + Assert.assertEquals(NullHandling.sqlCompatible(), doubleNull.isNumericNull()); + Assert.assertEquals(NullHandling.defaultLongValue(), longNull.valueOrDefault()); + Assert.assertEquals(NullHandling.defaultDoubleValue(), doubleNull.valueOrDefault()); + if (NullHandling.replaceWithDefault()) { + Assert.assertEquals(0L, longNull.asLong()); + Assert.assertEquals(0, longNull.asInt()); + Assert.assertEquals(0.0, longNull.asDouble(), 0.0); + + Assert.assertEquals(0L, doubleNull.asLong()); + Assert.assertEquals(0, doubleNull.asInt()); + Assert.assertEquals(0.0, doubleNull.asDouble(), 0.0); + } + } + @Test public void testEvalOfType() { @@ -831,7 +852,7 @@ public class EvalTest extends InitializedNullHandlingTest eval = ExprEval.ofType(ExpressionType.LONG_ARRAY, new Object[] {1L, 2L, null, 3L}); Assert.assertEquals(ExpressionType.LONG_ARRAY, eval.type()); - Assert.assertArrayEquals(new Object[] {1L, 2L, NullHandling.defaultLongValue(), 3L}, (Object[]) eval.value()); + Assert.assertArrayEquals(new Object[] {1L, 2L, null, 3L}, (Object[]) eval.value()); // arrays might have to fall back to using 'bestEffortOf', but will cast it to the expected output type eval = ExprEval.ofType(ExpressionType.LONG_ARRAY, new Object[] {"1", "2", "3"}); @@ -844,7 +865,7 @@ public class EvalTest extends InitializedNullHandlingTest eval = ExprEval.ofType(ExpressionType.LONG_ARRAY, new Object[] {"1", "2", "wat", "3"}); Assert.assertEquals(ExpressionType.LONG_ARRAY, eval.type()); - Assert.assertArrayEquals(new Object[] {1L, 2L, NullHandling.defaultLongValue(), 3L}, (Object[]) eval.value()); + Assert.assertArrayEquals(new Object[] {1L, 2L, null, 3L}, (Object[]) eval.value()); eval = ExprEval.ofType(ExpressionType.LONG_ARRAY, new Object[] {1.0, 2.0, 3.0}); Assert.assertEquals(ExpressionType.LONG_ARRAY, eval.type()); @@ -856,7 +877,7 @@ public class EvalTest extends InitializedNullHandlingTest eval = ExprEval.ofType(ExpressionType.LONG_ARRAY, new Object[] {1.0, 2.0, null, 3.0}); Assert.assertEquals(ExpressionType.LONG_ARRAY, eval.type()); - Assert.assertArrayEquals(new Object[] {1L, 2L, NullHandling.defaultLongValue(), 3L}, (Object[]) eval.value()); + Assert.assertArrayEquals(new Object[] {1L, 2L, null, 3L}, (Object[]) eval.value()); eval = ExprEval.ofType(ExpressionType.LONG_ARRAY, new Object[] {1.0, 2L, "3", true, false}); Assert.assertEquals(ExpressionType.LONG_ARRAY, eval.type()); @@ -885,7 +906,7 @@ public class EvalTest extends InitializedNullHandlingTest eval = ExprEval.ofType(ExpressionType.DOUBLE_ARRAY, new Object[] {"1", "2", "wat", "3"}); Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, eval.type()); - Assert.assertArrayEquals(new Object[] {1.0, 2.0, NullHandling.defaultDoubleValue(), 3.0}, (Object[]) eval.value()); + Assert.assertArrayEquals(new Object[] {1.0, 2.0, null, 3.0}, (Object[]) eval.value()); eval = ExprEval.ofType(ExpressionType.DOUBLE_ARRAY, new Object[] {1L, 2L, 3L}); Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, eval.type()); @@ -897,7 +918,7 @@ public class EvalTest extends InitializedNullHandlingTest eval = ExprEval.ofType(ExpressionType.DOUBLE_ARRAY, new Object[] {1L, 2L, null, 3L}); Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, eval.type()); - Assert.assertArrayEquals(new Object[] {1.0, 2.0, NullHandling.defaultDoubleValue(), 3.0}, (Object[]) eval.value()); + Assert.assertArrayEquals(new Object[] {1.0, 2.0, null, 3.0}, (Object[]) eval.value()); eval = ExprEval.ofType(ExpressionType.DOUBLE_ARRAY, new Object[] {1.0, 2L, "3", true, false}); Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, eval.type()); @@ -934,7 +955,7 @@ public class EvalTest extends InitializedNullHandlingTest ExpressionType nestedLongArray = ExpressionTypeFactory.getInstance().ofArray(ExpressionType.LONG_ARRAY); final Object[] expectedLongArray = new Object[]{ new Object[] {1L, 2L, 3L}, - new Object[] {5L, NullHandling.defaultLongValue(), 9L}, + new Object[] {5L, null, 9L}, null, new Object[] {2L, 4L, 6L} }; @@ -979,7 +1000,7 @@ public class EvalTest extends InitializedNullHandlingTest ExpressionType nestedDoubleArray = ExpressionTypeFactory.getInstance().ofArray(ExpressionType.DOUBLE_ARRAY); final Object[] expectedDoubleArray = new Object[]{ new Object[] {1.1, 2.2, 3.3}, - new Object[] {5.5, NullHandling.defaultDoubleValue(), 9.9}, + new Object[] {5.5, null, 9.9}, null, new Object[] {2.2, 4.4, 6.6} }; @@ -1109,7 +1130,7 @@ public class EvalTest extends InitializedNullHandlingTest eval = ExprEval.bestEffortOf(new Object[] {null, 1.0, 2.0, 3.0}); Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, eval.type()); - Assert.assertArrayEquals(new Object[] {NullHandling.defaultDoubleValue(), 1.0, 2.0, 3.0}, (Object[]) eval.value()); + Assert.assertArrayEquals(new Object[] {null, 1.0, 2.0, 3.0}, (Object[]) eval.value()); eval = ExprEval.bestEffortOf(new Double[] {1.0, 2.0, 3.0}); Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, eval.type()); diff --git a/processing/src/test/java/org/apache/druid/math/expr/ExprEvalTest.java b/processing/src/test/java/org/apache/druid/math/expr/ExprEvalTest.java index 15dc241a025..ca807076b4d 100644 --- a/processing/src/test/java/org/apache/druid/math/expr/ExprEvalTest.java +++ b/processing/src/test/java/org/apache/druid/math/expr/ExprEvalTest.java @@ -21,7 +21,6 @@ package org.apache.druid.math.expr; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.apache.druid.common.config.NullHandling; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.NonnullPair; import org.apache.druid.java.util.common.StringUtils; @@ -403,11 +402,11 @@ public class ExprEvalTest extends InitializedNullHandlingTest { ExprEval someStringArray = ExprEval.ofStringArray(new String[]{"1", "2", "foo", null, "3.3"}); Assert.assertArrayEquals( - new Object[]{1L, 2L, NullHandling.defaultLongValue(), NullHandling.defaultLongValue(), 3L}, + new Object[]{1L, 2L, null, null, 3L}, someStringArray.castTo(ExpressionType.LONG_ARRAY).asArray() ); Assert.assertArrayEquals( - new Object[]{1.0, 2.0, NullHandling.defaultDoubleValue(), NullHandling.defaultDoubleValue(), 3.3}, + new Object[]{1.0, 2.0, null, null, 3.3}, someStringArray.castTo(ExpressionType.DOUBLE_ARRAY).asArray() ); } diff --git a/processing/src/test/java/org/apache/druid/math/expr/FunctionTest.java b/processing/src/test/java/org/apache/druid/math/expr/FunctionTest.java index 7c1320e6589..93a12f37e97 100644 --- a/processing/src/test/java/org/apache/druid/math/expr/FunctionTest.java +++ b/processing/src/test/java/org/apache/druid/math/expr/FunctionTest.java @@ -139,7 +139,7 @@ public class FunctionTest extends InitializedNullHandlingTest public void testStrlen() { assertExpr("strlen(x)", 3L); - assertExpr("strlen(nonexistent)", NullHandling.defaultLongValue()); + assertExpr("strlen(nonexistent)", null); } @Test @@ -298,7 +298,7 @@ public class FunctionTest extends InitializedNullHandlingTest public void testArrayAppend() { assertArrayExpr("array_append([1, 2, 3], 4)", new Long[]{1L, 2L, 3L, 4L}); - assertArrayExpr("array_append([1, 2, 3], 'bar')", new Long[]{1L, 2L, 3L, NullHandling.defaultLongValue()}); + assertArrayExpr("array_append([1, 2, 3], 'bar')", new Long[]{1L, 2L, 3L, null}); assertArrayExpr("array_append([], 1)", new String[]{"1"}); assertArrayExpr("array_append([], 1)", new Long[]{1L}); } @@ -317,11 +317,11 @@ public class FunctionTest extends InitializedNullHandlingTest public void testArraySetAdd() { assertArrayExpr("array_set_add([1, 2, 3], 4)", new Long[]{1L, 2L, 3L, 4L}); - assertArrayExpr("array_set_add([1, 2, 3], 'bar')", new Long[]{NullHandling.defaultLongValue(), 1L, 2L, 3L}); + assertArrayExpr("array_set_add([1, 2, 3], 'bar')", new Long[]{null, 1L, 2L, 3L}); assertArrayExpr("array_set_add([1, 2, 2], 1)", new Long[]{1L, 2L}); assertArrayExpr("array_set_add([], 1)", new String[]{"1"}); assertArrayExpr("array_set_add([], 1)", new Long[]{1L}); - assertArrayExpr("array_set_add([], null)", new Long[]{NullHandling.defaultLongValue()}); + assertArrayExpr("array_set_add([], null)", new Long[]{null}); } @Test @@ -392,7 +392,7 @@ public class FunctionTest extends InitializedNullHandlingTest public void testArrayPrepend() { assertArrayExpr("array_prepend(4, [1, 2, 3])", new Long[]{4L, 1L, 2L, 3L}); - assertArrayExpr("array_prepend('bar', [1, 2, 3])", new Long[]{NullHandling.defaultLongValue(), 1L, 2L, 3L}); + assertArrayExpr("array_prepend('bar', [1, 2, 3])", new Long[]{null, 1L, 2L, 3L}); assertArrayExpr("array_prepend(1, [])", new String[]{"1"}); assertArrayExpr("array_prepend(1, [])", new Long[]{1L}); assertArrayExpr("array_prepend(1, [])", new Double[]{1.0}); @@ -797,10 +797,10 @@ public class FunctionTest extends InitializedNullHandlingTest // happy path maths assertExpr("safe_divide(3, 1)", 3L); assertExpr("safe_divide(4.5, 2)", 2.25); - assertExpr("safe_divide(3, 0)", NullHandling.defaultLongValue()); - assertExpr("safe_divide(1, 0.0)", NullHandling.defaultDoubleValue()); + assertExpr("safe_divide(3, 0)", null); + assertExpr("safe_divide(1, 0.0)", null); // NaN and Infinity cases - assertExpr("safe_divide(NaN, 0.0)", NullHandling.defaultDoubleValue()); + assertExpr("safe_divide(NaN, 0.0)", null); assertExpr("safe_divide(0, NaN)", 0.0); assertExpr("safe_divide(0, POSITIVE_INFINITY)", NullHandling.defaultLongValue()); assertExpr("safe_divide(POSITIVE_INFINITY,0)", NullHandling.defaultLongValue()); diff --git a/processing/src/test/java/org/apache/druid/math/expr/VectorExprSanityTest.java b/processing/src/test/java/org/apache/druid/math/expr/VectorExprSanityTest.java index 4819661f592..2e20a486fab 100644 --- a/processing/src/test/java/org/apache/druid/math/expr/VectorExprSanityTest.java +++ b/processing/src/test/java/org/apache/druid/math/expr/VectorExprSanityTest.java @@ -45,7 +45,7 @@ import java.util.function.Supplier; * randomize inputs to various vector expressions and make sure the results match nonvectorized expressions * * this is not a replacement for correctness tests, but will ensure that vectorized and non-vectorized expression - * evaluation is at least self consistent... + * evaluation is at least self-consistent... */ public class VectorExprSanityTest extends InitializedNullHandlingTest { @@ -302,11 +302,12 @@ public class VectorExprSanityTest extends InitializedNullHandlingTest { Assert.assertTrue(StringUtils.format("Cannot vectorize %s", expr), parsed.canVectorize(bindings.rhs)); ExpressionType outputType = parsed.getOutputType(bindings.rhs); - ExprEvalVector vectorEval = parsed.buildVectorized(bindings.rhs).evalVector(bindings.rhs); + ExprEvalVector vectorEval = parsed.asVectorProcessor(bindings.rhs).evalVector(bindings.rhs); // 'null' expressions can have an output type of null, but still evaluate in default mode, so skip type checks if (outputType != null) { Assert.assertEquals(expr, outputType, vectorEval.getType()); } + final Object[] vectorVals = vectorEval.getObjectVector(); for (int i = 0; i < VECTOR_SIZE; i++) { ExprEval eval = parsed.eval(bindings.lhs[i]); // 'null' expressions can have an output type of null, but still evaluate in default mode, so skip type checks @@ -315,8 +316,8 @@ public class VectorExprSanityTest extends InitializedNullHandlingTest } Assert.assertEquals( StringUtils.format("Values do not match for row %s for expression %s", i, expr), - eval.value(), - vectorEval.get(i) + eval.valueOrDefault(), + vectorVals[i] ); } } diff --git a/processing/src/test/java/org/apache/druid/query/expression/ExprMacroTest.java b/processing/src/test/java/org/apache/druid/query/expression/ExprMacroTest.java index 77e17493388..640ae4a02f9 100644 --- a/processing/src/test/java/org/apache/druid/query/expression/ExprMacroTest.java +++ b/processing/src/test/java/org/apache/druid/query/expression/ExprMacroTest.java @@ -193,8 +193,7 @@ public class ExprMacroTest @Test public void testIPv4AddressParse() { - Long nullLong = NullHandling.replaceWithDefault() ? NullHandling.ZERO_LONG : null; - assertExpr("ipv4_parse(x)", nullLong); + assertExpr("ipv4_parse(x)", null); assertExpr("ipv4_parse(ipv4_string)", IPV4_LONG); assertExpr("ipv4_parse(ipv4_long)", IPV4_LONG); assertExpr("ipv4_parse(ipv4_stringify(ipv4_long))", IPV4_LONG); diff --git a/processing/src/test/java/org/apache/druid/query/expression/IPv4AddressParseExprMacroTest.java b/processing/src/test/java/org/apache/druid/query/expression/IPv4AddressParseExprMacroTest.java index 19464b39c65..d48955d02ce 100644 --- a/processing/src/test/java/org/apache/druid/query/expression/IPv4AddressParseExprMacroTest.java +++ b/processing/src/test/java/org/apache/druid/query/expression/IPv4AddressParseExprMacroTest.java @@ -19,7 +19,6 @@ package org.apache.druid.query.expression; -import org.apache.druid.common.config.NullHandling; import org.apache.druid.math.expr.Expr; import org.apache.druid.math.expr.ExprEval; import org.apache.druid.math.expr.InputBindings; @@ -33,7 +32,6 @@ public class IPv4AddressParseExprMacroTest extends MacroTestBase { private static final Expr VALID = ExprEval.of("192.168.0.1").toExpr(); private static final long EXPECTED = 3232235521L; - private static final Long NULL = NullHandling.replaceWithDefault() ? NullHandling.ZERO_LONG : null; public IPv4AddressParseExprMacroTest() { @@ -57,45 +55,45 @@ public class IPv4AddressParseExprMacroTest extends MacroTestBase } @Test - public void testNullStringArg() + public void testnullStringArg() { Expr nullString = ExprEval.of(null).toExpr(); - Assert.assertSame(NULL, eval(nullString)); + Assert.assertNull(eval(nullString)); } @Test - public void testNullLongArg() + public void testnullLongArg() { Expr nullLong = ExprEval.ofLong(null).toExpr(); - Assert.assertEquals(NULL, eval(nullLong)); + Assert.assertNull(eval(nullLong)); } @Test public void testInvalidArgType() { Expr longArray = ExprEval.ofLongArray(new Long[]{1L, 2L}).toExpr(); - Assert.assertEquals(NULL, eval(longArray)); + Assert.assertNull(eval(longArray)); } @Test public void testInvalidStringArgNotIPAddress() { Expr notIpAddress = ExprEval.of("druid.apache.org").toExpr(); - Assert.assertEquals(NULL, eval(notIpAddress)); + Assert.assertNull(eval(notIpAddress)); } @Test public void testInvalidStringArgIPv6Compatible() { Expr ipv6Compatible = ExprEval.of("::192.168.0.1").toExpr(); - Assert.assertEquals(NULL, eval(ipv6Compatible)); + Assert.assertNull(eval(ipv6Compatible)); } @Test public void testValidStringArgIPv6Mapped() { Expr ipv6Mapped = ExprEval.of("::ffff:192.168.0.1").toExpr(); - Assert.assertEquals(NULL, eval(ipv6Mapped)); + Assert.assertNull(eval(ipv6Mapped)); } @Test @@ -108,14 +106,14 @@ public class IPv4AddressParseExprMacroTest extends MacroTestBase public void testValidStringArgUnsignedInt() { Expr unsignedInt = ExprEval.of("3232235521").toExpr(); - Assert.assertEquals(NULL, eval(unsignedInt)); + Assert.assertNull(eval(unsignedInt)); } @Test public void testInvalidLongArgTooLow() { Expr tooLow = ExprEval.ofLong(-1L).toExpr(); - Assert.assertEquals(NULL, eval(tooLow)); + Assert.assertNull(eval(tooLow)); } @Test @@ -138,7 +136,7 @@ public class IPv4AddressParseExprMacroTest extends MacroTestBase public void testInvalidLongArgTooHigh() { Expr tooHigh = ExprEval.ofLong(0x1_00_00_00_00L).toExpr(); - Assert.assertEquals(NULL, eval(tooHigh)); + Assert.assertNull(eval(tooHigh)); } @Test diff --git a/processing/src/test/java/org/apache/druid/query/expression/NestedDataExpressionsTest.java b/processing/src/test/java/org/apache/druid/query/expression/NestedDataExpressionsTest.java index 8f618325102..7798db652eb 100644 --- a/processing/src/test/java/org/apache/druid/query/expression/NestedDataExpressionsTest.java +++ b/processing/src/test/java/org/apache/druid/query/expression/NestedDataExpressionsTest.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.apache.druid.common.config.NullHandling; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.Pair; import org.apache.druid.math.expr.Expr; @@ -173,7 +172,7 @@ public class NestedDataExpressionsTest extends InitializedNullHandlingTest expr = Parser.parse("json_value(nester, '$.y.a', 'LONG')", MACRO_TABLE); eval = expr.eval(inputBindings); - Assert.assertEquals(NullHandling.defaultLongValue(), eval.value()); + Assert.assertNull(eval.value()); Assert.assertEquals(ExpressionType.LONG, eval.type()); expr = Parser.parse("json_value(nester, '$.y.a.b.c[12]')", MACRO_TABLE); diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidRexExecutor.java b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidRexExecutor.java index 6279f7e6738..ab8b54f69cd 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidRexExecutor.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidRexExecutor.java @@ -191,7 +191,7 @@ public class DruidRexExecutor implements RexExecutor // column selector anyway literal = constExp; } else { - literal = rexBuilder.makeLiteral(exprResult.value(), constExp.getType(), true); + literal = rexBuilder.makeLiteral(exprResult.valueOrDefault(), constExp.getType(), true); } } diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidUnnestDatasourceRel.java b/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidUnnestDatasourceRel.java index eaa544d4200..cb01a003eae 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidUnnestDatasourceRel.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidUnnestDatasourceRel.java @@ -118,7 +118,7 @@ public class DruidUnnestDatasourceRel extends DruidRel // with the input column being called "inline" in the native query UnnestDataSource dataSource = UnnestDataSource.create( InlineDataSource.fromIterable( - Collections.singletonList(new Object[]{eval.value()}), + Collections.singletonList(new Object[]{eval.valueOrDefault()}), RowSignature.builder().add("inline", ExpressionType.toColumnType(eval.type())).build() ), "inline", diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java index 0c12144f811..91ab2a839f2 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java @@ -707,7 +707,7 @@ public class ExpressionsTest extends ExpressionTestBase DruidExpression.ofColumn(ColumnType.STRING, "hexstr") ) ), - NullHandling.sqlCompatible() ? null : 0L + null ); } diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/expression/IPv4AddressParseExpressionTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/expression/IPv4AddressParseExpressionTest.java index 63e01cf6d12..6e4273f3552 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/expression/IPv4AddressParseExpressionTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/expression/IPv4AddressParseExpressionTest.java @@ -21,7 +21,6 @@ package org.apache.druid.sql.calcite.expression; import com.google.common.collect.ImmutableMap; import org.apache.calcite.rex.RexNode; -import org.apache.druid.common.config.NullHandling; import org.apache.druid.math.expr.ExpressionValidationException; import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.column.RowSignature; @@ -39,7 +38,6 @@ public class IPv4AddressParseExpressionTest extends ExpressionTestBase private static final String VALID = "192.168.0.1"; private static final long EXPECTED = 3232235521L; private static final Object IGNORE_EXPECTED_RESULT = null; - private static final Long NULL = NullHandling.replaceWithDefault() ? NullHandling.ZERO_LONG : null; private static final String VAR = "f"; private static final RowSignature ROW_SIGNATURE = RowSignature.builder().add(VAR, ColumnType.FLOAT).build(); @@ -88,7 +86,7 @@ public class IPv4AddressParseExpressionTest extends ExpressionTestBase testExpression( testHelper.getConstantNull(), buildExpectedExpression((String) null), - NULL + null ); } @@ -99,7 +97,7 @@ public class IPv4AddressParseExpressionTest extends ExpressionTestBase testExpression( testHelper.makeInputRef(variableNameWithInvalidType), buildExpectedExpression(testHelper.makeVariable(variableNameWithInvalidType)), - NULL + null ); } @@ -110,7 +108,7 @@ public class IPv4AddressParseExpressionTest extends ExpressionTestBase testExpression( testHelper.makeLiteral(notIpAddress), buildExpectedExpression(notIpAddress), - NULL + null ); } @@ -121,7 +119,7 @@ public class IPv4AddressParseExpressionTest extends ExpressionTestBase testExpression( testHelper.makeLiteral(ipv6Compatible), buildExpectedExpression(ipv6Compatible), - NULL + null ); } @@ -132,7 +130,7 @@ public class IPv4AddressParseExpressionTest extends ExpressionTestBase testExpression( testHelper.makeLiteral(ipv6Mapped), buildExpectedExpression(ipv6Mapped), - NULL + null ); } @@ -153,7 +151,7 @@ public class IPv4AddressParseExpressionTest extends ExpressionTestBase testExpression( testHelper.makeLiteral(unsignedInt), buildExpectedExpression(unsignedInt), - NULL + null ); } @@ -164,7 +162,7 @@ public class IPv4AddressParseExpressionTest extends ExpressionTestBase testExpression( testHelper.makeLiteral(tooLow), buildExpectedExpression(tooLow), - NULL + null ); } @@ -207,7 +205,7 @@ public class IPv4AddressParseExpressionTest extends ExpressionTestBase testExpression( testHelper.makeLiteral(tooHigh), buildExpectedExpression(tooHigh), - NULL + null ); }