Author: rick
Date: 2010-03-18 11:35:12 +0100 (Thu, 18 Mar 2010)
New Revision: 28600
Added:
plugins/sfCouchPlugin/trunk/config/couchdb/example_reduce.js
Removed:
plugins/sfCouchPlugin/trunk/config/couchdb/example_reduce.js
Log:
Fixed the reduce example
Deleted: plugins/sfCouchPlugin/trunk/config/couchdb/example_reduce.js
===================================================================
--- plugins/sfCouchPlugin/trunk/config/couchdb/example_reduce.js
2010-03-18 10:15:56 UTC (rev 28599)
+++ plugins/sfCouchPlugin/trunk/config/couchdb/example_reduce.js
2010-03-18 10:35:12 UTC (rev 28600)
@@ -1,30 +0,0 @@
-// This counts the amount of the numbers 0-9 in the document ids
-// it has no real use, it's just an example that works with every
-// document, regardless of the keys it contains.
-function (keys, values, rereduce) {
- var counts = {};
-
- // init the array
- for (var i=0; i<10; i++) {
- counts[i] = 0;
- }
-
- // This is the reduce phase, we are reducing over emitted values from
- // the map functions.
- for(var i in values) {
- if (!rereduce) {
- var chars = values[i].split("");
- } else {
- var chars = values[i];
- }
- for (var j=0; j<chars.length; j++) {
- if (chars[j] < 10) {
- counts[chars[j]] = counts[chars[j]]+1;
- }
- }
- };
-
- // the reduce result. It contains enough information to be rereduced
- // with other reduce results.
- return counts;
-};
\ No newline at end of file
Added: plugins/sfCouchPlugin/trunk/config/couchdb/example_reduce.js
===================================================================
--- plugins/sfCouchPlugin/trunk/config/couchdb/example_reduce.js
(rev 0)
+++ plugins/sfCouchPlugin/trunk/config/couchdb/example_reduce.js
2010-03-18 10:35:12 UTC (rev 28600)
@@ -0,0 +1,35 @@
+// This counts the amount of the numbers 0-9 in the document ids
+// it has no real use, it's just an example that works with every
+// document, regardless of the keys it contains.
+function (keys, values, rereduce) {
+ var counts = {};
+
+ // init the array
+ for (var i=0; i<10; i++) {
+ counts[i] = 0;
+ }
+
+ // This is the reduce phase, we are reducing over emitted values from
+ // the map functions.
+ for(var i in values) {
+ if (rereduce) {
+ var chars = values[i];
+ for (var i in chars) {
+ counts[i] = counts[i]+chars[i];
+ }
+ } else {
+ var chars = values[i].toString().split("");
+ for (var j=0; j<chars.length; j++) {
+ char = chars[j];
+ if (char < 10) {
+ counts[char] = counts[char]+1;
+ }
+ }
+ }
+
+ };
+
+ // the reduce result. It contains enough information to be rereduced
+ // with other reduce results.
+ return counts;
+};
\ No newline at end of file
Property changes on:
plugins/sfCouchPlugin/trunk/config/couchdb/example_reduce.js
___________________________________________________________________
Added: svn:mime-type
+ text/plain
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.