summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2008-06-09 19:55:34 +0000
committerDamien F. Katz <damien@apache.org>2008-06-09 19:55:34 +0000
commitbb4adba508b7abdc09850fc41de3479a0b2d6bb0 (patch)
tree67db07b305a634d9bd4fcea61df704f888637ca4 /share
parent2f56905cea40818e2517d6eba24765d3bdf3252d (diff)
Changed name of 'combine' phase of reduce to 'rereduce', to avoid confusion.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@665852 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share')
-rw-r--r--share/server/main.js8
-rw-r--r--share/www/script/couch_tests.js26
2 files changed, 17 insertions, 17 deletions
diff --git a/share/server/main.js b/share/server/main.js
index 7fe08608..9773cf6c 100644
--- a/share/server/main.js
+++ b/share/server/main.js
@@ -102,13 +102,13 @@ while (cmd = eval(readline())) {
print(toJSON(buf));
break;
- case "combine":
+ case "rereduce":
case "reduce":
{
var keys = null;
var values = null;
var reduceFuns = cmd[1];
- var is_combine = false;
+ var rereduce = false;
if (cmd[0] == "reduce") {
var kvs = cmd[2];
@@ -120,7 +120,7 @@ while (cmd = eval(readline())) {
}
} else {
values = cmd[2];
- is_combine = true;
+ rereduce = true;
}
for (var i in reduceFuns) {
@@ -130,7 +130,7 @@ while (cmd = eval(readline())) {
var reductions = new Array(funs.length);
for(var i = 0; i < reduceFuns.length; i++) {
try {
- reductions[i] = reduceFuns[i](keys, values, is_combine);
+ reductions[i] = reduceFuns[i](keys, values, rereduce);
} catch (err) {
if (err == "fatal_error") {
throw {error: "reduce_runtime_error",
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};
};