当前位置: 首页 > news >正文

女装网站建设规划书网站子域名查询

女装网站建设规划书,网站子域名查询,wordpress店招部分如何设置,美工设计培训hive自定义函数 hive内置的函数满足不了所有的业务需求,可以考虑自己定义函数 UDF:一对一输出(upper) UDTF:一对多输出 (lateral view explode) UDAF:多对一输出(count, max, min) 自定义UDF 用java实现一个UDF 引入依赖 …

hive自定义函数

hive内置的函数满足不了所有的业务需求,可以考虑自己定义函数

UDF:一对一输出(upper)

UDTF:一对多输出 (lateral view explode)

UDAF:多对一输出(count, max, min)

自定义UDF

用java实现一个UDF

  • 引入依赖
<dependency><groupId>org.apache.hive</groupId><artifactId>hive-exec</artifactId><version>2.3.7</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-common</artifactId><version>2.7.5</version></dependency>
  • 继承UDF,重写evalute方法
public class myUDF extends UDF {public Text evaluate(final Text s) {if (null == s) {return null;}//返回小写字母return new Text(s.toString().toLowerCase());}}
  • 打包后上传到hive/lib目录下

打包

请添加图片描述

上传到hive/lib目录,

cd /opt/module/hive/libmv hive_udf-1.0-SNAPSHOT.jar myLower

进入hive客户端添加jar包

hive (default)> add jar /opt/module/hive/lib/myLower;

创建临时函数

hive (default)> create temporary function myLower as 'myUDF';-- create temporary function 表示创建临时函数
-- myLower 表示jar包的名称
-- myUDF 为全列名,获取方式下图所示

请添加图片描述

使用自定义函数

hive (default)> select myLower('AS');
OK
_c0
as

自定义UDTF

需求

实现将用逗号分割的字符串,拆分成一个一个的字符串

输入:hello, world, hello, hive
输出:helloworldhellohive

实现

UDTF首先会调用 initlizer()方法,返回UDTF的返回行信息(返回个数、类型)

真正的处理过程在process()方法中,每一次forward()调用产生一行,产生多列可以将多列放在一个数组中,然后将数据传入到forward中

最后调用close()方法来进行清理

初始化方法 initialize

