public interface ScalarValuedFunction
Implementors of new functions should generally not implement this interface,
but instead implement FunctionEvaluator
in conjunction with
using ScalarFunctionDescriptor
.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
FunctionEvaluator |
getEvaluator(RecordValued input,
ScalarSettable result)
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.
|
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.
|
ScalarTokenType |
validateInputType(RecordTokenType inputType)
Calculates the actual output type of the function given the specified input type.
|
ScalarTokenType getUpperBound()
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.
Collection<String> getRequiredFields()
ScalarTokenType validateInputType(RecordTokenType inputType)
The type returned must be assignable to the type returned by
getUpperBound()
. If this is not the case, runtime type errors
may arise.
inputType
- the type of the record used as input to the functionInvalidFieldException
- if the function requires a field not present
in the input typeInvalidOperandTypeException
- if a subexpression evaluates to
a type incompatible with the functionFunctionEvaluator getEvaluator(RecordValued input, ScalarSettable result)
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()
input
- the record source to use as context for evaluating the
functionresult
- the buffer into which evaluation results are to be storedScalarValued getSubexpressionEvaluation(EvaluationContext ctx)
ctx
- the expression context in which the function is being
evaluated as a subexpressionboolean equals(Object o)
ScalarValuedFunctions should override this method to indicate whether they are equal to another ScalarValuedFunction.
int hashCode()
ScalarValuedFunctions should override this method in a manner consistent with equals(Object)
.
ScalarValuedFunction remapFieldReferences(Map<String,String> oldToNewMapping)
oldToNewMapping
- a mapping from old names to new names. If a name is not present in the
given mapping, it will remain as-is.ScalarValuedFunction mapFieldsToFunctions(Map<String,ScalarValuedFunction> mapping)
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.