欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Hive怎么實現WordCount

這篇文章將為大家詳細講解有關Hive怎么實現WordCount,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。

站在用戶的角度思考問題,與客戶深入溝通,找到頭屯河網站設計與頭屯河網站推廣的解決方案,憑借多年的經驗,讓設計與互聯(lián)網技術結合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網站建設、成都做網站、企業(yè)官網、英文網站、手機端網站、網站推廣、域名注冊、網絡空間、企業(yè)郵箱。業(yè)務覆蓋頭屯河地區(qū)。

1. 創(chuàng)建一個存放源數據的表(外部表)t_words_src, 表中字段line為string類型, 存放一行單詞

源數據示列: 

hello,tom
hello,jerry
hello,kitty
hello,world
hello,tom
hive> create external table t_words_src (line string)
row format delimited
fields terminated by '\n'    # 按\n來切分字段, 一行就是一個字段
location '/wc/input';    # 源數據路徑為 'hdfs://node1:9000/wc/input' 

hive> select * from t_words;
OK
hello,tom
hello,jerry
hello,kitty
hello,world
hello,tom

2. 創(chuàng)建一個存放所有單詞的表t_words, 表中字段word為string類型, 存放單詞

hive> create table t_words (word string);
hive> insert into table t_words select explode(split(line,',')) as word from t_words_src;

hive> select * from t_words;
OK
hello
tom
hello
jerry
hello
kitty
hello
world
hello
tom

3. 創(chuàng)建一個存放WordCount結果的表t_wc_result, 表中字段word為string類型, 存放單詞, counts為int類型, 存放單詞出現次數

hive> create table t_wc_result (word string, counts int);
hive> insert into table t_wc_result select word as word, count(word) as counts from t_words;

hive> select * from t_wc_result;
OK
hello	5
jerry	1
kitty	1
tom	2
world	1

相對MapReduce來說, Hive的HQL版WordCount寫起來代碼量少很多, 但他們的思想都是一樣的

關于Hive怎么實現WordCount就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

本文名稱:Hive怎么實現WordCount
本文地址:http://chinadenli.net/article38/ppgcsp.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、建站公司、靜態(tài)網站、全網營銷推廣、網站維護、響應式網站

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務器托管