0

映射器调用了这两次。

out.collect(new Text("Car"),new Text("Subaru");
out.collect(new Text("Cr-v"),new Text("Honda");

reduce()还会被调用两次吗?

4

1 回答 1

2

我假设你在谈论OutputCollector.collect(K,V)?

reduce()为每个 [key, (list of values)] 对调用一次。为了解释,假设你打电话给:

out.collect(new Text("Car"),new Text("Subaru");
out.collect(new Text("Car"),new Text("Honda");
out.collect(new Text("Car"),new Text("Ford");
out.collect(new Text("Truck"),new Text("Dodge");
out.collect(new Text("Truck"),new Text("Chevy");

然后reduce()将与对被调用两次

reduce(Car, <Subaru, Honda, Ford>)
reduce(Truck, <Dodge, Chevy>)

因此,在您的示例中,是的,该函数reduce()将被调用两次。我希望这会有所帮助。

于 2012-09-10T03:15:18.503 回答