Package org.apache.druid.math.expr
Interface ApplyFunction
-
- All Superinterfaces:
NamedFunction
- All Known Implementing Classes:
ApplyFunction.AllMatchFunction,ApplyFunction.AnyMatchFunction,ApplyFunction.BaseFoldFunction,ApplyFunction.BaseMapFunction,ApplyFunction.CartesianFoldFunction,ApplyFunction.CartesianMapFunction,ApplyFunction.FilterFunction,ApplyFunction.FoldFunction,ApplyFunction.MapFunction,ApplyFunction.MatchFunction
public interface ApplyFunction extends NamedFunction
Base interface describing the mechanism used to evaluate anApplyFunctionExpr, which 'applies' aLambdaExprto one or more arrayExpr. AllApplyFunctionimplementations are immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classApplyFunction.AllMatchFunctionEvaluates to true if all element of the array inputExprcauses theLambdaExprto evaluate to a 'truthy' valuestatic classApplyFunction.AnyMatchFunctionEvaluates to true if any element of the array inputExprcauses theLambdaExprto evaluate to a 'truthy' valuestatic classApplyFunction.BaseFoldFunctionBase class for family ofApplyFunctionwhich aggregate a scalar or array value given one or more array inputExprarguments and an array or scalar "accumulator" argument with an initial valuestatic classApplyFunction.BaseMapFunctionBase class for "map" functions, which are a class ofApplyFunctionwhich take a lambda function that is mapped to the values of anApplyFunction.IndexableMapLambdaObjectBindingwhich is created from the outerExpr.ObjectBindingand the values of the arrayExprargument(s)static classApplyFunction.CartesianFoldFunctionAccumulate a value for the cartesian product of 'n' array inputs arguments with an 'n + 1' argumentLambdaExpr.static classApplyFunction.CartesianFoldLambdaBindingstatic classApplyFunction.CartesianMapFunctionMap the cartesian product of 'n' array input arguments to an 'n' argumentLambdaExprstatic classApplyFunction.CartesianMapLambdaBindingstatic classApplyFunction.FilterFunctionFilter an array to all elements that evaluate to a 'truthy' value for aLambdaExprstatic classApplyFunction.FoldFunctionAccumulate a value for a single array input with a 2 argumentLambdaExpr.static classApplyFunction.FoldLambdaBindingstatic interfaceApplyFunction.IndexableFoldLambdaBindingExpr.ObjectBindingwhich can be iterated by an integer index position forApplyFunction.BaseFoldFunction.static interfaceApplyFunction.IndexableMapLambdaObjectBindingExpr.ObjectBindingwhich can be iterated by an integer index position forApplyFunction.BaseMapFunction.static classApplyFunction.LambdaInputBindingInspectorHelper that can wrap anotherExpr.InputBindingInspectorto use to supply the type information of aLambdaExprwhen evaluatingExpr.getOutputType(org.apache.druid.math.expr.Expr.InputBindingInspector).static classApplyFunction.MapFunctionMap the scalar values of a single array inputExprto a single argumentLambdaExprstatic classApplyFunction.MapLambdaBindingstatic classApplyFunction.MatchFunctionBase class for family ofApplyFunctionwhich evaluate elements elements of a single array input against aLambdaExprto evaluate to a final 'truthy' valuestatic classApplyFunction.SettableLambdaBindingSimple, mutable,Expr.ObjectBindingfor aLambdaExprwhich provides aMapfor storing arbitrary values to use as values forIdentifierExprin the body of the lambda that are arguments to the lambda
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ExprEvalapply(LambdaExpr lambdaExpr, List<Expr> argsExpr, Expr.ObjectBinding bindings)default <T> ExprVectorProcessor<T>asVectorProcessor(Expr.VectorInputBindingInspector inspector, Expr lambda, List<Expr> args)Builds a 'vectorized' function expression processor, that can build vectorized processors for its input values usingExpr.asVectorProcessor(org.apache.druid.math.expr.Expr.VectorInputBindingInspector), for use in vectorized query engines.default booleancanVectorize(Expr.InputBindingInspector inspector, Expr lambda, List<Expr> args)Check if an apply function can be 'vectorized', for a givenLambdaExprand set ofExprinputs.Set<Expr>getArrayInputs(List<Expr> args)Get list of input arguments which must evaluate to an arrayExprTypeExpressionTypegetOutputType(Expr.InputBindingInspector inspector, LambdaExpr expr, List<Expr> args)Compute the output type of this function for a given lambda and the argument expressions which will be applied as its inputs.default booleanhasArrayOutput(LambdaExpr lambdaExpr)Returns true if apply function produces an array output.voidvalidateArguments(LambdaExpr lambdaExpr, List<Expr> args)Validate function arguments.-
Methods inherited from interface org.apache.druid.math.expr.NamedFunction
name, processingFailed, validationFailed, validationFailed, validationHelperCheckAnyOfArgumentCount, validationHelperCheckArgIsLiteral, validationHelperCheckArgumentCount, validationHelperCheckArgumentCount, validationHelperCheckArgumentRange, validationHelperCheckLambaArgumentCount, validationHelperCheckMinArgumentCount, validationHelperCheckMinArgumentCount
-
-
-
-
Method Detail
-
canVectorize
default boolean canVectorize(Expr.InputBindingInspector inspector, Expr lambda, List<Expr> args)
Check if an apply function can be 'vectorized', for a givenLambdaExprand set ofExprinputs. If this method returns true,asVectorProcessor(org.apache.druid.math.expr.Expr.VectorInputBindingInspector, org.apache.druid.math.expr.Expr, java.util.List<org.apache.druid.math.expr.Expr>)is expected to produce aExprVectorProcessorwhich can evaluate values in batches to use with vectorized query engines.
-
asVectorProcessor
default <T> ExprVectorProcessor<T> asVectorProcessor(Expr.VectorInputBindingInspector inspector, Expr lambda, List<Expr> args)
Builds a 'vectorized' function expression processor, that can build vectorized processors for its input values usingExpr.asVectorProcessor(org.apache.druid.math.expr.Expr.VectorInputBindingInspector), for use in vectorized query engines.
-
apply
ExprEval apply(LambdaExpr lambdaExpr, List<Expr> argsExpr, Expr.ObjectBinding bindings)
ApplyLambdaExprto argument list ofExprgiven a set of outerExpr.ObjectBinding. These outer bindings will be used to form the scope for the bindings used to evaluate theLambdaExpr, which use the array inputs to supply scalar values to use as bindings forIdentifierExprin the lambda body.
-
getArrayInputs
Set<Expr> getArrayInputs(List<Expr> args)
Get list of input arguments which must evaluate to an arrayExprType
-
hasArrayOutput
default boolean hasArrayOutput(LambdaExpr lambdaExpr)
Returns true if apply function produces an array output. AllApplyFunctionimplementations are expected to exclusively produce either scalar or array values.
-
validateArguments
void validateArguments(LambdaExpr lambdaExpr, List<Expr> args)
Validate function arguments. This method is called whenever aApplyFunctionExpris created, and should validate everything that is feasible up front. Note that input type information is typically unavailable at the timeExprare parsed, and so this method is incapable of performing complete validation.
-
getOutputType
@Nullable ExpressionType getOutputType(Expr.InputBindingInspector inspector, LambdaExpr expr, List<Expr> args)
Compute the output type of this function for a given lambda and the argument expressions which will be applied as its inputs.
-
-