In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to achieve WordCount in Hive. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
1. Create a table (external table) t_words_src that stores the source data. The field line in the table is of type string and holds one line of words.
Source data shows the column:
Hello,tomhello,jerryhello,kittyhello,worldhello,tomhive > create external table t_words_src (line string) row format delimitedfields terminated by'\ n'# Press\ n to split the field. One line is a field. The source data path of location'/ wc/input'; # is' hdfs://node1:9000/wc/input' hive > select * from tweewords.There is OKhello.tomhello.jerryhello.jittyhello.worldhellotom.hello.jerryhello.jittyhello.worldhellotom.jerryhello.jittyhello.World hello.tom
two。 Create a table t _ words that stores all words. The field word in the table is of type string, and the words are stored.
Hive > create table t_words (word string); hive > insert into table t_words select explode (split (line,',')) as word from tasking wordsThe world hellotom
3. Create a table t _ wc_result to store WordCount results. The field word in the table is of string type, the counts is of int type, and the number of occurrence of words is stored.
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 tasking wordsThere is Hive > select * from tincture wcking result: OKhello 5jerry 1kitty 1tom 2world 1
Compared with MapReduce, Hive's HQL version of WordCount has much less code to write, but their ideas are all the same.
On how to achieve Hive WordCount to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.