【发布时间】:2012-07-30 18:32:35
【问题描述】:
如何有效地将数据存储在 Hive 中,并在 Hive 中存储和检索压缩数据? 目前我将它存储为一个文本文件。 我正在查看Bejoy article,我发现 LZO 压缩将有利于存储文件并且它是可拆分的。
我有一个 HiveQL Select 查询正在生成一些输出,我将该输出存储在某处,以便我的一个 Hive 表(质量)可以使用该数据,以便我可以查询该 quality 表。
下面是quality 表,我通过创建用于覆盖表quality 的分区来从下面的SELECT 查询中加载数据。
create table quality
(id bigint,
total bigint,
error bigint
)
partitioned by (ds string)
row format delimited fields terminated by '\t'
stored as textfile
location '/user/uname/quality'
;
insert overwrite table quality partition (ds='20120709')
SELECT id , count2 , coalesce(error, cast(0 AS BIGINT)) AS count1 FROM Table1;
所以目前我将其存储为TextFile,我应该将其设置为Sequence file 并开始将数据存储在LZO compression format 中吗?或者文本文件在这里也可以吗?从选择查询中,我将获得一些 GB 的数据,这些数据需要每天根据表质量上传。
那么哪种方式最好呢?我应该将输出存储为 TextFile 还是 SequenceFile 格式(LZO 压缩),以便在查询 Hive 质量表时,我可以更快地获得结果。意味着查询速度更快。
更新:-
如果我使用块压缩存储为 SequenceFile 会怎样?如下-
set mapred.output.compress=true;
set mapred.output.compression.type=BLOCK;
set mapred.output.compression.codec=org.apache.hadoop.io.compress.LzoCodec;
除了上述之外,我还需要设置一些其他的东西来启用块压缩吗?而且我正在将 Table 创建为 SequenceFile 格式
再次更新
我应该像下面这样创建表格吗?还是需要进行一些其他更改才能使用序列文件启用 BLOCK 压缩?
create table lipy
( buyer_id bigint,
total_chkout bigint,
total_errpds bigint
)
partitioned by (dt string)
row format delimited fields terminated by '\t'
stored as sequencefile
location '/apps/hdmi-technology/lipy'
;
【问题讨论】: