mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 17:10:48 +01:00
Merge branch 'master' of git@github.com:mongodb/mongo
This commit is contained in:
commit
ff458d03b7
15
db/mr.cpp
15
db/mr.cpp
@ -48,9 +48,9 @@ namespace mongo {
|
||||
for ( list<BSONObj>::iterator i=values.begin(); i!=values.end(); i++){
|
||||
BSONObj o = *i;
|
||||
if ( n == 0 ){
|
||||
reduceArgs.append( o["key"] );
|
||||
reduceArgs.append( o["_id"] );
|
||||
BSONObjBuilder temp;
|
||||
temp.append( o["key"] );
|
||||
temp.append( o["_id"] );
|
||||
key = temp.obj();
|
||||
}
|
||||
valueBuilder.appendAs( o["value"] , BSONObjBuilder::numStr( n++ ).c_str() );
|
||||
@ -65,7 +65,7 @@ namespace mongo {
|
||||
return BSONObj();
|
||||
}
|
||||
BSONObjBuilder b;
|
||||
b.append( key["key"] );
|
||||
b.append( key["_id"] );
|
||||
s->append( b , "value" , "return" );
|
||||
return b.obj();
|
||||
}
|
||||
@ -180,7 +180,7 @@ namespace mongo {
|
||||
{
|
||||
assert( i.more() );
|
||||
BSONObjBuilder b;
|
||||
b.appendAs( i.next() , "key" );
|
||||
b.appendAs( i.next() , "_id" );
|
||||
key = b.obj();
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ namespace mongo {
|
||||
if ( values.size() == 0 )
|
||||
return;
|
||||
|
||||
BSONObj key = values.begin()->extractFields( BSON( "key" << 1 ) );
|
||||
BSONObj key = values.begin()->extractFields( BSON( "_id" << 1 ) );
|
||||
|
||||
if ( values.size() == 1 ){
|
||||
assert( db.count( resultColl , key ) == 1 );
|
||||
@ -259,7 +259,6 @@ namespace mongo {
|
||||
string finalOutputShort = finalOutput.substr( database->name.size() + 1 );
|
||||
log(1) << "\t resultColl: " << resultColl << " short: " << resultCollShort << endl;
|
||||
db.dropCollection( resultColl );
|
||||
db.ensureIndex( resultColl , BSON( "key" << 1 ) );
|
||||
|
||||
int num = 0;
|
||||
|
||||
@ -305,9 +304,9 @@ namespace mongo {
|
||||
|
||||
BSONObj prev;
|
||||
list<BSONObj> all;
|
||||
BSONObj sortKey = BSON( "key" << 1 );
|
||||
BSONObj sortKey = BSON( "_id" << 1 );
|
||||
|
||||
cursor = db.query( resultColl, Query().sort( BSON( "key" << 1 ) ) );
|
||||
cursor = db.query( resultColl, Query().sort( sortKey ) );
|
||||
while ( cursor->more() ){
|
||||
BSONObj o = cursor->next().getOwned();
|
||||
|
||||
|
7
jstests/basicb.js
Normal file
7
jstests/basicb.js
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
t = db.basicb;
|
||||
t.drop();
|
||||
|
||||
assert.throws( "t.insert( { '$a' : 5 } );" );
|
||||
t.insert( { '$a' : 5 } , true );
|
||||
|
@ -32,7 +32,7 @@ x = db[res.result];
|
||||
assert.eq( 3 , x.find().count() , "B" );
|
||||
x.find().forEach( printjson );
|
||||
z = {};
|
||||
x.find().forEach( function(a){ z[a.key] = a.value.count; } );
|
||||
x.find().forEach( function(a){ z[a._id] = a.value.count; } );
|
||||
printjson( z );
|
||||
assert.eq( 3 , z.keySet().length , "C" );
|
||||
assert.eq( 2 , z.a , "D" );
|
||||
@ -44,7 +44,7 @@ res = db.runCommand( { mapreduce : "mr1" , map : m , reduce : r , query : { x :
|
||||
assert.eq( 2 , res.numObjects , "B" );
|
||||
x = db[res.result];
|
||||
z = {};
|
||||
x.find().forEach( function(a){ z[a.key] = a.value.count; } );
|
||||
x.find().forEach( function(a){ z[a._id] = a.value.count; } );
|
||||
assert.eq( 1 , z.a , "C1" );
|
||||
assert.eq( 1 , z.b , "C2" );
|
||||
assert.eq( 2 , z.c , "C3" );
|
||||
@ -55,7 +55,7 @@ assert.eq( 2 , res.numObjects , "B2" );
|
||||
assert.eq( "foo" , res.result , "B2-c" );
|
||||
x = db[res.result];
|
||||
z = {};
|
||||
x.find().forEach( function(a){ z[a.key] = a.value.count; } );
|
||||
x.find().forEach( function(a){ z[a._id] = a.value.count; } );
|
||||
assert.eq( 1 , z.a , "C1a" );
|
||||
assert.eq( 1 , z.b , "C2a" );
|
||||
assert.eq( 2 , z.c , "C3a" );
|
||||
@ -73,11 +73,11 @@ assert.eq( 999 , res.numObjects , "Z1" );
|
||||
x = db[res.result];
|
||||
x.find().forEach( printjson )
|
||||
assert.eq( 4 , x.find().count() , "Z2" );
|
||||
assert.eq( "a,b,c,d" , x.distinct( "key" ) , "Z3" );
|
||||
assert.eq( 2 , x.findOne( { key : "a" } ).value.count , "ZA" );
|
||||
assert.eq( 998 , x.findOne( { key : "b" } ).value.count , "ZB" );
|
||||
assert.eq( 3 , x.findOne( { key : "c" } ).value.count , "ZC" );
|
||||
assert.eq( 995 , x.findOne( { key : "d" } ).value.count , "ZD" );
|
||||
assert.eq( "a,b,c,d" , x.distinct( "_id" ) , "Z3" );
|
||||
assert.eq( 2 , x.findOne( { _id : "a" } ).value.count , "ZA" );
|
||||
assert.eq( 998 , x.findOne( { _id : "b" } ).value.count , "ZB" );
|
||||
assert.eq( 3 , x.findOne( { _id : "c" } ).value.count , "ZC" );
|
||||
assert.eq( 995 , x.findOne( { _id : "d" } ).value.count , "ZD" );
|
||||
|
||||
print( Date.timeFunc(
|
||||
function(){
|
||||
|
Loading…
Reference in New Issue
Block a user