org.apache.pig.scripting.jython
Class JythonScriptEngine

java.lang.Object
  extended by org.apache.pig.scripting.ScriptEngine
      extended by org.apache.pig.scripting.jython.JythonScriptEngine

public class JythonScriptEngine
extends ScriptEngine

Implementation of the script engine for Jython


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.pig.scripting.ScriptEngine
ScriptEngine.SupportedScriptLang
 
Field Summary
 
Fields inherited from class org.apache.pig.scripting.ScriptEngine
NAMESPACE_SEPARATOR
 
Constructor Summary
JythonScriptEngine()
           
 
Method Summary
static org.python.core.PyFunction getFunction(String path, String functionName)
          Gets the Python function object.
protected  Map<String,Object> getParamsFromVariables()
          Returns a map from local variable names to their values
protected  String getScriptingLang()
          Gets ScriptEngine classname or keyword for the scripting language
 void load(InputStream script, String scriptFile, PigContext pigContext)
          execs the script text using the interpreter.
protected  Map<String,List<PigStats>> main(PigContext pigContext, String scriptFile)
          Actually runs the script file.
 void registerFunctions(String path, String namespace, PigContext pigContext)
          Registers scripting language functions as Pig functions with given namespace
 
Methods inherited from class org.apache.pig.scripting.ScriptEngine
getInstance, getJarPath, getPigStatsMap, getScriptAsStream, getSupportedScriptLang, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JythonScriptEngine

public JythonScriptEngine()
Method Detail

registerFunctions

public void registerFunctions(String path,
                              String namespace,
                              PigContext pigContext)
                       throws IOException
Description copied from class: ScriptEngine
Registers scripting language functions as Pig functions with given namespace

Specified by:
registerFunctions in class ScriptEngine
Parameters:
path - path of the script
namespace - namespace for the functions
pigContext - pigcontext to register functions to pig in the given namespace
Throws:
IOException

getFunction

public static org.python.core.PyFunction getFunction(String path,
                                                     String functionName)
                                              throws IOException
Gets the Python function object.

Parameters:
path - Path of the jython script file containing the function.
functionName - Name of the function
Returns:
a function object
Throws:
IOException

main

protected Map<String,List<PigStats>> main(PigContext pigContext,
                                          String scriptFile)
                                   throws IOException
Description copied from class: ScriptEngine
Actually runs the script file. This method will be implemented by individual script engines.

Specified by:
main in class ScriptEngine
Parameters:
pigContext - ScriptPigContext to run the script file
scriptFile - the file
Throws:
IOException

load

public void load(InputStream script,
                 String scriptFile,
                 PigContext pigContext)
          throws IOException
execs the script text using the interpreter. populates the pig context with necessary module paths. does not close the inputstream.

Parameters:
script -
scriptFile -
pigContext -
Throws:
IOException

getScriptingLang

protected String getScriptingLang()
Description copied from class: ScriptEngine
Gets ScriptEngine classname or keyword for the scripting language

Specified by:
getScriptingLang in class ScriptEngine

getParamsFromVariables

protected Map<String,Object> getParamsFromVariables()
                                             throws IOException
Description copied from class: ScriptEngine
Returns a map from local variable names to their values

Specified by:
getParamsFromVariables in class ScriptEngine
Throws:
IOException


Copyright © 2007-2012 The Apache Software Foundation