真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

hadoop的Hive實戰(zhàn)操作sogou的日志

動手實戰(zhàn)操作搜狗日志文件

創(chuàng)新互聯(lián)專注于企業(yè)成都營銷網(wǎng)站建設(shè)、網(wǎng)站重做改版、正陽網(wǎng)站定制設(shè)計、自適應品牌網(wǎng)站建設(shè)、H5響應式網(wǎng)站、電子商務商城網(wǎng)站建設(shè)、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應式網(wǎng)頁設(shè)計等建站業(yè)務,價格優(yōu)惠性價比高,為正陽等各大城市提供網(wǎng)站開發(fā)制作服務。

本節(jié)中所用到的內(nèi)容是來自搜狗實驗室,網(wǎng)址為:

http://www.sogou.com/labs/dl/q.html

用戶可以根據(jù)自己的Spark機器實際的內(nèi)存配置等情況選擇下載不同的數(shù)據(jù)版本,為了讓所有的學習者都可以成功操作日志,我們使用的是迷你版本的tar.gz格式的文件,其大小為384K,下載地址:http://www.sogou.com/labs/resource/q.php

日志格式如下:

單挑記錄:

00:00:002982199073774412[360安全衛(wèi)士]8 3download.it.com.cn/softweb/software/firewall/antivirus/20067/17938.html

該文件的格式如下所示:

訪問時間\t用戶ID\t查詢詞\t該URL在返回結(jié)果中的排名\t用戶點擊的順序號\t用戶點擊的URL

在hive中創(chuàng)建表格:

create table sogou(sTime string,userId string,Keyword string,Paiming int,Dianji int,URL string) row format delimited 

fields terminated by '\t' lines terminated by '\n' stored as textfile

結(jié)果如下:

hive> create table sogou(sTime string,userId string,Keyword string,Paiming int,Dianji int,URL string) row format delimited 

    > fields terminated by '\t' lines terminated by '\n' stored as textfile;

OK

Time taken: 4.422 seconds

導入數(shù)據(jù):

load data local inpath  '/home/dyq/Documents/SogouQ.sample' overwrite into table sogou;

結(jié)果顯示:

hive> load data local inpath  '/home/dyq/Documents/SogouQ.sample' overwrite into table sogou;

Loading data to table default.sogou

OK

Time taken: 3.567 seconds

查看表的建立情況:

hive> desc sogou;

OK

stime               string                                  

userid              string                                  

keyword             string                                  

paiming             int                                    

dianji              int                                    

url                 string                                  

Time taken: 2.515 seconds, Fetched: 6 row(s)

查看數(shù)據(jù)導入情況:

查看記錄條數(shù):

select count(*) from sogou;

可以看到查詢過程很漫長,效率不高的說

hive> select count(*) from sogou;

WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. tez, spark) or using Hive 1.X releases.

Query ID = dyq_20160828114648_be63db30-cce4-47f0-aa1d-2e0f626c274c

Total jobs = 1

Launching Job 1 out of 1

Number of reduce tasks determined at compile time: 1

In order to change the average load for a reducer (in bytes):

  set hive.exec.reducers.bytes.per.reducer=

In order to limit the maximum number of reducers:

  set hive.exec.reducers.max=

In order to set a constant number of reducers:

  set mapreduce.job.reduces=

Starting Job = job_1472347049416_0004, Tracking URL = http://ubuntu:8088/proxy/application_1472347049416_0004/

Kill Command = /opt/hadoop-2.6.2/bin/hadoop job  -kill job_1472347049416_0004

Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1

2016-08-28 11:47:28,067 Stage-1 map = 0%,  reduce = 0%

2016-08-28 11:48:09,628 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 8.1 sec

2016-08-28 11:48:35,383 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 10.68 sec

MapReduce Total cumulative CPU time: 10 seconds 680 msec

Ended Job = job_1472347049416_0004

MapReduce Jobs Launched: 

Stage-Stage-1: Map: 1  Reduce: 1   Cumulative CPU: 10.68 sec   HDFS Read: 906303 HDFS Write: 105 SUCCESS

Total MapReduce CPU Time Spent: 10 seconds 680 msec

OK

10000

Time taken: 109.492 seconds, Fetched: 1 row(s)

導出數(shù)據(jù)到外部文件

insert overwrite local directory '/home/dyq/Documents/SogouQdept' select a.Keyword,a.URL from sogou a; 

只導出2個字段,看看情況

hive> insert overwrite local directory '/home/dyq/Documents/SogouQdept' select a.Keyword,a.URL from sogou a; 

WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. tez, spark) or using Hive 1.X releases.

Query ID = dyq_20160828115140_2bc274b4-7845-46c2-9ac7-e45fcc5b7b23

Total jobs = 1

Launching Job 1 out of 1

Number of reduce tasks is set to 0 since there's no reduce operator

Starting Job = job_1472347049416_0005, Tracking URL = http://ubuntu:8088/proxy/application_1472347049416_0005/

Kill Command = /opt/hadoop-2.6.2/bin/hadoop job  -kill job_1472347049416_0005

Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0

2016-08-28 11:51:54,594 Stage-1 map = 0%,  reduce = 0%

2016-08-28 11:52:06,398 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 3.14 sec

MapReduce Total cumulative CPU time: 3 seconds 140 msec

Ended Job = job_1472347049416_0005

Moving data to local directory /home/dyq/Documents/SogouQdept

MapReduce Jobs Launched: 

Stage-Stage-1: Map: 1   Cumulative CPU: 3.14 sec   HDFS Read: 901894 HDFS Write: 178503 SUCCESS

Total MapReduce CPU Time Spent: 3 seconds 140 msec

OK

Time taken: 28.859 seconds

查看sogouQdept文件的內(nèi)容:


名稱欄目:hadoop的Hive實戰(zhàn)操作sogou的日志
當前網(wǎng)址:http://weahome.cn/article/gjsjio.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部