Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 6303 invoked from network); 19 Apr 2010 16:52:48 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 19 Apr 2010 16:52:48 -0000 Received: (qmail 96700 invoked by uid 500); 19 Apr 2010 16:52:47 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 96645 invoked by uid 500); 19 Apr 2010 16:52:46 -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 96637 invoked by uid 99); 19 Apr 2010 16:52:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Apr 2010 16:52:46 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jchris@gmail.com designates 209.85.221.172 as permitted sender) Received: from [209.85.221.172] (HELO mail-qy0-f172.google.com) (209.85.221.172) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Apr 2010 16:52:38 +0000 Received: by qyk2 with SMTP id 2so5493475qyk.0 for ; Mon, 19 Apr 2010 09:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=aBdUkWXHGBEvOeI2EBV3bH5OjFXxg+hnRZeLO6FucEs=; b=RT+fZeS+jVHvXYHiMW9Rq+uf/AkdNoZva9c6yZmJEaOZQ0/+M4zGZ2kVJ70yGETdoY e19yxJpCO2Xx1UgWV7EkdgWMjJiCsGQLzw7libTjTCbqGLfOKHQycXgm8mn0cLxjiD5I h3tyd1YngO/Ij6utFUb4wknI4xBfbtGggFIRw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=hGYF+wIdHus904fTNv8g/hLl2XRnuScQYkAgfGjosc5+OSwNE3+6ZWGkaHLmxU9Cs2 5aGBnKKMcT1o5nx2+1J6lGGqn5dFQYWgv027prpJyJ12jIsyRUfPysXDoQTWQrvc86SY 1QBNBnpUgWkubboefo8RW0OOMN/PE0/11DRn0= Received: by 10.224.110.202 with SMTP id o10mr1769683qap.58.1271695935894; Mon, 19 Apr 2010 09:52:15 -0700 (PDT) Received: from [192.168.0.10] (dpc6745141052.direcpc.com [67.45.141.52]) by mx.google.com with ESMTPS id 21sm4109263qyk.5.2010.04.19.09.51.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 19 Apr 2010 09:52:15 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1077) Subject: Re: Is there anyway to specify a group_level of "id"? From: J Chris Anderson In-Reply-To: Date: Mon, 19 Apr 2010 09:50:57 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <01FC0EB2-79DF-4408-9D13-8E21E7F347F3@gmail.com> References: To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1077) X-Virus-Checked: Checked by ClamAV on apache.org On Apr 19, 2010, at 9:27 AM, Jarrod Roberson wrote: > On Mon, Apr 19, 2010 at 10:10 AM, Adam Kocoloski = wrote: >> On Apr 18, 2010, at 1:37 AM, Jarrod Roberson wrote: >>=20 >>=20 >> Hi Jarrod, I'd need a little more detail or an example before I could = whether what you want to do is possible. Best, >>=20 >> Adam >=20 > I am working on what I think is a clever solution to not being able to > do variable "select where" sql like selections on CouchDB. >=20 > here is my map function >=20 > function(doc) > { > emit(['cnnid', doc.cnnid], null); > emit(['guid', doc.guid], null); > emit(['src', doc.sourceServer], null); > emit(['dest', doc.destServer], null); > } >=20 > running a reduce that works with group_level=3D1 it is merging lists = of > _ids by field. what the result is a unique list of _ids that match > each field name when run with keys=3D[['cnnid',"11111111"],["src","a"]].= > I get output that groups by cnnid and src what I want to do is > rereduce just the "final" output one more time to reduce the keys down > to the unique list of _ids from the resulting groups. >=20 I think this is misuse of CouchDB's reduce, which is really just there = to provide numerical aggregation (or other constant-space operations). = I'm surprised you haven't been hit with the reduce_overflow_error yet. = As your database becomes larger, this will surely happen. If you want to do something like this, you are better off moving all = your uniqueness logic to a _list function, and then optimizing your map = collation to keep the memory usage of your _list low. Chris >=20 > curl -X POST -d '{"keys":[["cnnid","82534864"],["src","a"]]}' > = http://localhost:5984/transfer_central/_design/transfer/_view/search?group= =3Dtrue&group_level=3D1 > looks like this >=20 > {"rows":[ > = {"key":["cnnid","82534864"],"value":["fdbc746e0026B93BD6FE6f83c80de090","f= dbc6f930026B92F3075118c8e46f574","fdbc59760026B92F30754e88a5fb1d0a"]}, > = {"key":["src","a"],"value":["2fe5b7620026B93BD6FE54240135cf78","3028f10100= 26B93BD6FE27430d5ff179","3028f3df0026B93BD6FE1aaf792acaec","48a5d7ab0026B9= 3BD6FE347e40beba22","48a5dada0026B93BD6FE5759f3f61946","48a8630c0026B93BD6= FE6bc36f72aaf9","673fd21a0026B93BD6FE56b473da6a77","673fd4790026B93BD6FE47= aeffcaa16b","67af7dbc0026B93BD6FE3134aabda4b6","67af80b60026B93BD6FE132454= bf17b5"]} > ]} >=20 > I tried group_level=3D0 but that does the same thing as 1 in my case. = I > tried hacking at the Erlang source to get it to run a another final > rereduce with a "special" group_level=3D9999 but I didn't have any = luck > getting that to work. What I finally resorted to is a List function > that does the final reduce/merge of the _ids (same thing the reduce > function is doing really) but I really think it would be clever if I > could get the reduce to run one last rereduce instead of the List > function solution. >=20 > Here is a post about it in more detail > = http://www.vertigrated.com/blog/2010/04/where-clauses-like-selects-against= -couchdb/