Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-2333

mapreduce optimization: do not execute reduce on unique keys

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.7.5
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      By accident I had a wrong reduce method:
      map = function()

      { emit(this.ln, 1); }

      reduce = function(key, vals) { var sum = 0; for (var val in vals)

      { sum += val; }

      return sum; }

      The rows in collection actually have only 1 entry per this.ln.
      If using inline the results look like:

      { "_id" : "zzucdarlws", "value" : 1 }

      If output goes to collection, it's
      > db.output.find(

      {"_id": "zzucdarlws"}

      )

      { "_id" : "zzucdarlws", "value" : "00" }

      It looks like for inline, the reduce function is never called, whereas it's called once for the collection.

            Assignee:
            antoine Antoine Girbal
            Reporter:
            antoine Antoine Girbal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: