映射器调用了这两次。
out.collect(new Text("Car"),new Text("Subaru");
out.collect(new Text("Cr-v"),new Text("Honda");
reduce()
还会被调用两次吗?
映射器调用了这两次。
out.collect(new Text("Car"),new Text("Subaru");
out.collect(new Text("Cr-v"),new Text("Honda");
reduce()
还会被调用两次吗?
我假设你在谈论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()
将被调用两次。我希望这会有所帮助。