Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the rereduce parameter in CouchDB's reduce function for?

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...

like image 235
Manoj Avatar asked Mar 29 '12 21:03

Manoj


People also ask

What is MAP reduce in CouchDB?

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.

Which of the following are inbuilt reduce functions of Apache CouchDB?

CouchDB has three built-in Reduce functions: _count , _sum , and _stats (shown in Table 2-5).

What is emit in CouchDB?

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.


1 Answers

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:

  • to reduce a block
  • to reduce results of the first step

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.

like image 198
Bergi Avatar answered Sep 22 '22 16:09

Bergi