public abstract class FieldDerivation extends Object
DeriveFields
operator.Modifier and Type | Method and Description |
---|---|
static FieldDerivation |
apply(ScalarTokenType fieldType,
ScalarValuedFunction f,
String variableName)
Applies a function to each input field matching the specified
type criteria.
|
static FieldDerivation |
apply(ScalarTokenType fieldType,
String expression,
String variableName)
Applies an expression to each input field matching the specified
type criteria.
|
abstract void |
collectMapping(RecordTokenType inputType,
Map<String,ScalarValuedFunction> mappings)
Verifies derivation can be applied in the given input context and
records the field mapping.
|
static FieldDerivation |
derive(String name,
ScalarValuedFunction f)
Defines a derivation of the named field using the specified function.
|
static FieldDerivation |
derive(String name,
String expression)
Defines a derivation of the named field using the specified expression.
|
ScalarValuedFunction |
getFunction()
Gets the function for deriving the field value.
|
String |
getName()
Gets the name of the target field to derive.
|
static FieldDerivation |
id(String name)
Defines an identity mapping for the specified field.
|
abstract FieldDerivation |
mapFieldsToFunctions(Map<String,ScalarValuedFunction> mapping)
Creates a new field derivation, equivalent to the given derivation, but with specified field references
mapped to functions.
|
public String getName()
null
.public ScalarValuedFunction getFunction()
public abstract void collectMapping(RecordTokenType inputType, Map<String,ScalarValuedFunction> mappings)
inputType
- the datatype of the inputmappings
- the field to function mappublic abstract FieldDerivation 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.public static FieldDerivation derive(String name, ScalarValuedFunction f)
name
- the name of the field to use in the output recordf
- the function producing the field's value from the input recordpublic static FieldDerivation derive(String name, String expression)
name
- the name of the field to use in the output recordexpression
- the expression producing the field's value from the input recordpublic static FieldDerivation id(String name)
name
- the field being mapped to itselfpublic static FieldDerivation apply(ScalarTokenType fieldType, ScalarValuedFunction f, String variableName)
The function supplied is a "template" used to produce the function to apply to each matching field. This template is expected to have a field which acts as a place holder to be replaced with the name of matching field. As an example, to define a derivation which will add 3 to every number field in the input:
ScalarValuedFunction f= Arithmetic.add("X",ConstantReference.constant(3)); FieldDerivation d= apply(TokenTypeConstant.DOUBLE, f, "X");Note that the same name,
"X"
is used in both the function declaration
and the derivation. This is the variable name.fieldType
- the type of input fields to which to apply the
functionf
- the function to apply to matching fieldsvariableName
- the name of the field used as a place holder
in the function. References to this field will be replaced
with references to the matching fields to produce specific
instances of the function for each field.public static FieldDerivation apply(ScalarTokenType fieldType, String expression, String variableName)
The function supplied is a "template" used to produce the function to apply to each matching field. This template is expected to have a field which acts as a place holder to be replaced with the name of matching field. As an example, to define a derivation which will add 3 to every number field in the input:
String expression= "X+3"; FieldDerivation d= apply(TokenTypeConstant.DOUBLE, expression, "X");Note that the same name,
"X"
is used in both the function declaration
and the derivation. This is the variable name.fieldType
- the type of input fields to which to apply the
functionexpression
- the expression to apply to matching fieldsvariableName
- the name of the field used as a place holder
in the function. References to this field will be replaced
with references to the matching fields to produce specific
instances of the function for each field.Copyright © 2021 Actian Corporation. All rights reserved.