hive的压缩

hive支持存储的表的文件压缩,压缩可以减少空间,但同时耗费性能

建表语句

create  table if not exists tb02(name string,age  int ,male varchar(2) )row format delimited fields terminated by "," stored as sequencefile;

hive支持的压缩格式:

在这里插入图片描述

开启压缩

hive > set ---> 查看所有参数
hive > set hive.exec.compress.intermediate=true -- 开启中间 压缩
     > set mapred.map.output.compression.codec = CodeName
    	 #结果压缩
     > set hive.exec.compress.output=true
     > set mapred.map.output.compression.type = BLOCK/RECORD 

注意:SequenceFile、RCFile、ORC格式的表不能直接从本地文件导入数据,数据要先导入到TextFile格式的表中,然后再从TextFile表中用insert导入到SequenceFile、RCFile表中。也就是

INSERT OVERWRITE TABLE raw_sequence SELECT * FROM raw;

hive导入hdfs上的压缩文件

导入的是压缩文件:

CREATE TABLE raw (line STRING)
   ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';
 
LOAD DATA LOCAL INPATH '/tmp/weblogs/20090603-access.log.gz' INTO TABLE raw;

为了效率可以:

CREATE TABLE raw (line STRING)
   ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';
 
CREATE TABLE raw_sequence (line STRING)
   STORED AS SEQUENCEFILE;
 
LOAD DATA LOCAL INPATH '/tmp/weblogs/20090603-access.log.gz' INTO TABLE raw;
 
SET hive.exec.compress.output=true;
SET io.seqfile.compression.type=BLOCK; 
INSERT OVERWRITE TABLE raw_sequence SELECT * FROM raw;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值