Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 71736 invoked from network); 2 Jan 2011 11:52:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Jan 2011 11:52:53 -0000 Received: (qmail 65316 invoked by uid 500); 2 Jan 2011 11:52:51 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 65105 invoked by uid 500); 2 Jan 2011 11:52:51 -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 65097 invoked by uid 99); 2 Jan 2011 11:52:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Jan 2011 11:52:50 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bitroot@gmail.com designates 209.85.216.52 as permitted sender) Received: from [209.85.216.52] (HELO mail-qw0-f52.google.com) (209.85.216.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Jan 2011 11:52:45 +0000 Received: by qwi4 with SMTP id 4so13122476qwi.11 for ; Sun, 02 Jan 2011 03:52:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=4FqS7cJGPKl8uCZTgN2mrTqHWCaD4Wjj9QEk6o1wD8g=; b=d24a/tY0yO2DemU5fTOALmCllSPGoeDy0LLOPdhF0fEofs8JypqLsTu9gGTDs2xd/c Ml4xfeesBIpXmaR/V5wmBC51J8gxz2Nw+8G23B9PyrYb3tv9LU/WmxZC42/Q3b+gLl1Z RF1QT61NRfcrCpLSmZiNbgNjiIO2TIiP83ozQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=mmDCh79KwFze8prJVUCJq5TaifI9NyxJ2u35OLBEdAz3e4dV9Qe4pOL1u+t9YPWfj9 0lQ7A2NJGlqeLTh2zYzC7C8KJFrrWMQUUGVqb8bES2XN734NYtCayxUq//VFv3gOYpX0 ClKtJxZH1/L8PYK+pCeYqdxNph6ZHW5FgJs78= MIME-Version: 1.0 Received: by 10.229.91.147 with SMTP id n19mr17120899qcm.153.1293969143207; Sun, 02 Jan 2011 03:52:23 -0800 (PST) Sender: bitroot@gmail.com Received: by 10.229.222.72 with HTTP; Sun, 2 Jan 2011 03:52:23 -0800 (PST) Date: Sun, 2 Jan 2011 11:52:23 +0000 X-Google-Sender-Auth: XcVK-9jppNBy9XaKd18FuzHHdI0 Message-ID: Subject: Document versioning with multiple documents From: Joe Freeman To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 I'm trying to implement document versioning using a variation of the method described under 'Multiple Documents' here: http://blog.couchone.com/post/632718824/simple-document-versioning-with-couchdb (I'd like to have been able to use the 'attachPrevRev' approach, but unfortunately that doesn't seem to allow me to setup a view that lists all the revisions for a document - i.e., I can't access the older revisions (attachments) from the view server.) I have documents like this: {_id: '1', type: 'page'} {_id: '2', type: 'page_revision', page: '1', created_at: [2011, 1, 1, 11, 28, 0], content: 'First revision of first page.'} {_id: '3', type: 'page'} {_id: '4', type: 'page_revision', page: '3', created_at: [2011, 1, 1, 11, 29, 0], content: 'First revision of second page.'} {_id: '5', type: 'page_revision', page: '3', created_at: [2011, 1, 1, 11, 30, 0], content: 'Second revision of second page.'} My view then has a map function: function(doc) { if (doc.type == 'page_revision') { emit([doc.page, doc.created_at], doc); } } Which emits the following keys: [1, [2011, 1, 1, 11, 28, 0]] // First revision of first page. [3, [2011, 1, 1, 11, 29, 0]] // First revision of second page. [3, [2011, 1, 1, 11, 30, 0]] // Second revision of second page. So I add a reduce function to get the latest revision for each page (and use group_level=1): function(keys, values) { return values[values.length - 1]; } When I try to run this, I get a 'reduce_overflow_error' ("Reduce output must shrink more rapidly"), and I think I understand why. However, if I change the reduce function to this: function(keys, values) { return values[values.length - 1]; /*aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa*/ } (i.e., pad out the content of the function with a comment) Then I don't get the overflow error, and I get the result I was expecting. So this raises two questions: 1) Does the fact that I initially get the overflow error suggest that there's something wrong with my approach? 2) Why don't I get the error in the second case? And hence, can anyone suggest how I should be solving this problem? Thanks :)