def reduce(self, f): #1 parameter
def func(iterator):
iterator = iter(iterator)
try:
initial = next(iterator)
except StopIteration:
return
yield reduce(f, iterator, initial) #3 parameter
vals = self.mapPartitions(func).collect()
if vals:
return reduce(f, vals) #2 parameter
raise ValueError("Can not reduce() empty RDD")
The reduce function only takes 1 parameter, but it gives 2 or 3 parameters.
I search the whole python code without any other definition about reduce.