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

System.js functions are not available to map/reduce jobs

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.4.0-rc2
    • 2.4.0-rc0
    • MapReduce
    • None
    • OSX
    • ALL
    • Hide

      In 2.4.0-rc0:

      > db.system.js.save({_id: "sum", value: function (x, y) { return x + y; }});
      > db.records.insert(

      {foo:'bar'}

      )
      > db.records.mapReduce(function()

      { sum(1,2) },function() {}, {out: 'test_mr_out'});
      Wed Feb 20 10:21:53.844 map reduce failed:{
      "errmsg" : "exception: map invoke failed: ReferenceError: sum is not defined _funcs1:1",
      "code" : 9014,
      "ok" : 0
      } src/mongo/shell/collection.js:939

      In 2.2.0:

      > db.system.js.save({_id: "sum", value: function (x, y) { return x + y; }});
      > db.records.insert({foo:'bar'})
      > db.records.mapReduce(function() { sum(1,2) }

      ,function() {},

      {out: 'test_mr_out'}

      );
      {
      "result" : "test_mr_out",
      "timeMillis" : 59,
      "counts" :

      { "input" : 36, "emit" : 0, "reduce" : 0, "output" : 0 }

      ,
      "ok" : 1,
      }

      Show
      In 2.4.0-rc0: > db.system.js.save({_id: "sum", value: function (x, y) { return x + y; }}); > db.records.insert( {foo:'bar'} ) > db.records.mapReduce(function() { sum(1,2) },function() {}, {out: 'test_mr_out'}); Wed Feb 20 10:21:53.844 map reduce failed:{ "errmsg" : "exception: map invoke failed: ReferenceError: sum is not defined _funcs1:1", "code" : 9014, "ok" : 0 } src/mongo/shell/collection.js:939 In 2.2.0: > db.system.js.save({_id: "sum", value: function (x, y) { return x + y; }}); > db.records.insert({foo:'bar'}) > db.records.mapReduce(function() { sum(1,2) } ,function() {}, {out: 'test_mr_out'} ); { "result" : "test_mr_out", "timeMillis" : 59, "counts" : { "input" : 36, "emit" : 0, "reduce" : 0, "output" : 0 } , "ok" : 1, }

    Description

      It does not appear that functions defined in system.js are available to map reduce jobs in 2.4.0-rc0. In 2.2.0 and before these functions were available. Without the ability to add functions to system.js for map reduce jobs, jobs with common functionality or that rely on JS libraries become unmanageable. Also, the full jobs must be sent to the server rather than simply calling a function defined in system.js

      Attachments

        Activity

          People

            benjamin.becker Ben Becker
            aquina Andre Quina
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: