public class Pig extends Object
Modifier | Constructor and Description |
---|---|
protected |
Pig(String script,
ScriptPigContext scriptContext,
String name) |
Modifier and Type | Method and Description |
---|---|
BoundScript |
bind()
Bind a Pig object to variables in the host language (optional
operation).
|
BoundScript |
bind(List<Map<String,Object>> vars)
Bind this to multiple sets of variables.
|
BoundScript |
bind(Map<String,Object> vars)
Bind this to a set of variables.
|
static Pig |
compile(String pl)
Define a Pig pipeline.
|
static Pig |
compile(String name,
String pl)
Define a named portion of a Pig pipeline.
|
static Pig |
compileFromFile(String filename)
Define a Pig pipeline based on Pig Latin in a separate file.
|
static Pig |
compileFromFile(String name,
String filename)
Define a named Pig pipeline based on Pig Latin in a separate file.
|
static void |
define(String alias,
String definition)
Define an alias for a UDF or a streaming command.
|
static int |
fs(String cmd)
Run a filesystem command.
|
static void |
registerJar(String jarfile)
Register a jar for use in Pig.
|
static void |
registerUDF(String udffile,
String namespace)
Register scripting UDFs for use in Pig.
|
static void |
set(String var,
String value)
Set a variable for use in Pig Latin.
|
static int |
sql(String cmd)
Run a sql command.
|
protected Pig(String script, ScriptPigContext scriptContext, String name)
public static int fs(String cmd) throws IOException
cmd
- Filesystem command to run along with its arguments as one
string.IOException
public static int sql(String cmd) throws IOException
cmd
- sql command to run along with its arguments as one
string. Currently only hcat is supported as a sql backendIOException
public static void registerJar(String jarfile) throws IOException
jarfile
- Path of jar to include.IOException
- if the indicated jarfile cannot be found.public static void registerUDF(String udffile, String namespace) throws IOException
udffile
- Path of the script UDF filenamespace
- namespace of the UDFsIOException
public static void define(String alias, String definition) throws IOException
alias
- name of the defined aliasdefinition
- string this alias is defined asIOException
public static void set(String var, String value) throws IOException
var
- variable to setvalue
- to set it toIOException
public static Pig compile(String pl) throws IOException
pl
- Pig Latin definition of the pipeline.IOException
- if the Pig Latin does not compile.public static Pig compile(String name, String pl) throws IOException
name
- Name that will be used to define this pipeline.
The namespace is global.pl
- Pig Latin definition of the pipeline.IOException
- if the Pig Latin does not compile.public static Pig compileFromFile(String filename) throws IOException
filename
- File to read Pig Latin from. This must be a purely
Pig Latin file. It cannot contain host language constructs in it.IOException
- if the Pig Latin does not compile or the file
cannot be found.public static Pig compileFromFile(String name, String filename) throws IOException
name
- Name that will be used to define this pipeline.
The namespace is global.filename
- File to read Pig Latin from. This must be a purely
Pig Latin file. It cannot contain host language constructs in it.IOException
- if the Pig Latin does not compile or the file
cannot be found.public BoundScript bind(Map<String,Object> vars) throws IOException
vars
- map of variables to bind. Keys should be parameters defined
in the Pig Latin. Values should be strings that provide values for those
parameters. They can be either constants or variables from the host
language. Host language variables must contain strings.BoundScript
objectIOException
- if there is not a key for each
Pig Latin parameter or if they contain unsupported types.public BoundScript bind(List<Map<String,Object>> vars) throws IOException
vars
- list of maps of variables to bind. Keys should be parameters defined
in the Pig Latin. Values should be strings that provide values for those
variables. They can be either constants or variables from the host
language. Host language variables must be strings.BoundScript
objectIOException
- if there is not a key for each
Pig Latin parameter or if they contain unsupported types.public BoundScript bind() throws IOException
IOException
- if host language variables are not found to resolve all
Pig Latin parameters or if they contain unsupported types.Copyright © 2007-2017 The Apache Software Foundation