Hive将ORC文件拆分为小块

4
create table n_data(MARKET string,CATEGORY string,D map<string,string>,monthid int,value  DOUBLE)
  STORED AS ORC
 ;

我将数据加载到其中(超过45000000行),查看hive warehouse。
结果表由5个文件组成,每个文件大小为10MB-20MB,但是dfs.block.size设置为128MB,这不是存储小文件的最佳选择,因为它使用整个块!
如何设置HIVE拆分文件为128 MB? 编辑 插入查询:
insert into n_data
select tmp.market,tmp.category,d,adTable.monthid,tmp.factperiod[adTable.monthid] as fact 
from (select market,category,d,factperiod,map_keys(factperiod) as month_arr  from n_src where market is not null) as tmp 
LATERAL VIEW explode(month_arr) adTable AS monthid

你是如何插入记录的?请展示插入语句。除了Hive设置相关的属性,你还有其他的属性吗? - Ambrish
@Ambrish,我在问题中添加了插入查询。 - rpc1
@Ambrish 我没有其他关于Hive设置的相关内容。 - rpc1
插入(insert into) 将在每次运行时创建新文件。因此,如果您在批处理中运行工具,则将看到至少 BATCH_COUNT 个文件。 - Ambrish
@Ambrish,我只运行一次插入操作,当加载事实时,它不会以批处理模式运行。 - rpc1
1个回答

2

您需要为Hive设置以下配置参数:

hive.merge.mapfiles = true
hive.merge.mapredfiles = true
hive.merge.tezfiles = true
hive.merge.smallfiles.avgsize = 16000000

我曾经遇到过完全相同的问题,直到我找到了这个来源。您可以尝试在Hive会话中使用“set”命令手动设置这些参数,例如:

set hive.merge.mapfiles=true;
set hive.merge.mapredfiles=true;
set hive.merge.tezfiles=true;
set hive.merge.smallfiles.avgsize=16000000;

如果你在hive会话控制台中只输入“set;”,你可以检查上述参数是否正确设置。测试后,建议您在hive-site.xml配置文件或通过Ambari(如果使用Hortonworks分发版)更改它们。干杯!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接