org.apache.pig
Class PrimitiveEvalFunc<IN,OUT>

java.lang.Object
  extended by org.apache.pig.EvalFunc<OUT>
      extended by org.apache.pig.TypedOutputEvalFunc<OUT>
          extended by org.apache.pig.PrimitiveEvalFunc<IN,OUT>
Direct Known Subclasses:
FunctionWrapperEvalFunc

public abstract class PrimitiveEvalFunc<IN,OUT>
extends TypedOutputEvalFunc<OUT>

Base class for simple Pig UDFs that are functions of primitive types IN to OUT. Handles marshalling objects, basic error checking, etc. Extend this class and implement the

OUT exec(IN input)
method when writting a UDF that operates on only the first input (of expected type IN) from the Tuple.


Field Summary
protected  Class<IN> inTypeClass
           
 
Fields inherited from class org.apache.pig.TypedOutputEvalFunc
outTypeClass
 
Fields inherited from class org.apache.pig.EvalFunc
log, pigLogger, reporter, returnType
 
Constructor Summary
PrimitiveEvalFunc()
           
PrimitiveEvalFunc(Class inTypeClass, Class outTypeClass)
           
 
Method Summary
abstract  OUT exec(IN input)
           
 OUT exec(Tuple tuple)
          This callback method must be implemented by all subclasses.
 Class<IN> getInputTypeClass()
           
 
Methods inherited from class org.apache.pig.TypedOutputEvalFunc
getCounterGroup, getOutputTypeClass, getTypeArguments, safeIncrCounter, verifyInput, verifyUdfInput
 
Methods inherited from class org.apache.pig.EvalFunc
finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, isAsynchronous, outputSchema, progress, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inTypeClass

protected Class<IN> inTypeClass
Constructor Detail

PrimitiveEvalFunc

public PrimitiveEvalFunc()

PrimitiveEvalFunc

public PrimitiveEvalFunc(Class inTypeClass,
                         Class outTypeClass)
Method Detail

getInputTypeClass

public Class<IN> getInputTypeClass()

exec

public OUT exec(Tuple tuple)
         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<OUT>
Parameters:
tuple - the Tuple to be processed.
Returns:
result, of type T.
Throws:
IOException

exec

public abstract OUT exec(IN input)
                  throws IOException
Throws:
IOException


Copyright © 2007-2012 The Apache Software Foundation