public class ExpressionFunction extends ExpressionOperation implements cascading.operation.Function<ScriptOperation.Context>
Tuple
values. This Function
is based on the Janino compiler.
Specifically this function uses the ExpressionEvaluator
, thus the syntax from that class is inherited here.
An expression may use field names directly as parameters in the expression, or field positions with the syntax "$n", where n is an integer.
Given an argument tuple with the fields "a" and "b", the following expression returns true:
a + b == $0 + $1
Further, the types of the tuple elements will be coerced into the given parameterTypes. Regardless of the actual tuple element values, they will be converted to the types expected by the expression.
Field names used in the expression should be valid Java variable names; for example, '+' or '-' are not allowed. Also the use of a field name that begins with an upper-case character is likely to fail and should be avoided.
ScriptOperation.Context, ScriptOperation.Evaluator
block, parameterNames, parameterTypes, returnType
Constructor and Description |
---|
ExpressionFunction(cascading.tuple.Fields fieldDeclaration,
java.lang.String expression)
Constructor ExpressionFunction creates a new ExpressionFunction instance.
|
ExpressionFunction(cascading.tuple.Fields fieldDeclaration,
java.lang.String expression,
java.lang.Class parameterType)
Constructor ExpressionFunction creates a new ExpressionFunction instance.
|
ExpressionFunction(cascading.tuple.Fields fieldDeclaration,
java.lang.String expression,
java.lang.String[] parameterNames,
java.lang.Class[] parameterTypes)
Constructor ExpressionFunction creates a new ExpressionFunction instance.
|
Modifier and Type | Method and Description |
---|---|
void |
operate(cascading.flow.FlowProcess flowProcess,
cascading.operation.FunctionCall<ScriptOperation.Context> functionCall) |
getEvaluator, getExpression, guessParameterNames
equals, evaluate, getBlock, getExtendedClass, getParameterNames, getParameterTypes, getReturnType, hashCode, prepare
cleanup, flush, getFieldDeclaration, getNumArgs, getTrace, isSafe, printOperationInternal, toString, toStringInternal
@ConstructorProperties(value={"fieldDeclaration","expression"}) public ExpressionFunction(cascading.tuple.Fields fieldDeclaration, java.lang.String expression)
This constructor, when used with incoming arguments that have type information, the argument field
names can be used directly in the the expression, for example a + b
. The type of a
and b
will be inherited from the incoming argument fields.
Or, if the incoming argument selector is Fields.NONE
, an expression using only static method calls
or constants can be used.
This is useful when inserting random numbers for example, (int) (Math.random() * Integer.MAX_VALUE)
.
fieldDeclaration
- of type Fieldsexpression
- of type String@ConstructorProperties(value={"fieldDeclaration","expression","parameterType"}) public ExpressionFunction(cascading.tuple.Fields fieldDeclaration, java.lang.String expression, java.lang.Class parameterType)
This constructor assumes all parameter are of the same type.
fieldDeclaration
- of type Fieldsexpression
- of type StringparameterType
- of type Class@ConstructorProperties(value={"fieldDeclaration","expression","parameterNames","parameterTypes"}) public ExpressionFunction(cascading.tuple.Fields fieldDeclaration, java.lang.String expression, java.lang.String[] parameterNames, java.lang.Class[] parameterTypes)
This constructor expects all parameter type names to be declared with their types. Positional parameters must be named the same as in the given expression with the "$" sign prepended.
fieldDeclaration
- of type Fieldsexpression
- of type StringparameterNames
- of type String[]parameterTypes
- of type Class[]public void operate(cascading.flow.FlowProcess flowProcess, cascading.operation.FunctionCall<ScriptOperation.Context> functionCall)
operate
in interface cascading.operation.Function<ScriptOperation.Context>
Copyright © 2007-2017 Cascading Maintainers. All Rights Reserved.