use of org.apache.druid.math.expr.ExpressionType in project druid by apache.
the class VectorProcessors method makeSymmetricalProcessor.
/**
* Make a 2 argument, symmetrical processor where both argments must be the same input type and produce the same
* output type
* long, long -> long
* double, double -> double
* string, string -> string
*/
public static <T> ExprVectorProcessor<T> makeSymmetricalProcessor(Expr.VectorInputBindingInspector inspector, Expr left, Expr right, Supplier<ExprVectorProcessor<?>> longProcessor, Supplier<ExprVectorProcessor<?>> doubleProcessor, Supplier<ExprVectorProcessor<?>> stringProcessor) {
final ExpressionType leftType = left.getOutputType(inspector);
if (leftType == null) {
return right.buildVectorized(inspector);
}
Preconditions.checkArgument(inspector.areSameTypes(left, right));
ExprVectorProcessor<?> processor = null;
if (Types.is(leftType, ExprType.STRING)) {
processor = stringProcessor.get();
} else if (Types.is(leftType, ExprType.LONG)) {
processor = longProcessor.get();
} else if (Types.is(leftType, ExprType.DOUBLE)) {
processor = doubleProcessor.get();
}
if (processor == null) {
throw Exprs.cannotVectorize();
}
return (ExprVectorProcessor<T>) processor;
}
Aggregations