@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.SchemaType
log, 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(java.util.Iterator<Tuple> iter) |
T |
getValue()
Called when all tuples from current key have been passed to accumulate.
|
boolean |
isFinished() |
exec
allowCompileTimeCalculation, finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLoadCaster, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, needEndOfAllInputProcessing, outputSchema, progress, setEndOfAllInput, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
public boolean isFinished()
isFinished
in interface TerminatingAccumulator<T>
public void accumulate(Tuple input) throws java.io.IOException
Accumulator
accumulate
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.java.io.IOException
public T getValue()
Accumulator
getValue
in interface Accumulator<T>
getValue
in class AccumulatorEvalFunc<T>
public void cleanup()
Accumulator
cleanup
in interface Accumulator<T>
cleanup
in class AccumulatorEvalFunc<T>
Copyright © 2007-2017 The Apache Software Foundation