On Sep 13, 2010, at 9:11 AM, Thomas Rampelberg wrote: > It would be epically awsome to have unit test functionality for > map/reduce baked into couchapp ..... >
On my infinite todo list is the idea to implement CouchApp in Node.js, which would make adding extensions like this "trivial." I doubt that will ever get to the top of my list, so if someone else takes it on that'd be rad. Work should probably be coordinated on the CouchApp list: http://groups.google.com/group/couchapp/ Chris > On Mon, Sep 13, 2010 at 8:49 AM, Mark J. Reed <[email protected]> wrote: >> On Mon, Sep 13, 2010 at 11:08 AM, Paweł Stawicki >> <[email protected]> wrote: >>> You can take a look on my blog post: >>> http://pawelstawicki.blogspot.com/2009/12/couchdb.html >>> At the end are reduce parameters explained. >> >> Nitpick: this reduce call given in your post is invalid: >> >>> function(["developer", "manager", "administrator"], [17, 4, 2], true); >> >> Because when rereduce is true, the first parameter (keys) is presumably null. >> >> Basically, a map function emits a (key, value) pair; the plumbing >> automatically adds the document id that was being processed when the >> pair was emitted, so what you get out of the map phase is essentially >> a bunch of triples: (key1, value1, document1), (key2, value2, >> document2), etc. >> >> The reduce function, pre-rereduce, gets some subset of those triples, >> slightly re-organized. A single call to reduce might look like this: >> >> reduce([[key1, document1], [key2, document2], [value1, value2], false) >> >> Unlike classical map/reduce, the reduce function is not guaranteed to >> get all of the values associated with a given key. Nonetheless, it is >> expected to return a single result value (which may be a complex value >> like an array or object). >> >> The results of the reduce function may be passed back into another >> reduce pass. In this case, there are no keys, values, or documents, >> just a single array of results from a previous call to the same reduce >> function. >> >> reduce(null, [reduced1, reduced2, reduced3], true) >> >> - >> Mark J. Reed <[email protected]> >>
