diff options
author | Brian DeLeonardis <brian.deleonardis@mongodb.com> | 2020-10-12 22:12:47 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-14 20:06:45 +0000 |
commit | 1426816fd1ee13598f0d48a8c36ff8c8d7d24b28 (patch) | |
tree | a0d060cc967e1e678137dda7f87565f940a4e471 | |
parent | 4a2fbeebf482f4be1148479d12283819e55d933c (diff) | |
download | mongo-1426816fd1ee13598f0d48a8c36ff8c8d7d24b28.tar.gz |
SERVER-51094 Remove collection parameter in IndexDescriptor constructor
11 files changed, 20 insertions, 34 deletions
diff --git a/src/mongo/db/catalog/index_build_block.cpp b/src/mongo/db/catalog/index_build_block.cpp index 1409d7147cb..95ae6f51f20 100644 --- a/src/mongo/db/catalog/index_build_block.cpp +++ b/src/mongo/db/catalog/index_build_block.cpp @@ -123,8 +123,8 @@ Status IndexBuildBlock::init(OperationContext* opCtx, Collection* collection) { // need this first for names, etc... BSONObj keyPattern = _spec.getObjectField("key"); - auto descriptor = std::make_unique<IndexDescriptor>( - collection, IndexNames::findPluginName(keyPattern), _spec); + auto descriptor = + std::make_unique<IndexDescriptor>(IndexNames::findPluginName(keyPattern), _spec); _indexName = descriptor->indexName(); diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index 7b65a2f5521..6ba972ea18e 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -127,8 +127,7 @@ Status IndexCatalogImpl::init(OperationContext* opCtx) { "geoHaystack indexes has been deprecated. Instead create a 2d index. See " "https://dochub.mongodb.org/core/4.4-deprecate-geoHaystack"); } - auto descriptor = - std::make_unique<IndexDescriptor>(_collection, _getAccessMethodName(keyPattern), spec); + auto descriptor = std::make_unique<IndexDescriptor>(_getAccessMethodName(keyPattern), spec); if (spec.hasField(IndexDescriptor::kExpireAfterSecondsFieldName)) { TTLCollectionCache::get(opCtx->getServiceContext()) .registerTTLInfo(std::make_pair(_collection->uuid(), indexName)); @@ -798,7 +797,7 @@ Status IndexCatalogImpl::_doesSpecConflictWithExisting(OperationContext* opCtx, if (desc) { // Index already exists with same name. Check whether the options are the same as well. - IndexDescriptor candidate(_collection, _getAccessMethodName(key), spec); + IndexDescriptor candidate(_getAccessMethodName(key), spec); auto indexComparison = candidate.compareIndexOptions(opCtx, _collection->ns(), getEntry(desc)); @@ -857,7 +856,7 @@ Status IndexCatalogImpl::_doesSpecConflictWithExisting(OperationContext* opCtx, // Index already exists with a different name. Check whether the options are identical. // We will return an error in either case, but this check allows us to generate a more // informative error message. - IndexDescriptor candidate(_collection, _getAccessMethodName(key), spec); + IndexDescriptor candidate(_getAccessMethodName(key), spec); auto indexComparison = candidate.compareIndexOptions(opCtx, _collection->ns(), getEntry(desc)); @@ -1165,7 +1164,7 @@ const IndexDescriptor* IndexCatalogImpl::findIndexByKeyPatternAndOptions( const BSONObj& indexSpec, bool includeUnfinishedIndexes) const { std::unique_ptr<IndexIterator> ii = getIndexIterator(opCtx, includeUnfinishedIndexes); - IndexDescriptor needle(_collection, _getAccessMethodName(key), indexSpec); + IndexDescriptor needle(_getAccessMethodName(key), indexSpec); while (ii->more()) { const auto* entry = ii->next(); if (needle.compareIndexOptions(opCtx, {}, entry) != @@ -1271,8 +1270,7 @@ const IndexDescriptor* IndexCatalogImpl::refreshEntry(OperationContext* opCtx, // Re-register this index in the index catalog with the new spec. Also, add the new index // to the CollectionQueryInfo. - auto newDesc = - std::make_unique<IndexDescriptor>(_collection, _getAccessMethodName(keyPattern), spec); + auto newDesc = std::make_unique<IndexDescriptor>(_getAccessMethodName(keyPattern), spec); auto newEntry = createIndexEntry(opCtx, std::move(newDesc), CreateIndexEntryFlags::kIsReady); invariant(newEntry->isReady(opCtx)); CollectionQueryInfo::get(_collection).addedIndex(opCtx, _collection, newEntry->descriptor()); diff --git a/src/mongo/db/catalog/index_signature_test.cpp b/src/mongo/db/catalog/index_signature_test.cpp index e7a83ffefc6..4abc6922e0f 100644 --- a/src/mongo/db/catalog/index_signature_test.cpp +++ b/src/mongo/db/catalog/index_signature_test.cpp @@ -60,8 +60,7 @@ public: std::unique_ptr<IndexDescriptor> makeIndexDescriptor(BSONObj spec) { auto keyPattern = spec.getObjectField(IndexDescriptor::kKeyPatternFieldName); - return std::make_unique<IndexDescriptor>( - coll(), IndexNames::findPluginName(keyPattern), spec); + return std::make_unique<IndexDescriptor>(IndexNames::findPluginName(keyPattern), spec); } const NamespaceString& nss() const { diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp index dec4d7bb7e3..d8428904003 100644 --- a/src/mongo/db/index/index_descriptor.cpp +++ b/src/mongo/db/index/index_descriptor.cpp @@ -31,7 +31,6 @@ #include "mongo/platform/basic.h" -#include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/matcher/expression_parser.h" @@ -99,9 +98,7 @@ constexpr StringData IndexDescriptor::kUniqueFieldName; constexpr StringData IndexDescriptor::kHiddenFieldName; constexpr StringData IndexDescriptor::kWeightsFieldName; -IndexDescriptor::IndexDescriptor(const CollectionPtr& collection, - const std::string& accessMethodName, - BSONObj infoObj) +IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj infoObj) : _accessMethodName(accessMethodName), _indexType(IndexNames::nameToType(accessMethodName)), _infoObj(infoObj.getOwned()), diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h index ad4c17b6cf6..c37577a4801 100644 --- a/src/mongo/db/index/index_descriptor.h +++ b/src/mongo/db/index/index_descriptor.h @@ -42,8 +42,6 @@ namespace mongo { -class Collection; -class CollectionPtr; class IndexCatalogEntry; class IndexCatalogEntryContainer; class OperationContext; @@ -96,9 +94,7 @@ public: /** * infoObj is a copy of the index-describing BSONObj contained in the catalog. */ - IndexDescriptor(const CollectionPtr& collection, - const std::string& accessMethodName, - BSONObj infoObj); + IndexDescriptor(const std::string& accessMethodName, BSONObj infoObj); /** * Returns true if the specified index version is supported, and returns false otherwise. diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp index 6535535505b..7b3c88a4532 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp @@ -61,7 +61,7 @@ public: << "unique" << true); auto collection = std::make_unique<CollectionMock>(NamespaceString(ns)); - IndexDescriptor desc(collection.get(), "", spec); + IndexDescriptor desc("", spec); invariant(desc.isIdIndex()); return _kvEngine.getSortedDataInterface(&opCtx, "ident"_sd, &desc); @@ -84,7 +84,7 @@ public: } auto collection = std::make_unique<CollectionMock>(NamespaceString(ns)); - _descs.emplace_back(collection.get(), "", spec); + _descs.emplace_back("", spec); return _kvEngine.getSortedDataInterface(&opCtx, "ident"_sd, &_descs.back()); } diff --git a/src/mongo/db/storage/kv/durable_catalog_test.cpp b/src/mongo/db/storage/kv/durable_catalog_test.cpp index c8992c4608e..384615ef75f 100644 --- a/src/mongo/db/storage/kv/durable_catalog_test.cpp +++ b/src/mongo/db/storage/kv/durable_catalog_test.cpp @@ -103,8 +103,7 @@ public: std::string indexName = "idx" + std::to_string(numIndexesCreated); auto collection = std::make_unique<CollectionMock>(_nss); - IndexDescriptor desc(collection.get(), - indexType, + IndexDescriptor desc(indexType, BSON("v" << 1 << "key" << keyPattern << "name" << indexName)); { diff --git a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp index 1c916c31207..a44e0f7abd2 100644 --- a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp +++ b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp @@ -236,8 +236,7 @@ TEST(KVEngineTestHarness, SimpleSorted1) { uow.commit(); } - IndexDescriptor desc(collection.get(), - "", + IndexDescriptor desc("", BSON("v" << static_cast<int>(IndexDescriptor::kLatestIndexVersion) << "key" << BSON("a" << 1))); std::unique_ptr<SortedDataInterface> sorted; @@ -1486,8 +1485,7 @@ DEATH_TEST_REGEX_F(DurableCatalogImplTest, uow.commit(); } - IndexDescriptor desc(collection.get(), - "", + IndexDescriptor desc("", BSON("v" << "1" << "key" << BSON("a" << 1))); diff --git a/src/mongo/db/storage/storage_engine_test_fixture.h b/src/mongo/db/storage/storage_engine_test_fixture.h index cbbbac1053d..e9c9946cd5c 100644 --- a/src/mongo/db/storage/storage_engine_test_fixture.h +++ b/src/mongo/db/storage/storage_engine_test_fixture.h @@ -159,8 +159,7 @@ public: CollectionPtr collection = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, collNs); - auto descriptor = - std::make_unique<IndexDescriptor>(collection, IndexNames::findPluginName(spec), spec); + auto descriptor = std::make_unique<IndexDescriptor>(IndexNames::findPluginName(spec), spec); auto ret = DurableCatalog::get(opCtx)->prepareForIndexBuild(opCtx, collection->getCatalogId(), diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp index 1202ce8b0a0..20afb98beac 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_prefixed_index_test.cpp @@ -79,7 +79,7 @@ public: << "v" << static_cast<int>(IndexDescriptor::kLatestIndexVersion) << "unique" << true); auto collection = std::make_unique<CollectionMock>(nss); - IndexDescriptor desc(collection.get(), "", spec); + IndexDescriptor desc("", spec); invariant(desc.isIdIndex()); KVPrefix prefix = KVPrefix::generateNextPrefix(); @@ -111,7 +111,7 @@ public: } auto collection = std::make_unique<CollectionMock>(nss); - IndexDescriptor& desc = _descriptors.emplace_back(collection.get(), "", spec); + IndexDescriptor& desc = _descriptors.emplace_back("", spec); KVPrefix prefix = KVPrefix::generateNextPrefix(); StatusWith<std::string> result = WiredTigerIndex::generateCreateString( diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp index f899a214669..66c0562350c 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp @@ -80,7 +80,7 @@ public: << "unique" << true); auto collection = std::make_unique<CollectionMock>(NamespaceString(ns)); - IndexDescriptor desc(collection.get(), "", spec); + IndexDescriptor desc("", spec); invariant(desc.isIdIndex()); KVPrefix prefix = KVPrefix::kNotPrefixed; @@ -112,7 +112,7 @@ public: auto collection = std::make_unique<CollectionMock>(NamespaceString(ns)); - IndexDescriptor& desc = _descriptors.emplace_back(collection.get(), "", spec); + IndexDescriptor& desc = _descriptors.emplace_back("", spec); KVPrefix prefix = KVPrefix::kNotPrefixed; StatusWith<std::string> result = WiredTigerIndex::generateCreateString( |