In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
In our work, we need to use the custom UDF function:
1. You can create persistent functions
two。 You can also compile it in the source code
This document is used in source code compilation. Here are the compilation steps
Download the source package
Wget http://archive.cloudera.com/cdh6/cdh/5/hive-1.1.0-cdh6.7.0-src.tar.gztar xf hive-1.1.0-cdh6.7.0-src.tar.gzcd hive-1.1.0-cdh6.7.0/
Enter the directory of the UDF code
Cd ql/src/java/org/apache/hadoop/hive/ql/udf/- We can see a lot of UDF code here, starting with UDFXXX.java
Put the UDF code in the directory above
HelloUDF.javapackage com.ruozedata.hadoop.udf;import org.apache.hadoop.hive.ql.exec.UDF;public class HelloUDF extends UDF {public String evaluate (String input) {/ / TODO... Here is the return "Hello:" + input;} / / the following is the test code public static void main (String [] args) {HelloUDF udf = new HelloUDF (); String output = udf.evaluate ("test data"); System.out.println (output);}}
Register a custom UDF function in the source code
Cd ql/src/java/org/apache/hadoop/hive/ql/exec/#vim FunctionRegistry.javaimport org.apache.hadoop.hive.ql.udf.HelloUDF
Add the following to line 176
System.registerUDF ("HelloUDF", HelloUDF.class,false)
Compile hive
[root@hadoop001 exec] # pwd/opt/sourcecode/hive-1.1.0-cdh6.7.0 [root@hadoop001 hive-1.1.0-cdh6.7.0] # mvn clean package-DskipTests-Phadoop-2-Pdist
The compiled file is:
1.packaging/target/apache-hive-1.1.0-cdh6.7.0-bin.tar.gz
2.. / lib/hive-exec-1.1.0-cdh6.7.0.jar
Mode of use
Method 1: redeploy apache-hive-1.1.0-cdh6.7.0-bin.tar.gz
Method 2: copy the compiled / lib/hive-exec-1.1.0-cdh6.7.0.jar to the ${HIVE_HOME} / lib/ directory
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.