You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by hhsuper <hh...@gmail.com> on 2009/06/15 08:28:17 UTC

when we should implement the rereduce in reduce function

Hi, guys, I need some help, i want to know when we should implement the
rereduce in reduce function?

-- 
Yours sincerely

Jack Su

Re: when we should implement the rereduce in reduce function

Posted by Rangachari Anand <rx...@gmail.com>.
On Sun, Jun 21, 2009 at 9:20 PM, Oliver Boermans<bo...@gmail.com> wrote:
> Nice diagram Brian!
>
> Sent from the olliPod
>

I would second this - If someone could add it to the Wiki, it would
definitely help new comers.

Anand

Re: when we should implement the rereduce in reduce function

Posted by Oliver Boermans <bo...@gmail.com>.
Nice diagram Brian!

Sent from the olliPod

On 22/06/2009, at 5:51 AM, Brian Candler <B....@pobox.com> wrote:

>
>    doc \
>    doc -> reduce -
>    doc /          \
>    doc \           \
>    doc -> reduce ---rereduce --> answer
>    doc /           /
>    doc \          /
>    doc -> reduce -
>    doc /

Re: when we should implement the rereduce in reduce function

Posted by hhsuper <hh...@gmail.com>.
Thanks guys, I got more info from wiki these two days, like you say that
rereduce is for internal caculating, we always impl it although we may not
be explicitly handle rereduce==true sometimes

On Mon, Jun 22, 2009 at 6:13 AM, Zachary Zolton <za...@gmail.com>wrote:

> One thing that might not be clear, from some of the examples, is that
> you don't have to explicitly handle the rereduce == true case when the
> shape of the data emitted from the map is the same as that returned by
> the reduce. This is the case when using reduce to return the sum of an
> array of numeric values, for instance.
> —Zach
>
> On Sun, Jun 21, 2009 at 3:21 PM, Brian Candler<B....@pobox.com> wrote:
> > On Mon, Jun 15, 2009 at 02:28:17PM +0800, hhsuper wrote:
> >> Hi, guys, I need some help, i want to know when we should implement the
> >> rereduce in reduce function?
> >
> > Answer: always.
> >
> > Once you get above a handful of documents you will see re-reduces taking
> > place. This is because reduce is done in multiple steps:
> >
> >    doc \
> >    doc -> reduce -
> >    doc /          \
> >    doc \           \
> >    doc -> reduce ---rereduce --> answer
> >    doc /           /
> >    doc \          /
> >    doc -> reduce -
> >    doc /
> >
> > Also: each btree node contains a bunch of documents, and the btree node
> also
> > contains a cached reduce value for that set of docs. This makes it much
> > cheaper for couchdb to calculate the reduce value across a range of keys;
> it
> > can use already-reduced values where available, and combine them using
> > rereduce.
> >
> > There's more info linked from the Wiki.
> >
> > Regards,
> >
> > Brian.
> >
>



-- 
Yours sincerely

Jack Su

Re: when we should implement the rereduce in reduce function

Posted by Zachary Zolton <za...@gmail.com>.
One thing that might not be clear, from some of the examples, is that
you don't have to explicitly handle the rereduce == true case when the
shape of the data emitted from the map is the same as that returned by
the reduce. This is the case when using reduce to return the sum of an
array of numeric values, for instance.
—Zach

On Sun, Jun 21, 2009 at 3:21 PM, Brian Candler<B....@pobox.com> wrote:
> On Mon, Jun 15, 2009 at 02:28:17PM +0800, hhsuper wrote:
>> Hi, guys, I need some help, i want to know when we should implement the
>> rereduce in reduce function?
>
> Answer: always.
>
> Once you get above a handful of documents you will see re-reduces taking
> place. This is because reduce is done in multiple steps:
>
>    doc \
>    doc -> reduce -
>    doc /          \
>    doc \           \
>    doc -> reduce ---rereduce --> answer
>    doc /           /
>    doc \          /
>    doc -> reduce -
>    doc /
>
> Also: each btree node contains a bunch of documents, and the btree node also
> contains a cached reduce value for that set of docs. This makes it much
> cheaper for couchdb to calculate the reduce value across a range of keys; it
> can use already-reduced values where available, and combine them using
> rereduce.
>
> There's more info linked from the Wiki.
>
> Regards,
>
> Brian.
>

Re: when we should implement the rereduce in reduce function

Posted by Brian Candler <B....@pobox.com>.
On Mon, Jun 15, 2009 at 02:28:17PM +0800, hhsuper wrote:
> Hi, guys, I need some help, i want to know when we should implement the
> rereduce in reduce function?

Answer: always.

Once you get above a handful of documents you will see re-reduces taking
place. This is because reduce is done in multiple steps:

    doc \
    doc -> reduce -
    doc /          \
    doc \           \
    doc -> reduce ---rereduce --> answer
    doc /           /
    doc \          /
    doc -> reduce -
    doc /

Also: each btree node contains a bunch of documents, and the btree node also
contains a cached reduce value for that set of docs. This makes it much
cheaper for couchdb to calculate the reduce value across a range of keys; it
can use already-reduced values where available, and combine them using
rereduce.

There's more info linked from the Wiki.

Regards,

Brian.