public String getScript() { return getBlock(); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor expects all parameter type names to be declared with their types. Positional parameters must * be named the same as in the given script with the "$" sign prepended. * * @param fieldDeclaration of type Fields * @param script of type String * @param returnType of type Class * @param parameterNames of type String[] * @param parameterTypes of type Class[] */ @ConstructorProperties({"fieldDeclaration", "script", "returnType", "parameterNames", "parameterTypes"}) public ScriptFunction( Fields fieldDeclaration, String script, Class returnType, String[] parameterNames, Class[] parameterTypes ) { super( parameterTypes.length, fieldDeclaration, script, returnType, parameterNames, parameterTypes ); verify( fieldDeclaration ); }
private Object evaluate( String expression, Class returnType, String[] names, Class[] types, TupleEntry tupleEntry ) { ScriptFunction function = new ScriptFunction( new Fields( "result" ), expression, returnType, names, types ); ConcreteCall<ExpressionOperation.Context> call = new ConcreteCall<ExpressionOperation.Context>( tupleEntry.getFields(), function.getFieldDeclaration() ); function.prepare( FlowProcess.NULL, call ); return function.evaluate( call.getContext(), tupleEntry ); }
@Override public void operate( FlowProcess flowProcess, FunctionCall<Context> functionCall ) { functionCall.getContext().result.set( 0, evaluate( functionCall.getContext(), functionCall.getArguments() ) ); functionCall.getOutputCollector().add( functionCall.getContext().result ); } }
private Object evaluate( String expression, Class returnType, String[] names, Class[] types, TupleEntry tupleEntry ) { ScriptFunction function = new ScriptFunction( new Fields( "result" ), expression, returnType, names, types ); ConcreteCall<ExpressionOperation.Context> call = new ConcreteCall<ExpressionOperation.Context>( tupleEntry.getFields(), function.getFieldDeclaration() ); function.prepare( FlowProcess.NULL, call ); return function.evaluate( call.getContext(), tupleEntry ); }
@Override public void operate( FlowProcess flowProcess, FunctionCall<Context> functionCall ) { functionCall.getContext().result.set( 0, evaluate( functionCall.getContext(), functionCall.getArguments() ) ); functionCall.getOutputCollector().add( functionCall.getContext().result ); } }
private Object evaluate( String expression, Class returnType, TupleEntry tupleEntry ) { ScriptFunction function = new ScriptFunction( new Fields( "result" ), expression, returnType ); ConcreteCall<ExpressionOperation.Context> call = new ConcreteCall<ExpressionOperation.Context>( tupleEntry.getFields(), function.getFieldDeclaration() ); function.prepare( FlowProcess.NULL, call ); return function.evaluate( call.getContext(), tupleEntry ); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor will use the runtime {@link cascading.operation.OperationCall#getArgumentFields()} * to source the {@code parameterNames} and {@code parameterTypes} required by the other constructors. * * @param fieldDeclaration of type Fields * @param script of type String * @param returnType of type Class */ @ConstructorProperties({"fieldDeclaration", "script", "returnType"}) public ScriptFunction( Fields fieldDeclaration, String script, Class returnType ) { super( ANY, fieldDeclaration, script, returnType ); verify( fieldDeclaration ); }
public String getScript() { return getBlock(); }
private Object evaluate( String expression, Class returnType, TupleEntry tupleEntry ) { ScriptFunction function = new ScriptFunction( new Fields( "result" ), expression, returnType ); ConcreteCall<ExpressionOperation.Context> call = new ConcreteCall<ExpressionOperation.Context>( tupleEntry.getFields(), function.getFieldDeclaration() ); function.prepare( FlowProcess.NULL, call ); return function.evaluate( call.getContext(), tupleEntry ); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor will use the runtime {@link cascading.operation.OperationCall#getArgumentFields()} * to source the {@code parameterNames} and {@code parameterTypes} required by the other constructors. * * @param fieldDeclaration of type Fields * @param script of type String * @param returnType of type Class */ @ConstructorProperties({"fieldDeclaration", "script", "returnType"}) public ScriptFunction( Fields fieldDeclaration, String script, Class returnType ) { super( ANY, fieldDeclaration, script, returnType ); verify( fieldDeclaration ); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor expects all parameter type names to be declared with their types. Positional parameters must * be named the same as in the given script with the "$" sign prepended. * * @param fieldDeclaration of type Fields * @param script of type String * @param returnType of type Class * @param parameterNames of type String[] * @param parameterTypes of type Class[] */ @ConstructorProperties({"fieldDeclaration", "script", "returnType", "parameterNames", "parameterTypes"}) public ScriptFunction( Fields fieldDeclaration, String script, Class returnType, String[] parameterNames, Class[] parameterTypes ) { super( parameterTypes.length, fieldDeclaration, script, returnType, parameterNames, parameterTypes ); verify( fieldDeclaration ); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor will use the runtime {@link cascading.operation.OperationCall#getArgumentFields()} * to source the {@code parameterNames} and {@code parameterTypes} required by the other constructors. * <p> * The {@code returnType} will be retrieved from the given {@code fieldDeclaration.getTypeClass(0)}. * * @param fieldDeclaration of type Fields * @param script of type String */ @ConstructorProperties({"fieldDeclaration", "script"}) public ScriptFunction( Fields fieldDeclaration, String script ) { super( ANY, fieldDeclaration, script ); verify( fieldDeclaration ); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor will use the runtime {@link cascading.operation.OperationCall#getArgumentFields()} * to source the {@code parameterNames} and {@code parameterTypes} required by the other constructors, but * use {@code expectedTypes} to coerce the incoming types to before passing as parameters to the expression. * * @param fieldDeclaration of type Fields * @param script of type String * @param returnType of type Class * @param expectedTypes of type Class[] */ @ConstructorProperties({"fieldDeclaration", "script", "returnType", "expectedTypes"}) public ScriptFunction( Fields fieldDeclaration, String script, Class returnType, Class[] expectedTypes ) { super( expectedTypes.length, fieldDeclaration, script, returnType, expectedTypes ); verify( fieldDeclaration ); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor will use the runtime {@link cascading.operation.OperationCall#getArgumentFields()} * to source the {@code parameterNames} and {@code parameterTypes} required by the other constructors. * <p> * The {@code returnType} will be retrieved from the given {@code fieldDeclaration.getTypeClass(0)}. * * @param fieldDeclaration of type Fields * @param script of type String */ @ConstructorProperties({"fieldDeclaration", "script"}) public ScriptFunction( Fields fieldDeclaration, String script ) { super( ANY, fieldDeclaration, script ); verify( fieldDeclaration ); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor will use the runtime {@link cascading.operation.OperationCall#getArgumentFields()} * to source the {@code parameterNames} and {@code parameterTypes} required by the other constructors, but * use {@code expectedTypes} to coerce the incoming types to before passing as parameters to the expression. * * @param fieldDeclaration of type Fields * @param script of type String * @param returnType of type Class * @param expectedTypes of type Class[] */ @ConstructorProperties({"fieldDeclaration", "script", "returnType", "expectedTypes"}) public ScriptFunction( Fields fieldDeclaration, String script, Class returnType, Class[] expectedTypes ) { super( expectedTypes.length, fieldDeclaration, script, returnType, expectedTypes ); verify( fieldDeclaration ); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor expects all parameter type names to be declared with their types. Positional parameters must * be named the same as in the given script with the "$" sign prepended. * * @param fieldDeclaration of type Fields * @param script of type String * @param parameterNames of type String[] * @param parameterTypes of type Class[] */ @ConstructorProperties({"fieldDeclaration", "script", "parameterNames", "parameterTypes"}) public ScriptFunction( Fields fieldDeclaration, String script, String[] parameterNames, Class[] parameterTypes ) { super( parameterTypes.length, fieldDeclaration, script, asClass( fieldDeclaration.getType( 0 ) ), parameterNames, parameterTypes ); verify( fieldDeclaration ); }
/** * Constructor ScriptFunction creates a new ScriptFunction instance. * <p> * This constructor expects all parameter type names to be declared with their types. Positional parameters must * be named the same as in the given script with the "$" sign prepended. * * @param fieldDeclaration of type Fields * @param script of type String * @param parameterNames of type String[] * @param parameterTypes of type Class[] */ @ConstructorProperties({"fieldDeclaration", "script", "parameterNames", "parameterTypes"}) public ScriptFunction( Fields fieldDeclaration, String script, String[] parameterNames, Class[] parameterTypes ) { super( parameterTypes.length, fieldDeclaration, script, asClass( fieldDeclaration.getType( 0 ) ), parameterNames, parameterTypes ); verify( fieldDeclaration ); }