您应该考虑编写两个映射器,一个处理
.csv
文件和其他
.xml
。但是,两个映射器都应该生成
key-value
属于
same type
,用于单个减速器处理。
下面是一个使用
org.apache.hadoop.mapred.lib.MultipleInputs
对于相同的:
MultipleInputs.addInputPath(jobConf,
new Path(csvFilePath),
SequenceFileInputFormat.class,
CSVProcessingMapper.class);
MultipleInputs.addInputPath(jobConf,
new Path(xmlFilePath),
XmlInputFormat.class,
XMLProcessingMapper.class);
在这里
CSVProcessingMapper.class
和
XmlInputFormat.class
是
CSV
和
XML
正在处理映射器。您可以为不同的输入类型使用尽可能多的映射器。
类似地
SequenceFileInputFormat.class
和
XmlInputFormat。班
类是相应的输入格式类。