Guest User

Untitled

a guest
Sep 27th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. # coding=utf-8
  2. from mapreduce import SimpleMapReduce
  3. from simple import FILES, file_parser
  4.  
  5.  
  6. def count_err_log(item):
  7. word, occurances = item
  8. return (word, sum(occurances))
  9.  
  10.  
  11. def map_wrapper(*args, **kwargs):
  12. matches = file_parser(*args, **kwargs)
  13. return [(match, 1) for match in matches]
  14.  
  15.  
  16. def main():
  17. mapper = SimpleMapReduce(map_wrapper, count_err_log)
  18. log_counts = mapper(FILES)
  19. print sorted(log_counts, key=lambda x: x[1], reverse=True)[0]
  20.  
  21.  
  22. if __name__ == '__main__':
  23. import time
  24. start = time.time()
  25. main()
  26. print 'COST: {}'.format(time.time() - start)
Add Comment
Please, Sign In to add comment