T
- public abstract class GenericInvoker<T> extends EvalFunc<T>
The Invoker family of udfs understand the following class names (all case-independent):
Invokers can also work with array arguments, represented in Pig as DataBags of single-tuple
elements. Simply refer to string[]
, for example.
This UDF allows one to dynamically invoke Java methods that return a T
Usage of the Invoker family of UDFs (adjust as appropriate):
-- invoking a static method
DEFINE StringToLong InvokeForLong('java.lang.Long.valueOf', 'String')
longs = FOREACH strings GENERATE StringToLong(some_chararray);
-- invoking a method on an object
DEFINE StringConcat InvokeForString('java.lang.String.concat', 'String String', 'false')
concatenations = FOREACH strings GENERATE StringConcat(str1, str2);
The first argument to the constructor is the full path to desired method.
The second argument is a list of classes of the method parameters.
If the method is not static, the first element in this list is the object to invoke the method on.
The second argument is optional (a no-argument static method is assumed if it is not supplied).
The third argument is the keyword "static" (or "true") to signify that the method is static.
The third argument is optional, and true by default.
EvalFunc.SchemaType
log, pigLogger, reporter, returnType
Constructor and Description |
---|
GenericInvoker() |
GenericInvoker(String fullName) |
GenericInvoker(String fullName,
String paramSpecsStr) |
GenericInvoker(String fullName,
String paramSpecsStr,
String isStatic) |
Modifier and Type | Method and Description |
---|---|
T |
exec(Tuple input)
This callback method must be implemented by all subclasses.
|
Schema |
outputSchema(Schema input)
Report the schema of the output of this UDF.
|
allowCompileTimeCalculation, finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, needEndOfAllInputProcessing, progress, setEndOfAllInput, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
public GenericInvoker()
public GenericInvoker(String fullName) throws ClassNotFoundException, FrontendException, SecurityException, NoSuchMethodException
public GenericInvoker(String fullName, String paramSpecsStr) throws ClassNotFoundException, FrontendException, SecurityException, NoSuchMethodException
public GenericInvoker(String fullName, String paramSpecsStr, String isStatic) throws ClassNotFoundException, FrontendException, SecurityException, NoSuchMethodException
public T exec(Tuple input) throws IOException
EvalFunc
exec
in class EvalFunc<T>
input
- the Tuple to be processed.IOException
public Schema outputSchema(Schema input)
EvalFunc
The default implementation interprets the OutputSchema
annotation,
if one is present. Otherwise, it returns null
(no known output schema).
outputSchema
in class EvalFunc<T>
input
- Schema of the inputCopyright © 2007-2012 The Apache Software Foundation