大数据开发工程师-第九周 Hive扩展内容 常见数据存储格式的使用

大数据开发工程师-第九周 Hive扩展内容 常见数据存储格式的使用

数据存储格式

1
2
在最开始学习Hive的时候我们说到了,Hive没有专门的数据存储格式,默认可以直接加载文本文件TextFile,还支持SequenceFile、RCFile这些。
其实完整来说,主要包括下面这些数据存储格式。

image-20240721163746302

1
2
3
4
其中RCFile数据存储格式是从Hive 0.6版本开始支持的。
Avro数据存储格式是从Hive 0.9版本开始支持的。
ORC数据存储格式是从Hive 0.11版本开始支持的。
PARQUET数据存储格式是Hive 0.13版本开始支持的。
1
2
这些信息主要来源于Hive官网。
https://cwiki.apache.org/confluence/display/Hive/

image-20240721163840325

image-20240721163851105

1
2
3
4
5
6
7
8
目前工作中使用最多的是TextFile、ORC和Parquet。

默认情况下使用TextFile即可,想要提高数据存储和计算效率,可以考虑使用ORC或者Parquet。

本次课程中我们主要演示TextFile、SequenceFile、RCFile、ORC、以及PARQUET的用法。
Avro存储格式在这里不再详细分析,因为这个基本上用不到。

下面首先分析一下TextFile。

数据存储格式之TextFile 2.09g

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
TextFile是Hive的默认数据存储格式,基于行存储。
它的主要特点是磁盘存储开销大,数据解析开销大。

怎么理解呢?

磁盘存储开销大:因为存储的是原始文件内容,没有使用压缩,所以存储开销会比较大。
数据解析开销大:因为在反序列化读取数据的过程中,必须逐个字符判断是不是字段分隔符和行结束符,所以数据解析开销大。

当然了,如果想要减少磁盘存储开销,也可以对TextFile格式的数据进行压缩,但是部分压缩格式在Hive中无法切割。

数据的压缩格式其实是在MapReduce中提出的,因为Hive底层支持MapReduce,所以Hive中也支持这些压缩格式。

在这里做一个试验,验证一下Hive中如何集成这些数据压缩格式,以及对数据切分的支持程度。

