Permalink
Browse files

Fixed map reduce

  • Loading branch information...
1 parent eadc52b commit 394f0e12d42e641d43d252b0eeb1919c37a27bc2 @mckk committed Mar 13, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 Rest/mapreduce.txt
View
@@ -1,10 +1,11 @@
-function(doc) {
+var map = function(doc) {
var tmstp = Math.floor(doc.timestamp / 10000);
- emit([tmstp, "Temp"], doc.temp);
- emit([tmstp, "Lux"], doc.lux);
+ emit([doc.sensorId, "Temp", tmstp], doc.temp);
+ emit([doc.sensorId, "Lux", tmstp], doc.lux);
}
-function(key, values, rereduce) {
- return key(0) + ' ' + (sum(values) / values.length);
+var reduce = function(key, values) {
+ average = sum(values) / values.length;
+ return Math.round(average*100)/100;
}

0 comments on commit 394f0e1

Please sign in to comment.