2020大資料資料處理綜合練習

2021-10-01 23:21:03 字數 2892 閱讀 9642

@override

protected void map(longwritable key, text value, context context) throws ioexception, interruptedexception else if (line.length>10)

relatedids=newrelatedid.substring(0,newrelatedid.lastindexof(","));

}//處理整段資料

string data=value.tostring().replace(line[3],category);

string orelatedids=value.tostring().substring(value.tostring().indexof(line[9]));

//最終資料

string finaldata=data.replace(orelatedids,relatedids);

//context.write(key,new text(finaldata));

}}}

reducer:

public class reducer02 extends reducer}}

driver:

public class driver02 extends configured implements tool 

public static void main(string args) throws exception

}

util:

public class util 

return categorys.substring(0,categorys.lastindexof(","));

}return category;}}

把預處理之後的資料進行入庫到hive中

roi:

create table video_user_ori(

uploader string,

videos string,

friends string)

row format delimited

fields terminated by ","

stored as textfile;

orc:

create table video_user_orc(

uploader string,

videos string,

friends string)

row format delimited

fields terminated by ","

stored as orc;

load data local inpath '/opt/user.txt' into table video_user_ori;
insert into table video_user_orc select * from video_user_ori;
對入庫之後的資料進行hivesql查詢操作

hive -e "select * from video.video_orc where rate=5 " > 5.txt
把hive分析出的資料儲存到hbase中

建立rate外部表的語句:

create external  table rate(

videoid string,

uploader string,

age string,

category string,

length string,

views string,

rate string,

ratings string,

comments string,

relatedid string)

row format delimited

fields terminated by "\t"

stored as textfile;

load data local inpath '/opt/5.txt' into table rate;
建立hive hbase對映表:

create table video.hbase_rate(

videoid string,

uploader string,

age string,

category string,

length string,

views string,

rate string,

ratings string,

comments string,

relatedid string)

stored by 'org.apache.hadoop.hive.hbase.hbasestoragehandler'

tblproperties("hbase.table.name" = "hbase_rate");

插入資料:

結果:

大資料處理

大資料處理的流程主要包括以下四個環節 採集 匯入 預處理 統計 分析 挖掘,下面針對這四環節進行簡單闡述。大資料處理之一 採集 在大資料的採集過程中,其主要特點和挑戰是併發數高,因為同時有可能會有成千上萬的使用者來進行訪問和操作,比如火車票售票 和 它們併發的訪問量在峰值時達到上百萬,所以需要在採集...

大資料資料處理分析

案例1 假設乙個檔案中有9億條不重複的9位整數,現在要求對這個檔案進行排序。方法 bit 位操作 首先32位機的定址能力是 2的32次方,即4g.定址能力最大是這樣了.乙個最大的9位整數為999999999 這9億條資料是不重複的 宣告乙個bit陣列,長度為10億 一共需要10億 8 1024 10...

大資料處理隨筆

1.mssql當資料庫資料超過1000萬的時候超時是正常的,所以當表資料到1000萬時候注意delete 2.今天遇到資料庫時間格式2014021000 當然是int型別哦 3.聯合索引使用 開始時間與結束時間這樣一起查詢的要建成索引 4.訂閱資料庫,只可以查詢操作,這樣的話可以在這個表上面建立索引...