public final class ConstantReference extends Object implements ScalarValuedFunction
Constructor and Description |
---|
ConstantReference(ScalarValued v)
Defines a function evaluating to the specified value
|
Modifier and Type | Method and Description |
---|---|
static ScalarValuedFunction |
constant(BigDecimal value)
Creates a function evaluating to the specified numeric
constant.
|
static ScalarValuedFunction |
constant(boolean value)
Creates a function evaluating to the specified boolean
constant.
|
static ScalarValuedFunction |
constant(byte[] value)
Creates a function evaluating to the specified binary
constant.
|
static ScalarValuedFunction |
constant(char value)
Creates a function evaluating to the specified char
constant.
|
static ScalarValuedFunction |
constant(double value)
Creates a function evaluating to the specified double
constant.
|
static ScalarValuedFunction |
constant(float value)
Creates a function evaluating to the specified float
constant.
|
static ScalarValuedFunction |
constant(int value)
Creates a function evaluating to the specified int
constant.
|
static ScalarValuedFunction |
constant(long value)
Creates a function evaluating to the specified long
constant.
|
static <O> ScalarValuedFunction |
constant(O value)
Creates a function evaluating to the specified object
constant.
|
static ScalarValuedFunction |
constant(ScalarToken value)
Creates a function evaluating to the specified value.
|
static ScalarValuedFunction |
constant(String value)
Creates a function evaluating to the specified string
constant.
|
boolean |
equals(Object obj) |
FunctionEvaluator |
getEvaluator(RecordValued input,
ScalarSettable output)
Constructs an instance of an evaluator for the function.
|
Collection<String> |
getRequiredFields()
Get the input fields required in the function input.
|
ScalarValued |
getSubexpressionEvaluation(EvaluationContext ctx)
Constructs an instance of an evaluation of the function in the context
of a larger expression.
|
ScalarTokenType |
getUpperBound()
Gets the upper bound on the output type of the function.
|
int |
hashCode() |
ScalarValuedFunction |
mapFieldsToFunctions(Map<String,ScalarValuedFunction> mapping)
Creates a new function, equivalent to the given function, but with specified field references
mapped to functions.
|
static ScalarValuedFunction |
nullValue()
Creates a function evaluating to null.
|
static ScalarValuedFunction |
nullValue(ScalarValuedFunction expr)
Deprecated.
Untyped null tokens are now supported. Use
nullValue() to generate
a null token without an input type. |
static ScalarValuedFunction |
nullValue(String fieldName)
Deprecated.
Untyped null tokens are now supported. Use
nullValue() to generate
a null token without an input type. |
ScalarValuedFunction |
remapFieldReferences(Map<String,String> oldToNewMapping)
Creates a new function, equivalent to the given function, but with all field references
renamed according to the given mapping.
|
String |
toString() |
ScalarTokenType |
validateInputType(RecordTokenType inputType)
Calculates the actual output type of the function given the specified input type.
|
public ConstantReference(ScalarValued v)
v
- the value to return from the functionpublic ScalarTokenType getUpperBound()
ScalarValuedFunction
TokenType#isAssignableFrom(TokenType)
.
This value is used to detect type consistency issues as early
as possible.
It is always valid to return TokenTypeConstant#SCALAR
, in which
case no type consistency issues can be caught early.
getUpperBound
in interface ScalarValuedFunction
public ScalarTokenType validateInputType(RecordTokenType inputType)
ScalarValuedFunction
The type returned must be assignable to the type returned by
ScalarValuedFunction.getUpperBound()
. If this is not the case, runtime type errors
may arise.
validateInputType
in interface ScalarValuedFunction
inputType
- the type of the record used as input to the functionpublic FunctionEvaluator getEvaluator(RecordValued input, ScalarSettable output)
ScalarValuedFunction
Implementations may assume that the input and output are known to be compatible with the function. Normally, this method is only invoked by the DataRush framework, which guarantees this is the case. In general, to satisfy this requirement, callers are expected to:
validateInputType(input.getType())
does not throw an exceptionresult.getType()
getEvaluator
in interface ScalarValuedFunction
input
- the record source to use as context for evaluating the
functionoutput
- the buffer into which evaluation results are to be storedpublic ScalarValued getSubexpressionEvaluation(EvaluationContext ctx)
ScalarValuedFunction
getSubexpressionEvaluation
in interface ScalarValuedFunction
ctx
- the expression context in which the function is being
evaluated as a subexpressionpublic int hashCode()
ScalarValuedFunction
ScalarValuedFunctions should override this method in a manner consistent with ScalarValuedFunction.equals(Object)
.
hashCode
in interface ScalarValuedFunction
hashCode
in class Object
public boolean equals(Object obj)
ScalarValuedFunction
ScalarValuedFunctions should override this method to indicate whether they are equal to another ScalarValuedFunction.
equals
in interface ScalarValuedFunction
equals
in class Object
public static ScalarValuedFunction constant(byte[] value)
value
- the constant value to returnpublic static ScalarValuedFunction constant(boolean value)
value
- the constant value to returnpublic static ScalarValuedFunction constant(char value)
value
- the constant value to returnpublic static ScalarValuedFunction constant(int value)
value
- the constant value to returnpublic static ScalarValuedFunction constant(long value)
value
- the constant value to returnpublic static ScalarValuedFunction constant(float value)
value
- the constant value to returnpublic static ScalarValuedFunction constant(double value)
value
- the constant value to returnpublic static ScalarValuedFunction constant(BigDecimal value)
value
- the constant value to returnpublic static ScalarValuedFunction constant(String value)
value
- the constant value to returnpublic static <O> ScalarValuedFunction constant(O value)
O
- the type of the objectvalue
- the constant value to returnpublic static ScalarValuedFunction constant(ScalarToken value)
value
- the constant value to return@Deprecated public static ScalarValuedFunction nullValue(String fieldName)
nullValue()
to generate
a null token without an input type.fieldName
- an input field, the type of which will be used as the result type@Deprecated public static ScalarValuedFunction nullValue(ScalarValuedFunction expr)
nullValue()
to generate
a null token without an input type.fieldName
- an expression, the type of which will be used as the result typepublic static ScalarValuedFunction nullValue()
public Collection<String> getRequiredFields()
ScalarValuedFunction
getRequiredFields
in interface ScalarValuedFunction
public ScalarValuedFunction remapFieldReferences(Map<String,String> oldToNewMapping)
ScalarValuedFunction
remapFieldReferences
in interface ScalarValuedFunction
oldToNewMapping
- a mapping from old names to new names. If a name is not present in the
given mapping, it will remain as-is.public ScalarValuedFunction mapFieldsToFunctions(Map<String,ScalarValuedFunction> mapping)
ScalarValuedFunction
mapFieldsToFunctions
in interface ScalarValuedFunction
mapping
- a mapping from field names to functions. If a name is not present in the
given mapping, it will remain as-is.Copyright © 2019 Actian Corporation. All rights reserved.