Skip to content

Commit

Permalink
geo haystack SERVER-1315
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Jul 23, 2010
1 parent 10e4067 commit 39b8b84
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions db/geo/quadrant_search.cpp → db/geo/haystack.cpp
@@ -1,4 +1,4 @@
// index_geosearch.cpp // db/geo/haystack.cpp


/** /**
* Copyright (C) 2008 10gen Inc. * Copyright (C) 2008 10gen Inc.
Expand Down Expand Up @@ -39,11 +39,11 @@
*/ */
namespace mongo { namespace mongo {


string GEOSEARCHNAME = "geosearch"; string GEOSEARCHNAME = "geoHaystack";


class GeoQuandrantSearchHopper { class GeoHaystackSearchHopper {
public: public:
GeoQuandrantSearchHopper( const BSONObj& n , double maxDistance , unsigned limit , const string& geoField ) GeoHaystackSearchHopper( const BSONObj& n , double maxDistance , unsigned limit , const string& geoField )
: _near( n ) , _maxDistance( maxDistance ) , _limit( limit ) , _geoField(geoField){ : _near( n ) , _maxDistance( maxDistance ) , _limit( limit ) , _geoField(geoField){


} }
Expand All @@ -69,11 +69,11 @@ namespace mongo {
vector<DiskLoc> _locs; vector<DiskLoc> _locs;
}; };


class GeoQuandrantSearchIndex : public IndexType { class GeoHaystackSearchIndex : public IndexType {


public: public:


GeoQuandrantSearchIndex( const IndexPlugin* plugin , const IndexSpec* spec ) GeoHaystackSearchIndex( const IndexPlugin* plugin , const IndexSpec* spec )
: IndexType( plugin , spec ){ : IndexType( plugin , spec ){


BSONElement e = spec->info["bucketSize"]; BSONElement e = spec->info["bucketSize"];
Expand Down Expand Up @@ -185,7 +185,7 @@ namespace mongo {
} }
int scale = (int)ceil( maxDistance / _bucketSize ); int scale = (int)ceil( maxDistance / _bucketSize );


GeoQuandrantSearchHopper hopper(n,maxDistance,limit,_geo); GeoHaystackSearchHopper hopper(n,maxDistance,limit,_geo);


long long btreeMatches = 0; long long btreeMatches = 0;


Expand Down Expand Up @@ -246,21 +246,21 @@ namespace mongo {
double _bucketSize; double _bucketSize;
}; };


class GeoQuandrantSearchIndexPlugin : public IndexPlugin { class GeoHaystackSearchIndexPlugin : public IndexPlugin {
public: public:
GeoQuandrantSearchIndexPlugin() : IndexPlugin( GEOSEARCHNAME ){ GeoHaystackSearchIndexPlugin() : IndexPlugin( GEOSEARCHNAME ){
} }


virtual IndexType* generate( const IndexSpec* spec ) const { virtual IndexType* generate( const IndexSpec* spec ) const {
return new GeoQuandrantSearchIndex( this , spec ); return new GeoHaystackSearchIndex( this , spec );
} }


} nameIndexPlugin; } nameIndexPlugin;




class GeoQuandrantSearchCommand : public Command { class GeoHaystackSearchCommand : public Command {
public: public:
GeoQuandrantSearchCommand() : Command( "geoSearch" ){} GeoHaystackSearchCommand() : Command( "geoSearch" ){}
virtual LockType locktype() const { return READ; } virtual LockType locktype() const { return READ; }
bool slaveOk() const { return true; } bool slaveOk() const { return true; }
bool slaveOverrideOk() const { return true; } bool slaveOverrideOk() const { return true; }
Expand Down Expand Up @@ -288,7 +288,7 @@ namespace mongo {
int idxNum = idxs[0]; int idxNum = idxs[0];


IndexDetails& id = d->idx( idxNum ); IndexDetails& id = d->idx( idxNum );
GeoQuandrantSearchIndex * si = (GeoQuandrantSearchIndex*)id.getSpec().getType(); GeoHaystackSearchIndex * si = (GeoHaystackSearchIndex*)id.getSpec().getType();
assert( &id == si->getDetails() ); assert( &id == si->getDetails() );


BSONElement n = cmdObj["near"]; BSONElement n = cmdObj["near"];
Expand Down
4 changes: 2 additions & 2 deletions jstests/geo_search1.js → jstests/geo_haystack1.js
@@ -1,5 +1,5 @@


t = db.geo_search1 t = db.geo_haystack1
t.drop() t.drop()


function distance( a , b ){ function distance( a , b ){
Expand Down Expand Up @@ -42,7 +42,7 @@ for ( x=0; x<20; x++ ){
} }
} }


t.ensureIndex( { loc : "geosearch" , z : 1 } , { bucketSize : .7 } ); t.ensureIndex( { loc : "geoHaystack" , z : 1 } , { bucketSize : .7 } );


for ( i=0; i<queries.length; i++ ){ for ( i=0; i<queries.length; i++ ){
print( "---------" ); print( "---------" );
Expand Down
4 changes: 2 additions & 2 deletions jstests/geo_search2.js → jstests/geo_haystack2.js
@@ -1,5 +1,5 @@


t = db.geo_search2 t = db.geo_haystack2
t.drop() t.drop()


function distance( a , b ){ function distance( a , b ){
Expand Down Expand Up @@ -43,7 +43,7 @@ for ( x=0; x<20; x++ ){
} }
} }


t.ensureIndex( { loc : "geosearch" , z : 1 } , { bucketSize : .7 } ); t.ensureIndex( { loc : "geoHaystack" , z : 1 } , { bucketSize : .7 } );


for ( i=0; i<queries.length; i++ ){ for ( i=0; i<queries.length; i++ ){
print( "---------" ); print( "---------" );
Expand Down

0 comments on commit 39b8b84

Please sign in to comment.