org.apache.pig
Class AccumulatorEvalFunc<T>
java.lang.Object
org.apache.pig.EvalFunc<T>
org.apache.pig.AccumulatorEvalFunc<T>
- All Implemented Interfaces:
- Accumulator<T>
- Direct Known Subclasses:
- AlgebraicEvalFunc, GroovyAccumulatorEvalFunc, IteratingAccumulatorEvalFunc, JrubyAccumulatorEvalFunc
public abstract class AccumulatorEvalFunc<T>
- extends EvalFunc<T>
- implements Accumulator<T>
This class is used to provide a free implementation of the EvalFunc exec function given
implementation of the Accumulator interface. Instead of having to provide a redundant
implementation, this provides the base exec function for free, given that the methods
associated with the Accumulator interface are implemented. For information on how to
implement Accumulator, see Accumulator
.
Method Summary |
abstract void |
accumulate(Tuple b)
Pass tuples to the UDF. |
abstract void |
cleanup()
Called after getValue() to prepare processing for next key. |
T |
exec(Tuple input)
This callback method must be implemented by all subclasses. |
abstract T |
getValue()
Called when all tuples from current key have been passed to accumulate. |
Methods inherited from class org.apache.pig.EvalFunc |
finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, isAsynchronous, outputSchema, progress, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AccumulatorEvalFunc
public AccumulatorEvalFunc()
accumulate
public abstract void accumulate(Tuple b)
throws IOException
- Description copied from interface:
Accumulator
- Pass tuples to the UDF.
- Specified by:
accumulate
in interface Accumulator<T>
- 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 abstract void cleanup()
- Description copied from interface:
Accumulator
- Called after getValue() to prepare processing for next key.
- Specified by:
cleanup
in interface Accumulator<T>
getValue
public abstract T getValue()
- Description copied from interface:
Accumulator
- Called when all tuples from current key have been passed to accumulate.
- Specified by:
getValue
in interface Accumulator<T>
- Returns:
- the value for the UDF for this key.
exec
public T exec(Tuple input)
throws IOException
- Description copied from class:
EvalFunc
- This callback method must be implemented by all subclasses. This
is the method that will be invoked on every Tuple of a given dataset.
Since the dataset may be divided up in a variety of ways the programmer
should not make assumptions about state that is maintained between
invocations of this method.
- Specified by:
exec
in class EvalFunc<T>
- Parameters:
input
- the Tuple to be processed.
- Returns:
- result, of type T.
- Throws:
IOException
Copyright © 2007-2012 The Apache Software Foundation