org.apache.pig.scripting.jruby
Class JrubyEvalFunc

java.lang.Object
  extended by org.apache.pig.EvalFunc<Object>
      extended by org.apache.pig.scripting.jruby.JrubyEvalFunc

public class JrubyEvalFunc
extends EvalFunc<Object>

This class serves at the bridge between Ruby methods that are registered with and extend PigUdf, and their execution in Pig. An instance of the containing class is created, and their method name will be called against that instance. If they have a schema function associated, then when outputSchema is called, that function will be given the input Schema and the output will be given to Pig.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.pig.EvalFunc
EvalFunc.SchemaType
 
Field Summary
 
Fields inherited from class org.apache.pig.EvalFunc
log, pigLogger, reporter, returnType
 
Constructor Summary
JrubyEvalFunc(String filename, String functionName)
          The constructor for this class registers the filename of the Ruby script and the name of the method we care about.
 
Method Summary
 Object exec(Tuple tuple)
          The exec method passes the tuple argument to the Ruby function, and converts the result back to Pig.
 Schema outputSchema(Schema input)
          This method uses the schema method of the function encapsulation object to get the Schema information for the Ruby method.
 
Methods inherited from class org.apache.pig.EvalFunc
finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, isAsynchronous, progress, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JrubyEvalFunc

public JrubyEvalFunc(String filename,
                     String functionName)
              throws IOException
The constructor for this class registers the filename of the Ruby script and the name of the method we care about. The difference between function name and method name is that the former is the name that was used to register the function, whereas the method name is the actual method that must be invoked. The two are often the same, but not always. functionName is the key to the list of EvalFuncs that are registered.

Throws:
IOException
Method Detail

exec

public Object exec(Tuple tuple)
            throws IOException
The exec method passes the tuple argument to the Ruby function, and converts the result back to Pig.

Specified by:
exec in class EvalFunc<Object>
Parameters:
tuple - the Tuple to be processed.
Returns:
result, of type T.
Throws:
IOException

outputSchema

public Schema outputSchema(Schema input)
This method uses the schema method of the function encapsulation object to get the Schema information for the Ruby method.

Overrides:
outputSchema in class EvalFunc<Object>
Parameters:
input - Schema of the input
Returns:
Schema of the output


Copyright © 2007-2012 The Apache Software Foundation