@InterfaceAudience.Public @InterfaceStability.Unstable public abstract class IteratingAccumulatorEvalFunc<T> extends AccumulatorEvalFunc<T> implements TerminatingAccumulator<T>
public class IsEmpty extends IteratingAccumulatorEvalFunc {
     public Boolean exec(Iterator iter) throws IOException {
         return !iter.hashNext();
     }
 }  
 Count could be implemented as follows:
 public class Count extends IteratingAccumulatorEvalFunc {
     public Long exec(Iterator iter) throws IOException {
         long ct = 0;
         for (; iter.hasNext(); iter.next()) {
             ct++;
         }
         return ct;
     }
 }  EvalFunc.SchemaTypelog, pigLogger, reporter, returnType| Constructor and Description | 
|---|
IteratingAccumulatorEvalFunc()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
accumulate(Tuple input)
Pass tuples to the UDF. 
 | 
void | 
cleanup()
Called after getValue() to prepare processing for next key. 
 | 
abstract T | 
exec(Iterator<Tuple> iter)  | 
T | 
getValue()
Called when all tuples from current key have been passed to accumulate. 
 | 
boolean | 
isFinished()  | 
execallowCompileTimeCalculation, finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, needEndOfAllInputProcessing, outputSchema, progress, setEndOfAllInput, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warnpublic boolean isFinished()
isFinished in interface TerminatingAccumulator<T>public void accumulate(Tuple input) throws IOException
Accumulatoraccumulate in interface Accumulator<T>accumulate in class AccumulatorEvalFunc<T>input - 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.IOExceptionpublic T getValue()
AccumulatorgetValue in interface Accumulator<T>getValue in class AccumulatorEvalFunc<T>public void cleanup()
Accumulatorcleanup in interface Accumulator<T>cleanup in class AccumulatorEvalFunc<T>public abstract T exec(Iterator<Tuple> iter) throws IOException
IOExceptionCopyright © 2007-2012 The Apache Software Foundation