Hive表的几种存储格式

Hive的文件存储格式:sql

  • textFile

    textFile为默认格式api

    存储方式:行存储    ide

    缺点:磁盘开销大;数据解析开销大;压缩的text文件,hive没法进行合并和拆分oop

  • sequencefile

    二进制文件,以<key,value>的形式序列化到文件中性能

    存储方式:行存储优化

    优势:可分割、压缩,通常选择block压缩,与hadoop api中的mapfile是互相兼容的。编码

  • Rcfile

    存储方式:数据按行分块 每块按照列存储spa

    压缩快 快速列存取orm

    读记录尽可能涉及到的block最少blog

    读取须要的列只须要读取每一个row group 的头部定义。

    读取全量数据的操做 性能可能比sequencefile没有明显的优点

  • ORC

    存储方式:数据按行分块 每块按照列存储

    压缩快 快速列存取

    效率比rcfile高,是rcfile的改良版本

    官网介绍:

    The Optimized Row Columnar (ORC) file format provides a highly efficient way to store Hive data. It was designed to overcome limitations of the other Hive file formats. Using ORC files improves performance when Hive is reading, writing, and processing data.

    ORC其实是在RC文件存储格式作了一些优化,它的主要优势有:
      (1)、每一个task只输出单个文件,这样能够减小NameNode的负载;
      (2)、支持各类复杂的数据类型,好比: datetime, decimal, 以及一些复杂类型(struct, list, map, and union);
      (3)、在文件中存储了一些轻量级的索引数据;
      (4)、基于数据类型的块模式压缩:a、integer类型的列用行程长度编码(run-length encoding);b、String类型的列用字典编码(dictionary encoding);
      (5)、用多个互相独立的RecordReaders并行读相同的文件;
      (6)、无需扫描markers就能够分割文件;
      (7)、绑定读写所须要的内存;
      (8)、metadata的存储是用 Protocol Buffers的,因此它支持添加和删除一些列。

  • 自定义格式

    用户能够经过实现inoutformat和outputformat来定义输入输出格式。

相关文章
相关标签/搜索