public abstract class ScriptEngine
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ScriptEngine.SupportedScriptLang |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAMESPACE_SEPARATOR |
Constructor and Description |
---|
ScriptEngine() |
Modifier and Type | Method and Description |
---|---|
static ScriptEngine |
getInstance(java.lang.String scriptingLang)
Gets instance of the scriptEngine for the given scripting language
|
static java.lang.String |
getJarPath(java.lang.Class<?> clazz)
Figures out the jar location from the class
|
protected abstract java.util.Map<java.lang.String,java.lang.Object> |
getParamsFromVariables()
Returns a map from local variable names to their values
|
protected java.util.Map<java.lang.String,java.util.List<PigStats>> |
getPigStatsMap()
Gets the collection of
PigStats after the script is run. |
static java.io.InputStream |
getScriptAsStream(java.lang.String scriptPath)
open a stream load a script locally or in the classpath
|
protected abstract java.lang.String |
getScriptingLang()
Gets ScriptEngine classname or keyword for the scripting language
|
static ScriptEngine.SupportedScriptLang |
getSupportedScriptLang(java.lang.String file) |
protected abstract java.util.Map<java.lang.String,java.util.List<PigStats>> |
main(PigContext context,
java.lang.String scriptFile)
Actually runs the script file.
|
abstract void |
registerFunctions(java.lang.String path,
java.lang.String namespace,
PigContext pigContext)
Registers scripting language functions as Pig functions with given namespace
|
java.util.Map<java.lang.String,java.util.List<PigStats>> |
run(PigContext pigContext,
java.lang.String scriptFile)
Runs a script file.
|
public static final java.lang.String NAMESPACE_SEPARATOR
public static java.io.InputStream getScriptAsStream(java.lang.String scriptPath)
scriptPath
- the path of the scriptjava.lang.IllegalStateException
- if we could not open a streampublic static ScriptEngine.SupportedScriptLang getSupportedScriptLang(java.lang.String file) throws java.io.IOException
file
- the file to inspectjava.io.IOException
- if there was an error reading the file or if the file defines explicitly an unknown #!public abstract void registerFunctions(java.lang.String path, java.lang.String namespace, PigContext pigContext) throws java.io.IOException
path
- path of the scriptnamespace
- namespace for the functionspigContext
- pigcontext to register functions to pig in the given namespacejava.io.IOException
protected abstract java.util.Map<java.lang.String,java.util.List<PigStats>> main(PigContext context, java.lang.String scriptFile) throws java.io.IOException
context
- ScriptPigContext
to run the script filescriptFile
- the filejava.io.IOException
protected abstract java.lang.String getScriptingLang()
protected abstract java.util.Map<java.lang.String,java.lang.Object> getParamsFromVariables() throws java.io.IOException
java.io.IOException
public static java.lang.String getJarPath(java.lang.Class<?> clazz) throws java.io.FileNotFoundException
clazz
- class in the jar filejava.io.FileNotFoundException
public static ScriptEngine getInstance(java.lang.String scriptingLang) throws java.io.IOException
scriptingLang
- ScriptEngine classname or keyword for the scriptingLangjava.io.IOException
public java.util.Map<java.lang.String,java.util.List<PigStats>> run(PigContext pigContext, java.lang.String scriptFile) throws ExecException, java.io.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
java.io.IOException
Copyright © 2007-2012 The Apache Software Foundation