while loop in dumbo

15 views
Skip to first unread message

Vincenzo De Leo

unread,
Oct 24, 2014, 10:51:23 AM10/24/14
to dumbo...@googlegroups.com
Dear Dumbo users,
I'd like to know if there is any way to modify this simple working code that increment the value variable of 1 unit each time that a map/reduce step is executed:

class mapper:
    def __init__(self):
        pass
    def __call__(self,key,value):
        if key==0:
            yield 1,1
        else:
            value = value + 1
            yield 1,value

class reducer:
    def __init__(self):        
        pass
    def __call__(self,key,value):
        yield key,value.next()

def runner(job):
    for i in range(10):
        job.additer(mapper, reducer)        
    
if __name__ == "__main__":
    import dumbo
    dumbo.main(runner)

changing the "for loop" in a "while loop" because I have to implement a code where the number of map/reduce steps it is not known a priori but it depends from the value of a variable stored in the (key,value) couple that is updated each map/reduce step.

Thanks to all,
Best!

Vincenzo

A Srivastava

unread,
Apr 14, 2016, 9:01:56 PM4/14/16
to dumbo-user
Hi Vincenzo,

Were you able to figure this out? I am having the same doubt while implementing the medians of median algorithm. 
Any help would be great. Thanks!
Reply all
Reply to author
Forward
0 new messages