Why do we need to use rereduce?


#1

I have gone through the documentation available in website to understand the usage of rereduce functions, but I was not able to figure it out. Can somebody explain me the proper use of rereduce with exampled illustrations.

Thanks in advance,
SK


#2

Have you seen this post from Aaron? http://crate.im/posts/couchbase-views-reddit-data/

It covers rereduce too


#3

I tried understanding what he explained, however, I could not understand in which situation REREDUCE will be true. I understand that rereduce accepts returned values of previous call of reduce function in value parameter something like

function(‘James’, [ 19000, function(‘James’, [ 13000,20000,5000 ]) ]) { … }

but the battle I am fighting is when should I use the code something like below

if (rereduce) {…}

I have read the documentation at http://docs.couchbase.com/couchbase-manual-2.5/cb-admin/#handling-re-reduce that it is used to include new or updated or deleted documents to update views incrementally. What I understand is that if ‘stale’=false then the index of view will get updated and include the (new/updated/deleted) documents as well and reduce will aggregate them based on the keys returned(emitted) from map function.

If it’s true then how ‘rereduce’ is playing the role here for incremental update?


#4

In short rereduce will be true on large databases. On a large datasets reducer will be called on batches. These batches will be broken up on B-tree boundaries, which may occur in arbitrary places.


#5

“On a large datasets reducer will be called on batches” is new for me. I didn’t find this info anywhere in couchbase documentation.