Guest User

Untitled

a guest
Jan 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. map_func = Code("""
  2. function () {
  3. emit(this.timestamp, [this.publish_bytes, this.subscribe_bytes, this.history_bytes, this.time_bytes,
  4. this.unknown_bytes, this.publish, this.subscribe, this.history, this.unknown, this.time]);
  5. }
  6. """)
  7.  
  8. reduce_func = Code("""
  9. function (key, values) {
  10. var totals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  11. for (var i=0; i<values.length; i++) {
  12. for (var j=0; j<values[i].length; j++) {
  13. totals[j] += values[i][j];
  14. }
  15. }
  16. return totals;
  17. }
  18. """)
  19.  
  20. results = db.system_stats.inline_map_reduce(map_func, reduce_func)
Add Comment
Please, Sign In to add comment