【发布时间】:2015-09-02 19:54:15
【问题描述】:
我正在运行 Map Reduce 程序。但是,即使我只使用 mapper 或同时使用 mapper 和 reducer 运行它,我也会得到类似的输出。
在此之后它永远不会完成。它挂在那里。
我不明白为什么 reducer 在 mapper 完成 100% 之前就开始了?可能存在哪些潜在问题?
输出:
Map 10% Reduce 0%
Map 19% Reduce 0%
Map 21% Reduce 0%
Map 39% Reduce 0%
Map 49% Reduce 0%
Map 63% Reduce 0%
Map 67% Reduce 0%
Map 68% Reduce 0%
Map 68% Reduce 22%
Map 69% Reduce 22%
这是一个映射器代码:
public class EntityCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
static String total_record="";
@Override
protected void map(LongWritable baseAddress, Text line, Context context)
throws IOException, InterruptedException {
Text entity=new Text();
IntWritable one=new IntWritable(1);
total_record=total_record.concat(line.toString());
String[] fields=total_record.split("::");
if(fields.length==24)
{
entity.set(fields[22].trim());
context.write(entity,one);
total_record="";
}
}
}
【问题讨论】:
-
为什么reduce进程必须等待所有映射完成?一旦有足够的数据可以启动 Reduce 就可以启动它 - 例如。两个节点完成了他们的地图工作。
-
@user3707125 不是真的,在 所有 映射器完成之前,它无法开始 reducing。到那时,它只能开始shuffle,即获取已经完成的mapper的输出。
-
你的意思是“我得到了类似的输出,即使我只使用 mapper 或同时使用 mapper 和 reducer 运行它”?
-
@vefthym 我的意思是在一种情况下我只设置了映射器类,在另一种情况下我将映射器和减速器类都设置为作业配置
-
@GauravGandhi 这是因为,如果您不指定减速器,则默认使用 identityReducer。如果你不想要reducer,请将reduce 任务的数量设置为零
conf.setNumReduceTasks(0);
标签: java hadoop mapreduce bigdata