--- Revision None +++ Revision 653536373336 @@ -0,0 +1,36 @@ +function(keys, values, rereduce) { + + + var ucount = 0; + var seen = new Object(); + + if (!rereduce) { + // This is the reduce phase, we are reducing over emitted values from + // the map functions. + + // we count 1 if a given uname has not been seen + + for(var i in values) { + if (seen[values[i][0]] == undefined) { + seen[values[i][0]] = 1; + ucount += 1; + } + } + + } + else { + // This is the rereduce phase, we are re-reducing previosuly + // reduced values. + for(var i in values) { + // loop around seen object values + + for(var j in values[i][1]) { + if (seen[j] == undefined) { + seen[j] = 1; + ucount += 1; + } + } + } + } + return [ucount, seen]; + }