hive 存储格式和压缩方式 一:Snappy + SequenceFile

本文探讨了在Hive中使用SequenceFile作为存储格式并配合Snappy压缩的原因,包括可分割性和并发读取的优势。引用了《Programming Hive》中的参数设置,并介绍了Hive的两个虚拟列INPUT__FILE__NAME和BLOCK__OFFSET__INSIDE__FILE在文件处理中的作用。
摘要由CSDN通过智能技术生成

为什么要用Sequence File:

a).压缩 b).这种格式可分割,可供多个mapper 并发读取

贴一段《Programming Hive》的:

Compressing files results in space savings but one of the downsides of storing raw
compressed files in Hadoop is that often these files are not splittable. Splittable files
can be broken up and processed in parts by multiple mappers in parallel. Most com-
pressed files are not splittable because you can only start reading from the beginning.
The sequence file format supported by Hadoop breaks a file into blocks and then op-
tionally compresses the blocks in a splittable way.
下面就用它一用

1、设置三个参数:

hive.exec.compress.output 声明对 hive 查询的输出结果进行压缩,并指定压缩方式为 Snappy。

对SequenceFile 有 mapred.output.compression.type,在CDH4中默认就是 BLOCK。

SET hive.exec.compress.output=true;
SET mapred.output.compression.codec=org.apache.hadoop.io.compress.SnappyCodec;
SET mapred.output.compression.type=BLOCK;

               > SET hive.exec.compress.output;
hive.exec.compress.output=false
hive (sequence)> SET hive.exec.compress.output=true;
hive (sequence)> SET mapred.output.compression.codec;
mapred.output.comp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值