将Hive数据库存储格式转换为orc
2017-03-17 12:54
435 查看
Hive的存储格式
textfilehive的默认存储格式
存储方式:行存储
磁盘开销大 数据解析开销大
压缩的text文件 hive无法进行合并和拆分
SequenceFile
二进制文件以key,value的形式序列化到文件中
存储方式:行存储
可分割 压缩
一般选择block压缩
优势是文件和hadoop api中的mapfile是相互兼容的
rcfile
存储方式:数据按行分块 每块按照列存储
压缩快 快速列存取
读记录尽量涉及到的block最少
读取需要的列只需要读取每个row group 的头部定义。
读取全量数据的操作 性能可能比sequencefile没有明显的优势
orc
存储方式:数据按行分块 每块按照列存储
压缩快 快速列存取
效率比rcfile高,是rcfile的改良版本
自定义格式
用户可以通过实现inputformat和 outputformat来自定义输入输出格式
Hive导入数据的几种方式
从本地文件系统中导入load data local inpath 'customer .data' into table customer;
从HDFS上导入
load data inpath '/hive/customer .data' into table customer;
从别的表中查询出相应的数据导入
insert into table customer select * from customer_tmp;
将存储格式转换为orc
因为textfile类型的数据不能直接保存到orc类型的表中,根据上面的几种导入数据的方式我们做一下转换就可以了,先导入到一个textfile类型的表中然后在通过查询导入到另外一个表就可以了示例:
use tpcds_orc; drop table if exists customer_tmp; create table customer_tmp ( c_customer_sk int , c_customer_id char(16) , c_current_cdemo_sk int , c_current_hdemo_sk int , c_current_addr_sk int , c_first_shipto_date_sk int , c_first_sales_date_sk int , c_salutation char(10) , c_first_name char(20) , c_last_name char(30) , c_preferred_cust_flag char(1) , c_birth_day int , c_birth_month int , c_birth_year int , c_birth_country varchar(20) , c_login char(13) , c_email_address char(50) , c_last_review_date char(10) ) row format delimited fields terminated by '|'; load data local inpath '/data1/tpcds/data100/customer.dat' into table customer_tmp; drop table if exists customer; create table customer ( c_customer_sk int , c_customer_id char(16) , c_current_cdemo_sk int , c_current_hdemo_sk int , c_current_addr_sk int , c_first_shipto_date_sk int , c_first_sales_date_sk int , c_salutation char(10) , c_first_name char(20) , c_last_name char(30) , c_preferred_cust_flag char(1) , c_birth_day int , c_birth_month int , c_birth_year int , c_birth_country varchar(20) , c_login char(13) , c_email_address char(50) , c_last_review_date char(10) ) row format delimited fields terminated by '|' stored as orc ; insert into table customer select * from customer_tmp; drop table customer_tmp;
相关文章推荐
- Hive数据导入方案—使用ORC格式存储hive数据
- Hive-ORC文件存储格式(续)
- hive 压缩全解读(hive表存储格式以及外部表直接加载压缩格式数据);HADOOP存储数据压缩方案对比(LZO,gz,ORC)
- Hive-ORC文件存储格式
- java.sql.Data java.util.Data的转换 及时间格式化后的两者之间的转换,数据库中时间存储格式
- hive表的存储格式 . ORC格式的使用
- 大数据:Hive - ORC 文件存储格式
- hive表的存储格式; ORC格式的使用
- Hive-ORC文件存储格式
- Hive-ORC文件存储格式(续)
- hive 压缩全解读(hive表存储格式以及外部表直接加载压缩格式数据);HADOOP存储数据压缩方案对比(LZO,gz,ORC)
- hive表的存储格式; ORC格式的使用
- Hive:ORC与RC存储格式之间的区别
- 通过Spark结合使用Hive和ORC存储格式
- 高级数据库十二(2):HIVE文件存储格式
- Hive:ORC File Format存储格式详解
- 关于json格式存储数据库成bean对象list,取出来再次转换成json格式
- Hive-ORC文件存储格式(续)
- 数据库存储的数据为 unicode格式,在.NET 读取出来并转换为繁体字?
- Hive-ORC文件存储格式