Details
-
Improvement
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
-
redhat linux 64bit
mongodb-linux-i686-2.2.3
*Location*: http://docs.mongodb.org/manual/applications/map-reduce/
*User-Agent*: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
*Referrer*: http://www.cnblogs.com/daizhj/archive/2010/06/10/1755761.html
*Screen Resolution*: 1366 x 768
*repo*: docs
*source*: applications/map-reduce
redhat linux 64bit mongodb-linux-i686-2.2.3 *Location*: http://docs.mongodb.org/manual/applications/map-reduce/ *User-Agent*: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11 *Referrer*: http://www.cnblogs.com/daizhj/archive/2010/06/10/1755761.html *Screen Resolution*: 1366 x 768 *repo*: docs *source*: applications/map-reduce
Description
I find a strange problem when I use map-reduce,here is the description:
first I insert data into database like this:
//insert.js
for(var i=0;i<5;i++){
db.RegistRecord.save(
);
}
for(var i=0;i<2;i++){
db.RegistRecord.save(
);
}
for(var i=0;i<1;i++){
db.RegistRecord.save(
);
}
then run map-reduce through a javascript like this:
//regmp.js
printjson("job start");
var map = function() {
emit(this.ip,
);
}
var reduce = function(key, values) {
var count = 0;
values.forEach(function(v)
);
return
;
}
var res = db.runCommand(
{mapreduce:"RegistRecord",map:map, reduce:reduce, out:"log_results"});
printjson("job end")
Ok,you'll find the result is no problem and like this:
/* 0 */
{
"_id" : "11.11.11.11",
"value" :
}
/* 1 */
{
"_id" : "11.11.11.22",
"value" :
}
/* 2 */
{
"_id" : "11.11.11.33",
"value" :
}
but,when the records increase to 2000,strange problem comes:
insert data first like this :
//insert.js
for(var i=0;i<2000;i++){
db.RegistRecord.save(
);
}
for(var i=0;i<2;i++){
db.RegistRecord.save(
);
}
for(var i=0;i<1;i++){
db.RegistRecord.save(
);
}
run the same script and the result is like this :
/* 0 */
{
"_id" : "11.11.11.11",
"value" :
}
/* 1 */
{
"_id" : "11.11.11.22",
"value" :
}
/* 2 */
{
"_id" : "11.11.11.33",
"value" :
}
see the fird record ? "NaN"??
And I also find that the data reduce function received is strange:
/* 0 */
{
"_id" : "11.11.11.22",
"value" : {
"count" : [
,
{ "value" : 1.0 }]
}
}
/* 1 */
{
"_id" : "11.11.11.33",
"value" :
}
/* 2 */
{
"_id" : "11.11.11.11",
"value" : {
"count" : [{
"count" : [
,
{ "value" : 1.0 },
{ "value" : 1.0 },
。。。。
Sorry for my poor English...
hope for your response!