Package org.apache.druid.math.expr
Class InputBindings
- java.lang.Object
-
- org.apache.druid.math.expr.InputBindings
-
public class InputBindings extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InputBindings.BestEffortInputBindings
Expr.ObjectBinding
backed by a cache populated byExprEval.bestEffortOf(Object)
for when the input type information is totally unknown, for a single row worth of values.static class
InputBindings.InputSupplier<T>
-
Constructor Summary
Constructors Constructor Description InputBindings()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Expr.ObjectBinding
forInputSupplier(String supplierName, ExpressionType type, com.google.common.base.Supplier<?> supplier)
Create aExpr.ObjectBinding
for a single input value of a known type provided by someSupplier
static Expr.ObjectBinding
forInputSupplier(ExpressionType type, com.google.common.base.Supplier<?> supplier)
Create aExpr.ObjectBinding
for a single input value of a known type provided by someSupplier
static Expr.ObjectBinding
forInputSuppliers(Map<String,InputBindings.InputSupplier<?>> bindings)
CreateExpr.ObjectBinding
backed by map ofSupplier
to provide values for identifiers to evaluateExpr
static Expr.ObjectBinding
forMap(Map<String,?> bindings)
Deprecated.static Expr.ObjectBinding
forMap(Map<String,?> bindings, Expr.InputBindingInspector inspector)
CreateExpr.ObjectBinding
backed byMap
to provide values for identifiers to evaluateExpr
Types are detected and values are coereced viaExprEval.bestEffortOf(Object)
because input types are currently unknown.static Expr.ObjectBinding
forRow(Row row)
Creates aExpr.ObjectBinding
backed by someRow
.static <T> InputBindings.InputSupplier<T>
inputSupplier(ExpressionType type, com.google.common.base.Supplier<T> supplier)
static Expr.InputBindingInspector
inspectorForColumn(String column, ExpressionType type)
static Expr.InputBindingInspector
inspectorFromTypeMap(Map<String,ExpressionType> types)
Create anExpr.InputBindingInspector
backed by a map of binding identifiers to theirExprType
static Expr.ObjectBinding
nilBindings()
EmptyExpr.ObjectBinding
that doesn't complain about attempts to access type or value for any input identifiers, both of which will be nulls.static Expr.ObjectBinding
validateConstant(Expr expr)
Empty binding that throw aUOE
if anything attempts to lookup an identifier type or value
-
-
-
Method Detail
-
nilBindings
public static Expr.ObjectBinding nilBindings()
EmptyExpr.ObjectBinding
that doesn't complain about attempts to access type or value for any input identifiers, both of which will be nulls. Typically used for evaluating known constant expressions, or finding a default or initial value of some expression if all inputs are null.
-
validateConstant
public static Expr.ObjectBinding validateConstant(Expr expr)
Empty binding that throw aUOE
if anything attempts to lookup an identifier type or value
-
inspectorFromTypeMap
public static Expr.InputBindingInspector inspectorFromTypeMap(Map<String,ExpressionType> types)
Create anExpr.InputBindingInspector
backed by a map of binding identifiers to theirExprType
-
inspectorForColumn
public static Expr.InputBindingInspector inspectorForColumn(String column, ExpressionType type)
-
forRow
public static Expr.ObjectBinding forRow(Row row)
Creates aExpr.ObjectBinding
backed by someRow
.ColumnHolder.TIME_COLUMN_NAME
is special handled to be backed byRow.getTimestampFromEpoch()
, all other values are ethically sourced fromRow.getRaw(String)
. Types are detected and values are coereced viaExprEval.bestEffortOf(Object)
because input types are currently unknown.
-
forMap
@Deprecated public static Expr.ObjectBinding forMap(Map<String,?> bindings)
Deprecated.CreateExpr.ObjectBinding
backed byMap
to provide values for identifiers to evaluateExpr
Types are detected and values are coereced viaExprEval.bestEffortOf(Object)
because input types are currently unknown. This method is only used for testing and mimics the behavior offorRow(Row)
except lacks special handling for columns namedColumnHolder.TIME_COLUMN_NAME
.
-
forMap
public static Expr.ObjectBinding forMap(Map<String,?> bindings, Expr.InputBindingInspector inspector)
CreateExpr.ObjectBinding
backed byMap
to provide values for identifiers to evaluateExpr
Types are detected and values are coereced viaExprEval.bestEffortOf(Object)
because input types are currently unknown.
-
forInputSupplier
public static Expr.ObjectBinding forInputSupplier(ExpressionType type, com.google.common.base.Supplier<?> supplier)
Create aExpr.ObjectBinding
for a single input value of a known type provided by someSupplier
-
forInputSupplier
public static Expr.ObjectBinding forInputSupplier(String supplierName, ExpressionType type, com.google.common.base.Supplier<?> supplier)
Create aExpr.ObjectBinding
for a single input value of a known type provided by someSupplier
-
inputSupplier
public static <T> InputBindings.InputSupplier<T> inputSupplier(ExpressionType type, com.google.common.base.Supplier<T> supplier)
-
forInputSuppliers
public static Expr.ObjectBinding forInputSuppliers(Map<String,InputBindings.InputSupplier<?>> bindings)
CreateExpr.ObjectBinding
backed by map ofSupplier
to provide values for identifiers to evaluateExpr
-
-