hive UDAF

java 程序
package com.ibeifeng.udaf; import org.apache.hadoop.hive.ql.exec.UDAF;
import org.apache.hadoop.hive.ql.exec.UDAFEvaluator; public class Wm_concat extends UDAF { public static class MYUDAFVAL implements UDAFEvaluator{ private PartialResult partial = new PartialResult();
public static class PartialResult{
String result = "";
String delilmiter = null;
}
@Override
public void init() {
// TODO 自动生成的方法存根
partial.result = ""; }
public boolean iterate(String value, String deli){
if(value == null || "null".equalsIgnoreCase(value)){
return true;
}
if(partial.delilmiter == null){
partial.delilmiter = deli; }
if(partial.result.length() > 0){ partial.result = partial.result.concat(partial.delilmiter); } partial.result = partial.result.concat(value); return true; } public PartialResult terminatePartial(){ return partial;
} public boolean merge(PartialResult other){ if(other == null)
return true;
if(partial.delilmiter == null){
partial.delilmiter = other.delilmiter;
partial.result = other.result;
}else{
if(partial.result.length()>0){
partial.result = partial.result.concat(partial.delilmiter); }
partial.result = partial.result.concat(other.result); }
return true; }
public String terminate(){ if(partial == null || partial.result == null){ return null;
}
return partial.result;
}
} }
hive UDAF的更多相关文章
- Hive UDAF开发之同时计算最大值与最小值
卷首语 前一篇文章hive UDAF开发入门和运行过程详解(转)里面讲过UDAF的开发过程,其中说到如果要深入理解UDAF的执行,可以看看求平均值的UDF的源码 本人在看完源码后,也还是没能十分理解里 ...
- Hive UDAF开发详解
说明 这篇文章是来自Hadoop Hive UDAF Tutorial - Extending Hive with Aggregation Functions:的不严格翻译,因为翻译的文章示例写得比较 ...
- Hive UDAF介绍与开发
UDAF简介 UDAF是用户自定义聚合函数.Hive支持其用户自行开发聚合函数完成业务逻辑. 通俗点说,就是你可能需要做一些特殊的甚至是非常扭曲的逻辑聚合,但是Hive自带的聚合函数不够玩,同时也还找 ...
- hive UDAF源代码分析
sss /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license a ...
- hive UDAF开发入门和运行过程详解(转)
介绍 hive的用户自定义聚合函数(UDAF)是一个很好的功能,集成了先进的数据处理.hive有两种UDAF:简单和通用.顾名思义,简单的UDAF,写的相当简单的,但因为使用Java反射导致性能损失, ...
- DeveloperGuide Hive UDAF
Writing GenericUDAFs: A Tutorial User-Defined Aggregation Functions (UDAFs) are an excellent way to ...
- 自定义Hive UDAF 实现相邻去重
内置的两个聚合函数(UDAF) collect_list():多行字符串拼接为一行collect_set():多行字符串拼接为一行并去重多行字符串拼接为一行并相邻去重UDAF:Concat() con ...
- hive UDAF开发和运行全过程
介绍 hive的用户自定义聚合函数(UDAF)是一个很好的功能,集成了先进的数据处理.hive有两种UDAF:简单和通用.顾名思义,简单的UDAF,写的相当简单的,但因为使用Java反射导致性能损失, ...
- hive udaf 用maven打包运行create temporary function 时报错
用maven打包写好的jar,在放到hive中作暂时函数时报错. 错误信息例如以下: hive> create temporary function maxvalue as "com. ...
随机推荐
- 转贴: A Simple c# Wrapper for ffMpeg
原帖地址:http://jasonjano.wordpress.com/2010/02/09/a-simple-c-wrapper-for-ffmpeg/ A Simple c# Wrapper fo ...
- login.java
import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Login extends JFrame ...
- Nmap扫描原理与用法
Nmap扫描原理与用法 1 Nmap介绍 Nmap扫描原理与用法PDF:下载地址 Nmap是一款开源免费的网络发现(Network Discovery)和安全审计(Security Audit ...
- kail新手安装
Kali Linux下载链接:http://mirrors.ustc.edu.cn/kali-images/kali-2.0/ (ps:建议用国内镜像源下载,速度有保证) Kali Linux安装之后 ...
- ctrlsf插件
输入CtrlSF pattern <dir>来搜索 想要搜索当前文件,用CtrlSF pattern %p(或者C-R %) 在结果界面,p键预览,回车进入闭关内关闭搜索结果框,t键打开一 ...
- Altium Designer哪里下载和导入元件库_图文教程
http://jingyan.baidu.com/article/46650658064621f549e5f88f.html
- [LA 3887] Slim Span
3887 - Slim SpanTime limit: 3.000 seconds Given an undirected weighted graph G <tex2html_verbatim ...
- Lost connection to MySQL server at 'reading initial communication packet' 错误解决
Lost connection to MySQL server at 'reading initial communication packet' 错误解决 上次解决了这个问题,今天又碰到,突然失忆, ...
- 自定义View,圆形头像
1. 效果图 2. xml中 <com.etoury.etoury.ui.view.CircleImg android:id="@+id/user_info_head_img" ...
- [转帖]Asp.NET 弹出页面
原文链接:http://www.cnblogs.com/adi-liu/archive/2008/07/18/1246091.html ASP.NET 弹出对话框和页面之间传递值的经验总结 今天碰到一 ...