couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject Re: Problems with reduce in view appear when record size > 6
Date Wed, 29 Jul 2009 09:35:54 GMT
On Mon, Jul 27, 2009 at 08:33:48PM -0400, Jochen Kempf wrote:
> But once I define the following reduce function it stops working from 6 or 7
> records on upwards (if the total record size of the corresponding database
> is < 6 it works fine):
> 
> > function(key, values, combine) {
> >         var ids = [];
> >         var revs = [];
> >         var variables = [];
> >         for (i in values) {
> >           ids.push(values[i][0]);
> >           revs.push(values[i][1]);
> >           variables.push([values[i][2], values[i][3], values[i][4],
> > values[i][5], values[i][6]]);
> >         }
> >         return [ids, revs, variables];
> >       }
> 
> 
> This is the error message:
> 
> > Error: case_clause
> >
> {{badmatch,<<"Cannot encode 'undefined' value as JSON">>},
> >  [{couch_query_servers,'-rereduce/3-fun-0-',3},
> >   {lists,zipwith,3},
> >   {couch_query_servers,rereduce,3},
> >   {couch_view_group,'-init_group/4-fun-0-',4},
> >   {couch_btree,'-write_node/3-lc$^0/1-0-',3},
> >   {couch_btree,write_node,3},
> >   {couch_btree,complete_root,2},
> >   {couch_btree,query_modify,4}]}
> >
> 
> Anyone knows what is going on?

Yes, one of ids, revs or variables is undefined :-)

You can use 'log' to see what values are being passed into your reduce
function.

As a guess, I'd say that a re-reduce operation is taking place: 'combine'
will be true, 'key' will be null, and 'values' will be the output of a
previous reduce operation.

That is: your reduce function must be written in such a way as to be able to
process values generated by a previous reduce function, as well as values
emitted by a document. The Wiki talks about this further.

Mime
View raw message