- All Implemented Interfaces:
ScalarValuedFunction
-
Constructor Summary
ConstructorsConstructorDescriptionDefines a function evaluating to the specified value -
Method Summary
Modifier and TypeMethodDescriptionstatic ScalarValuedFunctionconstant(boolean value) Creates a function evaluating to the specified boolean constant.static ScalarValuedFunctionconstant(byte[] value) Creates a function evaluating to the specified binary constant.static ScalarValuedFunctionconstant(char value) Creates a function evaluating to the specified char constant.static ScalarValuedFunctionconstant(double value) Creates a function evaluating to the specified double constant.static ScalarValuedFunctionconstant(float value) Creates a function evaluating to the specified float constant.static ScalarValuedFunctionconstant(int value) Creates a function evaluating to the specified int constant.static ScalarValuedFunctionconstant(long value) Creates a function evaluating to the specified long constant.static ScalarValuedFunctionconstant(ScalarToken value) Creates a function evaluating to the specified value.static ScalarValuedFunctionCreates a function evaluating to the specified string constant.static ScalarValuedFunctionconstant(BigDecimal value) Creates a function evaluating to the specified numeric constant.static <O> ScalarValuedFunctionconstant(O value) Creates a function evaluating to the specified object constant.booleangetEvaluator(RecordValued input, ScalarSettable output) Constructs an instance of an evaluator for the function.Get the input fields required in the function input.Constructs an instance of an evaluation of the function in the context of a larger expression.Gets the upper bound on the output type of the function.inthashCode()mapFieldsToFunctions(Map<String, ScalarValuedFunction> mapping) Creates a new function, equivalent to the given function, but with specified field references mapped to functions.static ScalarValuedFunctionCreates a function evaluating to null.static ScalarValuedFunctionDeprecated.Untyped null tokens are now supported.static ScalarValuedFunctionDeprecated.Untyped null tokens are now supported.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.toString()validateInputType(RecordTokenType inputType) Calculates the actual output type of the function given the specified input type.
-
Constructor Details
-
ConstantReference
Defines a function evaluating to the specified value- Parameters:
v- the value to return from the function
-
-
Method Details
-
getUpperBound
Description copied from interface:ScalarValuedFunctionGets the upper bound on the output type of the function. This need not be the exact type of the output, but is expected to be a type to which the actual output type is assignable, as according toTokenType#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.- Specified by:
getUpperBoundin interfaceScalarValuedFunction- Returns:
- the most specific type to which any possible return type is assignable.
-
validateInputType
Description copied from interface:ScalarValuedFunctionCalculates the actual output type of the function given the specified input type.The type returned must be assignable to the type returned by
ScalarValuedFunction.getUpperBound(). If this is not the case, runtime type errors may arise.- Specified by:
validateInputTypein interfaceScalarValuedFunction- Parameters:
inputType- the type of the record used as input to the function- Returns:
- the return type of the function for the given input record schema
-
getEvaluator
Description copied from interface:ScalarValuedFunctionConstructs an instance of an evaluator for the function. The evaluator returns the result of the the function applied to the specified input into the given output target.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:
- verify that
validateInputType(input.getType())does not throw an exception - verify the output type returned is assignable to
result.getType()
- Specified by:
getEvaluatorin interfaceScalarValuedFunction- Parameters:
input- the record source to use as context for evaluating the functionoutput- the buffer into which evaluation results are to be stored- Returns:
- an evaluator bound to the provided input and output
- verify that
-
getSubexpressionEvaluation
Description copied from interface:ScalarValuedFunctionConstructs an instance of an evaluation of the function in the context of a larger expression.- Specified by:
getSubexpressionEvaluationin interfaceScalarValuedFunction- Parameters:
ctx- the expression context in which the function is being evaluated as a subexpression- Returns:
- an object representing the subexpression's current value
-
hashCode
public int hashCode()Description copied from interface:ScalarValuedFunctionScalarValuedFunctions should override this method in a manner consistent with
ScalarValuedFunction.equals(Object).- Specified by:
hashCodein interfaceScalarValuedFunction- Overrides:
hashCodein classObject
-
equals
Description copied from interface:ScalarValuedFunctionScalarValuedFunctions should override this method to indicate whether they are equal to another ScalarValuedFunction.
- Specified by:
equalsin interfaceScalarValuedFunction- Overrides:
equalsin classObject
-
toString
-
constant
Creates a function evaluating to the specified binary constant.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified boolean constant.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified char constant.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified int constant.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified long constant.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified float constant.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified double constant.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified numeric constant.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified string constant.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified object constant.- Type Parameters:
O- the type of the object- Parameters:
value- the constant value to return- Returns:
- the constant function
-
constant
Creates a function evaluating to the specified value.- Parameters:
value- the constant value to return- Returns:
- the constant function
-
nullValue
Deprecated.Untyped null tokens are now supported. UsenullValue()to generate a null token without an input type.Creates a function, of the same type as the specified field, evaluating to null.- Parameters:
fieldName- an input field, the type of which will be used as the result type- Returns:
- the null function
-
nullValue
Deprecated.Untyped null tokens are now supported. UsenullValue()to generate a null token without an input type.Creates a function, of the same type as the specified expression, evaluating to null.- Parameters:
fieldName- an expression, the type of which will be used as the result type- Returns:
- the null function
-
nullValue
Creates a function evaluating to null.- Returns:
- the null function
-
getRequiredFields
Description copied from interface:ScalarValuedFunctionGet the input fields required in the function input. An empty collection implies no specific fields are required.- Specified by:
getRequiredFieldsin interfaceScalarValuedFunction- Returns:
- the names of fields which must be present in the record input schema
-
remapFieldReferences
Description copied from interface:ScalarValuedFunctionCreates a new function, equivalent to the given function, but with all field references renamed according to the given mapping.- Specified by:
remapFieldReferencesin interfaceScalarValuedFunction- Parameters:
oldToNewMapping- a mapping from old names to new names. If a name is not present in the given mapping, it will remain as-is.- Returns:
- a new function with all field reference renamed appropriately
-
mapFieldsToFunctions
Description copied from interface:ScalarValuedFunctionCreates a new function, equivalent to the given function, but with specified field references mapped to functions.- Specified by:
mapFieldsToFunctionsin interfaceScalarValuedFunction- Parameters:
mapping- a mapping from field names to functions. If a name is not present in the given mapping, it will remain as-is.- Returns:
- a new function with all field reference mapped appropriately
-