org.apache.pig.builtin
Class FunctionWrapperEvalFunc
java.lang.Object
org.apache.pig.EvalFunc<OUT>
org.apache.pig.TypedOutputEvalFunc<OUT>
org.apache.pig.PrimitiveEvalFunc<Object,Object>
org.apache.pig.builtin.FunctionWrapperEvalFunc
public class FunctionWrapperEvalFunc
- extends PrimitiveEvalFunc<Object,Object>
EvalFunc that wraps an implementation of the Function interface, which is passed as a String
in the constructor. When resolving the Function class, the Pig UDF package import list is used.
The Function must have a default no-arg constructor, which will be used. For Functions that
take args in the constructor, initialize the function in a subclass of this one and call
super(function)
.
Example: DEFINE myUdf FunctionWrapperEvalFunc('MyFunction')
Constructor Summary |
protected |
FunctionWrapperEvalFunc(ExceptionalFunction function)
Determines the input and output types of the Function and initializes the superclass. |
protected |
FunctionWrapperEvalFunc(com.google.common.base.Function function)
Determines the input and output types of the Function and initializes the superclass. |
|
FunctionWrapperEvalFunc(String functionClassName)
Takes the class name of a Function, initializes it using the default constructor and passes
it to FunctionWrapperEvalFunc(ExceptionalFunction function). |
Methods inherited from class org.apache.pig.EvalFunc |
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 |
FunctionWrapperEvalFunc
public FunctionWrapperEvalFunc(String functionClassName)
throws ClassNotFoundException,
NoSuchMethodException,
IllegalAccessException,
InstantiationException,
IOException
- Takes the class name of a Function, initializes it using the default constructor and passes
it to FunctionWrapperEvalFunc(ExceptionalFunction function). Functions must implement either
com.google.common.base.Function or ExceptionalFunction.
- Parameters:
functionClassName
- function class to initialize
- Throws:
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
InstantiationException
IOException
FunctionWrapperEvalFunc
protected FunctionWrapperEvalFunc(com.google.common.base.Function function)
throws IOException,
ClassNotFoundException,
NoSuchMethodException
- Determines the input and output types of the Function and initializes the superclass.
Subclass and call this constructor if a Function with a non-default constructor is required.
- Parameters:
function
- Function to be used by the UDF.
- Throws:
IOException
ClassNotFoundException
NoSuchMethodException
FunctionWrapperEvalFunc
protected FunctionWrapperEvalFunc(ExceptionalFunction function)
throws IOException,
ClassNotFoundException,
NoSuchMethodException
- Determines the input and output types of the Function and initializes the superclass.
Subclass and call this constructor if a Function with a non-default constructor is required.
- Parameters:
function
- Function to be used by the UDF.
- Throws:
IOException
ClassNotFoundException
NoSuchMethodException
exec
public Object exec(Object input)
throws IOException
- Specified by:
exec
in class PrimitiveEvalFunc<Object,Object>
- Throws:
IOException
getCounterGroup
protected String getCounterGroup()
- Description copied from class:
TypedOutputEvalFunc
- 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.
- Overrides:
getCounterGroup
in class TypedOutputEvalFunc<Object>
Copyright © 2007-2012 The Apache Software Foundation