Hive基础之Hive的存储类型
Hive常用的存储类型有:
1、TextFile: Hive默认的存储类型;文件大占用空间大,未压缩,查询慢;
2、Sequence File:将属于以<KEY,VALUE>的形式序列化到文件中;该类型的文件存储略大于TEXTFILE类型;

3、RCFile:面向列的文件格式。遵循“先按列划分再按行划分”的理念。在查询过程中,针对它并不关心的列时会在IO上跳过这些列;RCFile并没有性能优势,只是在存储上省了10%的空间,因为列的数据类型是一样的,更方便进行压缩;在读取所有列的情况下,RCFile的性能还没有SequenceFile高。

RCFile案例:
创建表:
create table emp_rcfile(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int
)
row format delimited fields terminated by '\t' lines terminated by '\n'
stored as rcfile;
加载表数据:
load data local inpath '/home/spark/software/data/emp.txt' overwrite into table emp_rcfile;
报错:
Failed with exception Wrong file format. Please check the file's format.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask
解决方法:在创建rcfile表的同时再创建一个textfile的临时表,将数据先导入到textfile表中;
创建与rcfile表相同的textfile的表:
create table emp_rcfile_raw(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int
)
row format delimited fields terminated by '\t' lines terminated by '\n'
stored as textfile;
导入原始数据到textfile的表:
load data local inpath '/home/spark/software/data/emp.txt' overwrite into table emp_rcfile_raw;
然后再将textfile表中的数据插入到rcfile表中:
insert into table emp_rcfile select * from emp_rcfile_raw;
查看hdfs文件
hadoop fs -ls /user/hive/warehouse/emp_rcfile
/user/hive/warehouse/emp_rcfile/000000_0
Hive基础之Hive的存储类型的更多相关文章
- Hive基础之Hive体系架构&运行模式&Hive与关系型数据的区别
Hive架构 1)用户接口: CLI(hive shell):命令行工具:启动方式:hive 或者 hive --service cli ThriftServer:通过Thrift对外提供服务,默认端 ...
- Hive基础之Hive数据类型
Hive数据类型 参考:中文博客:http://www.cnblogs.com/ggjucheng/archive/2013/01/03/2843448.html 英文:https: ...
- Hive基础之Hive环境搭建
Hive默认元数据信息存储在Derby里,Derby内置的关系型数据库.单Session的(只支持单客户端连接,两个客户端连接过去会报错): Hive支持将元数据存储在关系型数据库中,比如:Mysql ...
- Hive基础之Hive的复杂类型
ARRAY 一组有序字段,字段的类型必须相同.Array(1,2) create table hive_array(ip string, uid array<string>) row fo ...
- Hive基础之Hive与关系型数据库的比较
Hive与关系型数据库的比较 使用Hive的CTL(命令行接口)时,你会感觉它很像是在操作关系型数据库,但是实际上,Hive和关系型数据库有很大的不同. 1)Hive和关系型数据库 ...
- Hive基础之Hive表常用操作
本案例使用的数据均来源于Oracle自带的emp和dept表 创建表 语法: CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name ...
- Hive基础之Hive是什么以及使用场景
Hive是什么1)Hive由facebook开源,构建在Hadoop (HDFS/MR)上的用于管理和查询结果化/非结构化的数据仓库:2)一种可以存储.查询和分析存储在Hadoop 中的大规模数据的机 ...
- Hive基础之Hive开启查询列名及行转列显示
Hive默认情况下查询结果里面是只显示值: hive> select * from click_log; OK ad_101 :: ad_102 :: ad_103 :: ad_104 :: a ...
- Hive基础(1)
Hive基础(1) Hive的HQL(2) 1. Hive并不是分布式的,它独立于机器之外,类似于Hadoop的客户端. 2. 元数据和数据的区别,前者如表名.列名.字段名等. 3. Hive的三种安 ...
随机推荐
- PHP 之 Ci框架下隐藏index.php
1. 修改 apache 配置文件 开启重写模块 conf/httpd.conf 去掉前面的# LoadModule rewrite_module modules/mod_rewrite.so 对于U ...
- HDU 1501 Zipper(DFS)
Problem Description Given three strings, you are to determine whether the third string can be formed ...
- jmeter随笔(34)-WebSocket协议接口测试实战
2017年春节结束了,一切再次回归到正轨,我们飞测也开始继续分享,小怪在这里预祝大家在2017年工作顺利,满满的收获. 背景:今天研发哥们QQ我,请教websocket协议的接口测试,这哥们自己开发了 ...
- Redis 缓存服务器
Redis 服务器 Remote Dictionay Server Redis是一个key-value持久化产品,通常被称为数据结构服务器. Redis的key是string类型:value可以是 ...
- hog+svm+检测人(代替默认的参数)
#include <iostream>#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui. ...
- 2018-2019-2 网络对抗技术 20165212 Exp4 恶意代码分析
2018-2019-2 网络对抗技术 20165212 Exp4 恶意代码分析 原理与实践说明 1.实践目标 监控你自己系统的运行状态,看有没有可疑的程序在运行. 分析一个恶意软件,就分析Exp2或E ...
- LeetCode-Microsoft-Add Two Numbers II
You are given two non-empty linked lists representing two non-negative integers. The most significan ...
- JS实现表单多文件上传样式美化支持选中文件后删除相关项
http://www.youdaili.net/javascript/5903.html
- 【转】每天一个linux命令(45):free 命令
原文网址:http://www.cnblogs.com/peida/archive/2012/12/25/2831814.html free命令可以显示Linux系统中空闲的.已用的物理内存及swap ...
- es6比es5节省代码的地方总结
对象方法简写: es5写法: var obj = { name: 'jeff', getName: function () { return this.name; } } es6写法(方法定义里,少写 ...