首页 技术 正文
技术 2022年11月14日
0 收藏 396 点赞 3,895 浏览 1747 个字

0. 说明

  Hive 的存储格式 | textfile | sequencefile | rcfile | orc | parquet |


1. Hive的存储格式

  1.1 textfile

  行式存储

  1.2 sequencefile

  二进制的k-v对,行式存储

  配置块压缩

  SET hive.exec.compress.output=true;
  SET io.seqfile.compression.type=BLOCK;

  1.3 rcfile

  列式存储

  先将数据进行横切(4M),成为行组,行组内又纵向切割分为多个字段

  1.4 orc

  列式存储

  比 rc 文件更大的块(256M),优化磁盘的线性读取,通过指定的编码器确定数据类型并优化压缩
  还存储了基本统计数据,比如 min,max,sum,count。。。

  1.5 parquet

  列式存储

  适用范围更广(在 Hadoop 生态系统中)
  适用于嵌套文件格式


2. 测试

  2.0 前期配置

  设置 Hive自动使用本地模式

SET hive.exec.mode.local.auto=true;

  输入文件大小低于此值会进入本地模式

SET hive.exec.mode.local.auto.inputbytes.max=500000000;

  输入文件个数低于此值会进入本地模式

SET hive.exec.mode.local.auto.input.files.max=5;

  设置seqFile使用块压缩

SET hive.exec.compress.output=true;
SET io.seqfile.compression.type=BLOCK;

  2.1 建表

create table user_seq(id int, name string, pass string, email string, nickname string) stored as SEQUENCEFILE;create table user_rc(id int, name string, pass string, email string, nickname string) stored as rcfile;create table user_orc2(id int, name string, pass string, email string, nickname string) stored as orc tblproperties("orc.compress"="ZLIB");create table user_parquet2(id int, name string, pass string, email string, nickname string) stored as parquet tblproperties("parquet.compression"="GZIP");    

  2.2 插入数据

  导入大文件

load data local inpath '/home/centos/files/user_nopar.txt' into table user_nopar;

  插入数据

insert into user_seq select * from user_nopar;insert into user_rc select * from user_nopar;insert into user_orc2 select * from user_nopar;insert into user_parquet2 select * from user_nopar;

  2.3 性能比较

  1. 比较生成文件大小
  text:45 MB
  seq:78.18 MB性能差
  rc:114.84 KB
  orc:33.36 KB  //默认有压缩:ZLIB
  parquet:3.21 MB  //默认无压缩:NO ===GZIP==> 21.71 KB

  性能比较
  select count(*) from user_nopar;  //6.69
  select count(*) from user_seq;  //20.999 性能差
  select count(*) from user_rc;  //8.131
  select count(*) from user_orc2;  //6.84
  select count(*) from user_parquet2;  //2.56  √


相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,076
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,400
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,812
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,894