public class Enumerate
extends org.apache.pig.AccumulatorEvalFunc<org.apache.pig.data.DataBag>
{(A),(B),(C),(D)} => {(A,0),(B,1),(C,2),(D,3)}
The first constructor parameter (optional) dictates the starting index of the counting. This UDF implements the accumulator interface, reducing DataBag materialization costs.
Example:
define Enumerate datafu.pig.bags.Enumerate('1');
-- input:
-- ({(100),(200),(300),(400)})
input = LOAD 'input' as (B: bag{T: tuple(v2:INT)});
-- output:
-- ({(100,1),(200,2),(300,3),(400,4)})
output = FOREACH input GENERATE Enumerate(B);
Constructor and Description |
---|
Enumerate() |
Enumerate(java.lang.String start) |
Modifier and Type | Method and Description |
---|---|
void |
accumulate(org.apache.pig.data.Tuple arg0) |
void |
cleanup() |
org.apache.pig.data.DataBag |
getValue() |
org.apache.pig.impl.logicalLayer.schema.Schema |
outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input) |
allowCompileTimeCalculation, finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, progress, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
public void accumulate(org.apache.pig.data.Tuple arg0) throws java.io.IOException
accumulate
in interface org.apache.pig.Accumulator<org.apache.pig.data.DataBag>
accumulate
in class org.apache.pig.AccumulatorEvalFunc<org.apache.pig.data.DataBag>
java.io.IOException
public void cleanup()
cleanup
in interface org.apache.pig.Accumulator<org.apache.pig.data.DataBag>
cleanup
in class org.apache.pig.AccumulatorEvalFunc<org.apache.pig.data.DataBag>
public org.apache.pig.data.DataBag getValue()
getValue
in interface org.apache.pig.Accumulator<org.apache.pig.data.DataBag>
getValue
in class org.apache.pig.AccumulatorEvalFunc<org.apache.pig.data.DataBag>
public org.apache.pig.impl.logicalLayer.schema.Schema outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
outputSchema
in class org.apache.pig.EvalFunc<org.apache.pig.data.DataBag>