|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pig.EvalFunc<Long>
org.apache.pig.builtin.COUNT_STAR
public class COUNT_STAR
Generates the count of the values of the first field of a tuple. This class is different from COUNT in that it counts all NULL values and as such implements SQL COUNT(*) semantics. Generates the count of the number of values in a bag. This count does include null values, and thus matches SQL semantics for COUNT(*) (where in SQL indicates all) but not for COUNT(a) (where a is * field).
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_STAR 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.
Nested Class Summary | |
---|---|
static class |
COUNT_STAR.Final
|
static class |
COUNT_STAR.Initial
|
static class |
COUNT_STAR.Intermediate
|
Field Summary |
---|
Fields inherited from class org.apache.pig.EvalFunc |
---|
log, pigLogger, reporter, returnType |
Constructor Summary | |
---|---|
COUNT_STAR()
|
Method Summary | |
---|---|
void |
accumulate(Tuple b)
Pass tuples to the UDF. |
void |
cleanup()
Called after getValue() to prepare processing for next key. |
Long |
exec(Tuple input)
This callback method must be implemented by all subclasses. |
String |
getFinal()
Get the final function. |
String |
getInitial()
Get the initial function. |
String |
getIntermed()
Get the intermediate function. |
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 Long |
sum(Tuple input)
|
Methods inherited from class org.apache.pig.EvalFunc |
---|
finish, getArgToFuncMapping, getCacheFiles, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, isAsynchronous, progress, setPigLogger, setReporter, warn |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public COUNT_STAR()
Method Detail |
---|
public Long exec(Tuple input) throws IOException
EvalFunc
exec
in class EvalFunc<Long>
input
- the Tuple to be processed.
IOException
public String getInitial()
Algebraic
getInitial
in interface Algebraic
public String getIntermed()
Algebraic
getIntermed
in interface Algebraic
public String getFinal()
Algebraic
getFinal
in interface Algebraic
protected static Long sum(Tuple input) throws ExecException, NumberFormatException
ExecException
NumberFormatException
public Schema outputSchema(Schema input)
EvalFunc
outputSchema
in class EvalFunc<Long>
input
- Schema of the input
public void accumulate(Tuple b) throws IOException
Accumulator
accumulate
in interface Accumulator<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.
IOException
public void cleanup()
Accumulator
cleanup
in interface Accumulator<Long>
public Long getValue()
Accumulator
getValue
in interface Accumulator<Long>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |