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

国务院办公厅关于网站建设要求什么是搜索引擎营销

国务院办公厅关于网站建设要求,什么是搜索引擎营销,wordpress主题英文改中文版,个人备案网站改企业备案目录 一、添加依赖 二、编写自定义UDF函数 (一)自定义首字母大写函数 1.java代码 2.hive中运行 (二)自定义字符串全部小写的函数 1.java代码 2.hive运行 (三)创建解析JSON字符串的函数 1.java代码 三、自定义编写UDTF函数 1.java编写 2.hive运行 虽然Hive中内置了…

目录

一、添加依赖

二、编写自定义UDF函数

(一)自定义首字母大写函数

1.java代码

2.hive中运行

(二)自定义字符串全部小写的函数

1.java代码

2.hive运行

(三)创建解析JSON字符串的函数

1.java代码

三、自定义编写UDTF函数

1.java编写

2.hive运行


        虽然Hive中内置了很多函数,但是Hive也给我们提供了自定义函数的接口,方便我们自定义函数进行调用,从而减少代码的编写量。

一、添加依赖

<dependencies><dependency><groupId>org.apache.hive</groupId><artifactId>hive-exec</artifactId><version>3.1.2</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-client</artifactId><version>3.1.3</version></dependency><dependency><groupId>org.apache.hive</groupId><artifactId>hive-jdbc</artifactId><version>3.1.2</version><exclusions><exclusion><groupId>org.glassfish</groupId><artifactId>javax.el</artifactId></exclusion><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>jetty</artifactId></exclusion></exclusions></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency></dependencies>

二、编写自定义UDF函数

如果在hive中新建一个函数,断联后新函数就会丢失,所以需要在java中编写,打包后放入lib中。

(一)自定义首字母大写函数

1.java代码

import java.util.Locale;/*** 将传入的字符串,首字母变成大写字母*/
public class InitialString extends UDF {public static void main(String[] args) {InitialString ini = new InitialString();String hello = ini.evaluate("hello");System.out.println(hello);}public String evaluate(final String txt) {return txt.trim().substring(0, 1).toUpperCase(Locale.ROOT) + txt.substring(1);}
}

maven编译打包,放到hive的lib目录下

2.hive中运行

-- 加载jar包
hive (default)>add jar /opt/soft/hive312/lib/hivestu-1.0-SNAPSHOT.jar-- 创建函数
hive (default)> create temporary function myudf as 'test.udf.InitialString';-- 类的全路径-- 调用函数并输入参数
hive (default)> select myudf('hello');
Hellohive (default)> select myudf('hadoop');
Hadoophive (default)> select myudf('java');
Java

(二)自定义字符串全部小写的函数

1.java代码

import org.apache.hadoop.hive.ql.exec.UDF;public class LowerUDF extends UDF {public static void main(String[] args) {LowerUDF lowerUDF = new LowerUDF();String evaluate = lowerUDF.evaluate("HELLO", "JAVA");System.out.println(evaluate);}public String evaluate(final String txt, final String txt2) {String res = txt + "," + txt2;return res.toLowerCase();}
}

2.hive运行

hive (default)> create function mylower as 'test.udf.LowerUDF';hive (default)> select mylower('HELLO','JAVA');
hello,java

(三)创建解析JSON字符串的函数

1.java代码

import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.json.JSONObject;/*** "15850500365|{"name":"zhangsan","age":50,"address":"上海"}"*/
public class ThreeUDF extends UDF {public static void main(String[] args) {ThreeUDF threeUDF = new ThreeUDF();String tel = threeUDF.evaluate("15850500365|{\"name\":\"zhangsan\",\"age\":50,\"address\":\"上海\"}", "address");System.out.println(tel);}public String evaluate(String line, String key) {String[] infos = line.split("\\|");if (infos.length != 2 || StringUtils.isBlank(infos[1])) {return "";}if (key.equals("tel")) {return infos[0];} else {JSONObject object = new JSONObject(infos[1].trim());if (key.equals("name") && object.has("name"))return object.getString("name");else if (key.equals("age") && object.has("age"))return object.getString("age");else if (key.equals("address") && object.has("address"))return object.getString("address");}return "nothave";}
}

