s = new ShardingTest( "bigMapReduce" , 2 , 1 , 1 , { chunksize : 1 } );

s.adminCommand( { enablesharding : "test" } )
s.adminCommand( { shardcollection : "test.foo", key : { "_id" : 1 } } )

db = s.getDB( "test" );
var str=""
for (i=0;i<4*1024;i++) { str=str+"a"; }
for (j=0; j<50; j++) for (i=0; i<512; i++){ db.foo.save({y:str})}

function map() { emit('count', 1); } 
function reduce(key, values) { return Array.sum(values) } 

out = db.foo.mapReduce(map, reduce) 
printjson(out) // SERVER-1400

s.stop()
