hive應用例項1

wangmm0218發表於2014-05-07

 我們沿用之前hadoop  wordcount的結果資料:

[hadoop@icity0 ~]$ hadoop fs -cat /wc/out/part-r-00000
Warning: $HADOOP_HOME is deprecated.


beautiful 1
day 1
dear 2
hello 2
hometown 1
honey 2
is 2
my 2
one 1
sunny 1
this 1
today 1
world 3


現在我們在hive上新建一張wordcount的資料表,然後將hdfs 中的/wc/out/part-r-00000資料匯入到hive中:

cd hive/bin

./hive

 CREATE TABLE wordcount(name string,id int) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';

 LOAD DATA INPATH 'hdfs://icity0:9000/wc/out/part-r-00000' INTO TABLE wordcount;


查詢wordcount資料表:



統計wordcount 資料表中的不同的單詞個數,及count



從這個結果中,其實可以看出,我們之前所說的結論:

查詢是通過MapReduce來完成的(並不是所有的查詢都需要MapReduce來完成,比如select * from XXX就不需要;


相關文章