def avg(data, column): global __is_aggregate __is_aggregate = True vals = [row[column] for row in data] data = parallel.run(parallel.map( lambda chunk: [(sum([int(line) for line in chunk]), len(chunk))]), vals, 'avg()' ) dividend = parallel.run(parallel.reduce(lambda data: sum([d[0] for d in data], 0.0)), data) divisor = parallel.run(parallel.reduce(lambda data: sum([d[1] for d in data])), data) return sum(dividend)/sum(divisor)
def simple_test(): data = [i for i in range(1, 5)] expected = [i * i for i in data] def f(x): z = x * x l = list(z) d = dict(x=z, y=z) s = str(d) return z result = parallel.map(f, data) print(result)
def simple_test(): data = [ i for i in range(1, 5) ] expected = [ i*i for i in data ] def f(x): z = x * x l = list(z) d = dict(x=z, y=z) s = str(d) return z result = parallel.map(f, data) print(result)