From user-return-16278-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Fri May 20 14:00:11 2011 Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A07286C70 for ; Fri, 20 May 2011 14:00:11 +0000 (UTC) Received: (qmail 50691 invoked by uid 500); 20 May 2011 14:00:09 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 50662 invoked by uid 500); 20 May 2011 14:00:09 -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 50654 invoked by uid 99); 20 May 2011 14:00:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 May 2011 14:00:09 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of stephenp@agrussell.com designates 204.251.33.236 as permitted sender) Received: from [204.251.33.236] (HELO bifrost.agrussell.com) (204.251.33.236) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 May 2011 14:00:01 +0000 Received: from [192.168.16.106] (mccul.agrussell.com [204.251.33.100]) by bifrost.agrussell.com (8.14.4/8.14.4) with ESMTP id p4KDxX16035598 for ; Fri, 20 May 2011 08:59:38 -0500 (CDT) (envelope-from stephenp@agrussell.com) Message-Id: From: Stephen Prater To: user@couchdb.apache.org In-Reply-To: <249BE0F5-6A1B-4CA7-AC40-8F3085AE2D9D@sri.com> Content-Type: multipart/alternative; boundary=Apple-Mail-2--972225657 Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: Reduce function to perform a Union? Date: Fri, 20 May 2011 08:59:32 -0500 References: <249BE0F5-6A1B-4CA7-AC40-8F3085AE2D9D@sri.com> X-Mailer: Apple Mail (2.936) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bifrost.agrussell.com X-Old-Spam-Status: No, score=-101.9 required=6.0 tests=BAYES_00,HTML_MESSAGE, T_RP_MATCHES_RCVD,USER_IN_WHITELIST autolearn=ham version=3.3.1 --Apple-Mail-2--972225657 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Why do you need to reduce those docs? In this particular exmple, you can do a range query on the key and get the same (basically) results. Also, I think the growth rate for reduce functions is log(rows) - so reducing the view size by 50% is still going to run up against the limit. On May 19, 2011, at 9:41 PM, Jim Klo wrote: > I'm a little dumbfounded by reduce functions. > > What I'm trying to do is take a view that has heterogeneous values > and union into a single object; logically this seems like what the > reduce function should be capable of doing, but it seems I keep > getting the reduce overflow error. Effectively I'm reducing the view > by 50%. > > Consider the the simplistic scenario: > > doc A: { _id : "abc123", type:"resource", keyword:"nasa" } > doc B: { _id : "abc123-timestamp", type: "timestamp", timestamp: > "2011/05/19T12:00:00.0000Z", ref_doc: "abc123" } > doc N: .... > > Doc A is the original doc... Doc B is the timestamp doc referencing > Doc A via ref_doc field... Doc N is just another doc also > referencing Doc A via ref_doc field. > > I can create a view that essentially looks like: > > Key Value > ------------ ------------------ > "abc123" { .... doc A object .... } > "abc123" { .... doc B object .... } > "abc123" { .... doc N object .... } > > I would expect I could build a reduced view that looks something > like this: > > Key Value > ------------ ------------------ > "abc123" { .... merged doc .... } > > Ultimately this goes back to an issue we have where we need the node > local timestamp of a document, without generating an event that > would cause an update to doc A, causing it to get replicated. We > figure we can store local data like a timestamp then join it back > with the original doc via a view & list. > > Is there something magical about the reduce that's not well > documented? Or maybe is there a better way to do this? I know about > using linked docs, were in my map function you can reference the _id > of the linked document in the value you can return @ 1 - 1 merge > with the include_docs=true, but don't think I can do that with N > docs; or can I? > > Jim Klo > Senior Software Engineer > Center for Software Engineering > SRI International > > > > --Apple-Mail-2--972225657--