ORC支持三种压缩:ZLIB,SNAPPY,NONE。最后一种就是不压缩,orc默认采用的是ZLIB压缩。
1.创建一个不压缩的ORC存储方式表
create table test_orc_none (
track_time string,
url string,
ip string
)
row format delimited fields terminated by '\t'
stored as orc tblproperties("orc.compress"="NONE") ;
insert into table test_orc_none select * from test_text ;
查看表的数据量大小:
hdfs -du -h /user/hive/warehouse/test_orc_none;
| 7.7 M /user/hive/warehouse/test_orc_none/000000_0 |
2.创建一个snappy压缩的ORC存储方式表
create table test_orc_snappy (
track_time string,
url string,
ip string
)
row format delimited fields terminated by '\t'
stored as orc tblproperties("orc.compress"="SNAPPY") ;
insert into table test_orc_snappy select * from test_text ;
查看表的数据量大小:
hdfs -du -h /user/hive/warehouse/test_orc_snappy;
| 3.8 M /user/hive/warehouse/test_orc_snappy/000000_0 |
3.创建一个ZLIB压缩的ORC存储方式表(默认方式)
- 不指定压缩格式的就是默认的采用ZLIB压缩
- 可以参考上面创建的 test_orc 表
查看表的数据量大小:
hdfs -du -h /user/hive/warehouse/test_orc;
| 2.8 M /user/hive/warehouse/test_orc/000000_0 |
4.存储方式和压缩总结
- orc 默认的压缩方式ZLIB比Snappy压缩的还小。
- 在实际的项目开发当中,hive表的数据存储格式一般选择:orc或parquet。
- 由于snappy的压缩和解压缩 效率都比较高,压缩方式一般选择snappy。