Advertisement
assaflavie

mongod OOM in map_reduce

Jun 27th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from pymongo import Connection
  4. from pymongo.code import Code
  5.  
  6. conn = Connection().lab
  7. col = conn.usage
  8.  
  9. def query():
  10.     conn.report.drop()
  11.     m = Code(""" function() { emit({ user : this.user }, { count : 1 }); } """)
  12.     r = Code(""" function(key, vals) { return {count: 1}; } """)
  13.     q = { 'action' : 'push' }
  14.     col.ensure_index("action")
  15.     col.map_reduce(m, r, "report", query = q)
  16.  
  17. query()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement