datafu.pig.bags
Class PrependToBag

java.lang.Object
  extended by org.apache.pig.EvalFunc<T>
      extended by datafu.pig.util.SimpleEvalFunc<org.apache.pig.data.DataBag>
          extended by datafu.pig.bags.PrependToBag

public class PrependToBag
extends SimpleEvalFunc<org.apache.pig.data.DataBag>

Prepends a tuple to a bag.

N.B. this copies the entire input bag, so don't use it for large bags.

Example:

 define PrependToBag datafu.pig.bags.PrependToBag();
 
 -- input:
 -- ({(1),(2),(3)},(4))
 -- ({(10),(20),(30),(40),(50)},(60))
 input = LOAD 'input' AS (B: bag{T: tuple(v:INT)}, T: tuple(v:INT));

 -- output:
 -- ({(4),(1),(2),(3)})
 -- ({(60),(10),(20),(30),(40),(50)})
 output = FOREACH input GENERATE PrependToBag(B,T) as B;
 
 


Field Summary
 
Fields inherited from class org.apache.pig.EvalFunc
log, pigLogger, reporter, returnType
 
Constructor Summary
PrependToBag()
           
 
Method Summary
 org.apache.pig.data.DataBag call(org.apache.pig.data.DataBag inputBag, org.apache.pig.data.Tuple t)
           
 org.apache.pig.impl.logicalLayer.schema.Schema outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
          Override outputSchema so we can verify the input schema at pig compile time, instead of runtime
 
Methods inherited from class datafu.pig.util.SimpleEvalFunc
exec, getReturnType
 
Methods inherited from class org.apache.pig.EvalFunc
finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getSchemaName, isAsynchronous, progress, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrependToBag

public PrependToBag()
Method Detail

call

public org.apache.pig.data.DataBag call(org.apache.pig.data.DataBag inputBag,
                                        org.apache.pig.data.Tuple t)
                                 throws java.io.IOException
Throws:
java.io.IOException

outputSchema

public org.apache.pig.impl.logicalLayer.schema.Schema outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
Description copied from class: SimpleEvalFunc
Override outputSchema so we can verify the input schema at pig compile time, instead of runtime

Overrides:
outputSchema in class SimpleEvalFunc<org.apache.pig.data.DataBag>
Parameters:
input - input schema
Returns:
call to super.outputSchema in case schema was defined elsewhere


Matthew Hayes, Sam Shah