couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Kempf <jochenke...@gmail.com>
Subject Re: Problems with reduce in view appear when record size > 6
Date Thu, 30 Jul 2009 03:48:59 GMT
Hi Brian,

guessing that you refer to this page incremental
map<http://damienkatz.net/2008/02/incremental_map_1.html>the
corresponding reduce function would be as follows, right (the final
reduce result is slightly changed, being a hash now)?
I am asking as I am still not absolutely firm with that topic...

map =>
"
  function(doc) {
  emit(doc["_id"], [doc["_id"], doc["_rev"], doc["var1"], doc["var2"],
doc["var3"], doc["var4"], doc["var5"]]);
  }
"

reduce =>
"
  function(key, values, combine) {
        var result = {ids:[], revs:[], variables:[]}
          if (combine) {
            for (i in values) {
              result.ids.push(values[i].ids);
              result.revs.push(values[i].revs);
              result.variables.push(values[i].variables);
            }
          } else {
            for (i in values) {
              result.ids.push(values[i][0]);
              result.revs.push(values[i][1]);
              result.variables.push([values[i][2], values[i][3],
values[i][4], values[i][5], values[i][6]]);
            }
          }
        return result;
      }
"




>
> Yes, one of ids, revs or variables is undefined :-)
>
> You can use 'log' to see what values are being passed into your reduce
> function.
>
> As a guess, I'd say that a re-reduce operation is taking place: 'combine'
> will be true, 'key' will be null, and 'values' will be the output of a
> previous reduce operation.
>
> That is: your reduce function must be written in such a way as to be able
> to
> process values generated by a previous reduce function, as well as values
> emitted by a document. The Wiki talks about this further.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message