Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 23939 invoked from network); 11 Jul 2008 19:51:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Jul 2008 19:51:39 -0000 Received: (qmail 23220 invoked by uid 500); 11 Jul 2008 19:51:39 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 23188 invoked by uid 500); 11 Jul 2008 19:51:39 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 23177 invoked by uid 99); 11 Jul 2008 19:51:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jul 2008 12:51:38 -0700 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 jchris@gmail.com designates 209.85.146.178 as permitted sender) Received: from [209.85.146.178] (HELO wa-out-1112.google.com) (209.85.146.178) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jul 2008 19:50:44 +0000 Received: by wa-out-1112.google.com with SMTP id m16so2555193waf.6 for ; Fri, 11 Jul 2008 12:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:mime-version:content-type:content-transfer-encoding :content-disposition:x-google-sender-auth; bh=vYCT7O4H64Sd7dWXbZ68mg4wPtrXZnVuySTIQTSY6u4=; b=fp/r4L5cPHcb/ey3P0uR0b1TzN9okhR5Amx4ovWx112VYrHuewHkUeMeE6xCoMEq7W iDAtmjlWcqMMi4/UztKY8NK91a3lgAGu/IlZaCkWn+pzU2GpQ17yBPXP4XQndwxTkzS0 5R1thtqUrB2Aet75s3SALbt4yXpU0d3s7/mSo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition:x-google-sender-auth; b=HNBNeysATwGKdIvzyo4+JRnI09/OXAmxfn21qTwEN6KEqPILdixh6xkXvyk91z8RLs HK+7Ye67VWOY96+sG0xYrwYqKWH7PPZUbCU/ymKpZnozZHcIBGgEgR0tgqOv4ZjBah9V 1jMi0az98frIIXGoaqtf7mwkw9jbmrWltNrK4= Received: by 10.114.211.1 with SMTP id j1mr14546931wag.103.1215805867546; Fri, 11 Jul 2008 12:51:07 -0700 (PDT) Received: by 10.114.78.7 with HTTP; Fri, 11 Jul 2008 12:51:07 -0700 (PDT) Message-ID: Date: Fri, 11 Jul 2008 12:51:07 -0700 From: "Chris Anderson" Sender: jchris@gmail.com To: couchdb-user@incubator.apache.org Subject: reduce function without return value MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 55f21d71cc79c053 X-Virus-Checked: Checked by ClamAV on apache.org I'm implementing a job-pool with CouchDB, and have found a use-case that the reduce functionality almost-but-not-quite handles perfectly. I'd like the option to have reduce functions elect not to return anything (or undefined I guess as they'd look the same to the interpreter) and have that key be left out of the final group=true result altogether. Currently the reduction process fails with the "Cannot encode 'undefined' value as JSON" error. The idea is that I have a view that calls emit(key,"todo"). A job runner picks up the keys and runs a job. When the job is complete, the job runner creates a document which then emits to the same key, but with value "done". Completed jobs show up in the map as (key, "todo") next to (key, "done"). Currently I can write a reduce fro group=true which is always (key, "done") once the job is complete. I'd like to have a reduce where the "done" keys are completely absent. Not high-priority (I can just ignore the done keys for now) but it will be a nice thing to have once I get into a situation where the majority of keys are done. I haven't thought through the consequences when group=false, but the job pool pattern seems a common enough use case to consider. Is it possible to support this behavior? -- Chris Anderson http://jchris.mfdz.com