1.hive压缩
hive>set mapred.output.compress=true;
hive> set mapred.compress.map.output=true;hive> set hive.exec.compress.output=true;
hive> set mapred.map.output.compression.codec=org.apache.hadoop.io.compress.BZip2Codec;
hive> set hive.exec.compress.intermediate=true;
hive> set io.compression.codecs=org.apache.hadoop.io.compress.BZip2Codec;
hive> SET io.seqfile.compression.type=BLOCK;
最后hive表数据是.bz2后缀
奇怪现象true false参数在sql脚本中使用可以起作用,而mapred.map.output.compression.codec不起作用,需要在hive的xml中配置。
2.mapreduce压缩
conf.setBoolean("mapred.output.compress", true);
conf.setClass("mapred.output.compression.codec", BZip2Codec.class, CompressionCodec.class);压缩后有后缀
3.hive压缩后的表,可以用使用sql+python调用,数据会自动解压。
说明:
最终的结果数据开启压缩:
<property>
<name>hive.exec.compress.output</name>
<value>true</value>
<description> This controls whether the final outputs of a query (to a local/hdfs file or a hive table) is compressed. The compression codec and
other options are determined from hadoop config variables mapred.output.compress* </description>
</property>
中间的结果数据是否压缩,当sql生成多个MR,最后mr输出不压缩,之前MR的结果数据压缩。
<property>
<name>hive.exec.compress.intermediate</name>
<value>true</value>
<description> This controls whether intermediate files produced by hive between multiple map-reduce jobs are compressed. The compression codec and
other options are determined from hadoop config variables mapred.output.compress* </description>
</property>
<property>
<name>hive.intermediate.compression.codec</name>
<value>org.apache.hadoop.io.compress.LzoCodec</value>
</property>
本文深入探讨了Hive、MapReduce的压缩技术,包括如何设置参数以实现数据压缩,以及压缩后如何在SQL+Python环境中调用并自动解压数据。详细解释了Hive表数据和中间结果数据的压缩策略。
1909

被折叠的 条评论
为什么被折叠?



