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 "Built-In_Reduce_Functions" by JensAlfke
Date Fri, 03 Aug 2012 05:32:25 GMT
Dear Wiki user,

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

The "Built-In_Reduce_Functions" page has been changed by JensAlfke:
http://wiki.apache.org/couchdb/Built-In_Reduce_Functions?action=diff&rev1=5&rev2=6

Comment:
Grammatical cleanup

  = Built-In Reduce Functions =
  <<TableOfContents()>>
  
- Currently (CouchDB 0.11.0) there are three built-in reduce functions. Built-in reduce functions
are performed right inside CouchDB implemented in Erlang. In most cases it is very fast because
they are way more efficient.
+ CouchDB has three built-in reduce functions. These are implemented in Erlang and run right
inside CouchDB, so they are much faster than the equivalent JavaScript functions.
  
  == Usage ==
- To use built-in reduce functions, you simply need to replace your reduce function with a
string containing {{{_count}}}, {{{_sum}}} or {{{_stats}}} (without any preceding or tailing
whitespace).
+ To use built-in reduce functions, you simply need to replace your reduce function with the
string {{{_count}}}, {{{_sum}}} or {{{_stats}}} (without any preceding or tailing whitespace).
  
- Here is an example design document using build-in reduce functions:
+ Here is an example design document using built-in reduce functions:
  {{{
  {
    "_id":"_design/company",
@@ -30, +30 @@

  }
  }}}
  
- == Available Build-In Functions ==
+ == Available Built-In Functions ==
  
  === _sum ===
- {{{_sum}}} just sums up the emitted values. Therefore the mapped values need to be numbers.
+ {{{_sum}}} just adds up the emitted values, which must be numbers.
  
  The !JavaScript equivalent is:
  {{{
@@ -44, +44 @@

  
  
  === _count ===
- {{{_count}}} counts the emitted values. It's like {{{_sum}}} for {{{emit(foo, 1)}}}. The
map function may emit anything you want.
+ {{{_count}}} counts the number of emitted values. (It's like {{{_sum}}} for {{{emit(foo,
1)}}}.) It ignores the contents of the values, so they can by any type.
  
  The !JavaScript equivalent is:
  {{{
  function(keys, values, rereduce) {
    if (rereduce) {
      return sum(values);
-   }
-   else {
+   } else {
      return values.length;
    }
  }
@@ -61, +60 @@

  
  === _stats ===
  
- {{{_stats}}} calculates various numerical statistics on your emitted data. {{{_stats}}}
requires, just like {{{_sum}}}, your emitted values to be numbers.
+ {{{_stats}}} calculates some numerical statistics on your emitted values, which must be
numbers.
  
- The reduce output looks like this:
+ The reduce output is an object that looks like this:
  {{{
- {"update_seq":6,"rows":[
- {"key":null,"value":{"sum":2,"count":2,"min":1,"max":1,"sumsqr":2}}
+ {"sum":2,"count":2,"min":1,"max":1,"sumsqr":2}
- ]}
  }}}
  
- {{{sum}}} and {{{count}}} is the equiverlent to {{{_sum}}} and {{{_count}}}. {{{min}}} and
{{{max}}} are the minimum and maximum values of the emitted values. {{{sumsqr}}} is the sum
over all squares of the emitted values (useful for statistics calculations).
+ {{{"sum"}}} and {{{"count"}}} are equivalent to the {{{_sum}}} and {{{_count}}} reductions.
{{{"min"}}} and {{{"max"}}} are the minimum and maximum emitted values. {{{"sumsqr"}}} is
the sum of the squares of the emitted values (useful for statistical calculations like standard
deviation).
  

Mime
View raw message