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' aLambdaExpr
to one or more arrayExpr
. AllApplyFunction
implementations are immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ApplyFunction.AllMatchFunction
Evaluates to true if all element of the array inputExpr
causes theLambdaExpr
to evaluate to a 'truthy' valuestatic class
ApplyFunction.AnyMatchFunction
Evaluates to true if any element of the array inputExpr
causes theLambdaExpr
to evaluate to a 'truthy' valuestatic class
ApplyFunction.BaseFoldFunction
Base class for family ofApplyFunction
which aggregate a scalar or array value given one or more array inputExpr
arguments and an array or scalar "accumulator" argument with an initial valuestatic class
ApplyFunction.BaseMapFunction
Base class for "map" functions, which are a class ofApplyFunction
which take a lambda function that is mapped to the values of anApplyFunction.IndexableMapLambdaObjectBinding
which is created from the outerExpr.ObjectBinding
and the values of the arrayExpr
argument(s)static class
ApplyFunction.CartesianFoldFunction
Accumulate a value for the cartesian product of 'n' array inputs arguments with an 'n + 1' argumentLambdaExpr
.static class
ApplyFunction.CartesianFoldLambdaBinding
static class
ApplyFunction.CartesianMapFunction
Map the cartesian product of 'n' array input arguments to an 'n' argumentLambdaExpr
static class
ApplyFunction.CartesianMapLambdaBinding
static class
ApplyFunction.FilterFunction
Filter an array to all elements that evaluate to a 'truthy' value for aLambdaExpr
static class
ApplyFunction.FoldFunction
Accumulate a value for a single array input with a 2 argumentLambdaExpr
.static class
ApplyFunction.FoldLambdaBinding
static interface
ApplyFunction.IndexableFoldLambdaBinding
Expr.ObjectBinding
which can be iterated by an integer index position forApplyFunction.BaseFoldFunction
.static interface
ApplyFunction.IndexableMapLambdaObjectBinding
Expr.ObjectBinding
which can be iterated by an integer index position forApplyFunction.BaseMapFunction
.static class
ApplyFunction.LambdaInputBindingInspector
Helper that can wrap anotherExpr.InputBindingInspector
to use to supply the type information of aLambdaExpr
when evaluatingExpr.getOutputType(org.apache.druid.math.expr.Expr.InputBindingInspector)
.static class
ApplyFunction.MapFunction
Map the scalar values of a single array inputExpr
to a single argumentLambdaExpr
static class
ApplyFunction.MapLambdaBinding
static class
ApplyFunction.MatchFunction
Base class for family ofApplyFunction
which evaluate elements elements of a single array input against aLambdaExpr
to evaluate to a final 'truthy' valuestatic class
ApplyFunction.SettableLambdaBinding
Simple, mutable,Expr.ObjectBinding
for aLambdaExpr
which provides aMap
for storing arbitrary values to use as values forIdentifierExpr
in 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 ExprEval
apply(org.apache.druid.math.expr.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 boolean
canVectorize(Expr.InputBindingInspector inspector, Expr lambda, List<Expr> args)
Check if an apply function can be 'vectorized', for a givenLambdaExpr
and set ofExpr
inputs.Set<Expr>
getArrayInputs(List<Expr> args)
Get list of input arguments which must evaluate to an arrayExprType
ExpressionType
getOutputType(Expr.InputBindingInspector inspector, org.apache.druid.math.expr.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 boolean
hasArrayOutput(org.apache.druid.math.expr.LambdaExpr lambdaExpr)
Returns true if apply function produces an array output.void
validateArguments(org.apache.druid.math.expr.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 givenLambdaExpr
and set ofExpr
inputs. 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 aExprVectorProcessor
which 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(org.apache.druid.math.expr.LambdaExpr lambdaExpr, List<Expr> argsExpr, Expr.ObjectBinding bindings)
ApplyLambdaExpr
to argument list ofExpr
given 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 forIdentifierExpr
in 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(org.apache.druid.math.expr.LambdaExpr lambdaExpr)
Returns true if apply function produces an array output. AllApplyFunction
implementations are expected to exclusively produce either scalar or array values.
-
validateArguments
void validateArguments(org.apache.druid.math.expr.LambdaExpr lambdaExpr, List<Expr> args)
Validate function arguments. This method is called whenever aApplyFunctionExpr
is created, and should validate everything that is feasible up front. Note that input type information is typically unavailable at the timeExpr
are parsed, and so this method is incapable of performing complete validation.
-
getOutputType
@Nullable ExpressionType getOutputType(Expr.InputBindingInspector inspector, org.apache.druid.math.expr.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.
-
-