public class PigContext
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
int |
defaultParallel |
java.util.List<java.net.URL> |
extraJars |
boolean |
inDumpSchema |
boolean |
inExplain |
boolean |
inIllustrator |
static java.lang.String |
JOB_NAME |
static java.lang.String |
JOB_NAME_PREFIX |
static java.lang.String |
JOB_PRIORITY |
java.util.Map<java.lang.String,org.antlr.runtime.tree.Tree> |
macros |
static java.lang.String |
PIG_CMD_ARGS_REMAINDERS |
java.util.Vector<java.lang.String> |
predeployedJars |
java.util.List<java.lang.String> |
scriptFiles
Deprecated.
|
java.util.Map<java.lang.String,java.lang.String> |
scriptingUDFs |
java.util.List<java.lang.String> |
scriptJars |
Constructor and Description |
---|
PigContext() |
PigContext(org.apache.hadoop.conf.Configuration conf) |
PigContext(ExecType execType,
org.apache.hadoop.conf.Configuration conf) |
PigContext(ExecType execType,
java.util.Properties properties) |
PigContext(java.util.Properties properties) |
Modifier and Type | Method and Description |
---|---|
void |
addJar(java.lang.String path) |
void |
addJar(java.net.URL resource,
java.lang.String originalPath) |
void |
addPathToSkip(java.lang.String path)
Add a path to be skipped while automatically shipping binaries for
streaming.
|
void |
addScriptFile(java.lang.String path)
calls: addScriptFile(path, new File(path)), ensuring that a given path is
added to the jar at most once.
|
void |
addScriptFile(java.lang.String name,
java.lang.String path)
this method adds script files that must be added to the shipped jar
named differently from their local fs path.
|
void |
addScriptJar(java.lang.String path) |
void |
connect() |
void |
copy(java.lang.String src,
java.lang.String dst,
boolean localDst) |
java.lang.ClassLoader |
createCl(java.lang.String jarFile)
Creates a Classloader based on the passed jarFile and any extra jar files.
|
ExecutableManager |
createExecutableManager()
Create a new
ExecutableManager depending on the ExecType. |
java.lang.String |
doParamSubstitution(java.io.BufferedReader reader) |
java.lang.String |
doParamSubstitution(java.io.BufferedReader reader,
java.util.List<java.lang.String> params,
java.util.List<java.lang.String> paramFiles) |
java.lang.String |
doParamSubstitution(java.io.InputStream in,
java.util.List<java.lang.String> params,
java.util.List<java.lang.String> paramFiles) |
java.io.BufferedReader |
doParamSubstitutionOutputToFile(java.io.BufferedReader reader,
java.lang.String outputFilePath) |
java.io.BufferedReader |
doParamSubstitutionOutputToFile(java.io.BufferedReader reader,
java.lang.String outputFilePath,
java.util.List<java.lang.String> params,
java.util.List<java.lang.String> paramFiles) |
java.lang.Class |
getClassForAlias(java.lang.String alias) |
static java.lang.ClassLoader |
getClassLoader() |
StreamingCommand |
getCommandForAlias(java.lang.String alias)
Get the
StreamingCommand for the given alias. |
java.util.Properties |
getConf()
Deprecated.
use
getProperties() instead |
org.apache.log4j.Level |
getDefaultLogLevel() |
int |
getDefaultParallel() |
DataStorage |
getDfs() |
byte |
getErrorSource()
Check the execution mode and return the appropriate error source
|
ExecType |
getExecType()
Returns the type of execution currently in effect.
|
ExecutionEngine |
getExecutionEngine() |
DataStorage |
getFs() |
FuncSpec |
getFuncSpecFromAlias(java.lang.String alias) |
java.lang.String |
getLastAlias() |
DataStorage |
getLfs() |
java.util.Properties |
getLog4jProperties() |
static java.util.ArrayList<java.lang.String> |
getPackageImportList() |
java.util.List<java.lang.String> |
getParamFiles() |
java.util.List<java.lang.String> |
getParams() |
java.util.Map<java.lang.String,java.lang.String> |
getParamVal() |
java.util.List<java.lang.String> |
getPathsToSkip()
Get paths which are to skipped while automatically shipping binaries for
streaming.
|
PreprocessorContext |
getPreprocessorContext() |
java.util.Properties |
getProperties()
Provides configuration information.
|
java.util.Map<java.lang.String,java.io.File> |
getScriptFiles()
script files as name/file pairs to be added to the job jar
|
boolean |
hasJar(java.lang.String path) |
static void |
initializeImportList(java.lang.String importListCommandLineProperties) |
java.lang.Object |
instantiateFuncFromAlias(java.lang.String alias) |
static java.lang.Object |
instantiateFuncFromSpec(FuncSpec funcSpec) |
static java.lang.Object |
instantiateFuncFromSpec(java.lang.String funcSpec) |
static <T> T |
instantiateObjectFromParams(org.apache.hadoop.conf.Configuration conf,
java.lang.String classParamKey,
java.lang.String argParamKey,
java.lang.Class<T> clazz)
A common Pig pattern for initializing objects via system properties is to support passing
something like this on the command line:
-Dpig.notification.listener=MyClass
-Dpig.notification.listener.arg=myConstructorStringArg
This method will properly initialize the class with the args, if they exist. |
void |
markJarAsPredeployed(java.lang.String path)
Adds the specified path to the predeployed jars list.
|
void |
registerFunction(java.lang.String function,
FuncSpec functionSpec)
Defines an alias for the given function spec.
|
void |
registerStreamCmd(java.lang.String alias,
StreamingCommand command)
Defines an alias for the given streaming command.
|
void |
rename(java.lang.String oldName,
java.lang.String newName) |
static java.lang.Class |
resolveClassName(java.lang.String name) |
static void |
setClassLoader(java.lang.ClassLoader cl) |
void |
setDefaultLogLevel(org.apache.log4j.Level l) |
void |
setExecType(ExecType execType) |
void |
setJobtrackerLocation(java.lang.String newLocation) |
void |
setLastAlias(java.lang.String value) |
void |
setLog4jProperties(java.util.Properties p) |
static void |
setPackageImportList(java.util.ArrayList<java.lang.String> list) |
void |
setParamFiles(java.util.List<java.lang.String> paramFiles) |
void |
setParams(java.util.List<java.lang.String> params) |
static void |
staticDataCleanup() |
public static final java.lang.String JOB_NAME
public static final java.lang.String JOB_NAME_PREFIX
public static final java.lang.String JOB_PRIORITY
public static final java.lang.String PIG_CMD_ARGS_REMAINDERS
public transient java.util.List<java.net.URL> extraJars
public transient java.util.List<java.lang.String> scriptJars
public transient java.util.Vector<java.lang.String> predeployedJars
@Deprecated public java.util.List<java.lang.String> scriptFiles
public transient java.util.Map<java.lang.String,java.lang.String> scriptingUDFs
public transient java.util.Map<java.lang.String,org.antlr.runtime.tree.Tree> macros
public int defaultParallel
public boolean inExplain
public boolean inDumpSchema
public boolean inIllustrator
public PigContext()
public PigContext(org.apache.hadoop.conf.Configuration conf) throws PigException
PigException
public PigContext(java.util.Properties properties) throws PigException
PigException
public PigContext(ExecType execType, org.apache.hadoop.conf.Configuration conf)
public PigContext(ExecType execType, java.util.Properties properties)
public static void staticDataCleanup()
public java.util.List<java.lang.String> getParams()
public void setParams(java.util.List<java.lang.String> params)
public java.util.List<java.lang.String> getParamFiles()
public void setParamFiles(java.util.List<java.lang.String> paramFiles)
public PreprocessorContext getPreprocessorContext()
public java.util.Map<java.lang.String,java.lang.String> getParamVal() throws java.io.IOException
java.io.IOException
public static void initializeImportList(java.lang.String importListCommandLineProperties)
public void connect() throws ExecException
ExecException
public void setJobtrackerLocation(java.lang.String newLocation)
public void addScriptFile(java.lang.String path)
path
- public void addScriptFile(java.lang.String name, java.lang.String path)
name
- name in the jarpath
- path on the local fspublic void addScriptJar(java.lang.String path)
public void addJar(java.lang.String path) throws java.net.MalformedURLException
java.net.MalformedURLException
public void addJar(java.net.URL resource, java.lang.String originalPath) throws java.net.MalformedURLException
java.net.MalformedURLException
public boolean hasJar(java.lang.String path)
public void markJarAsPredeployed(java.lang.String path)
This can be called for jars that are pre-installed on the Hadoop cluster to reduce the size of the job jar.
public java.lang.String doParamSubstitution(java.io.InputStream in, java.util.List<java.lang.String> params, java.util.List<java.lang.String> paramFiles) throws java.io.IOException
java.io.IOException
public java.lang.String doParamSubstitution(java.io.BufferedReader reader, java.util.List<java.lang.String> params, java.util.List<java.lang.String> paramFiles) throws java.io.IOException
java.io.IOException
public java.lang.String doParamSubstitution(java.io.BufferedReader reader) throws java.io.IOException
java.io.IOException
public java.io.BufferedReader doParamSubstitutionOutputToFile(java.io.BufferedReader reader, java.lang.String outputFilePath, java.util.List<java.lang.String> params, java.util.List<java.lang.String> paramFiles) throws java.io.IOException
java.io.IOException
public java.io.BufferedReader doParamSubstitutionOutputToFile(java.io.BufferedReader reader, java.lang.String outputFilePath) throws java.io.IOException
java.io.IOException
public java.util.Map<java.lang.String,java.io.File> getScriptFiles()
public void rename(java.lang.String oldName, java.lang.String newName) throws java.io.IOException
java.io.IOException
public void copy(java.lang.String src, java.lang.String dst, boolean localDst) throws java.io.IOException
java.io.IOException
public ExecutionEngine getExecutionEngine()
public DataStorage getDfs()
public DataStorage getLfs()
public DataStorage getFs()
public java.util.Properties getProperties()
@Deprecated public java.util.Properties getConf()
getProperties()
insteadpublic java.lang.String getLastAlias()
public void setLastAlias(java.lang.String value)
public void registerFunction(java.lang.String function, FuncSpec functionSpec)
function
- - the new function alias to define.functionSpec
- - the FuncSpec object representing the name of
the function class and any arguments to constructor.public void registerStreamCmd(java.lang.String alias, StreamingCommand command)
alias
- - the new command alias to define.command
- - the commandpublic ExecType getExecType()
public java.lang.ClassLoader createCl(java.lang.String jarFile) throws java.net.MalformedURLException
jarFile
- the jar file to be part of the newly created Classloader. This jar file plus any
jars in the extraJars list will constitute the classpath.java.net.MalformedURLException
public static java.lang.Class resolveClassName(java.lang.String name) throws java.io.IOException
java.io.IOException
public static <T> T instantiateObjectFromParams(org.apache.hadoop.conf.Configuration conf, java.lang.String classParamKey, java.lang.String argParamKey, java.lang.Class<T> clazz) throws ExecException
-Dpig.notification.listener=MyClass
-Dpig.notification.listener.arg=myConstructorStringArg
This method will properly initialize the class with the args, if they exist.conf
- classParamKey
- the property used to identify the classargParamKey
- the property used to identify the class argsclazz
- The class that is expectedExecException
public static java.lang.Object instantiateFuncFromSpec(FuncSpec funcSpec)
public static java.lang.Object instantiateFuncFromSpec(java.lang.String funcSpec)
public java.lang.Class getClassForAlias(java.lang.String alias) throws java.io.IOException
java.io.IOException
public java.lang.Object instantiateFuncFromAlias(java.lang.String alias) throws java.io.IOException
java.io.IOException
public StreamingCommand getCommandForAlias(java.lang.String alias)
StreamingCommand
for the given alias.alias
- the alias for the StreamingCommand
StreamingCommand
for the aliaspublic void setExecType(ExecType execType)
public ExecutableManager createExecutableManager() throws ExecException
ExecutableManager
depending on the ExecType.ExecutableManager
depending on the ExecTypeExecException
public FuncSpec getFuncSpecFromAlias(java.lang.String alias)
public void addPathToSkip(java.lang.String path)
path
- path to be skippedpublic java.util.List<java.lang.String> getPathsToSkip()
public byte getErrorSource()
public static java.util.ArrayList<java.lang.String> getPackageImportList()
public static void setPackageImportList(java.util.ArrayList<java.lang.String> list)
public void setLog4jProperties(java.util.Properties p)
public java.util.Properties getLog4jProperties()
public org.apache.log4j.Level getDefaultLogLevel()
public void setDefaultLogLevel(org.apache.log4j.Level l)
public int getDefaultParallel()
public static java.lang.ClassLoader getClassLoader()
public static void setClassLoader(java.lang.ClassLoader cl)
Copyright © 2007-2017 The Apache Software Foundation