diff options
author | Eliot Horowitz <eliot@10gen.com> | 2014-01-04 01:38:14 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2014-01-09 14:21:49 -0500 |
commit | ea5d43f74e4ddf990a156ce37b05369cd9ee3479 (patch) | |
tree | fa61abd8eb81549c34b101cf217da74b3f20da04 /src/mongo/db/index | |
parent | 6b2bd70cf5d7f2cb04b351fc24279b702ebb6fec (diff) | |
download | mongo-ea5d43f74e4ddf990a156ce37b05369cd9ee3479.tar.gz |
SERVER-12213: do not use idxNo or IndexDetails in any non-short term transient way
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/btree_access_method.cpp | 24 | ||||
-rw-r--r-- | src/mongo/db/index/btree_access_method_internal.h | 2 | ||||
-rw-r--r-- | src/mongo/db/index/haystack_access_method.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/index/index_descriptor.h | 20 |
4 files changed, 18 insertions, 31 deletions
diff --git a/src/mongo/db/index/btree_access_method.cpp b/src/mongo/db/index/btree_access_method.cpp index f88d5249f5e..f3317725bdd 100644 --- a/src/mongo/db/index/btree_access_method.cpp +++ b/src/mongo/db/index/btree_access_method.cpp @@ -62,7 +62,7 @@ namespace mongo { for (BSONObjSet::const_iterator i = keys.begin(); i != keys.end(); ++i) { try { - _interface->bt_insert(_btreeState.get(), + _interface->bt_insert(_btreeState, _btreeState->head(), loc, *i, @@ -70,7 +70,7 @@ namespace mongo { true); ++*numInserted; } catch (AssertionException& e) { - if (10287 == e.getCode() && _descriptor->isBackgroundIndex()) { + if (10287 == e.getCode() && !_btreeState->isReady()) { // This is the duplicate key exception. We ignore it for some reason in BG // indexing. DEV log() << "info: key already in index during bg indexing (ok)\n"; @@ -101,7 +101,7 @@ namespace mongo { bool ret = false; try { - ret = _interface->unindex(_btreeState.get(), + ret = _interface->unindex(_btreeState, _btreeState->head(), key, loc); @@ -168,7 +168,7 @@ namespace mongo { int unusedPos; bool unusedFound; DiskLoc unusedDiskLoc; - _interface->locate(_btreeState.get(), + _interface->locate(_btreeState, _btreeState->head(), *i, unusedPos, @@ -182,12 +182,12 @@ namespace mongo { DiskLoc BtreeBasedAccessMethod::findSingle( const BSONObj& key ) { if ( 0 == _descriptor->version() ) { - return _btreeState->getHeadBucket<V0>()->findSingle( _btreeState.get(), + return _btreeState->getHeadBucket<V0>()->findSingle( _btreeState, _btreeState->head(), key ); } if ( 1 == _descriptor->version() ) { - return _btreeState->getHeadBucket<V1>()->findSingle( _btreeState.get(), + return _btreeState->getHeadBucket<V1>()->findSingle( _btreeState, _btreeState->head(), key ); } @@ -196,7 +196,7 @@ namespace mongo { Status BtreeBasedAccessMethod::validate(int64_t* numKeys) { - *numKeys = _interface->fullValidate(_btreeState.get(), + *numKeys = _interface->fullValidate(_btreeState, _btreeState->head(), _descriptor->keyPattern()); return Status::OK(); @@ -223,12 +223,12 @@ namespace mongo { if (checkForDups) { for (vector<BSONObj*>::iterator i = data->added.begin(); i != data->added.end(); i++) { - if (_interface->wouldCreateDup(_btreeState.get(), + if (_interface->wouldCreateDup(_btreeState, _btreeState->head(), **i, record)) { status->_isValid = false; return Status(ErrorCodes::DuplicateKey, - _interface->dupKeyError(_btreeState.get(), + _interface->dupKeyError(_btreeState, _btreeState->head(), **i)); } @@ -253,7 +253,7 @@ namespace mongo { } for (size_t i = 0; i < data->added.size(); ++i) { - _interface->bt_insert(_btreeState.get(), + _interface->bt_insert(_btreeState, _btreeState->head(), data->loc, *data->added[i], @@ -262,7 +262,7 @@ namespace mongo { } for (size_t i = 0; i < data->removed.size(); ++i) { - _interface->unindex(_btreeState.get(), + _interface->unindex(_btreeState, _btreeState->head(), *data->removed[i], data->loc); @@ -304,7 +304,7 @@ namespace mongo { } Status BtreeAccessMethod::newCursor(IndexCursor** out) const { - *out = new BtreeIndexCursor(_btreeState.get(), _interface); + *out = new BtreeIndexCursor(_btreeState, _interface); return Status::OK(); } diff --git a/src/mongo/db/index/btree_access_method_internal.h b/src/mongo/db/index/btree_access_method_internal.h index 1adc108774f..dc9b41e41db 100644 --- a/src/mongo/db/index/btree_access_method_internal.h +++ b/src/mongo/db/index/btree_access_method_internal.h @@ -92,7 +92,7 @@ namespace mongo { virtual void getKeys(const BSONObj &obj, BSONObjSet *keys) = 0; - scoped_ptr<BtreeInMemoryState> _btreeState; // OWNED HERE + BtreeInMemoryState* _btreeState; // owned by IndexCatalogEntry const IndexDescriptor* _descriptor; // There are 2 types of Btree disk formats. We put them both behind one interface. diff --git a/src/mongo/db/index/haystack_access_method.cpp b/src/mongo/db/index/haystack_access_method.cpp index 592a94f87c5..d67be2e506b 100644 --- a/src/mongo/db/index/haystack_access_method.cpp +++ b/src/mongo/db/index/haystack_access_method.cpp @@ -182,7 +182,8 @@ namespace mongo { unordered_set<DiskLoc, DiskLoc::Hasher> thisPass; - scoped_ptr<Runner> runner(InternalPlanner::indexScan(_descriptor, key, key, true)); + scoped_ptr<Runner> runner(InternalPlanner::indexScan(_btreeState->collection(), + _descriptor, key, key, true)); Runner::RunnerState state; DiskLoc loc; while (Runner::RUNNER_ADVANCED == (state = runner->getNext(NULL, &loc))) { diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h index 309123478de..59bb26800ae 100644 --- a/src/mongo/db/index/index_descriptor.h +++ b/src/mongo/db/index/index_descriptor.h @@ -54,9 +54,9 @@ namespace mongo { * OnDiskIndexData is a pointer to the memory mapped per-index data. * infoObj is a copy of the index-describing BSONObj contained in the OnDiskIndexData. */ - IndexDescriptor(Collection* collection, int indexNumber,BSONObj infoObj) + IndexDescriptor(Collection* collection, BSONObj infoObj) : _magic(123987), - _collection(collection), _indexNumber(indexNumber), + _collection(collection), _infoObj(infoObj.getOwned()), _numFields(infoObj.getObjectField("key").nFields()), _keyPattern(infoObj.getObjectField("key").getOwned()), @@ -124,7 +124,7 @@ namespace mongo { bool isSparse() const { return _sparse; } // Is this index multikey? - bool isMultikey() const { _checkOk(); return _collection->details()->isMultikey(_indexNumber); } + bool isMultikey() const { _checkOk(); return _collection->getIndexCatalog()->isMultikey( this ); } bool isIdIndex() const { _checkOk(); return _isIdIndex; } @@ -146,14 +146,6 @@ namespace mongo { // Return the info object. const BSONObj& infoObj() const { _checkOk(); return _infoObj; } - // Is this index being created in the background? - bool isBackgroundIndex() const { - return _indexNumber >= _collection->details()->getCompletedIndexCount(); - } - - // this is the collection over which the index is over - Collection* getIndexedCollection() const { return _collection; } - // this is the owner of this IndexDescriptor IndexCatalog* getIndexCatalog() const { return _collection->getIndexCatalog(); } @@ -166,17 +158,11 @@ namespace mongo { verify(0); } - int getIndexNumber() const { return _indexNumber; } - int _magic; // Related catalog information of the parent collection Collection* _collection; - // What # index are we in the catalog represented by _namespaceDetails? Needed for setting - // and getting multikey. - int _indexNumber; - // The BSONObj describing the index. Accessed through the various members above. const BSONObj _infoObj; |