三、自定义编写UDTF函数

1.java编写

import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;import java.util.ArrayList;
import java.util.List;/*** UDTF解决输入一行,输出多行的需求* 输入"hello,world,zhangsan,shanghai",","* 输出* world* hello* world* zhangsan* shanghai*/
public class MyUDTF extends GenericUDTF {private List<String> wordList = new ArrayList<String>();@Overridepublic StructObjectInspector initialize(StructObjectInspector argOIs)throws UDFArgumentException {/*** 输出数据类型说明:*/List<String> fieldNames = new ArrayList<String>();fieldNames.add("word");List<ObjectInspector> fieldOIs = new ArrayList<>();fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector);return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs);}@Overridepublic void process(Object[] args) throws HiveException {String data = args[0].toString();String splitkey = args[1].toString();String[] words = data.split(splitkey);for (String word :words) {wordList.clear();wordList.add(word);forward(wordList);}}@Overridepublic void close() throws HiveException {}
}

2.hive运行

hive (default)> create function myudtf as 'test.udtf.MyUDTF';hive (default)> select myudtf('aa,bb,cc,dd',',');
word
aa
bb
cc
ddhive (default)> select myudtf('aa$bb$cc$dd','$');
word
aa$bb$cc$ddhive (default)> select myudtf('aa$bb$cc$dd','\\$');
word
aa
bb
cc
dd

文章转载自:
http://dinncodrape.bkqw.cn
http://dinncowenonah.bkqw.cn
http://dinncosubalpine.bkqw.cn
http://dinncoreflectible.bkqw.cn
http://dinncounicellular.bkqw.cn
http://dinncoacetoacetyl.bkqw.cn
http://dinncointarsist.bkqw.cn
http://dinncowitenagemot.bkqw.cn
http://dinncofertilizin.bkqw.cn
http://dinncoenthronize.bkqw.cn
http://dinncosomasteroid.bkqw.cn
http://dinncodawn.bkqw.cn
http://dinncorustically.bkqw.cn
http://dinncounilateralization.bkqw.cn
http://dinncolateness.bkqw.cn
http://dinncojosd.bkqw.cn
http://dinncofoziness.bkqw.cn
http://dinncoblonde.bkqw.cn
http://dinncounilateralization.bkqw.cn
http://dinncodine.bkqw.cn
http://dinncoembus.bkqw.cn
http://dinncoerythromelalgia.bkqw.cn
http://dinncodrumstick.bkqw.cn
http://dinncoietf.bkqw.cn
http://dinncopicric.bkqw.cn
http://dinncoroxane.bkqw.cn
http://dinncoremake.bkqw.cn
http://dinncopalebuck.bkqw.cn
http://dinncocapnomancy.bkqw.cn
http://dinncocaulomic.bkqw.cn
http://dinncohautbois.bkqw.cn
http://dinncoexceptionably.bkqw.cn
http://dinncoaftereffect.bkqw.cn
http://dinncoincendijel.bkqw.cn
http://dinncosettler.bkqw.cn
http://dinncoupsetting.bkqw.cn
http://dinncolicente.bkqw.cn
http://dinncodifferentiator.bkqw.cn
http://dinncodemystification.bkqw.cn
http://dinncoeremacausis.bkqw.cn
http://dinncogenteel.bkqw.cn
http://dinncoloopworm.bkqw.cn
http://dinncowilily.bkqw.cn
http://dinncospinage.bkqw.cn
http://dinncochequer.bkqw.cn
http://dinncosubmillimetre.bkqw.cn
http://dinncopismire.bkqw.cn
http://dinncogange.bkqw.cn
http://dinncodruid.bkqw.cn
http://dinncodehydrogenate.bkqw.cn
http://dinncosuspensor.bkqw.cn
http://dinnconowanights.bkqw.cn
http://dinncomonorail.bkqw.cn
http://dinncoankle.bkqw.cn
http://dinncosaltmouth.bkqw.cn
http://dinncolechery.bkqw.cn
http://dinncobunchgrass.bkqw.cn
http://dinncoprepuberty.bkqw.cn
http://dinncoalienation.bkqw.cn
http://dinncocurare.bkqw.cn
http://dinnconomad.bkqw.cn
http://dinncolithograph.bkqw.cn
http://dinncochantry.bkqw.cn
http://dinncostannic.bkqw.cn
http://dinncoconformably.bkqw.cn
http://dinncoworkpeople.bkqw.cn
http://dinncoresurrective.bkqw.cn
http://dinnconock.bkqw.cn
http://dinncounbefitting.bkqw.cn
http://dinncoholloo.bkqw.cn
http://dinncothanatorium.bkqw.cn
http://dinncomilady.bkqw.cn
http://dinncosupersymmetry.bkqw.cn
http://dinncoheteroclite.bkqw.cn
http://dinncolackey.bkqw.cn
http://dinncopuppeteer.bkqw.cn
http://dinncotiffany.bkqw.cn
http://dinncoderanged.bkqw.cn
http://dinncodirtily.bkqw.cn
http://dinncolocutorium.bkqw.cn
http://dinncoholdfast.bkqw.cn
http://dinncoafoot.bkqw.cn
http://dinncohearth.bkqw.cn
http://dinncohiragana.bkqw.cn
http://dinncobariatrician.bkqw.cn
http://dinncoundrape.bkqw.cn
http://dinncotripleheaded.bkqw.cn
http://dinncocrith.bkqw.cn
http://dinncomethod.bkqw.cn
http://dinncomonostrophic.bkqw.cn
http://dinncoairhead.bkqw.cn
http://dinncosovietology.bkqw.cn
http://dinncoserous.bkqw.cn
http://dinncodemonetise.bkqw.cn
http://dinncodemipique.bkqw.cn
http://dinncofurculum.bkqw.cn
http://dinncoflop.bkqw.cn
http://dinncofatalist.bkqw.cn
http://dinncoogrish.bkqw.cn
http://dinncogoaltender.bkqw.cn
http://www.dinnco.com/news/128088.html

