Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 31799 invoked from network); 28 Jul 2009 00:43:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jul 2009 00:43:58 -0000 Received: (qmail 86944 invoked by uid 500); 28 Jul 2009 00:45:01 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 86871 invoked by uid 500); 28 Jul 2009 00:45:01 -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 86861 invoked by uid 99); 28 Jul 2009 00:45:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 00:45:01 +0000 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 paul.joseph.davis@gmail.com designates 209.85.132.240 as permitted sender) Received: from [209.85.132.240] (HELO an-out-0708.google.com) (209.85.132.240) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 00:44:53 +0000 Received: by an-out-0708.google.com with SMTP id b2so1673791ana.5 for ; Mon, 27 Jul 2009 17:44:32 -0700 (PDT) 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=9SurS/vEpc7WjhTyQicxOnNI+k/C9n3V+2tbtGuCiwk=; b=Wh1E/l1OZVZfB9kB2zw/8GWAJTcz3uh2V6lrSqiT5Zdl4cFluGmPqdQSn86FUFLcFt ipR9Z6qOaK7VTE7O/ilOeE7A1UlUbWoccwK3XsCg28UIn85VInjqmqj/wda+kO8O+mb2 sajUWKewvITwlG/HqR3nNyOGPpCbBmsXHLDUM= 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=r/9N0T0fxhgLmkeeX4I7vEZuWFUbmJKATDMJJEU6XyjE0FwYmOnxI0ZU7QSwTSO8d+ F8EIBnVjAh9RvcW5Hu2dzuRdiO1qvLZZkervdNDTcV5fS9hMOXBB2L7obZRDsd0xx1Ch ZAGENSvpN0nrT2JCqUIOBuJF1v+SaxvTbYm9E= MIME-Version: 1.0 Received: by 10.100.174.14 with SMTP id w14mr9076504ane.158.1248741872922; Mon, 27 Jul 2009 17:44:32 -0700 (PDT) In-Reply-To: <6d692b470907271733o3edca47aj4b4664fb0abeb559@mail.gmail.com> References: <6d692b470907271733o3edca47aj4b4664fb0abeb559@mail.gmail.com> Date: Mon, 27 Jul 2009 20:44:32 -0400 Message-ID: Subject: Re: Problems with reduce in view appear when record size > 6 From: Paul Davis To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Looks like you're creeping past the end of the array and getting an undefined value which the JSON serializer refuses to convert. Try protecting against it with '|| null' towards the end of your array access. Paul On Mon, Jul 27, 2009 at 8:33 PM, Jochen Kempf wrote: > Hi, > > I am experiencing a problem when using a reduce in the following way: > > First, I define a map function returning at least 4 values (here i define= 6 > values) --> > >> function(doc) { >> =A0 emit(doc["_id"], [doc["_id"], doc["_rev"], doc["var1"], doc["var2"], >> doc["var3"], doc["var4"], doc["var5"]]); >> } > > > > Until here, everything works fine! > But once I define the following reduce function it stops working from 6 o= r 7 > records on upwards (if the total record size of the corresponding databas= e > is < 6 it works fine): > >> function(key, values, combine) { >> =A0 =A0 =A0 =A0 var ids =3D []; >> =A0 =A0 =A0 =A0 var revs =3D []; >> =A0 =A0 =A0 =A0 var variables =3D []; >> =A0 =A0 =A0 =A0 for (i in values) { >> =A0 =A0 =A0 =A0 =A0 ids.push(values[i][0]); >> =A0 =A0 =A0 =A0 =A0 revs.push(values[i][1]); >> =A0 =A0 =A0 =A0 =A0 variables.push([values[i][2], values[i][3], values[i= ][4], >> values[i][5], values[i][6]]); >> =A0 =A0 =A0 =A0 } >> =A0 =A0 =A0 =A0 return [ids, revs, variables]; >> =A0 =A0 =A0 } > > > This is the error message: > >> Error: case_clause >> > {{badmatch,<<"Cannot encode 'undefined' value as JSON">>}, >> =A0[{couch_query_servers,'-rereduce/3-fun-0-',3}, >> =A0 {lists,zipwith,3}, >> =A0 {couch_query_servers,rereduce,3}, >> =A0 {couch_view_group,'-init_group/4-fun-0-',4}, >> =A0 {couch_btree,'-write_node/3-lc$^0/1-0-',3}, >> =A0 {couch_btree,write_node,3}, >> =A0 {couch_btree,complete_root,2}, >> =A0 {couch_btree,query_modify,4}]} >> > > Anyone knows what is going on? >