incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francisco Viramontes <>
Subject averaging and rereduce
Date Sun, 30 Aug 2009 09:36:06 GMT
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:


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);


function( keys, values, rereduce ) {
        return sum( values ) / values.length ;

View raw message