Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 36474 invoked from network); 20 Jan 2009 02:25:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Jan 2009 02:25:16 -0000 Received: (qmail 34154 invoked by uid 500); 20 Jan 2009 02:25:14 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 34125 invoked by uid 500); 20 Jan 2009 02:25:14 -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 34114 invoked by uid 99); 20 Jan 2009 02:25:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Jan 2009 18:25:14 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of dundeemt@gmail.com designates 209.85.198.233 as permitted sender) Received: from [209.85.198.233] (HELO rv-out-0506.google.com) (209.85.198.233) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jan 2009 02:25:06 +0000 Received: by rv-out-0506.google.com with SMTP id g37so2920592rvb.35 for ; Mon, 19 Jan 2009 18:24:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=lSzI9d7N4GhvKoYwnkE4mxtpnPUKtKp/Olspmo3iiYM=; b=wujHua2ntTPy+WprcpfJdF1nNyBGH9kEFOs3Kbo8tCORqY/ZGJx4pTwsL2C38hIG3n FFSZyp0Zvb0kaKORvWeE/9WxCSyEwYwrWuyr/fCugX+APVwrEsmqMFTZFSAoEusZZdYk UVqgShz+q7Gbhy4N0qDY49ZYpuH9jCnwvg90s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:content-type; b=Cx4/2g0aHF78KG6evTgPfE5QqSWnmYa4QM4tkhrHZg6eTRQg/B7A4P1iA/BLpvuRHM cuSlVeRajzR7qYi34rmniqprJlO3csAuOZk4XwFQn4wrZtIafvzrXG+X3ljXfDHbQhx8 0LRknyN9/pTGrQuN3DCkfahYIjRGvEzwIzHMk= MIME-Version: 1.0 Received: by 10.141.197.14 with SMTP id z14mr1038583rvp.63.1232418284350; Mon, 19 Jan 2009 18:24:44 -0800 (PST) Reply-To: tech@dundeemt.com In-Reply-To: References: <5aaed53f0901191615r6062c9e3gf1dd966ec206bd03@mail.gmail.com> Date: Mon, 19 Jan 2009 20:24:44 -0600 Message-ID: <5aaed53f0901191824r581ef9c1wcb977230d2b780a1@mail.gmail.com> Subject: Re: on Reduce w/ Python view server From: "Jeff Hinrichs - DM&T" To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=000e0cd28e3a0dae3c0460e0be74 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd28e3a0dae3c0460e0be74 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Mon, Jan 19, 2009 at 6:25 PM, Paul Davis wrote: > On Mon, Jan 19, 2009 at 7:15 PM, Jeff Hinrichs - DM&T > wrote: > > Using couchdb-python 0.5 and couchdb 0.9.0a735191-incubating > > > > I am working on a "rosetta stone" for javascript and python views. > (nothing > > like rewriting in a different language to lean something) I've worked > > though the simple map only views. I then did a simple reduce(keys,vals) > > which worked out fine. But I am stumped on rereduce when the function > > signature includes keys,vals,rereduce. I've been trying to work through > the > > js code from "Top N Tags" from the snippets page, > > http://wiki.apache.org/couchdb/View_Snippets > > > > In particular, I am confused as to what is passed to the rereduce > function > > when rereduce=True. The javascript is returning a complex structure > instead > > of a simple scalar, I see that it has to do with getting state back from > a > > previous reduce operation, but I'm confused. The unpacking of the > previous > > results, I think has me befuddled ;( > > > > The reduce function is always returning a structure of the form: > > { > "tag1": N1, > "tag2": N2, > ... > } > > When you get to rereduce=true, then the values array is an array of > the structures that your code needs to combine. > > And for berevity, the last bit of code outside the if statement is > just discarding all tags below the top N so that the growth of data > doesn't exceed the log(num_rows) rule. > > HTH, > Paul Davis > > That make sense from what I am reading. thanks. Any idea about the python view server from couchdb-python? The values tuple being returned works just fine however, the keys tuple, which appears to be a tuple of tuples is causing my reduce function to fail silently whenever I try to access an element by index. keys looks like [[tag, object_id],[tag, object_id],...] However when I try to access keys[0] (should be [tag, object_id]) or keys[0][0] (should be 'tag') my reduce script silently fails. If I just ignore tags and sum the values in a simple map/reduce I get the correct counts as simple vectors or atleast the same answer as the javascript equivalent. I'm hoping CMLenz will join the discussion or someone point me in the proper direction. Regards, Jeff --000e0cd28e3a0dae3c0460e0be74--