public class COUNT extends EvalFunc<java.lang.Long> implements Algebraic, Accumulator<java.lang.Long>
This class
implements Algebraic
, so if possible the execution will
performed in a distributed fashion.
There are no restrictions as to the data types inside the bag to be counted.
COUNT implements the Accumulator
interface as well.
While this will never be
the preferred method of usage it is available in case the combiner can not be
used for a given calculation.
Modifier and Type | Class and Description |
---|---|
static class |
COUNT.Final |
static class |
COUNT.Initial |
static class |
COUNT.Intermediate |
EvalFunc.SchemaType
log, pigLogger, reporter, returnType
Constructor and Description |
---|
COUNT() |
Modifier and Type | Method and Description |
---|---|
void |
accumulate(Tuple b)
Pass tuples to the UDF.
|
void |
cleanup()
Called after getValue() to prepare processing for next key.
|
java.lang.Long |
exec(Tuple input)
This callback method must be implemented by all subclasses.
|
java.util.List<FuncSpec> |
getArgToFuncMapping()
Allow a UDF to specify type specific implementations of itself.
|
java.lang.String |
getFinal()
Get the final function.
|
java.lang.String |
getInitial()
Get the initial function.
|
java.lang.String |
getIntermed()
Get the intermediate function.
|
java.lang.Long |
getValue()
Called when all tuples from current key have been passed to accumulate.
|
Schema |
outputSchema(Schema input)
Report the schema of the output of this UDF.
|
protected static java.lang.Long |
sum(Tuple input) |
allowCompileTimeCalculation, finish, getCacheFiles, getInputSchema, getLoadCaster, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, needEndOfAllInputProcessing, progress, setEndOfAllInput, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
public java.lang.Long exec(Tuple input) throws java.io.IOException
EvalFunc
public java.lang.String getInitial()
Algebraic
getInitial
in interface Algebraic
public java.lang.String getIntermed()
Algebraic
getIntermed
in interface Algebraic
public java.lang.String getFinal()
Algebraic
protected static java.lang.Long sum(Tuple input) throws ExecException, java.lang.NumberFormatException
ExecException
java.lang.NumberFormatException
public Schema outputSchema(Schema input)
EvalFunc
The default implementation interprets the OutputSchema
annotation,
if one is present. Otherwise, it returns null
(no known output schema).
outputSchema
in class EvalFunc<java.lang.Long>
input
- Schema of the inputpublic java.util.List<FuncSpec> getArgToFuncMapping() throws FrontendException
EvalFunc
getArgToFuncMapping
in class EvalFunc<java.lang.Long>
FrontendException
public void accumulate(Tuple b) throws java.io.IOException
Accumulator
accumulate
in interface Accumulator<java.lang.Long>
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.java.io.IOException
public void cleanup()
Accumulator
cleanup
in interface Accumulator<java.lang.Long>
public java.lang.Long getValue()
Accumulator
getValue
in interface Accumulator<java.lang.Long>
Copyright © 2007-2017 The Apache Software Foundation