summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-10-25 10:32:31 -0400
committerEliot Horowitz <eliot@10gen.com>2013-10-25 12:52:52 -0400
commit715e6a89e1db69d695588962dc5c9d35c699d1e8 (patch)
treeac33e9c129e13b4b51f426f64833eb60d6679bf6 /src/mongo
parent5e58c72061b11949db2d15254af99a9c34b242ce (diff)
downloadmongo-715e6a89e1db69d695588962dc5c9d35c699d1e8.tar.gz
SERVER-11178: move more CatalogHack calls to IndexCatalog
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/exec/index_scan.cpp4
-rw-r--r--src/mongo/db/exec/index_scan.h4
-rw-r--r--src/mongo/db/pdfile.cpp16
-rw-r--r--src/mongo/dbtests/query_multi_plan_runner.cpp6
-rw-r--r--src/mongo/dbtests/query_stage_and.cpp6
-rw-r--r--src/mongo/dbtests/query_stage_merge_sort.cpp6
-rw-r--r--src/mongo/dbtests/query_stage_tests.cpp6
-rw-r--r--src/mongo/dbtests/repltests.cpp2
8 files changed, 32 insertions, 18 deletions
diff --git a/src/mongo/db/exec/index_scan.cpp b/src/mongo/db/exec/index_scan.cpp
index 32b47b874a1..b85b96a2643 100644
--- a/src/mongo/db/exec/index_scan.cpp
+++ b/src/mongo/db/exec/index_scan.cpp
@@ -58,12 +58,12 @@ namespace mongo {
// If the query is using complex bounds, we must use a Btree access method, since that's the
// only one that handles complex bounds.
if (params.forceBtreeAccessMethod || !_params.bounds.isSimpleRange) {
- _iam.reset(CatalogHack::getBtreeIndex(_descriptor.get()));
+ _iam = CatalogHack::getBtreeIndex(_descriptor);
amName = "";
}
else {
amName = CatalogHack::getAccessMethodName(_descriptor->keyPattern());
- _iam.reset(CatalogHack::getIndex(_descriptor.get()));
+ _iam = CatalogHack::getIndex(_descriptor);
}
if (IndexNames::GEO_2D == amName || IndexNames::GEO_2DSPHERE == amName) {
diff --git a/src/mongo/db/exec/index_scan.h b/src/mongo/db/exec/index_scan.h
index ca6f26d70b2..891a97c6149 100644
--- a/src/mongo/db/exec/index_scan.h
+++ b/src/mongo/db/exec/index_scan.h
@@ -92,9 +92,9 @@ namespace mongo {
WorkingSet* _workingSet;
// Index access.
- scoped_ptr<IndexAccessMethod> _iam;
+ IndexAccessMethod* _iam; // owned by Collection -> IndexCatalog
scoped_ptr<IndexCursor> _indexCursor;
- scoped_ptr<IndexDescriptor> _descriptor;
+ IndexDescriptor* _descriptor; // owned by Collection -> IndexCatalog
// Have we hit the end of the index scan?
bool _hitEnd;
diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp
index 6f72423546e..f5f09c707fe 100644
--- a/src/mongo/db/pdfile.cpp
+++ b/src/mongo/db/pdfile.cpp
@@ -570,8 +570,11 @@ namespace mongo {
OwnedPointerVector<UpdateTicket> updateTickets;
updateTickets.mutableVector().resize(collection->details()->getTotalIndexCount());
for (int i = 0; i < collection->details()->getTotalIndexCount(); ++i) {
- auto_ptr<IndexDescriptor> descriptor(CatalogHack::getDescriptor(collection->details(), i));
- auto_ptr<IndexAccessMethod> iam(CatalogHack::getIndex(descriptor.get()));
+ IndexDescriptor* descriptor = collection->getIndexCatalog()->getDescriptor( i );
+ verify( descriptor );
+ IndexAccessMethod* iam = collection->getIndexCatalog()->getIndex( descriptor );
+ verify( iam );
+
InsertDeleteOptions options;
options.logIfError = false;
options.dupsAllowed = !(KeyPattern::isIdKeyPattern(descriptor->keyPattern())
@@ -581,7 +584,7 @@ namespace mongo {
Status ret = iam->validateUpdate(objOld, objNew, dl, options,
updateTickets.mutableVector()[i]);
- if (Status::OK() != ret) {
+ if ( !ret.isOK() ) {
uasserted(ASSERT_ID_DUPKEY, "Update validation failed: " + ret.toString());
}
}
@@ -610,8 +613,11 @@ namespace mongo {
debug.keyUpdates = 0;
for (int i = 0; i < collection->details()->getTotalIndexCount(); ++i) {
- auto_ptr<IndexDescriptor> descriptor(CatalogHack::getDescriptor(collection->details(), i));
- auto_ptr<IndexAccessMethod> iam(CatalogHack::getIndex(descriptor.get()));
+ IndexDescriptor* descriptor = collection->getIndexCatalog()->getDescriptor( i );
+ verify( descriptor );
+ IndexAccessMethod* iam = collection->getIndexCatalog()->getIndex( descriptor );
+ verify( iam );
+
int64_t updatedKeys;
Status ret = iam->update(*updateTickets.vector()[i], &updatedKeys);
if (Status::OK() != ret) {
diff --git a/src/mongo/dbtests/query_multi_plan_runner.cpp b/src/mongo/dbtests/query_multi_plan_runner.cpp
index b2376edd221..9324b6ef28e 100644
--- a/src/mongo/dbtests/query_multi_plan_runner.cpp
+++ b/src/mongo/dbtests/query_multi_plan_runner.cpp
@@ -23,6 +23,7 @@
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/query/multi_plan_runner.h"
+#include "mongo/db/structure/collection.h"
#include "mongo/dbtests/dbtests.h"
namespace QueryMultiPlanRunner {
@@ -40,9 +41,10 @@ namespace QueryMultiPlanRunner {
}
IndexDescriptor* getIndex(const BSONObj& obj) {
- NamespaceDetails* nsd = nsdetails(ns());
+ Collection* collection = cc().database()->getCollection( ns() );
+ NamespaceDetails* nsd = collection->details();
int idxNo = nsd->findIndexByKeyPattern(obj);
- return CatalogHack::getDescriptor(nsd, idxNo);
+ return collection->getIndexCatalog()->getDescriptor( idxNo );
}
void insert(const BSONObj& obj) {
diff --git a/src/mongo/dbtests/query_stage_and.cpp b/src/mongo/dbtests/query_stage_and.cpp
index ce977806cd2..70e7336096c 100644
--- a/src/mongo/dbtests/query_stage_and.cpp
+++ b/src/mongo/dbtests/query_stage_and.cpp
@@ -30,6 +30,7 @@
#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
+#include "mongo/db/structure/collection.h"
#include "mongo/dbtests/dbtests.h"
namespace QueryStageAnd {
@@ -47,9 +48,10 @@ namespace QueryStageAnd {
}
IndexDescriptor* getIndex(const BSONObj& obj) {
- NamespaceDetails* nsd = nsdetails(ns());
+ Collection* collection = cc().database()->getCollection( ns() );
+ NamespaceDetails* nsd = collection->details();
int idxNo = nsd->findIndexByKeyPattern(obj);
- return CatalogHack::getDescriptor(nsd, idxNo);
+ return collection->getIndexCatalog()->getDescriptor( idxNo );
}
void getLocs(set<DiskLoc>* out) {
diff --git a/src/mongo/dbtests/query_stage_merge_sort.cpp b/src/mongo/dbtests/query_stage_merge_sort.cpp
index b2afb2f5128..a3fef32a0a5 100644
--- a/src/mongo/dbtests/query_stage_merge_sort.cpp
+++ b/src/mongo/dbtests/query_stage_merge_sort.cpp
@@ -23,6 +23,7 @@
#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/query/plan_executor.h"
+#include "mongo/db/structure/collection.h"
#include "mongo/dbtests/dbtests.h"
/**
@@ -45,9 +46,10 @@ namespace QueryStageMergeSortTests {
}
IndexDescriptor* getIndex(const BSONObj& obj) {
- NamespaceDetails* nsd = nsdetails(ns());
+ Collection* collection = cc().database()->getCollection( ns() );
+ NamespaceDetails* nsd = collection->details();
int idxNo = nsd->findIndexByKeyPattern(obj);
- return CatalogHack::getDescriptor(nsd, idxNo);
+ return collection->getIndexCatalog()->getDescriptor( idxNo );
}
void insert(const BSONObj& obj) {
diff --git a/src/mongo/dbtests/query_stage_tests.cpp b/src/mongo/dbtests/query_stage_tests.cpp
index 153b70aab6d..16b4adf46d2 100644
--- a/src/mongo/dbtests/query_stage_tests.cpp
+++ b/src/mongo/dbtests/query_stage_tests.cpp
@@ -22,6 +22,7 @@
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/query/plan_executor.h"
+#include "mongo/db/structure/collection.h"
#include "mongo/dbtests/dbtests.h"
/**
@@ -87,9 +88,10 @@ namespace QueryStageTests {
IndexDescriptor* getIndex(const BSONObj& obj) {
Client::ReadContext ctx(ns());
- NamespaceDetails* nsd = nsdetails(ns());
+ Collection* collection = ctx.ctx().db()->getCollection( ns() );
+ NamespaceDetails* nsd = collection->details();
int idxNo = nsd->findIndexByKeyPattern(obj);
- return CatalogHack::getDescriptor(nsd, idxNo);
+ return collection->getIndexCatalog()->getDescriptor( idxNo );
}
static int numObj() { return 50; }
diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp
index 7a1334e9c8a..27bdd8b1d02 100644
--- a/src/mongo/dbtests/repltests.cpp
+++ b/src/mongo/dbtests/repltests.cpp
@@ -55,7 +55,7 @@ namespace ReplTests {
Collection* c = _context.db()->getCollection( ns() );
if ( ! c ) {
- c = _context.db()->createCollection( ns(), false, NULL );
+ c = _context.db()->createCollection( ns(), false, NULL, true );
}
c->getIndexCatalog()->ensureHaveIdIndex();
}