public class ScriptFilter extends ScriptOperation implements cascading.operation.Filter<ScriptOperation.Context>
Tuple values.
This Filter is based on the Janino compiler.
Specifically this filter uses the ScriptEvaluator,
thus the syntax from that class is inherited here.
A script 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 script returns true:
boolean result = (a + b == $0 + $1);
return boolean;
Unlike an "expression" used by ExpressionFilter, a "script" requires each line to end in an semi-colon
(@{code ;}) and the final line to be a return statement.
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 script if possible.
ScriptOperation.Context, ScriptOperation.Evaluatorblock, parameterNames, parameterTypes, returnType| Constructor and Description |
|---|
ScriptFilter(java.lang.String script)
Constructor ScriptFilter creates a new ScriptFilter instance.
|
ScriptFilter(java.lang.String script,
java.lang.Class[] expectedTypes)
Constructor ScriptFilter creates a new ScriptFilter instance.
|
ScriptFilter(java.lang.String script,
java.lang.String[] parameterNames,
java.lang.Class[] parameterTypes)
Constructor ScriptFilter creates a new ScriptFilter instance.
|
ScriptFilter(java.lang.String script,
java.lang.String parameterName,
java.lang.Class parameterType)
Constructor ScriptFilter creates a new ScriptFilter instance.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getScript() |
boolean |
isRemove(cascading.flow.FlowProcess flowProcess,
cascading.operation.FilterCall<ScriptOperation.Context> filterCall) |
equals, evaluate, getBlock, getEvaluator, getExtendedClass, getParameterNames, getParameterTypes, getReturnType, guessParameterNames, hashCode, preparecleanup, flush, getFieldDeclaration, getNumArgs, getTrace, isSafe, printOperationInternal, toString, toStringInternal@ConstructorProperties(value="script") public ScriptFilter(java.lang.String script)
script - of type String@ConstructorProperties(value={"script","parameterName","parameterType"})
public ScriptFilter(java.lang.String script,
java.lang.String parameterName,
java.lang.Class parameterType)
script - of type StringparameterName - of type StringparameterType - of type Class@ConstructorProperties(value={"script","expectedTypes"})
public ScriptFilter(java.lang.String script,
java.lang.Class[] expectedTypes)
This constructor will use the runtime OperationCall.getArgumentFields()
to source the parameterNames and parameterTypes required by the other constructors, but
use expectedTypes to coerce the incoming types to before passing as parameters to the expression.
script - of type StringexpectedTypes - of type Class[]@ConstructorProperties(value={"script","parameterNames","parameterTypes"})
public ScriptFilter(java.lang.String script,
java.lang.String[] parameterNames,
java.lang.Class[] parameterTypes)
script - of type StringparameterNames - of type String[]parameterTypes - of type Class[]public java.lang.String getScript()
public boolean isRemove(cascading.flow.FlowProcess flowProcess, cascading.operation.FilterCall<ScriptOperation.Context> filterCall)
isRemove in interface cascading.operation.Filter<ScriptOperation.Context>Copyright © 2007-2021 Cascading Maintainers. All Rights Reserved.