1+ // XXX THIS FILE IS DEPRECATED. PLEASE DON'T MODIFY.
12// db/geo/haystack.cpp
23
34/* *
2324#include " mongo/db/auth/action_set.h"
2425#include " mongo/db/auth/action_type.h"
2526#include " mongo/db/auth/privilege.h"
27+ #include " mongo/db/index/catalog_hack.h"
28+ #include " mongo/db/index/haystack_access_method.h"
29+ #include " mongo/db/index/index_descriptor.h"
30+ #include " mongo/db/index/index_access_method.h"
2631#include " mongo/db/namespace-inl.h"
2732#include " mongo/db/jsobj.h"
2833#include " mongo/db/index.h"
@@ -343,13 +348,6 @@ namespace mongo {
343348 return false ;
344349 }
345350
346- int idxNum = idxs[0 ];
347-
348- IndexDetails& id = nsd->idx (idxNum);
349- GeoHaystackSearchIndex *si =
350- static_cast <GeoHaystackSearchIndex*>(id.getSpec ().getType ());
351- verify (&id == si->getDetails ());
352-
353351 BSONElement nearElt = cmdObj[" near" ];
354352 BSONElement maxDistance = cmdObj[" maxDistance" ];
355353 BSONElement search = cmdObj[" search" ];
@@ -362,8 +360,20 @@ namespace mongo {
362360 if (cmdObj[" limit" ].isNumber ())
363361 limit = static_cast <unsigned >(cmdObj[" limit" ].numberInt ());
364362
365- si->searchCommand (nsd, nearElt.Obj (), maxDistance.numberDouble (), search.Obj (),
366- result, limit);
363+ int idxNum = idxs[0 ];
364+ IndexDetails& id = nsd->idx (idxNum);
365+ if (CatalogHack::testIndexMigration ()) {
366+ auto_ptr<IndexDescriptor> desc (CatalogHack::getDescriptor (nsd, idxNum));
367+ auto_ptr<HaystackAccessMethod> ham (new HaystackAccessMethod (desc.get ()));
368+ ham->searchCommand (nearElt.Obj (), maxDistance.numberDouble (), search.Obj (),
369+ &result, limit);
370+ } else {
371+ GeoHaystackSearchIndex *si =
372+ static_cast <GeoHaystackSearchIndex*>(id.getSpec ().getType ());
373+ verify (&id == si->getDetails ());
374+ si->searchCommand (nsd, nearElt.Obj (), maxDistance.numberDouble (), search.Obj (),
375+ result, limit);
376+ }
367377 return 1 ;
368378 }
369379 } nameSearchCommand;
0 commit comments