Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 36951 invoked from network); 21 May 2010 08:01:54 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 May 2010 08:01:54 -0000 Received: (qmail 19156 invoked by uid 500); 21 May 2010 08:01:53 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 18955 invoked by uid 500); 21 May 2010 08:01:50 -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 18947 invoked by uid 99); 21 May 2010 08:01:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 May 2010 08:01:50 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of tom.sante@gmail.com designates 74.125.82.180 as permitted sender) Received: from [74.125.82.180] (HELO mail-wy0-f180.google.com) (74.125.82.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 May 2010 08:01:41 +0000 Received: by wyi11 with SMTP id 11so327683wyi.11 for ; Fri, 21 May 2010 01:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=sE23pCLX3A3g60HJYHfnZMHWmU3o2/LRgQusZW479+w=; b=bCZgfb7+feOcP4Et7gJGNmrMdEbkcIaW5U9dhxp7v9lXwqpUWMd9PwR/K9dteiVi9D tdRCaEOIy0Gpqqbzuo0KplR11IzWCHSoIEHq0/Wqenwk1RSPem7Bmqtbqlr8O7HbcNVe LmTnD8BhrqXJXc4KJMDEwh3j//R0qFfF9HZZ0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=rUT0ibSnjp5rgK1ohjWS2VUzHpUjUlo4Z2sDjCAy2eD7WLS+lkVHsnFFXSFAqO/t0c apqkCbeBT6D8xXwT/+dmbWwBhbv+JGH5awccBdCH4ZfIcB8iam2VQiDICQizQ9n8NK4m 8Clr9etr3MJ74YxqdIItRNIx6zkFJXflVBsXk= Received: by 10.227.127.132 with SMTP id g4mr1015470wbs.177.1274428878679; Fri, 21 May 2010 01:01:18 -0700 (PDT) Received: from pb.local (145.234-246-81.adsl-dyn.isp.belgacom.be [81.246.234.145]) by mx.google.com with ESMTPS id p37sm1562933gvf.28.2010.05.21.01.01.15 (version=SSLv3 cipher=RC4-MD5); Fri, 21 May 2010 01:01:17 -0700 (PDT) Message-ID: <4BF63DC9.7060304@gmail.com> Date: Fri, 21 May 2010 10:01:13 +0200 From: Tom Sante User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.4) Gecko/20100519 Lanikai/3.1pre MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: Reduce function results References: <4BF51F4F.4070706@gmail.com> <4BF5CC48.7010604@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Yeah I'll try that, see if it gives me any clues. Is there a way to run your code manually for debugging via the command line with the JS engine the way couch calls it to build the view? (like an interactive mode of couchjs) On 21/05/10 04:59, Zachary Zolton wrote: > Reduce functions can be tricky. My best advice: try log()'ing all your > input and intermediary results; the answer usually jumps out to ya. > > On Thursday, May 20, 2010, Tom Sante wrote: >> On 20/05/10 23:52, David Goodlad wrote: >> >> On Thu, May 20, 2010 at 9:38 PM, Tom Sante wrote: >> >> Hi, >> >> I have a reduce function like this: >> [snip] >> So for some reason if there is only 1 element to be reduced, on the line of >> res[v_n]={'mi':v,'ma':v,'c':1,'t':v}; >> v becomes v={} and not the actual number. Any ideas why? >> >> I tested the reduce function with the command line 'js' and send it the >> above test keys manually as function argument and then it does result in the >> correct return: >> "01:00:000074" -> {raw: {mi: -0.213, ma: -0.213, c: 1, t: -0.213}} >> "01:00:000084" -> {raw: {mi: -0.213, ma: -0.213, c: 1, t: -0.213}} >> >> >> Sounds like you need to specify group_level; Try playing around in >> Futon, you'll see a group_level dropdown. >> >> Dave >> >> >> Why would I need a group_level parameter? >> My key is a simple string "01:00:000074". >> Its my values don't get correctly generated by couchjs, since it does out but proper values in normal commandline js. >> >> var v = new Number(values[val][v_n]); >> if(res.hasOwnProperty(v_n)){ >> res[v_n].mi = Math.min(v,res[v_n].mi); >> res[v_n].ma = Math.max(v,res[v_n].ma); >> res[v_n].c++; >> res[v_n].t += v; >> }else{ >> res[v_n]={'mi':v,'ma':v,'c':1,'t':v}; >> } >> >> It seems that in the above part in the 'else' case the v isn't a number but an empty object {} >>