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的更多相关文章

  1. Hive UDAF开发之同时计算最大值与最小值

    卷首语 前一篇文章hive UDAF开发入门和运行过程详解(转)里面讲过UDAF的开发过程,其中说到如果要深入理解UDAF的执行,可以看看求平均值的UDF的源码 本人在看完源码后,也还是没能十分理解里 ...

  2. Hive UDAF开发详解

    说明 这篇文章是来自Hadoop Hive UDAF Tutorial - Extending Hive with Aggregation Functions:的不严格翻译,因为翻译的文章示例写得比较 ...

  3. Hive UDAF介绍与开发

    UDAF简介 UDAF是用户自定义聚合函数.Hive支持其用户自行开发聚合函数完成业务逻辑. 通俗点说,就是你可能需要做一些特殊的甚至是非常扭曲的逻辑聚合,但是Hive自带的聚合函数不够玩,同时也还找 ...

  4. hive UDAF源代码分析

    sss /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license a ...

  5. hive UDAF开发入门和运行过程详解(转)

    介绍 hive的用户自定义聚合函数(UDAF)是一个很好的功能,集成了先进的数据处理.hive有两种UDAF:简单和通用.顾名思义,简单的UDAF,写的相当简单的,但因为使用Java反射导致性能损失, ...

  6. DeveloperGuide Hive UDAF

    Writing GenericUDAFs: A Tutorial User-Defined Aggregation Functions (UDAFs) are an excellent way to ...

  7. 自定义Hive UDAF 实现相邻去重

    内置的两个聚合函数(UDAF) collect_list():多行字符串拼接为一行collect_set():多行字符串拼接为一行并去重多行字符串拼接为一行并相邻去重UDAF:Concat() con ...

  8. hive UDAF开发和运行全过程

    介绍 hive的用户自定义聚合函数(UDAF)是一个很好的功能,集成了先进的数据处理.hive有两种UDAF:简单和通用.顾名思义,简单的UDAF,写的相当简单的,但因为使用Java反射导致性能损失, ...

  9. hive udaf 用maven打包运行create temporary function 时报错

    用maven打包写好的jar,在放到hive中作暂时函数时报错. 错误信息例如以下: hive> create temporary function maxvalue as "com. ...

随机推荐

  1. Project Euler 80:Square root digital expansion 平方根数字展开

    Square root digital expansion It is well known that if the square root of a natural number is not an ...

  2. log4j的基本配置参数

    转载:http://blog.csdn.net/fengyifei11228/article/details/6070006 log4j配置文件有三个主要的组件:Logger,Appender和Lay ...

  3. React gulp、Browserify、Webpack实例

    一.gulp var gulp = require('gulp'); var react = require('gulp-react'); gulp.task('jsx', function() { ...

  4. Photoshop:热气球的制作方法

    大致流程: 1.做等宽色块,加内发光 2.变形->膨化,弯曲20% 3.加高光和投影层,增加立体感 4.制作多列,合并后,滤镜->扭曲->球面化100%2次(注意放在在正方形画布中间 ...

  5. linux下手动安装apache详解

    引自:http://blog.chinaunix.net/uid-28458801-id-4211258.html error1:出现以下错误时候,需要下载安装apr configure: error ...

  6. 一个小应用的dbcp和c3p0配置实例

    以下是一个小应用的数据库连接池配置,包括DBCP和C3P0的配制方法 因为是小应用,完全不涉及访问压力,所以配置上采取尽量节约数据库资源的方式 具体要求如下:初始化连接数为0连接不够,需要新创建时,每 ...

  7. hadoop拾遗(五)---- mapreduce 输出到多个文件 / 文件夹

    今天要把HBase中的部分数据转移到HDFS上,想根据时间戳来自动输出到以时间戳来命名的每个文件夹下.虽然以前也做过相似工作,但有些细节还是忘记了,所以这次写个随笔记录一下. package com. ...

  8. 特殊的css样式

    在一定范围大小变化的div .div { width:auto; height:auto; min-height:100px; min-width:100px; max-height:200px; m ...

  9. myeclipse2014破解版本链接

    myeclipse2014破解版本下载链接 http://www.my-eclipse.cn/#download myeclipse2014破解版本汉化链接 https://blog.my-eclip ...

  10. ConcurrentDictionary和Dictionary

    http://stackoverflow.com/questions/6739193/is-the-concurrentdictionary-thread-safe-to-the-point-that ...