[Hive_add_9] Hive 的存儲格式
阿新 • • 發佈:2019-01-12
qfile 導入 說明 reat NPU 1.4 create 進入 大小
0. 說明
Hive 的存儲格式 | textfile | sequencefile | rcfile | orc | parquet |
1. Hive的存儲格式
1.1 textfile
行式存儲
1.2 sequencefile
二進制的k-v對,行式存儲
配置塊壓縮
SET hive.exec.compress.output=true;
SET io.seqfile.compression.type=BLOCK;
1.3 rcfile
列式存儲
先將數據進行橫切(4M),成為行組,行組內又縱向切割分為多個字段
1.4 orc
列式存儲
比 rc 文件更大的塊(256M),優化磁盤的線性讀取,通過指定的編碼器確定數據類型並優化壓縮
還存儲了基本統計數據,比如 min,max,sum,count。。。
1.5 parquet
列式存儲
適用範圍更廣(在 Hadoop 生態系統中)
適用於嵌套文件格式
2. 測試
2.0 前期配置
設置 Hive自動使用本地模式
SET hive.exec.mode.local.auto=true;
輸入文件大小低於此值會進入本地模式
SET hive.exec.mode.local.auto.inputbytes.max=500000000;
輸入文件個數低於此值會進入本地模式
SET hive.exec.mode.local.auto.input.files.max=5;
設置seqFile使用塊壓縮
SET hive.exec.compress.output=true; SET io.seqfile.compression.type=BLOCK;
2.1 建表
create table user_seq(id int, name string, pass string, email string, nickname string) stored as SEQUENCEFILE; createtable user_rc(id int, name string, pass string, email string, nickname string) stored as rcfile; create table user_orc2(id int, name string, pass string, email string, nickname string) stored as orc tblproperties("orc.compress"="ZLIB"); create table user_parquet2(id int, name string, pass string, email string, nickname string) stored as parquet tblproperties("parquet.compression"="GZIP");
2.2 插入數據
導入大文件
load data local inpath ‘/home/centos/files/user_nopar.txt‘ into table user_nopar;
插入數據
insert into user_seq select * from user_nopar; insert into user_rc select * from user_nopar; insert into user_orc2 select * from user_nopar; insert into user_parquet2 select * from user_nopar;
2.3 性能比較
[Hive_add_9] Hive 的存儲格式