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 > Servers >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you the implementation method of hive extension function development. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Provides the following two implementations: an inherits the org.apache.hadoop.hive.ql.exec.UDF class
The code package is packageorg.apache.hadoop.hive.ql.udf
The evaluate method is implemented, and the system automatically converts to the matching method implementation according to the input parameters and return parameter types.
For example:
UDFTestLength.java:
Importorg.apache.hadoop.io.IntWritable
Importorg.apache.hadoop.io.Text
Public classUDFTestLength extends UDF {
IntWritable result = new IntWritable ()
Public IntWritable evaluate (Text s) {
If (slots = null) {
Return null
}
Result.set (countUDF8Characters (s)
Return result
}
}
B inherits the org.apache.hadoop.hive.ql.udf.generic.GenericUDF class
The code package is packageorg.apache.hadoop.hive.ql.udf. Generic
Implement initialize, evaluate, getDisplayString methods
For example:
@ Description (name = "url_to_map", value = "_ FUNC_ (text,delimiter1, delimiter2) -"
Public class GenericUDFUrlToMap extends GenericUDF {
HashMap ret = new HashMap ()
@ Override
Public ObjectInspector initialize (ObjectInspector [] arguments)
ThrowsUDFArgumentException {
... ...
ReturnObjectInspectorFactory.getStandardMapObjectInspector (
PrimitiveObjectInspectorFactory.javaStringObjectInspector
PrimitiveObjectInspectorFactory.javaStringObjectInspector)
}
@ Override
Public Object evaluate (DeferredObject [] arguments) throws HiveException {
Ret.clear ()
... ...
Return ret
}
@ Override
Public String getDisplayString (String [] children) {
StringBuildersb = new StringBuilder ()
Sb.append ("url_to_map ("))
Assert (children.length
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.