org.apache.pig.builtin
Class AVG

java.lang.Object
  extended by org.apache.pig.EvalFunc<DataAtom>
      extended by org.apache.pig.builtin.AVG
All Implemented Interfaces:
Algebraic

public class AVG
extends EvalFunc<DataAtom>
implements Algebraic

Generates the average of the values of the first field of a tuple. This class is Algebraic in implemenation, so if possible the execution will be split into a local and global application


Nested Class Summary
static class AVG.Final
           
static class AVG.Initial
           
static class AVG.Intermed
           
 
Field Summary
 
Fields inherited from class org.apache.pig.EvalFunc
returnType
 
Constructor Summary
AVG()
           
 
Method Summary
protected static void combine(DataBag values, Tuple output)
           
protected static long count(Tuple input)
           
 void exec(Tuple input, DataAtom output)
          This callback method must be implemented by all subclasses.
 String getFinal()
           
 String getInitial()
           
 String getIntermed()
           
 Schema outputSchema(Schema input)
           
protected static double sum(Tuple input)
           
 
Methods inherited from class org.apache.pig.EvalFunc
finish, getReturnType, isAsynchronous, progress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AVG

public AVG()
Method Detail

exec

public void exec(Tuple input,
                 DataAtom output)
          throws IOException
Description copied from class: EvalFunc
This callback method must be implemented by all subclasses. This is the method that will be invoked on every Tuple of a given dataset. Since the dataset may be divided up in a variety of ways the programmer should not make assumptions about state that is maintained between invocations of this method.

Specified by:
exec in class EvalFunc<DataAtom>
Parameters:
input - the Tuple to be processed.
Throws:
IOException

getInitial

public String getInitial()
Specified by:
getInitial in interface Algebraic
Returns:
A string to instatiate f_init. f_init should be an eval func

getIntermed

public String getIntermed()
Specified by:
getIntermed in interface Algebraic
Returns:
A string to instantiate f_intermed. f_intermed should be an eval func

getFinal

public String getFinal()
Specified by:
getFinal in interface Algebraic
Returns:
A string to instantiate f_final. f_final should be an eval func parametrized by the same datum as the eval func implementing this interface

combine

protected static void combine(DataBag values,
                              Tuple output)
                       throws IOException
Throws:
IOException

count

protected static long count(Tuple input)
                     throws IOException
Throws:
IOException

sum

protected static double sum(Tuple input)
                     throws IOException
Throws:
IOException

outputSchema

public Schema outputSchema(Schema input)
Overrides:
outputSchema in class EvalFunc<DataAtom>
Parameters:
input - Schema of the input
Returns:
Schema of the output


Copyright © ${year} The Apache Software Foundation