最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the rereduce parameter in CouchDB's reduce function for? - Stack Overflow

programmeradmin0浏览0评论

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

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

Share Improve this question edited Mar 30, 2012 at 3:12 aaaidan 7,3468 gold badges68 silver badges107 bronze badges asked Mar 29, 2012 at 21:13 ManojManoj 5,09714 gold badges56 silver badges77 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

I think http://wiki.apache/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/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.

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.

发布评论

评论列表(0)

  1. 暂无评论