首先在Hive中创建一个不带压缩的普通表。
1
2
3
4
5
6
7
8
create external table stu_textfile(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
location 'hdfs://bigdata01:9000/stu_textfile';
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
然后生成测试数据,并把测试数据加载到这个表中。
生成测试数据的代码如下:
package com.imooc.hive;

import java.io.BufferedWriter;
import java.io.FileWriter;

/**
* Created by xuwei
*/
public class GenerateHiveData {
public static void main(String[] args) throws Exception{
String fileName = "D:\\stu_textfile.dat";
System.out.println("start: 开始生成文件->"+fileName);
BufferedWriter bfw = new BufferedWriter(new FileWriter(fileName));
int num = 0;
while(num<60000000){
bfw.write("1"+num+",zs"+num+",beijing"+num);
bfw.newLine();
num ++;
if(num%10000==0){
bfw.flush();
}
}
System.out.println("end: 文件已生成");
}
}
1
2
3
4
5
6
7
8
9
将这个数据文件上传到Hive表stu_textfile对应的hdfs目录中。
hdfs dfs -put stu_textfile.dat /stu_textfile

确认通过表stu_textfile是否可以查到数据:
hive (default)> select * from stu_textfile limit 1;
OK
stu_textfile.id stu_textfile.name stu_textfile.city
10 zs0 beijing0
Time taken: 1.936 seconds, Fetched: 1 row(s)

使用Defalte压缩格式 388m

1
2
接下来基于stu_textfile这个普通数据表构建一个新的压缩数据表。
创建这个压缩数据表:建表语句和普通表没有区别,唯一的区别就是在向表中添加数据的时候指定数据压缩格式。
1
2
3
4
5
6
7
8
create external table stu_textfile_deflate_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
location 'hdfs://bigdata01:9000/stu_textfile_deflate_compress';
1
2
3
4
5
6
7
8
9
Hive中默认是没有开启压缩的,想要开启压缩需要使用下面这条命令:
hive (default)> set hive.exec.compress.output=true;
hive (default)> set mapreduce.output.fileoutputformat.compress=true;
hive (default)> set mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.DeflateCodec;

这条命令表示开启Hive输出数据压缩功能,并且设置使用deflate压缩格式。
如果后期不确定使用的是哪种压缩格式,可以通过这条命令查看:
hive (default)> set mapreduce.output.fileoutputformat.compress.codec;
mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.DeflateCodec
1
2
3
4
5
6
7
8
接下来通过insert into select从普通表中查询数据,插入到压缩表中。

注意:为了能够控制任务最终产生的数据文件个数,在这里通过mapreduce.job.reduces来控制,并且SQL语句中需要有可以产生shuffle的操作,如果是普通的select语句,最终是不会产生Reduce任务的,那么mapreduce.job.reduces这个参数就无法生效了。

在这里我们设置mapreduce.job.reduces=1,表示将结果数据写入到一个数据文件中,这也便于后面验证这个数据文件是否支持Split。
hive (default)> set mapreduce.job.reduces=1;
hive (default)>insert into stu_textfile_deflate_compress select id,name,city from stu_textfile group by id,name,city;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
最终产生的结果数据是这样的:
[root@bigdata04 ~]# hdfs dfs -ls /stu_textfile_deflate_compress
Found 1 items
-rw-r--r-- 2 root supergroup 407444004 2027-08-25 17:18 /stu_textfile_deflate_compress/000000_0.deflate
这个结果数据文件大小为388M。

接下来写一个sql查询压缩表中的数据,确认一下是否会生成多个Map任务。
hive (default)> select id,count(*) from stu_textfile_deflate_compress group by id;
Query ID = root_20270825172055_a11694bd-92f8-4e1b-b813-ddf31f0fa746
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Defaulting to jobconf value of: 1
In order to change the average load for a reducer (in bytes):
set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
set mapreduce.job.reduces=<number>
Starting Job = job_1819179801908_0003, Tracking URL = http://bigdata01:8088/proxy/application_1819179801908_0003/
Kill Command = /data/soft/hadoop-3.2.0/bin/mapred job -kill job_1819179801908_0003
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1
1
2
3
4
5
6
在这里发现这个SQL最终只生成了1个Map任务,也就意味着这个388M的文件是有一个Map任务负责计算。

所以在Hive中,deflate压缩格式的特点和我们前面分析的也是一样的。

这个压缩表中的数据查看后最好删除一下,这样可以释放HDFS存储空间。
hdfs dfs -rm -r -skipTrash /stu_textfile_deflate_compress

使用Bzip2压缩格式 189m

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
再来验证一下Bzip2压缩格式。
创建压缩表:
create external table stu_textfile_bzip2_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
location 'hdfs://bigdata01:9000/stu_textfile_bzip2_compress';

指定bzip2压缩格式:
hive (default)> set hive.exec.compress.output=true;
hive (default)> set mapreduce.output.fileoutputformat.compress=true;
hive (default)> set mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.BZip2Codec;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
从普通表中查询数据插入到压缩表中。
hive (default)> set mapreduce.job.reduces=1;
hive (default)> insert into stu_textfile_bzip2_compress select id,name,city from stu_textfile group by id,name,city;

最终产生的结果数据是这样的:
[root@bigdata04 ~]# hdfs dfs -ls /stu_textfile_bzip2_compress
Found 1 items
-rw-r--r-- 2 root supergroup 199210105 2027-08-25 17:37 /stu_textfile_bzip2_compress/000000_0.bz2

这个数据文件大小为189M。

接下来写一个sql查询压缩表中的数据,确认一下是否会生成多个Map任务。
hive (default)> select id,count(*) from stu_textfile_bzip2_compress group by id;
Query ID = root_20270825174140_50d2ff59-69ea-4f8f-a149-76897b7a8b90
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Defaulting to jobconf value of: 1
In order to change the average load for a reducer (in bytes):
set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
set mapreduce.job.reduces=<number>
Starting Job = job_1819179801908_0006, Tracking URL = http://bigdata01:8088/proxy/application_1819179801908_0006/
Kill Command = /data/soft/hadoop-3.2.0/bin/mapred job -kill job_1819179801908_0006
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1
1
2
3
4
5
6
7
8
9
结果发现只产生了1个Map任务,正常情况下这份数据会被切分成2个Split,产生2个Map任务的,为什么这里只有1个Map任务呢?

难道是在Hive中,Bzip2不支持切分了?
不是这样的。
原因是:因为Hive中默认的Split大小是244M,这个结果文件小于244M,所以Hive最终只切分了1个Split,也就只产生了1个Map任务。

Hive在读取数据的时候目前使用的是CombineHiveInputFormat,可以这样确认一下:
hive (default)> set hive.input.format;
hive.input.format=org.apache.hadoop.hive.ql.io.CombineHiveInputFormat;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CombineHiveInputFormat中在切分Split的时候会参考mapred.max.split.size参数的值。
mapred.max.split.size参数的值在Hive中默认是244M。
hive (default)> set mapred.max.split.size;
mapred.max.split.size=256000000

所以Bzip2还是支持切分的,只是因为这个文件大小没有超过244M。
我们可以在这里调整mapred.max.split.size参数的值,改为128M来验证一下。
hive (default)> set mapred.max.split.size=134217728;
hive (default)> select id,count(*) from stu_textfile_bzip2_compress group by id;
Query ID = root_20270825174607_43ac6b00-93e6-4a96-b53b-75ddd1dddfd9
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Defaulting to jobconf value of: 1
In order to change the average load for a reducer (in bytes):
set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
set mapreduce.job.reduces=<number>
Starting Job = job_1819179801908_0007, Tracking URL = http://bigdata01:8088/proxy/application_1819179801908_0007/
Kill Command = /data/soft/hadoop-3.2.0/bin/mapred job -kill job_1819179801908_0007
Hadoop job information for Stage-1: number of mappers: 2; number of reducers: 1
1
2
这个时候发现产生了2个Map任务,最终可以确认,在Hive中Bzip2压缩文件也是支持切分的。
这个压缩表中的数据查看后最好也删除一下,这样可以释放HDFS存储空间。

数据存储格式之SequenceFile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
下面我们来看一下SequenceFile这种存储格式
其实我们前面在Hadoop课程中分析小文件解决方案的时候就讲过SequenceFile了。

它是一种二进制文件,内部数据是<Key,Value>的形式,也属于行存储。

它的特点是使用方便,MapReduce原生支持这种数据格式,并且它还支持切分,也支持压缩。

可以支持NONE、RECORD、BLOCK 级别的压缩。

NONE表示不压缩
RECORD表示行级别的压缩
Block表示块级别的压缩
由于Record是针对每一条数据分别进行压缩,压缩率比较低,所以一般都会选择Block压缩。

下面我们来演示一下具体的用法。

注意:为了避免在学习阶段导致Hive中参数混乱,建议每次验证不同数据存储格式的时候都重新开启一个新的Hive会话。

不使用压缩 2.7g

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
先不使用压缩,创建一个SequenceFile存储格式的表。
注意:在这需要使用stored as指定sequencefile存储格式,不指定的话默认是textfile。所以我们前面在创建表的时候其实都省略了这个配置。
create external table stu_seqfile_none_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as sequencefile
location 'hdfs://bigdata01:9000/stu_seqfile_none_compress';

确认一下这个表:
hive (default)> show create table stu_seqfile_none_compress;
OK
createtab_stmt
CREATE EXTERNAL TABLE `stu_seqfile_none_compress`(
`id` int,
`name` string,
`city` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'line.delim'='\n',
'serialization.format'=',')
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.SequenceFileInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat'
LOCATION
'hdfs://bigdata01:9000/stu_seqfile_none_compress'
TBLPROPERTIES (
'bucketing_version'='2',
'transient_lastDdlTime'='1819270622')
Time taken: 0.082 seconds, Fetched: 19 row(s)
1
2
3
4
5
6
7
8
9
10
如果INPUTFORMAT使用的是SequenceFileInputFormat,说明这个表中需要存储SequenceFile格式的数据。

然后从普通表中查询数据导入到这个SequenceFile存储格式的表中。
hive (default)> set mapreduce.job.reduces=1;
hive (default)> insert into stu_seqfile_none_compress select id,name,city from stu_textfile group by id,name,city;

产生的结果数据是这样的:
[root@bigdata04 ~]# hdfs dfs -ls /stu_seqfile_none_compress
Found 1 items
-rw-r--r-- 2 root supergroup 2907234377 2027-08-26 11:25 /stu_seqfile_none_compress/000000_0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
注意:这个文件在2.7G左右,比原始的TextFile文件还要大,原始的TextFile文件才2.09G。

验证是否支持切分:
hive (default)> hive (default)> select id,count(*) from stu_seqfile_none_compress group by id;
Query ID = root_20270826113636_fb67ba8f-82d7-4672-9641-3b34b90282d1
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Defaulting to jobconf value of: 1
In order to change the average load for a reducer (in bytes):
set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
set mapreduce.job.reduces=<number>
Starting Job = job_1819247895426_0003, Tracking URL = http://bigdata01:8088/proxy/application_1819247895426_0003/
Kill Command = /data/soft/hadoop-3.2.0/bin/mapred job -kill job_1819247895426_0003
Hadoop job information for Stage-1: number of mappers: 11; number of reducers: 1
1
2
3
4
5
6
7
可以看到产生了11个map任务,说明SequenceFile格式的文件支持切分。

这个SequenceFile格式的文件中的数据是什么样子的,我们可以查看一下,之前我们在学习Hadoop的时候写过读取SequenceFile文件的代码,基于之前的代码,创建一个类:SeqRead
详细代码如下:

注意:这个SequenceFile文件中的key是空的,value是每一条数据的内容。
key对应的是BytesWritable类型。value是Text类型。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.imooc.compress;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.Text;

/**
* Created by xuwei
*/
public class SeqRead {
public static void main(String[] args) throws Exception{
//创建一个配置对象
Configuration conf = new Configuration();
//指定HDFS的地址
conf.set("fs.defaultFS","hdfs://bigdata01:9000");
//seq文件路径
String inputFile = "/stu_seqfile_none_compress/000000_0";
//创建阅读器
SequenceFile.Reader reader = new SequenceFile.Reader(conf, SequenceFile.Reader.file(new Path(inputFile)));
BytesWritable key = new BytesWritable();
Text value = new Text();
//循环读取数据
while(reader.next(key,value)){
//输出文件名称
System.out.print("文件名:"+new String(key.getBytes())+",");
//输出文件内容
System.out.println("文件内容:"+value.toString()+"");
}
reader.close();
}
}
1
2
3
4
5
6
7
8
9
10
11
执行代码,可以看到这样的结果:
.......
文件名:,文件内容:1152574,zs152574,beijing152574
文件名:,文件内容:1152575,zs152575,beijing152575
文件名:,文件内容:1152576,zs152576,beijing152576
文件名:,文件内容:1152577,zs152577,beijing152577
.......

这个表中的数据验证完毕之后,建议删除一下数据,释放HDFS空间。

现在这个表没有使用压缩,接下来我们创建一个带有压缩的表。

使用Deflate压缩(Block级别) 2.39g

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
接下来使用Deflate压缩试验一下,基于Block压缩级别
首先创建表:
create external table stu_seqfile_deflate_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as sequencefile
location 'hdfs://bigdata01:9000/stu_seqfile_deflate_compress';

指定使用deflate压缩,Block级别。
hive (default)> set hive.exec.compress.output=true;
hive (default)> set mapreduce.output.fileoutputformat.compress=true;
hive (default)> set mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.DeflateCodec;
hive (default)> set io.seqfile.compression.type=BLOCK;

向表中导入数据:
hive (default)> set mapreduce.job.reduces=1;
hive (default)> insert into stu_seqfile_deflate_compress select id,name,city from stu_textfile group by id,name,city;

产生的结果数据是这样的:
[root@bigdata04 ~]# hdfs dfs -ls /stu_seqfile_deflate_compress
Found 1 items
-rw-r--r-- 2 root supergroup 2568183982 2027-08-26 11:54 /stu_seqfile_deflate_compress/000000_0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
压缩之后的数据小一些,2.39G。

验证是否支持切分:
hive (default)> select id,count(*) from stu_seqfile_deflate_compress group by id;
Query ID = root_20270826115618_807f09e0-f520-4ed7-8ea5-69492d18ed5c
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Defaulting to jobconf value of: 1
In order to change the average load for a reducer (in bytes):
set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
set mapreduce.job.reduces=<number>
Starting Job = job_1819247895426_0006, Tracking URL = http://bigdata01:8088/proxy/application_1819247895426_0006/
Kill Command = /data/soft/hadoop-3.2.0/bin/mapred job -kill job_1819247895426_0006
Hadoop job information for Stage-1: number of mappers: 10; number of reducers: 1

可以看到产生了10个map任务,说明SequenceFile格式带压缩的文件也支持切分。
1
2
3
4
5
这个怎么理解呢?

因为SequenceFile这个文件自身是支持切分的,我们现在的压缩是针对文件内部的数据进行压缩,并不会改变SequenceFile的特性。这一点和TextFile就不一样了。
所以说在SequenceFile中使用压缩的时候就不需要考虑压缩格式自身是否支持切分的特性了,主要考虑的是压缩格式的压缩比、以及压缩解压速度这些指标。
看一下下面这个图可以帮助理解:

image-20240721170346052

1
2
3
上面表示是SequenceFile中的数据,每一个Record代表里面的一条数据。
当没有压缩的时候,Record内部存储的是Record 的长度、key的长度、key和value。
当使用Record级别压缩的时候,Record内部存储的是Record 的长度、key的长度、key和压缩之后的Value。

image-20240721170417004

1
2
3
4
5
当使用Block级别压缩的时候,SequenceFile中的数据是以Block为单位存储的,每个Block中存储多个Record,并且对Block内部的多个Record统一压缩存储。

所以这里的压缩是针对SequenceFile内部数据的压缩,并没有改变SequenceFile自身的特性,所以他依然是可以支持切分的。

这个表中的数据验证完毕之后,建议删除一下数据,释放HDFS空间。

数据存储格式之RCFile

不使用压缩 1.6g

1
2
3
4
5
6
7
8
9
create external table stu_rcfile_none_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as rcfile
location 'hdfs://bigdata01:9000/stu_rcfile_none_compress';

使用Deflate压缩 382m

1
2
3
4
5
6
7
8
9
create external table stu_rcfile_deflate_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as rcfile
location 'hdfs://bigdata01:9000/stu_rcfile_deflate_compress';
1
2
3
4
指定使用deflate压缩。
hive (default)> set hive.exec.compress.output=true;
hive (default)> set mapreduce.output.fileoutputformat.compress=true;
hive (default)>set mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.DeflateCodec;

数据存储格式之ORC

不使用压缩 1.38g

1
2
3
4
5
6
7
8
9
10
create external table stu_orc_none_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as orc
location 'hdfs://bigdata01:9000/stu_orc_none_compress'
tblproperties("orc.compress"="NONE");

使用Zlib压缩 269m

1
2
3
4
5
6
7
8
9
10
create external table stu_orc_zlib_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as orc
location 'hdfs://bigdata01:9000/stu_orc_zlib_compress'
tblproperties("orc.compress"="ZLIB");

使用Snappy压缩 529m

1
2
3
4
5
6
7
8
9
10
create external table stu_orc_snappy_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as orc
location 'hdfs://bigdata01:9000/stu_orc_snappy_compress'
tblproperties("orc.compress"="SNAPPY");

数据存储格式之PARQUET

不使用压缩 2.05g

1
2
3
4
5
6
7
8
9
10
create external table stu_parquet_none_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as parquet
location 'hdfs://bigdata01:9000/stu_parquet_none_compress'
tblproperties("parquet.compression"="uncompressed");

使用Gzip压缩 358m

1
2
3
4
5
6
7
8
9
10
create external table stu_parquet_gzip_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as parquet
location 'hdfs://bigdata01:9000/stu_parquet_gzip_compress'
tblproperties("parquet.compression"="gzip");

使用Snappy压缩 804m

1
2
3
4
5
6
7
8
9
10
create external table stu_parquet_snappy_compress(
id int,
name string,
city string
)row format delimited
fields terminated by ','
lines terminated by '\n'
stored as parquet
location 'hdfs://bigdata01:9000/stu_parquet_snappy_compress'
tblproperties("parquet.compression"="snappy");

数据存储格式总结

数据存储格式之存储空间汇总

数据存储格式之压缩格式选择