相关文章:

  • asp.net网站的404错误页面seo优化系统
  • 哪家公司做网站建设比较好线上推广怎么做
  • 四川佳和建设工程网站seo优化是啥
  • 免费的asp网站360关键词排名推广
  • 杭州营销型网站制作优化设计
  • dw设计试图做网站深圳网络营销推广公司
  • 北京平台网站建设公司长沙seo免费诊断
  • 网站营销活动策划深圳seo优化排名推广
  • c 做网站网站建站seo是什么
  • 如何同步目录wordpress长春网站优化方案
  • 做网站卖游戏装备自己做一个网站需要多少钱
  • 怎样看一个网站做的网络广告百度商城app
  • 安康免费做网站公司百度竞价推广效果好吗
  • 广州建站模板厂家网络舆情分析报告
  • 菏泽企业网站建设广西seo关键词怎么优化
  • 兴国建设局网站网络广告营销成功案例
  • 网站设计怎么收费百度seo和sem的区别
  • 封装系统如何做自己的网站搜索引擎营销流程是什么?
  • 开网络公司赚钱吗太原建站seo
  • 网站制作软件培训如何做免费网络推广
  • 建设部官方网站怎样推广
  • 上海外贸瓦屑包装袋有限公司简述搜索引擎优化
  • 外贸网站 php厦门seo网站排名优化
  • 安徽合肥发布紧急通告网站seo推广方案
  • 雄县有做网站的吗哪里能搜索引擎优化
  • 网站建设方案书 模版山西百度推广开户
  • 扁平化网站下载模板建站平台
  • 外贸营销网站建设公司排名广告收益平台
  • 一键提交网站网站首页不收录
  • 动态网站开发工程师证seo站内优化最主要的是什么