8.4 开启 Reduce 输出阶段压缩(最终输出结果压缩)

当 Hive 将输出写入到表中时,输出内容同样可以进行压缩。

属性hive.exec.compress.output控制着这个功能。 用户可能需要保持默认设置文件中的默认值false,这样默认的输出就是非压缩的纯文本文件了。

用户可以通过在查询语句或执行脚本中设置这个值为true,来在当前会话中开启输出结果压缩功能。

步骤1: 开启 Hive 最终输出数据压缩功能

set hive.exec.compress.output=true;

步骤2: 设置 mapreduce 最终数据输出压缩方式

set mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.SnappyCodec;

步骤3: 设置 mapreduce 最终数据输出压缩为块压缩

set mapreduce.output.fileoutputformat.compress.type=BLOCK;

步骤4: 测试一下输出结果是否是压缩文件

insert overwrite local directory '/opt/module/datas/distribute-result' select * from emp distribute by deptno sort by empno desc;

Copyright © 尚硅谷大数据 2019 all right reserved,powered by Gitbook
该文件最后修订时间: 2019-03-16 07:15:56

results matching ""

    No results matching ""