Exemplo n.º 1
0
Arquivo: rdd.py Projeto: helfer/py-rdd
 def reduce(self, function, initializer, target = 'keys'):
   # target = 'keys': reduce across keys
   # target = 'values': reduce across values
   intermediate_results = []
   encoded_func = util.encode_function(function)
   for num in range(self.hash_grain):
     try:
       assignment = self.worker_assignment[num]
     except KeyError:
       self.execute()
     proxy = xmlrpclib.ServerProxy(self.worker_assignment[num].uri)
     args = util.pds(self.uid, num, encoded_func, initializer, target)
     intermediate_result = proxy.worker_reduce(args)
     intermediate_results.append(intermediate_result)
   return reduce(function, intermediate_results, initializer)