public class VAR
extends org.apache.pig.EvalFunc<java.lang.Double>
implements org.apache.pig.Algebraic, org.apache.pig.Accumulator<java.lang.Double>
Algebraic
, so if possible the execution will performed in a distributed fashion.
VAR implements the Accumulator
interface as well.
Input: Bag of int, long, double, float or bytearray
Output: Double
Example:
define VAR datafu.pig.stats.VAR(); -- input: 1,2,3,4,10,5,6,7,8,9 input = LOAD 'input' AS (val:int); grouped = GROUP input ALL; variance = FOREACH grouped GENERATE VAR(input.val) AS variance;
Modifier and Type | Class and Description |
---|---|
static class |
VAR.Final |
static class |
VAR.Initial |
static class |
VAR.Intermediate |
Constructor and Description |
---|
VAR() |
Modifier and Type | Method and Description |
---|---|
void |
accumulate(org.apache.pig.data.Tuple b) |
void |
cleanup() |
protected static org.apache.pig.data.Tuple |
combine(org.apache.pig.data.DataBag values) |
protected static long |
count(org.apache.pig.data.Tuple input) |
java.lang.Double |
exec(org.apache.pig.data.Tuple input) |
java.util.List<org.apache.pig.FuncSpec> |
getArgToFuncMapping() |
java.lang.String |
getFinal() |
java.lang.String |
getInitial() |
java.lang.String |
getIntermed() |
java.lang.Double |
getValue() |
org.apache.pig.impl.logicalLayer.schema.Schema |
outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input) |
protected static java.lang.Double |
sum(org.apache.pig.data.Tuple input) |
protected static java.lang.Double |
sumSquare(org.apache.pig.data.Tuple input) |
allowCompileTimeCalculation, finish, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, progress, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
public java.lang.Double exec(org.apache.pig.data.Tuple input) throws java.io.IOException
exec
in class org.apache.pig.EvalFunc<java.lang.Double>
java.io.IOException
public java.lang.String getInitial()
getInitial
in interface org.apache.pig.Algebraic
public java.lang.String getIntermed()
getIntermed
in interface org.apache.pig.Algebraic
public java.lang.String getFinal()
getFinal
in interface org.apache.pig.Algebraic
protected static org.apache.pig.data.Tuple combine(org.apache.pig.data.DataBag values) throws org.apache.pig.backend.executionengine.ExecException
org.apache.pig.backend.executionengine.ExecException
protected static long count(org.apache.pig.data.Tuple input) throws org.apache.pig.backend.executionengine.ExecException
org.apache.pig.backend.executionengine.ExecException
protected static java.lang.Double sum(org.apache.pig.data.Tuple input) throws org.apache.pig.backend.executionengine.ExecException, java.io.IOException
org.apache.pig.backend.executionengine.ExecException
java.io.IOException
protected static java.lang.Double sumSquare(org.apache.pig.data.Tuple input) throws org.apache.pig.backend.executionengine.ExecException, java.io.IOException
org.apache.pig.backend.executionengine.ExecException
java.io.IOException
public org.apache.pig.impl.logicalLayer.schema.Schema outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
outputSchema
in class org.apache.pig.EvalFunc<java.lang.Double>
public java.util.List<org.apache.pig.FuncSpec> getArgToFuncMapping() throws org.apache.pig.impl.logicalLayer.FrontendException
getArgToFuncMapping
in class org.apache.pig.EvalFunc<java.lang.Double>
org.apache.pig.impl.logicalLayer.FrontendException
public void accumulate(org.apache.pig.data.Tuple b) throws java.io.IOException
accumulate
in interface org.apache.pig.Accumulator<java.lang.Double>
java.io.IOException
public void cleanup()
cleanup
in interface org.apache.pig.Accumulator<java.lang.Double>
public java.lang.Double getValue()
getValue
in interface org.apache.pig.Accumulator<java.lang.Double>