hive.exec.orc.default.stripe.size相关

1.背景:

在日常的处理中发现了Warning: Ignoring non-Spark config property: hive.exec.orc.default.stripe.size这样的一个日志,

此处客户寻求解决方式.

2.解决方式:

hive.exec.orc.default.stripe.size, "256*1024*1024 " stripe的默认大小

hive.exec.orc.split.strategy, "BI"

以上这两个参数一起使用.

3.原理剖析:

见配置可以得知,该配置是针对orc进行相关设置的配置---hive.exec.orc

首先我们来看下orc file,

ORC File,它的全名是Optimized Row Columnar (ORC) file,实际上是对RCFile做了一些优化.

这种文件格式可比较高效的来存储Hive数据.

它的设计目标是来克服Hive其他格式的缺陷.

运用ORC File可以提高Hive的读、写以及处理数据的性能.

和RCFile格式相比.

ORC File格式有以下优点:

(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的,所以它支持添加和删除一些列.

ORC File包含一组组的行数据,称为stripes,ORC File的file footer还包含一些额外的辅助信息。在ORC File文件的最后,有一个被称为postscript的区,它主要是用来存储压缩参数及压缩页脚的大小。

在默认情况下,一个stripe的大小为250MB.

也就是对应的default设置值:hive.exec.orc.default.stripe.size, "256*1024*1024 " stripe的默认大小

(大尺寸的stripes使得从HDFS读数据更高效)

  在file footer里面包含了该ORC File文件中stripes的信息,每个stripe中有多少行,以及每列的数据类型。当然,它里面还包含了列级别的一些聚合的结果,比如:count, min, max, and sum.

orc文件架构如下所示:

1)因此在适当增大hive.exec.orc.default.stripe.size, "256*1024*1024"的值可提高效率,就像适当提高blocksize也可以加快效率原理类似.

2)hive.exec.orc.split.strategy, "BI"

2.1)场景使用,通过阅读hive源码可知,此配置hive,spark,tez均适用.

官方提供的配置描述如下所示:

HIVE_ORC_SPLIT_STRATEGY("hive.exec.orc.split.strategy", "HYBRID", new StringSet("HYBRID", "BI", "ETL"),
    "This is not a user level config. BI strategy is used when the requirement is to spend less time in split generation" +
    " as opposed to query execution (split generation does not read or cache file footers)." +
    " ETL strategy is used when spending little more time in split generation is acceptable" +
    " (split generation reads and caches file footers). HYBRID chooses between the above strategies" +
    " based on heuristics.")

复制

因此针对客户的场景,对较大的ORC表,因为其footer较大,ETL策略会导致其从hdfs拉取大量的数据来切分split,甚至会导致driver端OOM,因此这类表的读取建议使用BI策略.

此处:

适当加大hive.exec.orc.default.stripe.size配置,以及在orc表比较大的情况下使用BI策略可有效提高效率,

以及避免driver OOM.

hive.exec.orc.default.stripe.size, "256*1024*1024 " stripe的默认大小

hive.exec.orc.split.strategy, "BI"

spark引擎

spark-sql

--hiveconf hive.exec.orc.default.stripe.size=536870912

--hiveconf hive.exec.orc.default.block.size=536870912

--hiveconf hive.exec.orc.default.buffer.size=16384

--hiveconf hive.exec.orc.block.padding.tolerance=0.1

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值