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...
In order to retrieve data with CouchDB, we use a process called MapReduce, to create views. A view contains rows of data that is sorted by the row's key (you might use date as a key, for example, to sort your data based on the date). MapReduce is a combination of two concepts Map and Reduce.
CouchDB has three built-in Reduce functions: _count , _sum , and _stats (shown in Table 2-5).
The emit(key, value) function creates an entry in our view result . One more thing: the emit() function can be called multiple times in the map function to create multiple entries in the view results from a single document, but we are not doing that yet.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With