diff --git a/db/dbwebserver.cpp b/db/dbwebserver.cpp index 7a8e7d96278..c8e52f7d1c1 100644 --- a/db/dbwebserver.cpp +++ b/db/dbwebserver.cpp @@ -226,7 +226,7 @@ namespace mongo { if ( from.localhost() ) return true; - if ( db.findOne( "admin.system.users" , BSONObj() ).isEmpty() ) + if ( db.findOne( "admin.system.users" , BSONObj() ).isEmpty() , 0 , QueryOption_SlaveOk ) return true; string auth = getHeader( rq , "Authorization" ); diff --git a/db/index_geo2d.cpp b/db/index_geo2d.cpp index b0b5daf486f..fd622af1e93 100644 --- a/db/index_geo2d.cpp +++ b/db/index_geo2d.cpp @@ -513,8 +513,8 @@ namespace mongo { public: typedef multiset Holder; - GeoHopper( Geo2dType * g , unsigned max , const GeoHash& near , const BSONObj& filter = BSONObj() ) - : _g( g ) , _max( max ) , _near( near ) , _lookedAt(0) , _objectsLoaded(0){ + GeoHopper( Geo2dType * g , unsigned max , const GeoHash& n , const BSONObj& filter = BSONObj() ) + : _g( g ) , _max( max ) , _near( n ) , _lookedAt(0) , _objectsLoaded(0){ if ( ! filter.isEmpty() ) _matcher.reset( new CoveredIndexMatcher( filter , g->_spec->keyPattern ) ); @@ -701,7 +701,7 @@ namespace mongo { GeoHash start = n; if ( cmdObj["start"].type() == String){ - start = (string)cmdObj["start"].valuestr(); + start = (string) cmdObj["start"].valuestr(); if ( 2 * ( start.size() / 2 ) != start.size() ){ errmsg = "start has to be an even size"; return false; @@ -729,6 +729,8 @@ namespace mongo { if ( cmdObj["query"].type() == Object ) filter = cmdObj["query"].embeddedObject(); + //cout << "--------- GeoHopper " << n._hash << endl; + GeoHopper hopper( g , numWanted , n , filter ); GeoHash prefix = start; diff --git a/jstests/geo3.js b/jstests/geo3.js index 6403c0e3a5c..21b6f2b6f1d 100644 --- a/jstests/geo3.js +++ b/jstests/geo3.js @@ -9,15 +9,20 @@ for ( var x=-100; x<100; x+=2 ){ } } + t.ensureIndex( { loc : "2d" } ) fast = db.runCommand( { geo2d : t.getName() , near : [ 50 , 50 ] , num : 10 } ); + +//printjson( fast.stats ); + slow = db.runCommand( { geo2d : t.getName() , near : [ 50 , 50 ] , num : 10 , start : "11" } ); +//printjson( slow.stats ); + assert.lt( fast.stats.nscanned * 10 , slow.stats.nscanned , "A1" ); assert.lt( fast.stats.objectsLoaded , slow.stats.objectsLoaded , "A2" ); assert.eq( fast.stats.avgDistance , slow.stats.avgDistance , "A3" ); -//printjson( fast.stats ); // test filter diff --git a/shell/utils.cpp b/shell/utils.cpp index 38d3b620860..6b44a05afe5 100644 --- a/shell/utils.cpp +++ b/shell/utils.cpp @@ -697,10 +697,11 @@ namespace mongo { return; } BSONObj info; - uassert( 13010, "whatsmyuri failed", c.runCommand( "admin", BSON( "whatsmyuri" << 1 ), info ) ); - // There's no way to explicitly disconnect a DBClientConnection, but we might allocate - // a new uri on automatic reconnect. So just store one uri per connection. - _allMyUris[ &c ] = info[ "you" ].str(); + if ( c.runCommand( "admin", BSON( "whatsmyuri" << 1 ), info ) ) { + // There's no way to explicitly disconnect a DBClientConnection, but we might allocate + // a new uri on automatic reconnect. So just store one uri per connection. + _allMyUris[ &c ] = info[ "you" ].str(); + } } } } diff --git a/tools/stat.cpp b/tools/stat.cpp index cc4c5e3d456..f568d66e785 100644 --- a/tools/stat.cpp +++ b/tools/stat.cpp @@ -73,7 +73,7 @@ namespace mongo { void cell( stringstream& ss , string name , unsigned width , double val ){ cellstart( ss , name , width ); - ss << setw(width) << val << " "; + ss << setw(width) << setprecision(3) << val << " "; } void cell( stringstream& ss , string name , unsigned width , int val ){