From 0eb5d53338bfcff847ce1b9e34b7344dcaf9ed84 Mon Sep 17 00:00:00 2001 From: Zach Yam Date: Thu, 13 Jun 2019 13:06:39 -0400 Subject: Revert "Make get(Grouped)SortedDataInterface return a unique pointer" This reverts commit 90a74a50044d4daff7fa66e050bd76e70a0c7e56. --- src/mongo/db/catalog/index_catalog_impl.cpp | 4 ++-- src/mongo/db/index/2d_access_method.cpp | 5 ++--- src/mongo/db/index/2d_access_method.h | 2 +- src/mongo/db/index/btree_access_method.cpp | 5 ++--- src/mongo/db/index/btree_access_method.h | 2 +- src/mongo/db/index/fts_access_method.cpp | 6 ++---- src/mongo/db/index/fts_access_method.h | 2 +- src/mongo/db/index/hash_access_method.cpp | 5 ++--- src/mongo/db/index/hash_access_method.h | 2 +- src/mongo/db/index/haystack_access_method.cpp | 4 ++-- src/mongo/db/index/haystack_access_method.h | 2 +- src/mongo/db/index/index_access_method.cpp | 6 ++---- src/mongo/db/index/index_access_method.h | 7 +++---- .../db/index/index_access_method_factory_impl.cpp | 16 +++++++-------- .../db/index/index_access_method_factory_impl.h | 4 ++-- src/mongo/db/index/s2_access_method.cpp | 5 ++--- src/mongo/db/index/s2_access_method.h | 2 +- src/mongo/db/index/wildcard_access_method.cpp | 4 ++-- src/mongo/db/index/wildcard_access_method.h | 3 +-- src/mongo/db/storage/biggie/biggie_kv_engine.cpp | 7 ++++--- src/mongo/db/storage/biggie/biggie_kv_engine.h | 5 +++-- src/mongo/db/storage/devnull/devnull_kv_engine.cpp | 7 ++++--- src/mongo/db/storage/devnull/devnull_kv_engine.h | 5 +++-- .../ephemeral_for_test_btree_impl.cpp | 23 +++++++++++----------- .../ephemeral_for_test_btree_impl.h | 13 ++++++------ .../ephemeral_for_test_engine.cpp | 5 +++-- .../ephemeral_for_test/ephemeral_for_test_engine.h | 5 +++-- .../kv/kv_drop_pending_ident_reaper_test.cpp | 5 +++-- src/mongo/db/storage/kv/kv_engine.h | 13 +++++++----- src/mongo/db/storage/kv/kv_engine_test_harness.cpp | 4 ++-- src/mongo/db/storage/mobile/mobile_kv_engine.cpp | 9 +++++---- src/mongo/db/storage/mobile/mobile_kv_engine.h | 5 +++-- .../db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 10 ++++++---- .../db/storage/wiredtiger/wiredtiger_kv_engine.h | 13 ++++++------ 34 files changed, 109 insertions(+), 106 deletions(-) (limited to 'src/mongo/db') diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index 76e8c9b02ac..bb72fa8c453 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -153,11 +153,11 @@ IndexCatalogEntry* IndexCatalogImpl::_setupInMemoryStructures( std::string ident = engine->getCatalog()->getIndexIdent(opCtx, _collection->ns(), desc->indexName()); - std::unique_ptr sdi = + SortedDataInterface* sdi = engine->getEngine()->getGroupedSortedDataInterface(opCtx, ident, desc, entry->getPrefix()); std::unique_ptr accessMethod = - IndexAccessMethodFactory::get(opCtx)->make(entry.get(), std::move(sdi)); + IndexAccessMethodFactory::get(opCtx)->make(entry.get(), sdi); entry->init(std::move(accessMethod)); diff --git a/src/mongo/db/index/2d_access_method.cpp b/src/mongo/db/index/2d_access_method.cpp index efd9c56b4f6..99f52b5e5ed 100644 --- a/src/mongo/db/index/2d_access_method.cpp +++ b/src/mongo/db/index/2d_access_method.cpp @@ -41,9 +41,8 @@ namespace mongo { -TwoDAccessMethod::TwoDAccessMethod(IndexCatalogEntry* btreeState, - std::unique_ptr btree) - : AbstractIndexAccessMethod(btreeState, std::move(btree)) { +TwoDAccessMethod::TwoDAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree) + : AbstractIndexAccessMethod(btreeState, btree) { const IndexDescriptor* descriptor = btreeState->descriptor(); ExpressionParams::parseTwoDParams(descriptor->infoObj(), &_params); diff --git a/src/mongo/db/index/2d_access_method.h b/src/mongo/db/index/2d_access_method.h index 9e40c7aa2fc..0d350f99869 100644 --- a/src/mongo/db/index/2d_access_method.h +++ b/src/mongo/db/index/2d_access_method.h @@ -42,7 +42,7 @@ struct TwoDIndexingParams; class TwoDAccessMethod : public AbstractIndexAccessMethod { public: - TwoDAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr btree); + TwoDAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); private: const IndexDescriptor* getDescriptor() { diff --git a/src/mongo/db/index/btree_access_method.cpp b/src/mongo/db/index/btree_access_method.cpp index 51d4ba3acbe..c96fcfc1dc8 100644 --- a/src/mongo/db/index/btree_access_method.cpp +++ b/src/mongo/db/index/btree_access_method.cpp @@ -42,9 +42,8 @@ namespace mongo { using std::vector; // Standard Btree implementation below. -BtreeAccessMethod::BtreeAccessMethod(IndexCatalogEntry* btreeState, - std::unique_ptr btree) - : AbstractIndexAccessMethod(btreeState, std::move(btree)) { +BtreeAccessMethod::BtreeAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree) + : AbstractIndexAccessMethod(btreeState, btree) { // The key generation wants these values. vector fieldNames; vector fixed; diff --git a/src/mongo/db/index/btree_access_method.h b/src/mongo/db/index/btree_access_method.h index 3af203d1f78..126c1fa86eb 100644 --- a/src/mongo/db/index/btree_access_method.h +++ b/src/mongo/db/index/btree_access_method.h @@ -45,7 +45,7 @@ class IndexDescriptor; */ class BtreeAccessMethod : public AbstractIndexAccessMethod { public: - BtreeAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr btree); + BtreeAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); private: void doGetKeys(const BSONObj& obj, diff --git a/src/mongo/db/index/fts_access_method.cpp b/src/mongo/db/index/fts_access_method.cpp index 46f20b77b78..2912569dfb4 100644 --- a/src/mongo/db/index/fts_access_method.cpp +++ b/src/mongo/db/index/fts_access_method.cpp @@ -34,10 +34,8 @@ namespace mongo { -FTSAccessMethod::FTSAccessMethod(IndexCatalogEntry* btreeState, - std::unique_ptr btree) - : AbstractIndexAccessMethod(btreeState, std::move(btree)), - _ftsSpec(btreeState->descriptor()->infoObj()) {} +FTSAccessMethod::FTSAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree) + : AbstractIndexAccessMethod(btreeState, btree), _ftsSpec(btreeState->descriptor()->infoObj()) {} void FTSAccessMethod::doGetKeys(const BSONObj& obj, BSONObjSet* keys, diff --git a/src/mongo/db/index/fts_access_method.h b/src/mongo/db/index/fts_access_method.h index f4ec0c14468..dbd0a6eb175 100644 --- a/src/mongo/db/index/fts_access_method.h +++ b/src/mongo/db/index/fts_access_method.h @@ -39,7 +39,7 @@ namespace mongo { class FTSAccessMethod : public AbstractIndexAccessMethod { public: - FTSAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr btree); + FTSAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); const fts::FTSSpec& getSpec() const { return _ftsSpec; diff --git a/src/mongo/db/index/hash_access_method.cpp b/src/mongo/db/index/hash_access_method.cpp index 3aae1930d40..c78a3f1cf9f 100644 --- a/src/mongo/db/index/hash_access_method.cpp +++ b/src/mongo/db/index/hash_access_method.cpp @@ -36,9 +36,8 @@ namespace mongo { -HashAccessMethod::HashAccessMethod(IndexCatalogEntry* btreeState, - std::unique_ptr btree) - : AbstractIndexAccessMethod(btreeState, std::move(btree)) { +HashAccessMethod::HashAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree) + : AbstractIndexAccessMethod(btreeState, btree) { const IndexDescriptor* descriptor = btreeState->descriptor(); // We can change these if the single-field limitation is lifted later. diff --git a/src/mongo/db/index/hash_access_method.h b/src/mongo/db/index/hash_access_method.h index e96ce878625..a11403ff784 100644 --- a/src/mongo/db/index/hash_access_method.h +++ b/src/mongo/db/index/hash_access_method.h @@ -46,7 +46,7 @@ class CollatorInterface; */ class HashAccessMethod : public AbstractIndexAccessMethod { public: - HashAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr btree); + HashAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); private: /** diff --git a/src/mongo/db/index/haystack_access_method.cpp b/src/mongo/db/index/haystack_access_method.cpp index 93be4804030..bbfa78b1b35 100644 --- a/src/mongo/db/index/haystack_access_method.cpp +++ b/src/mongo/db/index/haystack_access_method.cpp @@ -53,8 +53,8 @@ using std::unique_ptr; namespace dps = ::mongo::dotted_path_support; HaystackAccessMethod::HaystackAccessMethod(IndexCatalogEntry* btreeState, - std::unique_ptr btree) - : AbstractIndexAccessMethod(btreeState, std::move(btree)) { + SortedDataInterface* btree) + : AbstractIndexAccessMethod(btreeState, btree) { const IndexDescriptor* descriptor = btreeState->descriptor(); ExpressionParams::parseHaystackParams( diff --git a/src/mongo/db/index/haystack_access_method.h b/src/mongo/db/index/haystack_access_method.h index 6c609e04cde..99ab21dfde4 100644 --- a/src/mongo/db/index/haystack_access_method.h +++ b/src/mongo/db/index/haystack_access_method.h @@ -57,7 +57,7 @@ class OperationContext; */ class HaystackAccessMethod : public AbstractIndexAccessMethod { public: - HaystackAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr btree); + HaystackAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); protected: friend class GeoHaystackSearchCommand; diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index 4fd9a9264bc..da5fd8cf64a 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -131,10 +131,8 @@ private: }; AbstractIndexAccessMethod::AbstractIndexAccessMethod(IndexCatalogEntry* btreeState, - std::unique_ptr btree) - : _btreeState(btreeState), - _descriptor(btreeState->descriptor()), - _newInterface(std::move(btree)) { + SortedDataInterface* btree) + : _btreeState(btreeState), _descriptor(btreeState->descriptor()), _newInterface(btree) { verify(IndexDescriptor::isIndexVersionSupported(_descriptor->version())); } diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index 39e98a3dfbb..91b35a95ddb 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -364,8 +364,8 @@ public: static void set(ServiceContext* service, std::unique_ptr collectionFactory); - virtual std::unique_ptr make( - IndexCatalogEntry* entry, std::unique_ptr sortedDataInterface) = 0; + virtual std::unique_ptr make(IndexCatalogEntry* entry, + SortedDataInterface* sortedDataInterface) = 0; }; /** @@ -449,8 +449,7 @@ public: static std::pair, std::vector> setDifference( const BSONObjSet& left, const BSONObjSet& right); - AbstractIndexAccessMethod(IndexCatalogEntry* btreeState, - std::unique_ptr btree); + AbstractIndexAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); Status insert(OperationContext* opCtx, const BSONObj& obj, diff --git a/src/mongo/db/index/index_access_method_factory_impl.cpp b/src/mongo/db/index/index_access_method_factory_impl.cpp index 2eb06511d1b..485bfac25b7 100644 --- a/src/mongo/db/index/index_access_method_factory_impl.cpp +++ b/src/mongo/db/index/index_access_method_factory_impl.cpp @@ -45,23 +45,23 @@ namespace mongo { std::unique_ptr IndexAccessMethodFactoryImpl::make( - IndexCatalogEntry* entry, std::unique_ptr sortedDataInterface) { + IndexCatalogEntry* entry, SortedDataInterface* sortedDataInterface) { auto desc = entry->descriptor(); const std::string& type = desc->getAccessMethodName(); if ("" == type) - return std::make_unique(entry, std::move(sortedDataInterface)); + return std::make_unique(entry, sortedDataInterface); else if (IndexNames::HASHED == type) - return std::make_unique(entry, std::move(sortedDataInterface)); + return std::make_unique(entry, sortedDataInterface); else if (IndexNames::GEO_2DSPHERE == type) - return std::make_unique(entry, std::move(sortedDataInterface)); + return std::make_unique(entry, sortedDataInterface); else if (IndexNames::TEXT == type) - return std::make_unique(entry, std::move(sortedDataInterface)); + return std::make_unique(entry, sortedDataInterface); else if (IndexNames::GEO_HAYSTACK == type) - return std::make_unique(entry, std::move(sortedDataInterface)); + return std::make_unique(entry, sortedDataInterface); else if (IndexNames::GEO_2D == type) - return std::make_unique(entry, std::move(sortedDataInterface)); + return std::make_unique(entry, sortedDataInterface); else if (IndexNames::WILDCARD == type) - return std::make_unique(entry, std::move(sortedDataInterface)); + return std::make_unique(entry, sortedDataInterface); log() << "Can't find index for keyPattern " << desc->keyPattern(); fassertFailed(31021); } diff --git a/src/mongo/db/index/index_access_method_factory_impl.h b/src/mongo/db/index/index_access_method_factory_impl.h index dae1a2204ac..7c89e702d0e 100644 --- a/src/mongo/db/index/index_access_method_factory_impl.h +++ b/src/mongo/db/index/index_access_method_factory_impl.h @@ -38,8 +38,8 @@ public: IndexAccessMethodFactoryImpl() = default; ~IndexAccessMethodFactoryImpl() = default; - std::unique_ptr make( - IndexCatalogEntry* entry, std::unique_ptr SortedDataInterface) final; + std::unique_ptr make(IndexCatalogEntry* entry, + SortedDataInterface* SortedDataInterface) final; }; } // namespace mongo diff --git a/src/mongo/db/index/s2_access_method.cpp b/src/mongo/db/index/s2_access_method.cpp index 3f9ac46d57e..731e0a14123 100644 --- a/src/mongo/db/index/s2_access_method.cpp +++ b/src/mongo/db/index/s2_access_method.cpp @@ -47,9 +47,8 @@ namespace mongo { static const string kIndexVersionFieldName("2dsphereIndexVersion"); -S2AccessMethod::S2AccessMethod(IndexCatalogEntry* btreeState, - std::unique_ptr btree) - : AbstractIndexAccessMethod(btreeState, std::move(btree)) { +S2AccessMethod::S2AccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree) + : AbstractIndexAccessMethod(btreeState, btree) { const IndexDescriptor* descriptor = btreeState->descriptor(); ExpressionParams::initialize2dsphereParams( diff --git a/src/mongo/db/index/s2_access_method.h b/src/mongo/db/index/s2_access_method.h index 4851f6fbc7d..164b38c5af5 100644 --- a/src/mongo/db/index/s2_access_method.h +++ b/src/mongo/db/index/s2_access_method.h @@ -40,7 +40,7 @@ namespace mongo { class S2AccessMethod : public AbstractIndexAccessMethod { public: - S2AccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr btree); + S2AccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); /** * Takes an index spec object for this index and returns a copy tweaked to conform to the diff --git a/src/mongo/db/index/wildcard_access_method.cpp b/src/mongo/db/index/wildcard_access_method.cpp index 4269d3dcab2..cfa6adc1e46 100644 --- a/src/mongo/db/index/wildcard_access_method.cpp +++ b/src/mongo/db/index/wildcard_access_method.cpp @@ -38,8 +38,8 @@ namespace mongo { WildcardAccessMethod::WildcardAccessMethod(IndexCatalogEntry* wildcardState, - std::unique_ptr btree) - : AbstractIndexAccessMethod(wildcardState, std::move(btree)), + SortedDataInterface* btree) + : AbstractIndexAccessMethod(wildcardState, btree), _keyGen( _descriptor->keyPattern(), _descriptor->pathProjection(), _btreeState->getCollator()) {} diff --git a/src/mongo/db/index/wildcard_access_method.h b/src/mongo/db/index/wildcard_access_method.h index 7fde78eb256..45d866c1020 100644 --- a/src/mongo/db/index/wildcard_access_method.h +++ b/src/mongo/db/index/wildcard_access_method.h @@ -56,8 +56,7 @@ public: */ static FieldRef extractMultikeyPathFromIndexKey(const IndexKeyEntry& entry); - WildcardAccessMethod(IndexCatalogEntry* wildcardState, - std::unique_ptr btree); + WildcardAccessMethod(IndexCatalogEntry* wildcardState, SortedDataInterface* btree); /** * Returns 'true' if the index should become multikey on the basis of the passed arguments. diff --git a/src/mongo/db/storage/biggie/biggie_kv_engine.cpp b/src/mongo/db/storage/biggie/biggie_kv_engine.cpp index 3aeefdf59c2..d0c4a4b987a 100644 --- a/src/mongo/db/storage/biggie/biggie_kv_engine.cpp +++ b/src/mongo/db/storage/biggie/biggie_kv_engine.cpp @@ -111,10 +111,11 @@ Status KVEngine::createSortedDataInterface(OperationContext* opCtx, return Status::OK(); // I don't think we actually need to do anything here } -std::unique_ptr KVEngine::getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) { +mongo::SortedDataInterface* KVEngine::getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) { _idents[ident.toString()] = false; - return std::make_unique(opCtx, ident, desc); + return new SortedDataInterface(opCtx, ident, desc); } Status KVEngine::dropIdent(OperationContext* opCtx, StringData ident) { diff --git a/src/mongo/db/storage/biggie/biggie_kv_engine.h b/src/mongo/db/storage/biggie/biggie_kv_engine.h index e41f334a329..e14a879bef6 100644 --- a/src/mongo/db/storage/biggie/biggie_kv_engine.h +++ b/src/mongo/db/storage/biggie/biggie_kv_engine.h @@ -70,8 +70,9 @@ public: StringData ident, const IndexDescriptor* desc); - virtual std::unique_ptr getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc); + virtual mongo::SortedDataInterface* getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc); virtual Status beginBackup(OperationContext* opCtx) { return Status::OK(); diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp index 6500879bde3..b53c345ceed 100644 --- a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp +++ b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp @@ -256,9 +256,10 @@ std::unique_ptr DevNullKVEngine::makeTemporaryRecordStore(Operation return std::make_unique("", CollectionOptions()); } -std::unique_ptr DevNullKVEngine::getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) { - return std::make_unique(); +SortedDataInterface* DevNullKVEngine::getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) { + return new DevNullSortedDataInterface(); } int64_t DevNullKVEngine::getCacheOverflowTableInsertCount(OperationContext* opCtx) const { diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.h b/src/mongo/db/storage/devnull/devnull_kv_engine.h index 33fe29d38f4..d73f5a97768 100644 --- a/src/mongo/db/storage/devnull/devnull_kv_engine.h +++ b/src/mongo/db/storage/devnull/devnull_kv_engine.h @@ -70,8 +70,9 @@ public: return Status::OK(); } - virtual std::unique_ptr getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc); + virtual SortedDataInterface* getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc); virtual Status dropIdent(OperationContext* opCtx, StringData ident) { return Status::OK(); diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp index c82d629a2af..d9fa673dba5 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp @@ -521,22 +521,21 @@ private: // IndexCatalogEntry argument taken by non-const pointer for consistency with other Btree // factories. We don't actually modify it. -std::unique_ptr getEphemeralForTestBtreeImpl( - const Ordering& ordering, - bool isUnique, - const NamespaceString& collectionNamespace, - const std::string& indexName, - const BSONObj& keyPattern, - std::shared_ptr* dataInOut) { +SortedDataInterface* getEphemeralForTestBtreeImpl(const Ordering& ordering, + bool isUnique, + const NamespaceString& collectionNamespace, + const std::string& indexName, + const BSONObj& keyPattern, + std::shared_ptr* dataInOut) { invariant(dataInOut); if (!*dataInOut) { *dataInOut = std::make_shared(IndexEntryComparison(ordering)); } - return std::make_unique(static_cast(dataInOut->get()), - isUnique, - collectionNamespace, - indexName, - keyPattern); + return new EphemeralForTestBtreeImpl(static_cast(dataInOut->get()), + isUnique, + collectionNamespace, + indexName, + keyPattern); } } // namespace mongo diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h index 60431c1cfa7..2b8b566e711 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h @@ -40,12 +40,11 @@ class IndexCatalogEntry; * Caller takes ownership. * All permanent data will be stored and fetch from dataInOut. */ -std::unique_ptr getEphemeralForTestBtreeImpl( - const Ordering& ordering, - bool isUnique, - const NamespaceString& collectionNamespace, - const std::string& indexName, - const BSONObj& keyPattern, - std::shared_ptr* dataInOut); +SortedDataInterface* getEphemeralForTestBtreeImpl(const Ordering& ordering, + bool isUnique, + const NamespaceString& collectionNamespace, + const std::string& indexName, + const BSONObj& keyPattern, + std::shared_ptr* dataInOut); } // namespace mongo diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp index 0cb25117917..782c425ffd0 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp @@ -92,8 +92,9 @@ Status EphemeralForTestEngine::createSortedDataInterface(OperationContext* opCtx return Status::OK(); } -std::unique_ptr EphemeralForTestEngine::getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) { +SortedDataInterface* EphemeralForTestEngine::getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) { stdx::lock_guard lk(_mutex); return getEphemeralForTestBtreeImpl(Ordering::make(desc->keyPattern()), desc->unique(), diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h index a499bba6b67..008c0084587 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h @@ -61,8 +61,9 @@ public: StringData ident, const IndexDescriptor* desc); - virtual std::unique_ptr getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc); + virtual SortedDataInterface* getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc); virtual Status beginBackup(OperationContext* opCtx) { return Status::OK(); diff --git a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp index 064a5ee66e6..e5fad9811a5 100644 --- a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp +++ b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp @@ -71,8 +71,9 @@ public: const CollectionOptions& options) override { return {}; } - std::unique_ptr getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) override { + SortedDataInterface* getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) override { return nullptr; } Status createRecordStore(OperationContext* opCtx, diff --git a/src/mongo/db/storage/kv/kv_engine.h b/src/mongo/db/storage/kv/kv_engine.h index e6801dab6c7..4f622259075 100644 --- a/src/mongo/db/storage/kv/kv_engine.h +++ b/src/mongo/db/storage/kv/kv_engine.h @@ -39,7 +39,6 @@ #include "mongo/db/catalog/collection_options.h" #include "mongo/db/storage/kv/kv_prefix.h" #include "mongo/db/storage/record_store.h" -#include "mongo/db/storage/sorted_data_interface.h" #include "mongo/db/storage/storage_engine.h" namespace mongo { @@ -48,6 +47,7 @@ class IndexDescriptor; class JournalListener; class OperationContext; class RecoveryUnit; +class SortedDataInterface; class SnapshotManager; class KVEngine { @@ -87,8 +87,9 @@ public: return getRecordStore(opCtx, ns, ident, options); } - virtual std::unique_ptr getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) = 0; + virtual SortedDataInterface* getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) = 0; /** * Get a SortedDataInterface that may share an underlying table with other @@ -99,8 +100,10 @@ public: * between indexes sharing an underlying table. A value of `KVPrefix::kNotPrefixed` * guarantees the index is the sole resident of the table. */ - virtual std::unique_ptr getGroupedSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc, KVPrefix prefix) { + virtual SortedDataInterface* getGroupedSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc, + KVPrefix prefix) { invariant(prefix == KVPrefix::kNotPrefixed); return getSortedDataInterface(opCtx, ident, desc); } 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 22cb8778836..afd0cbb68b8 100644 --- a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp +++ b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp @@ -182,7 +182,7 @@ TEST(KVEngineTestHarness, SimpleSorted1) { { MyOperationContext opCtx(engine); ASSERT_OK(engine->createSortedDataInterface(&opCtx, ident, &desc)); - sorted = engine->getSortedDataInterface(&opCtx, ident, &desc); + sorted.reset(engine->getSortedDataInterface(&opCtx, ident, &desc)); ASSERT(sorted); } @@ -725,7 +725,7 @@ DEATH_TEST_F(KVCatalogTest, TerminateOnNonNumericIndexVersion, "Fatal Assertion { MyOperationContext opCtx(engine); ASSERT_OK(engine->createSortedDataInterface(&opCtx, ident, &desc)); - sorted = engine->getSortedDataInterface(&opCtx, ident, &desc); + sorted.reset(engine->getSortedDataInterface(&opCtx, ident, &desc)); ASSERT(sorted); } } diff --git a/src/mongo/db/storage/mobile/mobile_kv_engine.cpp b/src/mongo/db/storage/mobile/mobile_kv_engine.cpp index 4c8b2401683..3426827ee1e 100644 --- a/src/mongo/db/storage/mobile/mobile_kv_engine.cpp +++ b/src/mongo/db/storage/mobile/mobile_kv_engine.cpp @@ -235,12 +235,13 @@ Status MobileKVEngine::createSortedDataInterface(OperationContext* opCtx, return MobileIndex::create(opCtx, ident.toString()); } -std::unique_ptr MobileKVEngine::getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) { +SortedDataInterface* MobileKVEngine::getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) { if (desc->unique()) { - return std::make_unique(opCtx, desc, ident.toString()); + return new MobileIndexUnique(opCtx, desc, ident.toString()); } - return std::make_unique(opCtx, desc, ident.toString()); + return new MobileIndexStandard(opCtx, desc, ident.toString()); } Status MobileKVEngine::dropIdent(OperationContext* opCtx, StringData ident) { diff --git a/src/mongo/db/storage/mobile/mobile_kv_engine.h b/src/mongo/db/storage/mobile/mobile_kv_engine.h index 10da2d2e1a0..a2e6f7702f1 100644 --- a/src/mongo/db/storage/mobile/mobile_kv_engine.h +++ b/src/mongo/db/storage/mobile/mobile_kv_engine.h @@ -68,8 +68,9 @@ public: StringData ident, const IndexDescriptor* desc) override; - std::unique_ptr getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) override; + SortedDataInterface* getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) override; Status beginBackup(OperationContext* opCtx) override { return Status::OK(); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 9971b1e387d..7e8aa78c7d1 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -1281,13 +1281,15 @@ Status WiredTigerKVEngine::createGroupedSortedDataInterface(OperationContext* op return wtRCToStatus(WiredTigerIndex::Create(opCtx, _uri(ident), config)); } -std::unique_ptr WiredTigerKVEngine::getGroupedSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc, KVPrefix prefix) { +SortedDataInterface* WiredTigerKVEngine::getGroupedSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc, + KVPrefix prefix) { if (desc->unique()) { - return std::make_unique(opCtx, _uri(ident), desc, prefix, _readOnly); + return new WiredTigerIndexUnique(opCtx, _uri(ident), desc, prefix, _readOnly); } - return std::make_unique(opCtx, _uri(ident), desc, prefix, _readOnly); + return new WiredTigerIndexStandard(opCtx, _uri(ident), desc, prefix, _readOnly); } std::unique_ptr WiredTigerKVEngine::makeTemporaryRecordStore(OperationContext* opCtx, diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index bf194231e61..1ad5243f710 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -123,8 +123,9 @@ public: return createGroupedSortedDataInterface(opCtx, ident, desc, KVPrefix::kNotPrefixed); } - std::unique_ptr getSortedDataInterface( - OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) override { + SortedDataInterface* getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) override { return getGroupedSortedDataInterface(opCtx, ident, desc, KVPrefix::kNotPrefixed); } @@ -145,10 +146,10 @@ public: const IndexDescriptor* desc, KVPrefix prefix) override; - std::unique_ptr getGroupedSortedDataInterface(OperationContext* opCtx, - StringData ident, - const IndexDescriptor* desc, - KVPrefix prefix) override; + SortedDataInterface* getGroupedSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc, + KVPrefix prefix) override; Status dropIdent(OperationContext* opCtx, StringData ident) override; -- cgit v1.2.1