incubator-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: 'Grouping' documents so that a set of documents is passed to the view function
Date Mon, 22 Jun 2009 19:05:31 GMT
On Mon, Jun 22, 2009 at 09:49:15PM +0800, hhsuper wrote:
> Brian's decription for reduce function is clearly, but i think you can
> achieve your goal as below:
> 
> function(doc){
>   emit(doc.group_key, doc)
> }
> 
> function(keys,values,rereduce){
>   //...
> }
> 
> with the group=true option you can impl doc process by group_key in reduce
> function,
> as your example reduce will be invoke two times with values:
> [firstdoc,seconddoc] which groupkey=1.... [thirddoc,forthdoc]  groupkey=2,

No, what I'm saying is it will *not necessarily* be invoked that way. If
there are only a handful of documents with the same group key then it is
quite likely to be invoked that way. However if there are dozens or hundreds
of documents with the same group key, it could be invoked like this:

  reduce(first bunch of documents)    => R1
  reduce(second bunch of documents)   => R2
  rereduce(R1,R2)

Mime
View raw message