public class BigDecimalAvg extends EvalFunc<BigDecimal> implements Algebraic, Accumulator<BigDecimal>
AVG
.Modifier and Type | Class and Description |
---|---|
static class |
BigDecimalAvg.Final |
static class |
BigDecimalAvg.Initial |
static class |
BigDecimalAvg.Intermediate |
EvalFunc.SchemaType
log, pigLogger, reporter, returnType
Constructor and Description |
---|
BigDecimalAvg() |
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.
|
protected static Tuple |
combine(DataBag values) |
protected static BigDecimal |
count(Tuple input) |
protected static BigDecimal |
div(BigDecimal dividend,
BigDecimal divisor) |
BigDecimal |
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.
|
BigDecimal |
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 BigDecimal |
sum(Tuple input) |
allowCompileTimeCalculation, finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLoadCaster, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, needEndOfAllInputProcessing, progress, setEndOfAllInput, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
public BigDecimal exec(Tuple input) throws IOException
EvalFunc
exec
in class EvalFunc<BigDecimal>
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
protected static Tuple combine(DataBag values) throws ExecException
ExecException
protected static BigDecimal count(Tuple input) throws ExecException
ExecException
protected static BigDecimal sum(Tuple input) throws ExecException, IOException
ExecException
IOException
protected static BigDecimal div(BigDecimal dividend, BigDecimal divisor)
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<BigDecimal>
input
- Schema of the inputpublic void accumulate(Tuple b) throws IOException
Accumulator
accumulate
in interface Accumulator<BigDecimal>
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<BigDecimal>
public BigDecimal getValue()
Accumulator
getValue
in interface Accumulator<BigDecimal>
Copyright © 2007-2017 The Apache Software Foundation