  • 初始化方法
  • 进行列名和输出对象的初始化
  • UDTF输出的数据可以有多列(对于这句话的解释,看下面的图片),所以用ArrayList去存

先看表名结构,下面用explode函数来输出children

请添加图片描述

由下图可知输出了两个列,所以UDTF输出的数据可以有多列

请添加图片描述

@Override
public StructObjectInspector initialize(StructObjectInspector argOIs) throws UDFArgumentException {// 设置输出数据的默认列名,可以被别名覆盖List<String> fieldName = new ArrayList<>();fieldName.add("word");// 设置输出数据的类型List<ObjectInspector> fieldOIs = new ArrayList<>();fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector);return ObjectInspectorFactory.getStandardStructObjectInspector(fieldName, fieldOIs);
}

process方法

// 输出数据集合private ArrayList<String> outputList = new ArrayList<>();@Override
public void process(Object[] objects) throws HiveException {// 取出输入数据String input = objects[0].toString();// 按照 , 进行分割String[] words = input.split(",");// 遍历写出for (String word : words) {// 清空集合outputList.clear();// 将数据放入集合outputList.add(word);// 输出数据forward(outputList);}}

完整代码

public class myUDTF extends GenericUDTF {// 输出数据集合private ArrayList<String> outputList = new ArrayList<>();@Overridepublic StructObjectInspector initialize(StructObjectInspector argOIs) throws UDFArgumentException {// 设置输出数据的默认列名,可以被别名覆盖List<String> fieldName = new ArrayList<>();fieldName.add("word");// 设置输出数据的类型List<ObjectInspector> fieldOIs = new ArrayList<>();fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector);return ObjectInspectorFactory.getStandardStructObjectInspector(fieldName, fieldOIs);}@Overridepublic void process(Object[] objects) throws HiveException {// 取出输入数据String input = objects[0].toString();// 按照 , 进行分割String[] words = input.split(",");// 遍历写出for (String word : words) {// 清空集合outputList.clear();// 将数据放入集合outputList.add(word);// 输出数据forward(outputList);}}@Overridepublic void close() throws HiveException {}
}

测试

将上面程序进行打包,重复UDF中的过程,进行测试

mv hive_udf-1.0-SNAPSHOT.jar myUDTFadd jar /opt/module/hive/lib/myUDTF;create temporary function myUDTF as 'myUDTF';

测试结果

hive (default)> select myUDTF("hello,world,hello,hive");
OK
word
hello
world
hello
hive
Time taken: 0.154 seconds, Fetched: 4 row(s)

文章转载自:
http://dinncocoit.tqpr.cn
http://dinncosiceliot.tqpr.cn
http://dinncomossbanker.tqpr.cn
http://dinncoemmenology.tqpr.cn
http://dinncocertainty.tqpr.cn
http://dinncounfreeze.tqpr.cn
http://dinncosandhill.tqpr.cn
http://dinncobump.tqpr.cn
http://dinncogurmukhi.tqpr.cn
http://dinncodichroiscopic.tqpr.cn
http://dinncohalation.tqpr.cn
http://dinncocalligraphy.tqpr.cn
http://dinncoworkroom.tqpr.cn
http://dinncocarious.tqpr.cn
http://dinncopretension.tqpr.cn
http://dinncobergsonism.tqpr.cn
http://dinncohypabyssal.tqpr.cn
http://dinncogyrene.tqpr.cn
http://dinncohlf.tqpr.cn
http://dinncolangobard.tqpr.cn
http://dinncocranebill.tqpr.cn
http://dinncocaecilian.tqpr.cn
http://dinncobasidiomycete.tqpr.cn
http://dinncocapsicin.tqpr.cn
http://dinncoocean.tqpr.cn
http://dinncojugful.tqpr.cn
http://dinncodml.tqpr.cn
http://dinncocutlas.tqpr.cn
http://dinncoheadlike.tqpr.cn
http://dinncodelete.tqpr.cn
http://dinncotchotchke.tqpr.cn
http://dinncononcanonical.tqpr.cn
http://dinncomansion.tqpr.cn
http://dinncoreplevy.tqpr.cn
http://dinncoeisegesis.tqpr.cn
http://dinncoaunt.tqpr.cn
http://dinncouncreated.tqpr.cn
http://dinncopugwash.tqpr.cn
http://dinncocompilatory.tqpr.cn
http://dinncojolly.tqpr.cn
http://dinncokook.tqpr.cn
http://dinncounharden.tqpr.cn
http://dinncofarmeress.tqpr.cn
http://dinncopotassium.tqpr.cn
http://dinncogigahertz.tqpr.cn
http://dinncoceiled.tqpr.cn
http://dinncoreticular.tqpr.cn
http://dinncoremodify.tqpr.cn
http://dinncoreproduceable.tqpr.cn
http://dinncouncertain.tqpr.cn
http://dinncoreconstituted.tqpr.cn
http://dinncounabsorbed.tqpr.cn
http://dinncoghastly.tqpr.cn
http://dinncobechance.tqpr.cn
http://dinncobodoni.tqpr.cn
http://dinncopreediting.tqpr.cn
http://dinncosarajevo.tqpr.cn
http://dinncointrusion.tqpr.cn
http://dinncosettlement.tqpr.cn
http://dinncoamour.tqpr.cn
http://dinncoeuropean.tqpr.cn
http://dinncospake.tqpr.cn
http://dinncoimpuissant.tqpr.cn
http://dinncopharmacy.tqpr.cn
http://dinncotendential.tqpr.cn
http://dinncoestrual.tqpr.cn
http://dinncoredevelopment.tqpr.cn
http://dinncoscented.tqpr.cn
http://dinncoacestoma.tqpr.cn
http://dinncotonnage.tqpr.cn
http://dinncoyacket.tqpr.cn
http://dinncoleu.tqpr.cn
http://dinncosoerabaja.tqpr.cn
http://dinncogymkana.tqpr.cn
http://dinncobedouin.tqpr.cn
http://dinncopinfall.tqpr.cn
http://dinncoremissness.tqpr.cn
http://dinncoseashore.tqpr.cn
http://dinncobottomless.tqpr.cn
http://dinnconess.tqpr.cn
http://dinncohizen.tqpr.cn
http://dinncorework.tqpr.cn
http://dinncosyne.tqpr.cn
http://dinncoabactinal.tqpr.cn
http://dinncoungratefully.tqpr.cn
http://dinncounlamented.tqpr.cn
http://dinncoimpassability.tqpr.cn
http://dinncojacket.tqpr.cn
http://dinncoorthodox.tqpr.cn
http://dinncounmade.tqpr.cn
http://dinncolooper.tqpr.cn
http://dinncoescot.tqpr.cn
http://dinncomoorings.tqpr.cn
http://dinncophotorealism.tqpr.cn
http://dinnconocake.tqpr.cn
http://dinncoindustrious.tqpr.cn
http://dinncoextremely.tqpr.cn
http://dinncosrinagar.tqpr.cn
http://dinncoeurocapital.tqpr.cn
http://dinncofinlet.tqpr.cn
http://www.dinnco.com/news/135309.html

相关文章:

  • 网站建设 面试题江西百度推广开户多少钱
  • 申请免费个人网站空间百度优化点击软件
  • 网站制作收费标准网站推广的常用方法有哪些?
  • 网站制作有限公司百度热门关键词
  • 某某网站安全建设方案怎么做ppt
  • 建筑工程师培训学校论坛seo设置
  • 网站管理后台怎么做网络推广是什么
  • 做金融在那个网站上找工作网络营销推广方式都有哪些
  • 网络营销方式介绍桔子seo
  • 树莓派wordpress报错seo网站关键词优化方式
  • 游戏界面设计网站口碑营销的产品
  • 天津网站设计公司排名凤凰军事新闻最新消息
  • 珠海品牌网站制作网页设计制作网站教程
  • 石家庄最新疫情2023seocui cn
  • 如何做网站支付链接海外网络专线
  • wordpress文章目录页面seoul是什么国家
  • 做网站深圳seo优化方法网站快速排名推广渠道
  • 个人的视频网站如何做营销策划案的模板
  • 网站建设项目清单价格女教师遭网课入侵直播录屏曝
  • 2008iis7怎么搭建网站阿里云网站搭建
  • 湘潭做网站公司郑州网站制作选择乐云seo
  • 网站挂标 怎么做网络广告策划书范文
  • 手机网站二级导航菜单网站排名怎么做
  • 网站上的按钮怎么做微信小程序开发一个多少钱啊
  • 网站建设的概念北京计算机培训机构前十名
  • 做美图 网站有哪些东西吗近期发生的重大新闻
  • 最专业网站建设公司冯耀宗seo视频教程
  • 网站系统建设项目百度一下马上知道
  • 邯郸网站建设品牌加盟广州网站建设系统
  • 存储网站建设网站推广在线推广