MongoDB v1.6.2
Given stored map and reduce and finalize functions as follows:
> db.system.js.find({},{_id:1})
{ "_id" : "mm" }
{ "_id" : "rr" }
{ "_id" : "ff" }
But the following command is wrong , because map function will emit
sth
> db.f.mapReduce("mm","rr")
{
"result" : "tmp.mr.mapreduce_1300965424_25",
"timeMillis" : 2,
"counts" : {
"input" : 2,
"emit" : 0,
"output" : 0
},
"ok" : 1,
}
So I change the command, and the result is correct.
> db.f.mapReduce(db.eval("mm"),db.eval("rr"))
{
"result" : "tmp.mr.mapreduce_1300965446_26",
"timeMillis" : 4,
"counts" : {
"input" : 2,
"emit" : 4,
"output" : 1
},
"ok" : 1,
}
Then I write it in java
MapReduceOutput mrout = coll.mapReduce("db.eval('mm')",
"db.eval('rr')", "mrout", null);
Here is the exception:
com.mongodb.CommandResult$CommandFailure: command failed [command
failed [mapreduce] { "assertion" : "map invoke failed: JS Error:
uncaught exception: {\n\t\"assertion\" : \"internal error: locks are
not upgradeable: { \\\"opid\\\" : 85231711, \\\"active\\\" : true, \\
\"waitingForLock\\\" : false, \\\"secs_running\\\" : 0, \\\"op\\\" : \\
\"query\\\", \\\"ns\\\" : \\\"?\\\", \\\"query\\\" : { \\\"$eval\\\" :
\\\"mm\\\" }, \\\"client\\\" : \\\"
0.0.0.0:0\\\", \\\"desc\\\" : \\
\"conn\\\" }\",\n\t\"assertionCode\" : 10293,\n\t\"errmsg\" : \"db
assertion failure\",\n\t\"ok\" : 0\n}" , "assertionCode" : 9014 ,
"errmsg" : "db assertion failure" , "ok" : 0.0}
Does it mean we cannot call mapReduce using stored js function?