You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by Apache Wiki <wi...@apache.org> on 2009/11/09 22:54:35 UTC

[Pig Wiki] Update of "PiggyBank" by FlipKromer

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Pig Wiki" for change notification.

The "PiggyBank" page has been changed by FlipKromer.
The comment on this change is: More detail on the CLASSPATH -- need to have hadoop and commons-logging jar's in there too.
http://wiki.apache.org/pig/PiggyBank?action=diff&rev1=13&rev2=14

--------------------------------------------------

  = Piggy Bank - User Defined Pig Functions =
- 
  This is a place for Pig users to share their functions. The functions are contributed "as-is". If you find a bug or if you feel a function is missing, take the time to fix it or write it yourself and contribute the changes.
  
  <<Anchor(Using_Functions)>>
+ 
  == Using Functions ==
- 
  To see how to use your own functions in a pig script, please, see the [[http://wiki.apache.org/pig-data/attachments/FrontPage/attachments/plrm.htm|Pig Latin Reference Manual]]. Note that only JAVA functions are supported at this time.
  
  The functions are currently distributed in source form. Users are required to checkout the code and build the package themselves.  No binary distributions or nightly builds are available at this time.
@@ -14, +13 @@

  To build a jar file that contains all available user defined functions (UDFs), please follow the steps:
  
   1. Checkout UDF code: `svn co http://svn.apache.org/repos/asf/hadoop/pig/trunk/contrib/piggybank`
-  2. Add pig.jar to your ClassPath : `export CLASSPATH=$CLASSPATH:/path/to/pig.jar`
+  1. Add pig.jar to your ClassPath : `export CLASSPATH=$CLASSPATH:/path/to/pig.jar`
-  3. Build the jar file: from `trunk/contrib/piggybank/java` directory run `ant`. This will generate `piggybank.jar` in the same directory.
+  1. Build the jar file: from `trunk/contrib/piggybank/java` directory run `ant`. This will generate `piggybank.jar` in the same directory.
  
+ Make sure your classpath includes the hadoop jars as well. This workedforme using the cloudera CDH2 / hadoop AMIs:
  
+ {{{
+ pig_version=0.4.99.0+10   ; pig_dir=/usr/lib/pig ;
+ hadoop_version=0.20.1+152 ; hadoop_dir=/usr/lib/hadoop ;
+ export CLASSPATH=$CLASSPATH:${hadoop_dir}/hadoop-${hadoop_version}-core.jar:${hadoop_dir}/hadoop-${hadoop_version}-tools.jar:${hadoop_dir}/hadoop-${hadoop_version}-ant.jar:${hadoop_dir}/lib/commons-logging-1.0.4.jar:${pig_dir}/pig-${pig_version}-core.jar
+ }}}
  To obtain `javadoc` description of the functions run `ant javadoc` from `trunk/contrib/piggybank/java` directory. The documentation is generate in `trunk/contrib/piggybank/java/build/javadoc` directory.
-  
+ 
  To use a function, you need to figure out which package it belongs to. The top level packages correspond to the function type and currently are:
  
-   * org.apache.pig.piggybank.comparison - for custom comparator used by ORDER operator
+  * org.apache.pig.piggybank.comparison - for custom comparator used by ORDER operator
-   * org.apache.pig.piggybank.evaluation - for eval functions like aggregates and column transformations
+  * org.apache.pig.piggybank.evaluation - for eval functions like aggregates and column transformations
-   * org.apache.pig.piggybank.filtering - for functions used in FILTER operator
+  * org.apache.pig.piggybank.filtering - for functions used in FILTER operator
-   * org.apache.pig.piggybank.grouping - for grouping functions
+  * org.apache.pig.piggybank.grouping - for grouping functions
-   * org.apache.pig.piggybank.storage - for load/store functions
+  * org.apache.pig.piggybank.storage - for load/store functions
  
  (The exact package of the function can be seen in the javadocs or by navigating the source tree.)
  
@@ -37, +42 @@

  TweetsInaug  = FILTER Tweets BY org.apache.pig.piggybank.evaluation.string.UPPER(text) MATCHES '.*(INAUG|OBAMA|BIDEN|CHENEY|BUSH).*' ;
  STORE TweetsInaug INTO 'meta/inaug/tweets_inaug' ;
  }}}
- 
- 
  == Contributing Functions ==
- 
  For details on how to create UDFs, please, see the [[http://wiki.apache.org/pig/UDFManual|UDF Manual]]. Note that only JAVA functions are supported at this time.
  
  To contribute a new function, please, follow the steps:
  
   1. Check existing javadoc to make sure that the function does not already exist as described in [[#Using_Functions]]
-  2. Checkout UDF code as described in [[#Using_Functions]]
+  1. Checkout UDF code as described in [[#Using_Functions]]
-  3. Place your java code in the directory that makes sense for your function. The directory structure as of now has two levels: function type as described in [[#Using_Functions]] and function subtype (like math or string for eval functions) for some of the types. If you feel that your function requires a new subtype, feel free to add one.
+  1. Place your java code in the directory that makes sense for your function. The directory structure as of now has two levels: function type as described in [[#Using_Functions]] and function subtype (like math or string for eval functions) for some of the types. If you feel that your function requires a new subtype, feel free to add one.
-  4. Make sure that your function is well documented and uses [[http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/javadoc.html|javadoc]] style of documentation.
+  1. Make sure that your function is well documented and uses [[http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/javadoc.html|javadoc]] style of documentation.
-  5. Make sure that your code follows Pig coding conventions described in HowToContribute
+  1. Make sure that your code follows Pig coding conventions described in HowToContribute
-  6. Make sure that for each function, you add a corresponding test class in the test part of the tree.
+  1. Make sure that for each function, you add a corresponding test class in the test part of the tree.
-  7. Submit your patch following the process described HowToContribute
+  1. Submit your patch following the process described HowToContribute