Hadoop Map-Reduce,需要将两个mapper与一个常见的Reducer相结合

时间:2013-09-18 10:34:05

标签: hadoop mapreduce reduce mapper

我需要使用Hadoop Map-Reduce实现以下功能吗?

1)我正在从一个来源和一个来源读取一个映射器的输入。来自另一个不同输入源的另一个输入。

2)我需要将mapper的两个输出传递到单个reducer中以进行进一步处理。

在Hadoop Map-Reduce

中是否有上述要求

2 个答案:

答案 0 :(得分:0)

您可以创建自定义可写。您可以在Mapper中填充相同的内容。稍后在Reducer中,您可以获得自定义可写对象并执行必要的业务操作。

答案 1 :(得分:0)

MultipleInputs.addInputPath正是您要找的。这就是您的配置的样子。确保AnyMapper1和AnyMapper2都写入MergeReducer期望的相同输出

JobConf conf = new JobConf(Merge.class);
conf.setJobName("merge");

conf.setOutputKeyClass(IntWritable.class); 
conf.setOutputValueClass(Text.class); 
conf.setReducerClass(MergeReducer.class);
conf.setOutputFormat(TextOutputFormat.class);

MultipleInputs.addInputPath(conf, inputDir1, SequenceFileInputFormat.class, AnyMapper1.class);
MultipleInputs.addInputPath(conf, inputDir2, TextInputFormat.class, AnyMapper2.class);

FileOutputFormat.setOutputPath(conf, outputPath);
相关问题