手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Hive中间结果和结果的压缩

[日期:2012-06-11] 来源:Linux社区  作者:inte_sleeper [字体:大 中 小]

配置完以后,可以在job.xml中查看运行的作业的配置是否启用了压缩,也可以使用

Hadoop fs -cat 输出结果文件 | more


来查看是否启用压缩。因为输出结果文件的文件头是标注了文件的格式的,如key和value的类名,以及是否压缩。如果启用压缩,你能看到类似下面的输出:

SEQ"org.apache.hadoop.io.BytesWritableorg.apache.hadoop.io.Text*org.apache.hadoop.io.compress.DefaultCodec...

上面讲的都是输出结果的压缩,map的中间结果也可以启用压缩,而且中间结果对输出结果是没有影响的:

hadoop-site.xml中:

 

<property>
  <name>mapred.compress.map.output</name>
  <value>true</value>
  <description>Should the outputs of the maps be compressed before being
               sent across the network. Uses SequenceFile compression.
  </description>
</property>
<property>
  <name>mapred.map.output.compression.codec</name>
  <value>org.apache.hadoop.io.compress.LzoCodec</value>
  <description>If the map outputs are compressed, how should they be
               compressed?
  </description>
</property>
也可以hive-site.xml中配置:


<property>
  <name>hive.exec.compress.intermediate</name>
  <value>true</value>
  <description>Should the outputs of the maps be compressed before being
               sent across the network. Uses SequenceFile compression.
  </description>
</property>
<property>
  <name>hive.intermediate.compression.codec</name>
  <value>org.apache.hadoop.io.compress.LzoCodec</value>
  <description>If the map outputs are compressed, how should they be
               compressed?
  </description>
</property>


或者直接在HIVE脚本中写:

set hive.exec.compress.intermediate=true;

set hive.intermediate.compression.codec="org.apache.hadoop.io.compress.LzoCodec";

中间结果的压缩,建议采用lzo,因为它速度比较快,不像其他压缩方式比较耗CPU。

当然,如果启用了lzo,也会有上面说的许可证的问题,要保证你的集群机器都单独安装了lzo压缩包。

linux
相关资讯       Hive  Hive使用 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款