public abstract class ScriptEngine extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ScriptEngine.SupportedScriptLang |
Modifier and Type | Field and Description |
---|---|
static String |
NAMESPACE_SEPARATOR |
Constructor and Description |
---|
ScriptEngine() |
Modifier and Type | Method and Description |
---|---|
static ScriptEngine |
getInstance(String scriptingLang)
Gets instance of the scriptEngine for the given scripting language
|
static String |
getJarPath(Class<?> clazz)
Figures out the jar location from the class
|
protected abstract Map<String,Object> |
getParamsFromVariables()
Returns a map from local variable names to their values
|
protected Map<String,List<PigStats>> |
getPigStatsMap()
Gets the collection of
PigStats after the script is run. |
static InputStream |
getScriptAsStream(String scriptPath)
open a stream load a script locally or in the classpath
|
protected abstract String |
getScriptingLang()
Gets ScriptEngine classname or keyword for the scripting language
|
static ScriptEngine.SupportedScriptLang |
getSupportedScriptLang(String file) |
protected abstract Map<String,List<PigStats>> |
main(PigContext context,
String scriptFile)
Actually runs the script file.
|
abstract void |
registerFunctions(String path,
String namespace,
PigContext pigContext)
Registers scripting language functions as Pig functions with given namespace
|
Map<String,List<PigStats>> |
run(PigContext pigContext,
String scriptFile)
Runs a script file.
|
public static final String NAMESPACE_SEPARATOR
public static InputStream getScriptAsStream(String scriptPath)
scriptPath
- the path of the scriptIllegalStateException
- if we could not open a streampublic static ScriptEngine.SupportedScriptLang getSupportedScriptLang(String file) throws IOException
file
- the file to inspectIOException
- if there was an error reading the file or if the file defines explicitly an unknown #!public abstract void registerFunctions(String path, String namespace, PigContext pigContext) throws IOException
path
- path of the scriptnamespace
- namespace for the functionspigContext
- pigcontext to register functions to pig in the given namespaceIOException
protected abstract Map<String,List<PigStats>> main(PigContext context, String scriptFile) throws IOException
context
- ScriptPigContext
to run the script filescriptFile
- the fileIOException
protected abstract String getScriptingLang()
protected abstract Map<String,Object> getParamsFromVariables() throws IOException
IOException
public static String getJarPath(Class<?> clazz) throws FileNotFoundException
clazz
- class in the jar fileFileNotFoundException
public static ScriptEngine getInstance(String scriptingLang) throws IOException
scriptingLang
- ScriptEngine classname or keyword for the scriptingLangIOException
public Map<String,List<PigStats>> run(PigContext pigContext, String scriptFile) throws ExecException, IOException
pigContext
- PigContext
to run the script filescriptFile
- the filePigStats
objects. One for each runtime
instance of Pig
in the script. For named pipelines, the
map key is the name of the pipeline. For unnamed pipeline, the map key
is the script id associated with the instance.ExecException
IOException
Copyright © 2007-2012 The Apache Software Foundation