From cba120e5615e3d37de01bc63fbc8b325108276c5 Mon Sep 17 00:00:00 2001 From: "Damien F. Katz" Date: Fri, 6 Jun 2008 19:30:34 +0000 Subject: Added comments and clarity to the reduce/combine test. again git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@664093 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/couch_tests.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'share/www') diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 2d7aaa66..cbec817e 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -361,14 +361,11 @@ var tests = { 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); } - var variance = (sqrTotal - ((total * total)/count)) / count; - stdDeviation = Math.sqrt(variance); } else { // This is the reduce phase, we are reducing over emitted values from @@ -378,12 +375,13 @@ var tests = { sqrTotal = sqrTotal + (values[i] * values[i]) } count = values.length; - var variance = (sqrTotal - ((total * total)/count)) / count; - stdDeviation = Math.sqrt(variance); } - // the reduce results. It contains enough information to compute - // further reduce results, and the final output values. + 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. return {"stdDeviation":stdDeviation,"count":count, "total":total,"sqrTotal":sqrTotal}; }; -- cgit v1.2.3