From 7e6790bf3b37c98fe9bf4396bac7a09d31b1b1dd Mon Sep 17 00:00:00 2001 From: Dwight Date: Tue, 23 Feb 2010 15:57:59 -0500 Subject: [PATCH] can't use "near" as a var on widnows --- db/index_geo2d.cpp | 8 +++++--- jstests/geo3.js | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/db/index_geo2d.cpp b/db/index_geo2d.cpp index 29ec74b1a5e..66fb09a5cd5 100644 --- a/db/index_geo2d.cpp +++ b/db/index_geo2d.cpp @@ -498,8 +498,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 ) ); @@ -686,7 +686,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; @@ -714,6 +714,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