couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: Problems with reduce in view appear when record size > 6
Date Tue, 28 Jul 2009 00:44:32 GMT
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<jochenkempf@gmail.com> 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) {
>>   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 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?
>

Mime
View raw message