Hi list!

I hava a question about grouping and the reduce function

If aI want to average the sum of manu values returned by my map function on a large database (~100000 rows ) the reduce function gets called with the rereduce boolean

The thing is a am not sure if its mathematically correct to average sets of floats in groups as optimized by couch where I can have to average smaller sets of previously averaged values. I certainly dont get the exact same result of averaging a whole set than a grouped set.

My question is how can I handle my reduce function to reduce a whole set and not in groups?

Note the emit call is done with complex keys:

map:

function(doc) {
if ((doc['couchrest-type'] == 'RawData') && doc['device_variable_id']) {
         date =  new Date(doc.date_time);
emit([doc.device_variable_id, date.getFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), parseInt(date.getUTCMinutes() / 20 + 1) ], doc.value);
       }
     }

reduce:

function( keys, values, rereduce ) {
     if(rereduce){
               log("rereduce");
             }
       return sum( values ) / values.length ;
     }

Reply via email to