summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZach Yam <zach.yam@mongodb.com>2019-06-13 13:06:39 -0400
committerZach Yam <zach.yam@mongodb.com>2019-06-13 13:06:39 -0400
commit027a917ad08296f90a1a4a010daf990c5f92beb6 (patch)
tree6f2b76145871cf97256f01df2d64092355eb8343 /src
parent0eb5d53338bfcff847ce1b9e34b7344dcaf9ed84 (diff)
downloadmongo-027a917ad08296f90a1a4a010daf990c5f92beb6.tar.gz
SERVER-36226 Make get(Grouped)SortedDataInterface return a unique pointer
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp4
-rw-r--r--src/mongo/db/index/2d_access_method.cpp5
-rw-r--r--src/mongo/db/index/2d_access_method.h2
-rw-r--r--src/mongo/db/index/btree_access_method.cpp5
-rw-r--r--src/mongo/db/index/btree_access_method.h2
-rw-r--r--src/mongo/db/index/fts_access_method.cpp6
-rw-r--r--src/mongo/db/index/fts_access_method.h2
-rw-r--r--src/mongo/db/index/hash_access_method.cpp5
-rw-r--r--src/mongo/db/index/hash_access_method.h2
-rw-r--r--src/mongo/db/index/haystack_access_method.cpp4
-rw-r--r--src/mongo/db/index/haystack_access_method.h2
-rw-r--r--src/mongo/db/index/index_access_method.cpp6
-rw-r--r--src/mongo/db/index/index_access_method.h7
-rw-r--r--src/mongo/db/index/index_access_method_factory_impl.cpp16
-rw-r--r--src/mongo/db/index/index_access_method_factory_impl.h4
-rw-r--r--src/mongo/db/index/s2_access_method.cpp5
-rw-r--r--src/mongo/db/index/s2_access_method.h2
-rw-r--r--src/mongo/db/index/wildcard_access_method.cpp4
-rw-r--r--src/mongo/db/index/wildcard_access_method.h3
-rw-r--r--src/mongo/db/storage/biggie/biggie_kv_engine.cpp7
-rw-r--r--src/mongo/db/storage/biggie/biggie_kv_engine.h5
-rw-r--r--src/mongo/db/storage/devnull/devnull_kv_engine.cpp7
-rw-r--r--src/mongo/db/storage/devnull/devnull_kv_engine.h5
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp23
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h13
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp5
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h5
-rw-r--r--src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp5
-rw-r--r--src/mongo/db/storage/kv/kv_engine.h13
-rw-r--r--src/mongo/db/storage/kv/kv_engine_test_harness.cpp4
-rw-r--r--src/mongo/db/storage/mobile/mobile_kv_engine.cpp9
-rw-r--r--src/mongo/db/storage/mobile/mobile_kv_engine.h5
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp10
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h13
34 files changed, 106 insertions, 109 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index bb72fa8c453..76e8c9b02ac 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());
- SortedDataInterface* sdi =
+ std::unique_ptr<SortedDataInterface> sdi =
engine->getEngine()->getGroupedSortedDataInterface(opCtx, ident, desc, entry->getPrefix());
std::unique_ptr<IndexAccessMethod> accessMethod =
- IndexAccessMethodFactory::get(opCtx)->make(entry.get(), sdi);
+ IndexAccessMethodFactory::get(opCtx)->make(entry.get(), std::move(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 99f52b5e5ed..efd9c56b4f6 100644
--- a/src/mongo/db/index/2d_access_method.cpp
+++ b/src/mongo/db/index/2d_access_method.cpp
@@ -41,8 +41,9 @@
namespace mongo {
-TwoDAccessMethod::TwoDAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree)
- : AbstractIndexAccessMethod(btreeState, btree) {
+TwoDAccessMethod::TwoDAccessMethod(IndexCatalogEntry* btreeState,
+ std::unique_ptr<SortedDataInterface> btree)
+ : AbstractIndexAccessMethod(btreeState, std::move(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 0d350f99869..9e40c7aa2fc 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, SortedDataInterface* btree);
+ TwoDAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<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 c96fcfc1dc8..51d4ba3acbe 100644
--- a/src/mongo/db/index/btree_access_method.cpp
+++ b/src/mongo/db/index/btree_access_method.cpp
@@ -42,8 +42,9 @@ namespace mongo {
using std::vector;
// Standard Btree implementation below.
-BtreeAccessMethod::BtreeAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree)
- : AbstractIndexAccessMethod(btreeState, btree) {
+BtreeAccessMethod::BtreeAccessMethod(IndexCatalogEntry* btreeState,
+ std::unique_ptr<SortedDataInterface> btree)
+ : AbstractIndexAccessMethod(btreeState, std::move(btree)) {
// The key generation wants these values.
vector<const char*> fieldNames;
vector<BSONElement> fixed;
diff --git a/src/mongo/db/index/btree_access_method.h b/src/mongo/db/index/btree_access_method.h
index 126c1fa86eb..3af203d1f78 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, SortedDataInterface* btree);
+ BtreeAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<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 2912569dfb4..46f20b77b78 100644
--- a/src/mongo/db/index/fts_access_method.cpp
+++ b/src/mongo/db/index/fts_access_method.cpp
@@ -34,8 +34,10 @@
namespace mongo {
-FTSAccessMethod::FTSAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree)
- : AbstractIndexAccessMethod(btreeState, btree), _ftsSpec(btreeState->descriptor()->infoObj()) {}
+FTSAccessMethod::FTSAccessMethod(IndexCatalogEntry* btreeState,
+ std::unique_ptr<SortedDataInterface> btree)
+ : AbstractIndexAccessMethod(btreeState, std::move(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 dbd0a6eb175..f4ec0c14468 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, SortedDataInterface* btree);
+ FTSAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<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 c78a3f1cf9f..3aae1930d40 100644
--- a/src/mongo/db/index/hash_access_method.cpp
+++ b/src/mongo/db/index/hash_access_method.cpp
@@ -36,8 +36,9 @@
namespace mongo {
-HashAccessMethod::HashAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree)
- : AbstractIndexAccessMethod(btreeState, btree) {
+HashAccessMethod::HashAccessMethod(IndexCatalogEntry* btreeState,
+ std::unique_ptr<SortedDataInterface> btree)
+ : AbstractIndexAccessMethod(btreeState, std::move(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 a11403ff784..e96ce878625 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, SortedDataInterface* btree);
+ HashAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<SortedDataInterface> btree);
private:
/**
diff --git a/src/mongo/db/index/haystack_access_method.cpp b/src/mongo/db/index/haystack_access_method.cpp
index bbfa78b1b35..93be4804030 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,
- SortedDataInterface* btree)
- : AbstractIndexAccessMethod(btreeState, btree) {
+ std::unique_ptr<SortedDataInterface> btree)
+ : AbstractIndexAccessMethod(btreeState, std::move(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 99ab21dfde4..6c609e04cde 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, SortedDataInterface* btree);
+ HaystackAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<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 da5fd8cf64a..4fd9a9264bc 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -131,8 +131,10 @@ private:
};
AbstractIndexAccessMethod::AbstractIndexAccessMethod(IndexCatalogEntry* btreeState,
- SortedDataInterface* btree)
- : _btreeState(btreeState), _descriptor(btreeState->descriptor()), _newInterface(btree) {
+ std::unique_ptr<SortedDataInterface> btree)
+ : _btreeState(btreeState),
+ _descriptor(btreeState->descriptor()),
+ _newInterface(std::move(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 91b35a95ddb..39e98a3dfbb 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<IndexAccessMethodFactory> collectionFactory);
- virtual std::unique_ptr<IndexAccessMethod> make(IndexCatalogEntry* entry,
- SortedDataInterface* sortedDataInterface) = 0;
+ virtual std::unique_ptr<IndexAccessMethod> make(
+ IndexCatalogEntry* entry, std::unique_ptr<SortedDataInterface> sortedDataInterface) = 0;
};
/**
@@ -449,7 +449,8 @@ public:
static std::pair<std::vector<BSONObj>, std::vector<BSONObj>> setDifference(
const BSONObjSet& left, const BSONObjSet& right);
- AbstractIndexAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree);
+ AbstractIndexAccessMethod(IndexCatalogEntry* btreeState,
+ std::unique_ptr<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 485bfac25b7..2eb06511d1b 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<IndexAccessMethod> IndexAccessMethodFactoryImpl::make(
- IndexCatalogEntry* entry, SortedDataInterface* sortedDataInterface) {
+ IndexCatalogEntry* entry, std::unique_ptr<SortedDataInterface> sortedDataInterface) {
auto desc = entry->descriptor();
const std::string& type = desc->getAccessMethodName();
if ("" == type)
- return std::make_unique<BtreeAccessMethod>(entry, sortedDataInterface);
+ return std::make_unique<BtreeAccessMethod>(entry, std::move(sortedDataInterface));
else if (IndexNames::HASHED == type)
- return std::make_unique<HashAccessMethod>(entry, sortedDataInterface);
+ return std::make_unique<HashAccessMethod>(entry, std::move(sortedDataInterface));
else if (IndexNames::GEO_2DSPHERE == type)
- return std::make_unique<S2AccessMethod>(entry, sortedDataInterface);
+ return std::make_unique<S2AccessMethod>(entry, std::move(sortedDataInterface));
else if (IndexNames::TEXT == type)
- return std::make_unique<FTSAccessMethod>(entry, sortedDataInterface);
+ return std::make_unique<FTSAccessMethod>(entry, std::move(sortedDataInterface));
else if (IndexNames::GEO_HAYSTACK == type)
- return std::make_unique<HaystackAccessMethod>(entry, sortedDataInterface);
+ return std::make_unique<HaystackAccessMethod>(entry, std::move(sortedDataInterface));
else if (IndexNames::GEO_2D == type)
- return std::make_unique<TwoDAccessMethod>(entry, sortedDataInterface);
+ return std::make_unique<TwoDAccessMethod>(entry, std::move(sortedDataInterface));
else if (IndexNames::WILDCARD == type)
- return std::make_unique<WildcardAccessMethod>(entry, sortedDataInterface);
+ return std::make_unique<WildcardAccessMethod>(entry, std::move(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 7c89e702d0e..dae1a2204ac 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<IndexAccessMethod> make(IndexCatalogEntry* entry,
- SortedDataInterface* SortedDataInterface) final;
+ std::unique_ptr<IndexAccessMethod> make(
+ IndexCatalogEntry* entry, std::unique_ptr<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 731e0a14123..3f9ac46d57e 100644
--- a/src/mongo/db/index/s2_access_method.cpp
+++ b/src/mongo/db/index/s2_access_method.cpp
@@ -47,8 +47,9 @@ namespace mongo {
static const string kIndexVersionFieldName("2dsphereIndexVersion");
-S2AccessMethod::S2AccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree)
- : AbstractIndexAccessMethod(btreeState, btree) {
+S2AccessMethod::S2AccessMethod(IndexCatalogEntry* btreeState,
+ std::unique_ptr<SortedDataInterface> btree)
+ : AbstractIndexAccessMethod(btreeState, std::move(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 164b38c5af5..4851f6fbc7d 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, SortedDataInterface* btree);
+ S2AccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<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 cfa6adc1e46..4269d3dcab2 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,
- SortedDataInterface* btree)
- : AbstractIndexAccessMethod(wildcardState, btree),
+ std::unique_ptr<SortedDataInterface> btree)
+ : AbstractIndexAccessMethod(wildcardState, std::move(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 45d866c1020..7fde78eb256 100644
--- a/src/mongo/db/index/wildcard_access_method.h
+++ b/src/mongo/db/index/wildcard_access_method.h
@@ -56,7 +56,8 @@ public:
*/
static FieldRef extractMultikeyPathFromIndexKey(const IndexKeyEntry& entry);
- WildcardAccessMethod(IndexCatalogEntry* wildcardState, SortedDataInterface* btree);
+ WildcardAccessMethod(IndexCatalogEntry* wildcardState,
+ std::unique_ptr<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 d0c4a4b987a..3aeefdf59c2 100644
--- a/src/mongo/db/storage/biggie/biggie_kv_engine.cpp
+++ b/src/mongo/db/storage/biggie/biggie_kv_engine.cpp
@@ -111,11 +111,10 @@ Status KVEngine::createSortedDataInterface(OperationContext* opCtx,
return Status::OK(); // I don't think we actually need to do anything here
}
-mongo::SortedDataInterface* KVEngine::getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc) {
+std::unique_ptr<mongo::SortedDataInterface> KVEngine::getSortedDataInterface(
+ OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) {
_idents[ident.toString()] = false;
- return new SortedDataInterface(opCtx, ident, desc);
+ return std::make_unique<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 e14a879bef6..e41f334a329 100644
--- a/src/mongo/db/storage/biggie/biggie_kv_engine.h
+++ b/src/mongo/db/storage/biggie/biggie_kv_engine.h
@@ -70,9 +70,8 @@ public:
StringData ident,
const IndexDescriptor* desc);
- virtual mongo::SortedDataInterface* getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc);
+ virtual std::unique_ptr<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 b53c345ceed..6500879bde3 100644
--- a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp
+++ b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp
@@ -256,10 +256,9 @@ std::unique_ptr<RecordStore> DevNullKVEngine::makeTemporaryRecordStore(Operation
return std::make_unique<DevNullRecordStore>("", CollectionOptions());
}
-SortedDataInterface* DevNullKVEngine::getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc) {
- return new DevNullSortedDataInterface();
+std::unique_ptr<SortedDataInterface> DevNullKVEngine::getSortedDataInterface(
+ OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) {
+ return std::make_unique<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 d73f5a97768..33fe29d38f4 100644
--- a/src/mongo/db/storage/devnull/devnull_kv_engine.h
+++ b/src/mongo/db/storage/devnull/devnull_kv_engine.h
@@ -70,9 +70,8 @@ public:
return Status::OK();
}
- virtual SortedDataInterface* getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc);
+ virtual std::unique_ptr<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 d9fa673dba5..c82d629a2af 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,21 +521,22 @@ private:
// IndexCatalogEntry argument taken by non-const pointer for consistency with other Btree
// factories. We don't actually modify it.
-SortedDataInterface* getEphemeralForTestBtreeImpl(const Ordering& ordering,
- bool isUnique,
- const NamespaceString& collectionNamespace,
- const std::string& indexName,
- const BSONObj& keyPattern,
- std::shared_ptr<void>* dataInOut) {
+std::unique_ptr<SortedDataInterface> getEphemeralForTestBtreeImpl(
+ const Ordering& ordering,
+ bool isUnique,
+ const NamespaceString& collectionNamespace,
+ const std::string& indexName,
+ const BSONObj& keyPattern,
+ std::shared_ptr<void>* dataInOut) {
invariant(dataInOut);
if (!*dataInOut) {
*dataInOut = std::make_shared<IndexSet>(IndexEntryComparison(ordering));
}
- return new EphemeralForTestBtreeImpl(static_cast<IndexSet*>(dataInOut->get()),
- isUnique,
- collectionNamespace,
- indexName,
- keyPattern);
+ return std::make_unique<EphemeralForTestBtreeImpl>(static_cast<IndexSet*>(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 2b8b566e711..60431c1cfa7 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,11 +40,12 @@ class IndexCatalogEntry;
* Caller takes ownership.
* All permanent data will be stored and fetch from dataInOut.
*/
-SortedDataInterface* getEphemeralForTestBtreeImpl(const Ordering& ordering,
- bool isUnique,
- const NamespaceString& collectionNamespace,
- const std::string& indexName,
- const BSONObj& keyPattern,
- std::shared_ptr<void>* dataInOut);
+std::unique_ptr<SortedDataInterface> getEphemeralForTestBtreeImpl(
+ const Ordering& ordering,
+ bool isUnique,
+ const NamespaceString& collectionNamespace,
+ const std::string& indexName,
+ const BSONObj& keyPattern,
+ std::shared_ptr<void>* 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 782c425ffd0..0cb25117917 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,9 +92,8 @@ Status EphemeralForTestEngine::createSortedDataInterface(OperationContext* opCtx
return Status::OK();
}
-SortedDataInterface* EphemeralForTestEngine::getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc) {
+std::unique_ptr<SortedDataInterface> EphemeralForTestEngine::getSortedDataInterface(
+ OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) {
stdx::lock_guard<stdx::mutex> 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 008c0084587..a499bba6b67 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,9 +61,8 @@ public:
StringData ident,
const IndexDescriptor* desc);
- virtual SortedDataInterface* getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc);
+ virtual std::unique_ptr<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 e5fad9811a5..064a5ee66e6 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,9 +71,8 @@ public:
const CollectionOptions& options) override {
return {};
}
- SortedDataInterface* getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc) override {
+ std::unique_ptr<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 4f622259075..e6801dab6c7 100644
--- a/src/mongo/db/storage/kv/kv_engine.h
+++ b/src/mongo/db/storage/kv/kv_engine.h
@@ -39,6 +39,7 @@
#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 {
@@ -47,7 +48,6 @@ class IndexDescriptor;
class JournalListener;
class OperationContext;
class RecoveryUnit;
-class SortedDataInterface;
class SnapshotManager;
class KVEngine {
@@ -87,9 +87,8 @@ public:
return getRecordStore(opCtx, ns, ident, options);
}
- virtual SortedDataInterface* getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc) = 0;
+ virtual std::unique_ptr<SortedDataInterface> getSortedDataInterface(
+ OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) = 0;
/**
* Get a SortedDataInterface that may share an underlying table with other
@@ -100,10 +99,8 @@ public:
* between indexes sharing an underlying table. A value of `KVPrefix::kNotPrefixed`
* guarantees the index is the sole resident of the table.
*/
- virtual SortedDataInterface* getGroupedSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc,
- KVPrefix prefix) {
+ virtual std::unique_ptr<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 afd0cbb68b8..22cb8778836 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.reset(engine->getSortedDataInterface(&opCtx, ident, &desc));
+ sorted = 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.reset(engine->getSortedDataInterface(&opCtx, ident, &desc));
+ sorted = 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 3426827ee1e..4c8b2401683 100644
--- a/src/mongo/db/storage/mobile/mobile_kv_engine.cpp
+++ b/src/mongo/db/storage/mobile/mobile_kv_engine.cpp
@@ -235,13 +235,12 @@ Status MobileKVEngine::createSortedDataInterface(OperationContext* opCtx,
return MobileIndex::create(opCtx, ident.toString());
}
-SortedDataInterface* MobileKVEngine::getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc) {
+std::unique_ptr<SortedDataInterface> MobileKVEngine::getSortedDataInterface(
+ OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) {
if (desc->unique()) {
- return new MobileIndexUnique(opCtx, desc, ident.toString());
+ return std::make_unique<MobileIndexUnique>(opCtx, desc, ident.toString());
}
- return new MobileIndexStandard(opCtx, desc, ident.toString());
+ return std::make_unique<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 a2e6f7702f1..10da2d2e1a0 100644
--- a/src/mongo/db/storage/mobile/mobile_kv_engine.h
+++ b/src/mongo/db/storage/mobile/mobile_kv_engine.h
@@ -68,9 +68,8 @@ public:
StringData ident,
const IndexDescriptor* desc) override;
- SortedDataInterface* getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc) override;
+ std::unique_ptr<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 7e8aa78c7d1..9971b1e387d 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -1281,15 +1281,13 @@ Status WiredTigerKVEngine::createGroupedSortedDataInterface(OperationContext* op
return wtRCToStatus(WiredTigerIndex::Create(opCtx, _uri(ident), config));
}
-SortedDataInterface* WiredTigerKVEngine::getGroupedSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc,
- KVPrefix prefix) {
+std::unique_ptr<SortedDataInterface> WiredTigerKVEngine::getGroupedSortedDataInterface(
+ OperationContext* opCtx, StringData ident, const IndexDescriptor* desc, KVPrefix prefix) {
if (desc->unique()) {
- return new WiredTigerIndexUnique(opCtx, _uri(ident), desc, prefix, _readOnly);
+ return std::make_unique<WiredTigerIndexUnique>(opCtx, _uri(ident), desc, prefix, _readOnly);
}
- return new WiredTigerIndexStandard(opCtx, _uri(ident), desc, prefix, _readOnly);
+ return std::make_unique<WiredTigerIndexStandard>(opCtx, _uri(ident), desc, prefix, _readOnly);
}
std::unique_ptr<RecordStore> 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 1ad5243f710..bf194231e61 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h
@@ -123,9 +123,8 @@ public:
return createGroupedSortedDataInterface(opCtx, ident, desc, KVPrefix::kNotPrefixed);
}
- SortedDataInterface* getSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc) override {
+ std::unique_ptr<SortedDataInterface> getSortedDataInterface(
+ OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) override {
return getGroupedSortedDataInterface(opCtx, ident, desc, KVPrefix::kNotPrefixed);
}
@@ -146,10 +145,10 @@ public:
const IndexDescriptor* desc,
KVPrefix prefix) override;
- SortedDataInterface* getGroupedSortedDataInterface(OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc,
- KVPrefix prefix) override;
+ std::unique_ptr<SortedDataInterface> getGroupedSortedDataInterface(OperationContext* opCtx,
+ StringData ident,
+ const IndexDescriptor* desc,
+ KVPrefix prefix) override;
Status dropIdent(OperationContext* opCtx, StringData ident) override;