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
Base interface describing the mechanism used to evaluate an
ApplyFunctionExpr, which 'applies' a
LambdaExpr to one or more array Expr. All ApplyFunction implementations are immutable.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classEvaluates to true if all element of the array inputExprcauses theLambdaExprto evaluate to a 'truthy' valuestatic classEvaluates to true if any element of the array inputExprcauses theLambdaExprto evaluate to a 'truthy' valuestatic classBase 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 classBase 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 classAccumulate a value for the cartesian product of 'n' array inputs arguments with an 'n + 1' argumentLambdaExpr.static classstatic classMap the cartesian product of 'n' array input arguments to an 'n' argumentLambdaExprstatic classstatic classFilter an array to all elements that evaluate to a 'truthy' value for aLambdaExprstatic classAccumulate a value for a single array input with a 2 argumentLambdaExpr.static classstatic interfaceExpr.ObjectBindingwhich can be iterated by an integer index position forApplyFunction.BaseFoldFunction.static interfaceExpr.ObjectBindingwhich can be iterated by an integer index position forApplyFunction.BaseMapFunction.static classHelper that can wrap anotherExpr.InputBindingInspectorto use to supply the type information of aLambdaExprwhen evaluatingExpr.getOutputType(org.apache.druid.math.expr.Expr.InputBindingInspector).static classMap the scalar values of a single array inputExprto a single argumentLambdaExprstatic classstatic classBase class for family ofApplyFunctionwhich evaluate elements elements of a single array input against aLambdaExprto evaluate to a final 'truthy' valuestatic classSimple, 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
Modifier and TypeMethodDescriptionapply(LambdaExpr lambdaExpr, List<Expr> argsExpr, Expr.ObjectBinding bindings) default <T> ExprVectorProcessor<T>asVectorProcessor(Expr.VectorInputBindingInspector inspector, LambdaExpr 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, LambdaExpr lambda, List<Expr> args) Check if an apply function can be 'vectorized', for a givenLambdaExprand set ofExprinputs.getArrayInputs(List<Expr> args) Get list of input arguments which must evaluate to an arrayExprTypegetOutputType(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, processingFailed, validationFailed, validationFailed, validationHelperCheckAnyOfArgumentCount, validationHelperCheckArgIsLiteral, validationHelperCheckArgumentCount, validationHelperCheckArgumentCount, validationHelperCheckArgumentRange, validationHelperCheckLambaArgumentCount, validationHelperCheckMinArgumentCount, validationHelperCheckMinArgumentCount
-
Method Details
-
canVectorize
default boolean canVectorize(Expr.InputBindingInspector inspector, LambdaExpr 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.LambdaExpr, 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, LambdaExpr 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
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
Get list of input arguments which must evaluate to an arrayExprType -
hasArrayOutput
Returns true if apply function produces an array output. AllApplyFunctionimplementations are expected to exclusively produce either scalar or array values. -
validateArguments
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.
-