我创建了一个读取自定义文件输入格式的配置单元外部表。当文件很小时,这工作得很好。但是当文件很大时,工作就是拆分文件,我的工作失败了。
我在 IsSplittable 方法的自定义输入格式类中返回 false。我还尝试将 mapreduce.input.fileinputformat.split.minsize 和 mapred.min.split.size 设置为较大的值。我创建了自定义输入格式、输出格式和 SerDe 类,并在创建此表时使用了它们。
在我的工作日志中,我仍然看到 split 正在发生。
Processing split: Paths:/user/test/testfile1:0+134217728,/user/test/testfile1:134217728+95198924,/user/test/testfile2:0+134217728,/user/test/testfile2:134217728+96092244...
134217728 是 128 MB,这一定是我的 HDFS block 大小。有什么办法可以防止这种 split 发生吗?和这个问题有关系吗https://issues.apache.org/jira/browse/HIVE-8630 ?
我的建表语句是:
CREATE EXTERNAL TABLE test_data(
key STRING,
body map<string, string>
)
PARTITIONED BY (year int, month int, day int)
ROW FORMAT SERDE 'com.hiveio.io.CustomHiveSerde'
STORED AS INPUTFORMAT 'com.hiveio.io.CustomHiveInputFormat'
OUTPUTFORMAT 'com.hiveio.io.CustomHiveOutputFormat'
LOCATION '/user/test/';
最佳答案
好吧..实际上,你提到了https://issues.apache.org/jira/browse/HIVE-8630铃响了。不久前,我们处理了一个非常相似的问题。 该错误提到 CombineHiveInputFormat 仍将如何拆分不可拆分的格式。 CombineHiveInputFormat 是默认的 HiveInputFormat,其目的是合并多个小文件以减少开销。 您可以禁用它,设置
set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat
在查询之前,或者如果你想要它作为默认值,则在 hive-site.xml 中将其设置为 xml:
<property>
<name>hive.input.format</name>
<value>org.apache.hadoop.hive.ql.io.HiveInputFormat</value>
</property>
请注意,您将牺牲 Combine 部分的功能,因此如果您有许多小文件,它们在处理时每个文件都会使用一个映射器……但这应该可行,它确实对我们有用。
关于hadoop - Hive MapReduce 作业拆分文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34296525/