public final class FieldReference extends Object implements ScalarValuedFunction
Constructor and Description |
---|
FieldReference(String name)
Defines a reference to the specified field.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
FunctionEvaluator |
getEvaluator(RecordValued input,
ScalarSettable output)
Constructs an instance of an evaluator for the function.
|
String |
getName()
Gets the name of the referenced field
|
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.
|
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.
|
static ScalarValuedFunction |
value(String fieldName)
Defines an expression returning the value of the given field.
|
static List<ScalarValuedFunction> |
values(String... fieldNames)
Defines a number of expressions returning the value of a field,
one for each given field.
|
public FieldReference(String name)
name
- the name of the field referencedpublic String getName()
public 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 value(String fieldName)
fieldName
- the field whose value is to be returnedpublic static List<ScalarValuedFunction> values(String... fieldNames)
fieldNames
- the fields whose values are to be returnedpublic 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 © 2020 Actian Corporation. All rights reserved.