-
Type:
Bug
-
Resolution: Done
-
Priority:
Trivial - P5
-
None
-
Affects Version/s: 2.0.2
-
Component/s: None
-
None
-
ALL
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
It looks like there's an optimization for map reduce jobs that can result in the wrong key name being returned if there is only a single tuple to process. Notice how the keys for groups 1 and 5 are returned as "thetot" instead of "tot" in the job below.
I believe this is caused by line 103/124 of db/commands/mr.cpp. The workaround appears easy enough but I thought I'd report it.
Thanks
> db.goo.save(
{group:1, amt:5});
> db.goo.save(
);
> db.goo.save(
);
> db.goo.save(
);
> db.goo.save(
);
> db.goo.save(
);
> db.goo.save(
);
> db.goo.save(
);
> db.goo.save(
);
> db.goo.save(
);
> db.goo.save(
);
>
> map = function(){ emit( this.group,
); }
function () {
emit(this.group,
);
}
>
> reduce = function(k, v){
... var r =
;
... v.forEach(function(v)
)
... return r;
... }
function (k, v) {
var r =
;
v.forEach(function (v)
);
return r;
}
>
> db.goo.mapReduce( map, reduce, { out:
});
{
"results" : [
{
"_id" : 1,
"value" :
},
{
"_id" : 2,
"value" :
},
{
"_id" : 3,
"value" :
},
{
"_id" : 4,
"value" :
},
{
"_id" : 5,
"value" :
}
],
"timeMillis" : 1,
"counts" :
,
"ok" : 1,
}