Jaap van der Plas wrote:
I've been searching around and found various hints towards the third
parameter of reduce-functions but I have not been able to find a
description of when exactly it is invoked, and if it is possible to
avoid your reduce function to be used in this way.
My understanding, which comes from these blog posts:
http://damienkatz.net/2008/02/incremental_map.html
http://damienkatz.net/2008/02/incremental_map_1.html
is that the third parameter is true if the function is being run on its
own output. So if the output of your reduce function "looks like" the
output of your map function, then you don't care about the third
parameter. But if you want your reduce function to produce something
different from what's coming out of your map function, then the third
parameter tells your reduce function what to expect (false for map
output, true for reduce output).
Chris Anderson has some examples; one that cares about that parameter:
http://github.com/jchris/couchrest/tree/master/examples/word_count/views/markov
and one that doesn't:
http://github.com/jchris/couchrest/tree/master/examples/word_count/views/word_count
I don't think it makes sense to try and "prevent" your function from
being used that way; re-running reduce on its own output (as a "combine"
function) makes it possible to incrementally update the view data, which
is a pretty nice win IMO.
Speaking up because I happen to have just read up on this one, so please
forgive any mistakes,
Mitch