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. ...
随机推荐
- spring3.0的jar包详解
1. spring.jar 是包含有完整发布模块的单个jar 包. 2. org.springframework.aop 包含在应用中使用Spring的AOP特性时所需的类. 3. org.sprin ...
- Android:控件的隐藏显示
布局中的:android:visibility 程序中可用setVisibility(); 对应的三个常量值:0.4.8 VISIBLE:0 意思是可见的INVISIBILITY:4 意思是不可见的, ...
- [cocoapods]如何卸载cocoapods
今天我们来讲一下cocoapods的删除步骤! 1.移除pod组件,打开终端执行which pod 然后输出了路径,我的是 /usr/local/bin/pod 2. 移除Cocoapods组件,继续 ...
- Maven远程仓库
根据Apache Maven声明:"只有当在本地和中心仓库找不到所需的依赖文件,才会到远程仓库去下载". 当在Maven里声明了一个本地和中心仓库都没有的库文件时,Maven会停止 ...
- git全局配置
使用git的童鞋都知道,git是非常好的版本管理工具,工具再好要想用的得心应手还是要下凡功夫的,比如可以通过对git的全局配置文件.gitconfig进行适当的配置,可以在日常项目开发中节省很多的时间 ...
- OAuth2.0和SSO授权的区别
OAuth2.0和SSO授权 一.OAuth2.0授权协议 一种安全的登陆协议,用户提交的账户密码不提交到本APP,而是提交到授权服务器,待服务器确认后,返回本APP一个访问令牌,本APP即可用该 ...
- RecyclerView(6)自定义RecyclerView.LayoutManager
A LayoutManager is responsible for measuring and positioning item views within a RecyclerView as wel ...
- Ubuntu 12.04搭建MTK 6577 安卓开发环境
Ubuntu 12.04搭建 MTK 6577安卓开发环境 1. 下载并安装Vmware虚拟机: 2. 下载并在虚拟机上安装Ubuntu 12.04 iso 安装包:下载地址: ...
- git stash 暂存当前修改
当我们在开发项目的时候,突然来一个变更需要修改,我们除了将当前项目提交(commit)后切换(checkout) 到其他分支外,我们还可以先将当前的修改暂存(stash)起来,然后再切换(checko ...
- HTML页面导出为Word
protected void btnExport_Click(object sender, EventArgs e) { string strFileName = DateTime.Now.ToStr ...