Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 5215 invoked from network); 3 Mar 2009 14:53:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Mar 2009 14:53:05 -0000 Received: (qmail 72752 invoked by uid 500); 3 Mar 2009 14:53:00 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 72100 invoked by uid 500); 3 Mar 2009 14:52:59 -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 72089 invoked by uid 99); 3 Mar 2009 14:52:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Mar 2009 06:52:59 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of wmertens@cisco.com designates 144.254.15.119 as permitted sender) Received: from [144.254.15.119] (HELO av-tac-bru.cisco.com) (144.254.15.119) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Mar 2009 14:52:50 +0000 X-TACSUNS: Virus Scanned Received: from strange-brew.cisco.com (localhost [127.0.0.1]) by av-tac-bru.cisco.com (8.11.7p3+Sun/8.11.7) with ESMTP id n23EqTn23817 for ; Tue, 3 Mar 2009 15:52:29 +0100 (CET) Received: from dhcp-10-61-99-131.cisco.com (dhcp-10-61-99-131.cisco.com [10.61.99.131]) by strange-brew.cisco.com (8.11.7p3+Sun/8.11.7) with ESMTP id n23EqSt27090 for ; Tue, 3 Mar 2009 15:52:28 +0100 (CET) Message-Id: From: Wout Mertens To: user@couchdb.apache.org In-Reply-To: <92E0BD49-BD57-4CBD-B0BD-2A8391C00E81@apache.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: [user] Obtaining unique values from a view Date: Tue, 3 Mar 2009 15:52:25 +0100 References: <55fad2460903030527r1295a39bl675478e8a9c5266d@mail.gmail.com> <3EA1C6DC-6331-4068-A89C-DBC462D0B890@cisco.com> <55fad2460903030558r34a2d6b9j5eda578f6002cca4@mail.gmail.com> <64BABFD7-8543-4762-B349-688E76ED6DB2@cisco.com> <92E0BD49-BD57-4CBD-B0BD-2A8391C00E81@apache.org> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org On Mar 3, 2009, at 3:29 PM, Jan Lehnardt wrote: > On 3 Mar 2009, at 15:08, Wout Mertens wrote: > >> On Mar 3, 2009, at 2:58 PM, Manolo Padron Martinez wrote: >> >>>> I believe this has been covered in this thread: >>>> http://markmail.org/thread/lwqfwlscrvilwm34 >>>> >>>> but I think a totally satisfactory answer was not found. >>> >>> Thanks that works for me. >> >> Actually now I'm curious where the sum() function comes from. I >> can't find it in any Javascript references. Is it something Couch >> provides? >> >> Answer: grepping through the source showed me it's in main.js. >> >> Since this question has been posed more than once, maybe main.js >> should have a uniq() function as well? > > Patches welcome :) Feel free to submit uniq() to JIRA: > > https://issues.apache.org/jira/browse/COUCHDB Actually it's slightly more difficult than I thought since the most efficient way to implement it is by guaranteeing that input is sorted. Here's a nice implementation: http://www.code-shop.com/2007/5/14/javascript-uniq so maybe the uniq() function should take the re-reduce parameter and if that's not set, sort the input? Would that be acceptible for a function in main.js? Wout.