Amazon web services 蜂巢压缩Orc在Snappy中
使用:Amazon Aws Hive 0.13 尝试:使用snappy压缩输出orc文件Amazon web services 蜂巢压缩Orc在Snappy中,amazon-web-services,compression,hive,snappy,Amazon Web Services,Compression,Hive,Snappy,使用:Amazon Aws Hive 0.13 尝试:使用snappy压缩输出orc文件 create external table output{ col1 string} partitioned by (col2 string) stored as orc location 's3://mybucket' tblproperties("orc.compress"="SNAPPY"); set hive.exec.dynamic.partition=true; set hive.exec.d
create external table output{
col1 string}
partitioned by (col2 string)
stored as orc
location 's3://mybucket'
tblproperties("orc.compress"="SNAPPY");
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.compress.output = true;
set mapred.output.compression.type = BLOCK;
set mapred.output.compression.codec = org.apache.hadoop.io.compress.SnappyCodec;
insert into table output
partition(col2)
select col1,col2 from input;
问题是,当我查看mybucket目录中的输出时,它没有使用SNAPPY扩展名。但是,它是一个二进制文件。将这些orc文件转换为压缩文件并以SNAPPY扩展名输出时,我遗漏了什么设置?orc文件是专门格式的二进制文件。指定orc.compress=SNAPPY时,将使用SNAPPY压缩文件内容。Orc是一种半柱状文件格式 有关数据布局的更多信息,请参阅 流使用编解码器进行压缩,编解码器被指定为该表中所有流的表属性,以优化内存使用,压缩在生成每个块时以增量方式进行。可以跳过压缩块,而无需先解压缩扫描。流中的位置由块开始位置和块中的偏移量表示
简而言之,您的文件是使用Snappy编解码器压缩的,您无法分辨它们是什么,因为文件中的块是实际压缩的块。文件是以特殊格式的二进制文件。指定orc.compress=SNAPPY时,将使用SNAPPY压缩文件内容。Orc是一种半柱状文件格式 有关数据布局的更多信息,请参阅 流使用编解码器进行压缩,编解码器被指定为该表中所有流的表属性,以优化内存使用,压缩在生成每个块时以增量方式进行。可以跳过压缩块,而无需先解压缩扫描。流中的位置由块开始位置和块中的偏移量表示 简而言之,您的文件是使用Snappy编解码器压缩的,您无法判断它们是压缩的,因为文件中的块是实际压缩的块。此外,您可以使用hive-orcfiledump/apps/hive/warehouse/orc/0000000查看文件的详细信息。输出将如下所示:
Reading ORC rows from /apps/hive/warehouse/orc/000000_0 with {include: null, offset: 0, length: 9223372036854775807}
Rows: 6
Compression: ZLIB
Compression size: 262144
Type: struct<_col0:string,_col1:int>
Stripe Statistics:
Stripe 1:
Column 0: count: 6
Column 1: count: 6 min: Beth max: Owen sum: 29
Column 2: count: 6 min: 1 max: 6 sum: 21
File Statistics:
Column 0: count: 6
Column 1: count: 6 min: Beth max: Owen sum: 29
Column 2: count: 6 min: 1 max: 6 sum: 21
....
此外,您可以使用hive-orcfiledump/apps/hive/warehouse/orc/000000\u 0查看文件的详细信息。输出将如下所示:
Reading ORC rows from /apps/hive/warehouse/orc/000000_0 with {include: null, offset: 0, length: 9223372036854775807}
Rows: 6
Compression: ZLIB
Compression size: 262144
Type: struct<_col0:string,_col1:int>
Stripe Statistics:
Stripe 1:
Column 0: count: 6
Column 1: count: 6 min: Beth max: Owen sum: 29
Column 2: count: 6 min: 1 max: 6 sum: 21
File Statistics:
Column 0: count: 6
Column 1: count: 6 min: Beth max: Owen sum: 29
Column 2: count: 6 min: 1 max: 6 sum: 21
....