某些时候map的数量太少,但是每个map的文件比较大,导致执行时间很长。为了充分利用hadoop的优势,我们把map的数据hash到更多的reduce节点去做处理。
使用随机数据都不是特别好,更好的方式是使用input line的hashCode。
public void map(LongWritable key, Text value,
OutputCollector<Text, Text> output, Reporter reporter)
throws IOException
{
try
{
String line = value.toString();
rand=line.hashCode();
x.set(rand.toString());
y.set(line);
output.collect(x,y);
} catch (Exception e)
{
reporter.incrCounter("map", "exp", 1);
}
}

本文讨论了在MapReduce中,当map数量不足而文件较大时,如何通过将数据hash到更多reduce节点来提高任务执行效率。建议使用inputline的hashCode进行更有效的数据分布。
7万+

被折叠的 条评论
为什么被折叠?



