org.apache.pig
Class TypedOutputEvalFunc<OUT>
java.lang.Object
org.apache.pig.EvalFunc<OUT>
org.apache.pig.TypedOutputEvalFunc<OUT>
- Direct Known Subclasses:
- PrimitiveEvalFunc
public abstract class TypedOutputEvalFunc<OUT>
- extends EvalFunc<OUT>
Base class for Pig UDFs that are functions from Tuples to generic type OUT. Handles marshalling
objects, basic error checking, etc. Also infers outputSchema and provides a function to verify
the input Tuple.
Extend this class and implement the OUT exec(Tuple input)
method when writting a UDF
that operates on multiple inputs from the Tuple.
Methods inherited from class org.apache.pig.EvalFunc |
exec, finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, 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 |
outTypeClass
protected Class<OUT> outTypeClass
TypedOutputEvalFunc
public TypedOutputEvalFunc()
getOutputTypeClass
public Class<OUT> getOutputTypeClass()
verifyInput
protected void verifyInput(Tuple input,
int minimumSize)
throws IOException
- Throws:
IOException
getCounterGroup
protected String getCounterGroup()
- Incremented counters will use this as the counter group. Typically this works fine, since
the subclass name is enough to identify the UDF. In some cases though (i.e. a UDF wrapper that
is a facade to a number of different transformation functions), a more specific group name is
needed.
getTypeArguments
protected static <T> List<Class<?>> getTypeArguments(Class<T> baseClass,
Class<? extends T> childClass)
- Get the actual type arguments a child class has used to extend a generic base class.
- Parameters:
baseClass
- the base classchildClass
- the child class
- Returns:
- a list of the raw classes for the actual type arguments.
verifyUdfInput
protected static void verifyUdfInput(String klass,
Tuple input,
int minimumSize)
throws IOException
- Increment Hadoop counters for bad inputs which are either null or too small.
- Parameters:
klass
- the name of the calling class, for recording purposesinput
- the tuple passed to the UDF.minimumSize
- the minimum size required of the tuple.
- Throws:
IOException
safeIncrCounter
protected static void safeIncrCounter(String group,
String name,
Long increment)
Copyright © 2007-2012 The Apache Software Foundation