datafu.pig.util
Class TransposeTupleToBag

java.lang.Object
  extended by org.apache.pig.EvalFunc<T>
      extended by datafu.pig.util.ContextualEvalFunc<T>
          extended by datafu.pig.util.AliasableEvalFunc<org.apache.pig.data.DataBag>
              extended by datafu.pig.util.TransposeTupleToBag

public class TransposeTupleToBag
extends AliasableEvalFunc<org.apache.pig.data.DataBag>

Performs a transpose on a tuple, resulting in a bag of key, value fields where the key is the column name and the value is the value of that column in the tuple.

Example:

 define TransposeTupleToBag datafu.pig.util.TransposeTupleToBag();

 -- input: 1,10,11,12
 input = LOAD 'input' AS (id:int,val1:int,val2:int,val3:int);

 -- produces: 1,{("val1",10),("val2",11),("val3",12)}
 output = FOREACH input GENERATE id, TransposeTupleToBag(val1 .. val3);

 
 

Author:
"William Vaughan "

Field Summary
 
Fields inherited from class org.apache.pig.EvalFunc
log, pigLogger, reporter, returnType
 
Constructor Summary
TransposeTupleToBag()
           
 
Method Summary
 org.apache.pig.data.DataBag exec(org.apache.pig.data.Tuple input)
           
 org.apache.pig.impl.logicalLayer.schema.Schema getOutputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
          Specify the output schema as in {link EvalFunc#outputSchema(Schema)}.
 
Methods inherited from class datafu.pig.util.AliasableEvalFunc
getBag, getBoolean, getDouble, getDouble, getFieldAliases, getFloat, getFloat, getInteger, getInteger, getLong, getLong, getObject, getPosition, getPosition, getPrefixedAliasName, getString, getString, outputSchema
 
Methods inherited from class datafu.pig.util.ContextualEvalFunc
getContextProperties, getInstanceName, getInstanceProperties, setUDFContextSignature
 
Methods inherited from class org.apache.pig.EvalFunc
finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, isAsynchronous, progress, setInputSchema, setPigLogger, setReporter, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransposeTupleToBag

public TransposeTupleToBag()
Method Detail

getOutputSchema

public org.apache.pig.impl.logicalLayer.schema.Schema getOutputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
Description copied from class: AliasableEvalFunc
Specify the output schema as in {link EvalFunc#outputSchema(Schema)}.

Specified by:
getOutputSchema in class AliasableEvalFunc<org.apache.pig.data.DataBag>
Returns:
outputSchema

exec

public org.apache.pig.data.DataBag exec(org.apache.pig.data.Tuple input)
                                 throws java.io.IOException
Specified by:
exec in class org.apache.pig.EvalFunc<org.apache.pig.data.DataBag>
Throws:
java.io.IOException


Matthew Hayes, Sam Shah