couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Introduction to CouchDB views" by JanLehnardt
Date Mon, 01 Dec 2008 15:59:51 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by JanLehnardt:
http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views

------------------------------------------------------------------------------
  Here is an example of a reduce function:
  
  {{{
- function (keys, values, rereduce) {
+ function (key, values, rereduce) {
      return sum(values);
  }
  }}}
  
- Reduce functions are passed three arguments in the order ''keys'', ''values'' and ''rereduce''
+ Reduce functions are passed three arguments in the order ''key'', ''values'' and ''rereduce''
  
  Reduce functions must handle two cases:
  
  1. When ''rereduce'' is ''false'':
-  * ''keys'' will be an array whose elements are arrays of the form ''[key,id]'', where ''key''
is a key emitted by the map function and ''id'' is that of the document from which the key
was generated. 
+  * ''key'' will be an array whose elements are arrays of the form ''[key,id]'', where ''key''
is a key emitted by the map function and ''id'' is that of the document from which the key
was generated. 
   * ''values'' will be an array of the values emitted for the respective elements in ''keys''
   * i.e. {{{reduce([ [key1,id1], [key2,id2], [key3,id3] ], [value1,value2,value3], false)}}}
  
  2. When ''rereduce'' is ''true'':
-  * ''keys'' will be ''null''
+  * ''key'' will be ''null''
   * ''values'' will be an array of values returned by previous calls to the reduce function
   * i.e. {{{reduce(null, [intermediate1,intermediate2,intermediate3], true)}}}
  

Mime
View raw message