summaryrefslogtreecommitdiff
path: root/share/www/script/couch_tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'share/www/script/couch_tests.js')
-rw-r--r--share/www/script/couch_tests.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index cbec817e..97a2bb17 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -351,23 +351,14 @@ var tests = {
var map = function (doc) {emit(null, doc.val)};
- var reduceCombine = function (keys, values, combine) {
+ var reduceCombine = function (keys, values, rereduce) {
// This computes the standard deviation of the mapped results
var stdDeviation=0;
var count=0;
var total=0;
var sqrTotal=0;
- if (combine) {
- // This is the combine phase, we are re-reducing previosuly returned
- // reduce values.
- for(var i in values) {
- count = count + values[i].count;
- total = total + values[i].total;
- sqrTotal = sqrTotal + (values[i].sqrTotal * values[i].sqrTotal);
- }
- }
- else {
+ if (!rereduce) {
// This is the reduce phase, we are reducing over emitted values from
// the map functions.
for(var i in values) {
@@ -376,12 +367,21 @@ var tests = {
}
count = values.length;
}
+ else {
+ // This is the rereduce phase, we are re-reducing previosuly
+ // reduced values.
+ for(var i in values) {
+ count = count + values[i].count;
+ total = total + values[i].total;
+ sqrTotal = sqrTotal + (values[i].sqrTotal * values[i].sqrTotal);
+ }
+ }
var variance = (sqrTotal - ((total * total)/count)) / count;
stdDeviation = Math.sqrt(variance);
- // the reduce result. It contains enough information to combine with
- // more reduce results, and the final output values.
+ // the reduce result. It contains enough information to be rereduced
+ // with other reduce results.
return {"stdDeviation":stdDeviation,"count":count,
"total":total,"sqrTotal":sqrTotal};
};