bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

hadoop的Hive實戰操作sogou的日志

動手實戰操作搜狗日志文件

創新互聯專注于企業成都營銷網站建設、網站重做改版、正陽網站定制設計、自適應品牌網站建設、H5響應式網站電子商務商城網站建設、集團公司官網建設、成都外貿網站制作、高端網站制作、響應式網頁設計等建站業務,價格優惠性價比高,為正陽等各大城市提供網站開發制作服務。

本節中所用到的內容是來自搜狗實驗室,網址為:

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

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

日志格式如下:

單挑記錄:

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

該文件的格式如下所示:

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

在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

結果如下:

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

導入數據:

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

結果顯示:

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)

查看數據導入情況:

查看記錄條數:

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=<number>

In order to limit the maximum number of reducers:

  set hive.exec.reducers.max=<number>

In order to set a constant number of reducers:

  set mapreduce.job.reduces=<number>

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)

導出數據到外部文件

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文件的內容:

新聞標題:hadoop的Hive實戰操作sogou的日志
文章地址:http://vcdvsql.cn/article0/gjsjio.html

成都網站建設公司_創新互聯,為您提供GoogleApp開發、定制開發服務器托管品牌網站建設、品牌網站設計

廣告

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

綿陽服務器托管