为什么要用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