mdrio

Untitled

Jul 17th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. #!//usr/bin/env python
  2.  
  3. from collections import Counter
  4.  
  5. import pydoop.mapreduce.api as api
  6. import pydoop.mapreduce.pipes as pp
  7. from pydoop.avrolib import AvroContext
  8.  
  9. class Mapper(api.Mapper):
  10.  
  11.     def map(self, ctx):
  12.         spectrum = ctx.value
  13.         mzsum = sum(spectrum["mzArray"])
  14.         ctx.emit("a", mzsum)
  15.  
  16. class Reducer(api.Reducer):
  17.  
  18.     def reduce(self, ctx):
  19.         ctx.emit(ctx.key, sum(ctx.values))
  20.  
  21. def __main__():
  22.     factory = pp.Factory(mapper_class=Mapper, reducer_class=Reducer)
  23.     pp.run_task(factory, private_encoding=True, context_class=AvroContext)
Advertisement
Add Comment
Please, Sign In to add comment