Reputation: 5087
As I understand the reduce function takes all the values of a particular key and we can write code to perform some kind of action on those values. I do not understand what is the use of the rereduce parameter. Can somebody explain with an example?
Thanks...
Upvotes: 6
Views: 5243
Reputation: 664513
I think http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views#Reduce_vs_rereduce gives you an good overview. Due to performance optimations, the reduce function may be called on two levels:
In the second level, the parameter rereduce
is true
. For an example see http://wiki.apache.org/couchdb/Built-In_Reduce_Functions#A_sum. In the first step the length of the block (values
) is returned, on the rereduce level these lengths must be summed up.
Upvotes: 8
Reputation: 7316
There's an explanation of the rereduce parameter here.
Quote: paraphrased. More info at the link.
Here is an example of a reduce function:
function (key, values, rereduce) { return sum(values); }
Reduce functions must handle two cases, when rereduce is true and when it is false.
Upvotes: -1