Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 74345 invoked from network); 5 Feb 2009 16:23:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Feb 2009 16:23:50 -0000 Received: (qmail 47055 invoked by uid 500); 5 Feb 2009 16:23:44 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 47024 invoked by uid 500); 5 Feb 2009 16:23:44 -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 47013 invoked by uid 99); 5 Feb 2009 16:23:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2009 08:23:44 -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 matt.goodall@gmail.com designates 209.85.134.191 as permitted sender) Received: from [209.85.134.191] (HELO mu-out-0910.google.com) (209.85.134.191) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2009 16:23:37 +0000 Received: by mu-out-0910.google.com with SMTP id w8so249279mue.5 for ; Thu, 05 Feb 2009 08:23:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ODLvaSjIW1XfOXzDuyMrWVsD0PisjkyPJKsRaakuFw0=; b=FTDZHV/sxZLo5houxOjNXSCJoI7ZQA+e8Sf9Gp6xtsIzbLjgwtLW+uabLXwDPUk2fe kreag1wKnSgRqnxFg6zr2Mx4QOfzHWQCmCIc5K4ODb+AdPJ3OONdyAlSWpL7FCliMuql Dntdyk+4s3R1mGJ8PdIgMaMoQyi5ql7wTgL8A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=Eiy0w5EWdQD2FjFs4SiGlh+0GdfK69JbbJWyinWoE27KkiQjdWM3dVuFjVq771Pn4O kEaq+tRilA24l0RrabNCb8G6j1loZHl4nIdmhB43ENxHQwwrjzF1VcTbjr5A8Vorth7w jvXuAC81QQUEhnFeBpFoQZdL95yp1fCgWOH24= MIME-Version: 1.0 Received: by 10.181.30.10 with SMTP id h10mr210821bkj.200.1233850995656; Thu, 05 Feb 2009 08:23:15 -0800 (PST) In-Reply-To: <498AFF12.6080409@gmx.de> References: <214c385b0902050633gac8a0b4g9c52f98de85d1c70@mail.gmail.com> <7c40ded80902050642o43770a11jc3c536feffe21604@mail.gmail.com> <7c40ded80902050644y644678cdj6be04ca8dddf1b90@mail.gmail.com> <214c385b0902050650n6a911e9cw9a0b9f86e049ea5@mail.gmail.com> <498AFF12.6080409@gmx.de> Date: Thu, 5 Feb 2009 16:23:15 +0000 Message-ID: <214c385b0902050823vc9c7f3fld0f0d4245ad296ca@mail.gmail.com> Subject: Re: Reduce to nothing From: Matt Goodall To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 2009/2/5 Michael Marks : > How about having a third attribute "state": with possible values "active", Sure, that's possible but it defeats the point of my original post, i.e. not touching the original document. Just to be clear, I know you can stick any old attribute on a "thing" document and filter it in a view. What I'm interested in is using the reduce function in more interesting ways that /may/ have additional benefits in some cases. - Matt > Matt Goodall schrieb: >> >> 2009/2/5 Jeremy Wall : >> >>> >>> Can't you just have the map screen out the cancellations? Seems like >>> that's >>> the most natural spot for the behaviour you want. >>> >> >> Nope, because the "thing" doesn't know it's been cancelled. >> >> - Matt >> >> >> >>> >>> On Feb 5, 2009 8:34 AM, "Matt Goodall" wrote: >>> >>> Hi, >>> >>> Is it possible to reduce a key to nothing, i.e. completely remove a >>> key from the reduction result. >>> >>> For instance, say you post three documents: >>> >>> {"_id": "thing1", "type": "thing"} >>> {"_id": "thing2", "type": "thing"} >>> {"_id": "...", "type": "cancellation", "cancels": "thing1"} >>> >>> It's trivial to produce a map function that collates the "thing" and >>> "cancellation" documents. However, I can't work out how, or even it >>> it's possible, to reduce the view that so that only "thing2" remains. >>> >>> This seems like it might be a useful thing to be able to do at times. >>> For instance, posting a "cancellation" document effectively removes a >>> "thing" from the database. Nothing needs to touch the "thing", >>> avoiding any chance of conflicts and it doesn't matter how many >>> "cancellation" documents get posted making cancellation an idempotent >>> operation. >>> >>> I tried not returning anything, just in case it worked ;-), but got a >>> JSON encoding error (can't encode undefined, iirc). That would be a >>> simple approach. However, I wondered if the more "normal" approach of >>> allowing a reduce function to emit zero or more (key, value) pairs >>> would be even better? Not sure if that would break the incremental >>> reduce though. >>> >>> Any ideas, or is there another way to achieve this that I'm missing? >>> >>> - Matt >>> >>> >> >> >