From user-return-12617-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Mon Sep 13 18:27:31 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 9701 invoked from network); 13 Sep 2010 18:27:31 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 Sep 2010 18:27:31 -0000 Received: (qmail 89189 invoked by uid 500); 13 Sep 2010 18:27:30 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 89023 invoked by uid 500); 13 Sep 2010 18:27:29 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 89015 invoked by uid 99); 13 Sep 2010 18:27:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Sep 2010 18:27:29 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.216.180] (HELO mail-qy0-f180.google.com) (209.85.216.180) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Sep 2010 18:27:22 +0000 Received: by qyk31 with SMTP id 31so5988823qyk.11 for ; Mon, 13 Sep 2010 11:27:01 -0700 (PDT) Received: by 10.224.80.133 with SMTP id t5mr72631qak.42.1284402421392; Mon, 13 Sep 2010 11:27:01 -0700 (PDT) Received: from [10.0.1.2] (c-24-130-240-73.hsd1.ca.comcast.net [24.130.240.73]) by mx.google.com with ESMTPS id t1sm6675425qcs.45.2010.09.13.11.26.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 13 Sep 2010 11:27:00 -0700 (PDT) Sender: J Chris Anderson Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Apple Message framework v1081) Subject: Re: Testing map/reduce functions From: J Chris Anderson In-Reply-To: Date: Mon, 13 Sep 2010 11:26:57 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <54F05625-C0B7-4D23-A072-7EFC2D7FE83B@apache.org> References: <4C88DC59.5030809@cedarsoft.com> <4C8E3D23.7090906@cedarsoft.com> To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1081) 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 ..... >=20 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 = wrote: >> On Mon, Sep 13, 2010 at 11:08 AM, Pawe=C5=82 Stawicki >> 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. >>=20 >> Nitpick: this reduce call given in your post is invalid: >>=20 >>> function(["developer", "manager", "administrator"], [17, 4, 2], = true); >>=20 >> Because when rereduce is true, the first parameter (keys) is = presumably null. >>=20 >> 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. >>=20 >> The reduce function, pre-rereduce, gets some subset of those triples, >> slightly re-organized. A single call to reduce might look like this: >>=20 >> reduce([[key1, document1], [key2, document2], [value1, value2], = false) >>=20 >> 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). >>=20 >> 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. >>=20 >> reduce(null, [reduced1, reduced2, reduced3], true) >>=20 >> - >> Mark J. Reed >>=20