|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pig.EvalFunc<T>
org.apache.pig.builtin.GenericInvoker<T>
T
- public abstract class GenericInvoker<T>
The generic Invoker class does all the common grunt work of setting up an invoker. Class-specific non-generic extensions of this class are needed for Pig to know what type of return to expect from exec, and to find the appropriate classes through reflection. All they have to do is implement the constructors that call into super(). Note that the no-parameter constructor is required, if seemingly nonsensical, for Pig to do its work.
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.
Field Summary |
---|
Fields inherited from class org.apache.pig.EvalFunc |
---|
log, pigLogger, reporter, returnType |
Constructor Summary | |
---|---|
GenericInvoker()
|
|
GenericInvoker(String fullName)
|
|
GenericInvoker(String fullName,
String paramSpecsStr)
|
|
GenericInvoker(String fullName,
String paramSpecsStr,
String isStatic)
|
Method Summary | |
---|---|
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. |
Methods inherited from class org.apache.pig.EvalFunc |
---|
finish, getArgToFuncMapping, getCacheFiles, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, isAsynchronous, progress, setPigLogger, setReporter, warn |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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
Method Detail |
---|
public T exec(Tuple input) throws IOException
EvalFunc
input
- the Tuple to be processed.
IOException
public Schema outputSchema(Schema input)
EvalFunc
outputSchema
in class EvalFunc<T>
input
- Schema of the input
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |