org.apache.pig.scripting.jruby
Class JrubyAccumulatorEvalFunc
java.lang.Object
org.apache.pig.EvalFunc<T>
org.apache.pig.AccumulatorEvalFunc<Object>
org.apache.pig.scripting.jruby.JrubyAccumulatorEvalFunc
- All Implemented Interfaces:
- Accumulator<Object>
public class JrubyAccumulatorEvalFunc
- extends AccumulatorEvalFunc<Object>
This class provides a bridge between Ruby classes that extend AccumulatorPigUdf
and their execution in Pig. This class passes a Bag of data to the Ruby "exec"
function, and ultimate gets the value by calling "get" on the class instance
that receives methods.
Method Summary |
void |
accumulate(Tuple b)
This uses the "exec" method required of AccumulatorPigUdf Ruby classes. |
void |
cleanup()
Called after getValue() to prepare processing for next key. |
Object |
getValue()
This method calls "get" on the AccumulatorPigUdf Ruby class that was specified. |
Schema |
outputSchema(Schema input)
This provides the Schema of the output, and leverages the get_output_schema function on the class object
that is defined on the ruby side. |
Methods inherited from class org.apache.pig.EvalFunc |
finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, isAsynchronous, progress, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JrubyAccumulatorEvalFunc
public JrubyAccumulatorEvalFunc(String path,
String methodName)
- This constructor is used by JrubyScriptEngine to register a Ruby class as an Accumulator.
The path and methodName are used to find the ruby Class, which is then instantated and used.
accumulate
public void accumulate(Tuple b)
throws IOException
- This uses the "exec" method required of AccumulatorPigUdf Ruby classes. It streams the data bags
it receives through the exec method defined on the registered class.
- Specified by:
accumulate
in interface Accumulator<Object>
- Specified by:
accumulate
in class AccumulatorEvalFunc<Object>
- Parameters:
b
- A tuple containing a single field, which is a bag. The bag will contain the set
of tuples being passed to the UDF in this iteration.
- Throws:
IOException
cleanup
public void cleanup()
- Description copied from interface:
Accumulator
- Called after getValue() to prepare processing for next key.
- Specified by:
cleanup
in interface Accumulator<Object>
- Specified by:
cleanup
in class AccumulatorEvalFunc<Object>
getValue
public Object getValue()
- This method calls "get" on the AccumulatorPigUdf Ruby class that was specified.
- Specified by:
getValue
in interface Accumulator<Object>
- Specified by:
getValue
in class AccumulatorEvalFunc<Object>
- Returns:
- the value for the UDF for this key.
outputSchema
public Schema outputSchema(Schema input)
- This provides the Schema of the output, and leverages the get_output_schema function on the class object
that is defined on the ruby side.
- Overrides:
outputSchema
in class EvalFunc<Object>
- Parameters:
input
- Schema of the input
- Returns:
- Schema of the output
Copyright © 2007-2012 The Apache Software Foundation