org.apache.pig.piggybank.evaluation
Class MaxTupleBy1stField
java.lang.Object
org.apache.pig.EvalFunc<Tuple>
org.apache.pig.piggybank.evaluation.MaxTupleBy1stField
- All Implemented Interfaces:
- Algebraic
public class MaxTupleBy1stField
- extends EvalFunc<Tuple>
- implements Algebraic
MaxTupleBy1stField UDF returns a tuple with max value of the first field in a
given bag.
Caveat: first field assumed to have type 'long'. You may need to enforece this
via schema when loading data, as sown in sample usage below.
Sample usage:
A = load 'test.tsv' as (first: long, second, third);
B = GROUP A by second;
C = FOREACH B GENERATE group, MaxTupleBy1stField(A);
- Author:
- Vadim Zaliva
Methods inherited from class org.apache.pig.EvalFunc |
finish, getArgToFuncMapping, 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 |
MaxTupleBy1stField
public MaxTupleBy1stField()
outputSchema
public Schema outputSchema(Schema input)
- Overrides:
outputSchema
in class EvalFunc<Tuple>
- Parameters:
input
- Schema of the input
- Returns:
- Schema of the output
exec
public Tuple exec(Tuple input)
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<Tuple>
- Parameters:
input
- the Tuple to be processed.
- Returns:
- result, of type T.
- Throws:
IOException
max
protected static Tuple max(Tuple input,
PigProgressable reporter)
throws ExecException
- Throws:
ExecException
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
Copyright © ${year} The Apache Software Foundation