hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hadoop Wiki] Update of "Hive/AdminManual/Plugins" by LarryOgrodnek
Date Tue, 23 Jun 2009 23:14:41 GMT
Dear Wiki user,

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

The following page has been changed by LarryOgrodnek:
http://wiki.apache.org/hadoop/Hive/AdminManual/Plugins

The comment on the change is:
added some docs for creating/registering custom UDFs

------------------------------------------------------------------------------
+ == creating custom UDFs ==
+ 
+ First, you need to create a new class that extends UDF, with one or more methods named evaluate.
+ 
+ {{{
+ package com.example.hive.udf;
+ 
+ import org.apache.hadoop.hive.ql.exec.UDF;
+ import org.apache.hadoop.io.Text;
+ 
+ public final class Lower extends UDF {
+   public Text evaluate(final Text s) {
+     if (s == null) { return null; }
+     return new Text(s.toString().toLowerCase());
+   }
+ }
+ }}}
+ 
+ 
+ (Note that there's already a built-in function for this, it's just an easy example).
+ 
+ After compiling your code to a jar, you need to add this to the hive classpath.  See the
section below on deploying jars.
+ 
+ Once hive is started up with your jars in the classpath, the final step is to register your
function:
+ {{{
+ register temporary function my_lower as 'com.example.hive.udf.Lower';
+ }}}
+ Now you can start using it:
+ {{{
+ hive> select my_lower(title), sum(freq) from titles group by my_lower(title);
+ 
+ ...
+ 
+ Ended Job = job_200906231019_0006
+ OK
+ cmo	13.0
+ vp	7.0
+ }}}
+ 
+ 
  == Deploying jars for User Defined Functions and User Defined SerDes ==
  
+ Currently you need to set the classpath before starting Hive.
+ 
+ This is done by setting {{{HIVE_AUX_JARS_PATH}}} to a directory containing your jars, or
adding a {{{hive.aux.jars.path}}} property to {{{$HIVE_HOME/conf/hive-site.xml}}}.
+ 
+ It looks like there is some code coming as part of HIVE-338 that will allow you to add/remove
jars to the classpath dynamically.
+ 

Mime
View raw message