org.apache.pig.scripting.js
Class JSPig

java.lang.Object
  extended by org.apache.pig.scripting.js.JSPig

public class JSPig
extends Object

Pig entry point from javascript

Author:
Julien Le Dem

Method Summary
 BoundScript bind()
          See: Pig.bind()
 BoundScript bind(Object o)
          javascript helper for binding parameters.
static JSPig compile(String pl)
          Define a Pig pipeline.
static JSPig compile(String name, String pl)
          Define a named portion of a Pig pipeline.
static JSPig compileFromFile(String filename)
          Define a Pig pipeline based on Pig Latin in a separate file.
static JSPig 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)
          See Pig
static int fs(String cmd)
          See Pig
static void registerJar(String jarfile)
          See Pig
static void registerUDF(String udffile, String namespace)
          See Pig
static void set(String var, String value)
          See Pig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fs

public static int fs(String cmd)
              throws IOException
See Pig

Parameters:
cmd - Filesystem command to run along with its arguments as one string.
Throws:
IOException

registerJar

public static void registerJar(String jarfile)
                        throws IOException
See Pig

Parameters:
jarfile - Path of jar to include.
Throws:
IOException - if the indicated jarfile cannot be found.

registerUDF

public static void registerUDF(String udffile,
                               String namespace)
                        throws IOException
See Pig

Parameters:
udffile - Path of the script UDF file
namespace - namespace of the UDFs
Throws:
IOException

define

public static void define(String alias,
                          String definition)
                   throws IOException
See Pig

Parameters:
alias - name of the defined alias
definition - string this alias is defined as
Throws:
IOException

set

public static void set(String var,
                       String value)
                throws IOException
See Pig

Parameters:
var - variable to set
value - to set it to
Throws:
IOException

compile

public static JSPig compile(String pl)
                     throws IOException
Define a Pig pipeline.

Parameters:
pl - Pig Latin definition of the pipeline.
Returns:
Pig object representing this pipeline.
Throws:
IOException - if the Pig Latin does not compile.

compile

public static JSPig compile(String name,
                            String pl)
                     throws IOException
Define a named portion of a Pig pipeline. This allows it to be imported into another pipeline.

Parameters:
name - Name that will be used to define this pipeline. The namespace is global.
pl - Pig Latin definition of the pipeline.
Returns:
Pig object representing this pipeline.
Throws:
IOException - if the Pig Latin does not compile.

compileFromFile

public static JSPig compileFromFile(String filename)
                             throws IOException
Define a Pig pipeline based on Pig Latin in a separate file.

Parameters:
filename - File to read Pig Latin from. This must be a purely Pig Latin file. It cannot contain host language constructs in it.
Returns:
Pig object representing this pipeline.
Throws:
IOException - if the Pig Latin does not compile or the file cannot be found.

compileFromFile

public static JSPig compileFromFile(String name,
                                    String filename)
                             throws IOException
Define a named Pig pipeline based on Pig Latin in a separate file. This allows it to be imported into another pipeline.

Parameters:
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.
Returns:
Pig object representing this pipeline.
Throws:
IOException - if the Pig Latin does not compile or the file cannot be found.

bind

public BoundScript bind(Object o)
                 throws IOException
javascript helper for binding parameters. See: Pig.bind(Map)

Parameters:
o - a javascript object to be converted into a Map
Returns:
the bound script
Throws:
IOException - if Pig.bind(Map) throws an IOException

bind

public BoundScript bind()
                 throws IOException
See: Pig.bind()

Throws:
IOException - if host language variables are not found to resolve all Pig Latin parameters or if they contain unsupported types.


Copyright © 2007-2012 The Apache Software Foundation