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(java.lang.String fullName) |
GenericInvoker(java.lang.String fullName,
java.lang.String paramSpecsStr) |
GenericInvoker(java.lang.String fullName,
java.lang.String paramSpecsStr,
java.lang.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, getLoadCaster, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, needEndOfAllInputProcessing, progress, setEndOfAllInput, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
public GenericInvoker()
public GenericInvoker(java.lang.String fullName) throws java.lang.ClassNotFoundException, FrontendException, java.lang.SecurityException, java.lang.NoSuchMethodException
java.lang.ClassNotFoundException
FrontendException
java.lang.SecurityException
java.lang.NoSuchMethodException
public GenericInvoker(java.lang.String fullName, java.lang.String paramSpecsStr) throws java.lang.ClassNotFoundException, FrontendException, java.lang.SecurityException, java.lang.NoSuchMethodException
java.lang.ClassNotFoundException
FrontendException
java.lang.SecurityException
java.lang.NoSuchMethodException
public GenericInvoker(java.lang.String fullName, java.lang.String paramSpecsStr, java.lang.String isStatic) throws java.lang.ClassNotFoundException, FrontendException, java.lang.SecurityException, java.lang.NoSuchMethodException
java.lang.ClassNotFoundException
FrontendException
java.lang.SecurityException
java.lang.NoSuchMethodException
public T exec(Tuple input) throws java.io.IOException
EvalFunc
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-2017 The Apache Software Foundation