日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

大數(shù)據(jù)學(xué)習(xí)路線(xiàn)之hive存儲(chǔ)格式

 好程序員IT 2019-07-30

  大數(shù)據(jù)學(xué)習(xí)路線(xiàn)之hive存儲(chǔ)格式,hive的存儲(chǔ)格式通常是三種:textfile 、 sequencefile 、 rcfile 、 orc 、自定義 set hive.default.fileformat=TextFile; 默認(rèn)存儲(chǔ)格式為:textfile textFile:普通文本存儲(chǔ),不進(jìn)行壓縮。查詢(xún)效率較低。

1.sequencefile:

hive提供的二進(jìn)制序列文件存儲(chǔ),天生壓縮。

sequeceFile 和 rcfile都不允許使用load方式加載數(shù)據(jù)。需要使用insert 方式插入

默認(rèn)支付壓縮、分割,使用便捷、寫(xiě)和查詢(xún)較快。sequencefile和壓縮屬性可以搭配使用。

create table if not exists seq1(
id int,
name string
)
row format delimited fields terminated by '\t'
lines terminated by '\n'
stored as sequencefile
;
###加載數(shù)據(jù)錯(cuò)誤方式
load data local inpath '/home/user' into table seq1;
###加載數(shù)據(jù)正確方式
insert into table seq1
select * from user1
;

2.rcfile:

 rcfile可以進(jìn)行行列混合壓縮,將附近的列和行的數(shù)據(jù)盡量保存到相同的塊里面,該存儲(chǔ)格式會(huì)提高查詢(xún)效率,但是寫(xiě)數(shù)據(jù)較慢。該方式和gzcodeC壓縮屬性結(jié)合不是很好() set mapred.output.compression=true; set mapred.output.compression.codec=org.apache.hadoop.io.compress.GzipCodec;

###創(chuàng)建rcfile表:
create table if not exists rc1(
id int,
name string
)
row format delimited fields terminated by '\t'
stored as rcfile
;
create table if not exists rc2(
id int,
name string
)
row format delimited fields terminated by '\t'
stored as rcfile
;
###加載數(shù)據(jù)錯(cuò)誤方式
load data local inpath '/home/user' into table rc1;
###加載數(shù)據(jù)正確方式
insert into table rc2
select * from user1
;

3.存儲(chǔ)自定義:

數(shù)據(jù): seqyd元數(shù)據(jù)文件: aGVsbG8saGl2ZQ== aGVsbG8sd29ybGQ= aGVsbG8saGFkb29w seqyd文件為base64編碼后的內(nèi)容,decode后數(shù)據(jù)為:

##hello,hive
##hello,world
##hello,hadoop
create table cus(str STRING)  
stored as  
inputformat 'org.apache.hadoop.hive.contrib.fileformat.base64.Base64TextInputFormat'  
outputformat 'org.apache.hadoop.hive.contrib.fileformat.base64.Base64TextOutputFormat';  
LOAD DATA LOCAL INPATH '/home/cus' INTO TABLE cus;

通常是使用 defaultCodec + rcfile搭配效率最好

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多