summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <redbeard0531@gmail.com>2022-02-03 16:53:32 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-03 17:45:43 +0000
commit5c269981850650efe95735846fa4b2676a22376f (patch)
treed68e8f8b0f79e684ad73d82d8008e65070a9ec3e
parent038b3ab5b4cc32da116097a256e25105046e1836 (diff)
downloadmongo-5c269981850650efe95735846fa4b2676a22376f.tar.gz
SERVER-63251 Rename AbstractIndexAccessMethod to SortedDataIndexAccessMethod
This is the first step in the refactoring process. All subclasses of AbstractIndexAccessMethod currently use SortedDataInterface as their storage, and most of AbstractIAM deals with the common code for working with SortedData. This rename codifies that relationship. Later commits in the refactor will move all SortedData specific functionality down from IAM to SortedDataIAM, to make room for indexes with other types of storage.
-rw-r--r--src/mongo/db/index/2d_access_method.cpp2
-rw-r--r--src/mongo/db/index/2d_access_method.h2
-rw-r--r--src/mongo/db/index/btree_access_method.cpp2
-rw-r--r--src/mongo/db/index/btree_access_method.h2
-rw-r--r--src/mongo/db/index/fts_access_method.cpp2
-rw-r--r--src/mongo/db/index/fts_access_method.h2
-rw-r--r--src/mongo/db/index/hash_access_method.cpp2
-rw-r--r--src/mongo/db/index/hash_access_method.h2
-rw-r--r--src/mongo/db/index/index_access_method.cpp221
-rw-r--r--src/mongo/db/index/index_access_method.h10
-rw-r--r--src/mongo/db/index/s2_access_method.cpp2
-rw-r--r--src/mongo/db/index/s2_access_method.h2
-rw-r--r--src/mongo/db/index/s2_bucket_access_method.cpp2
-rw-r--r--src/mongo/db/index/s2_bucket_access_method.h2
-rw-r--r--src/mongo/db/index/wildcard_access_method.cpp2
-rw-r--r--src/mongo/db/index/wildcard_access_method.h2
-rw-r--r--src/mongo/dbtests/index_access_method_test.cpp22
17 files changed, 141 insertions, 140 deletions
diff --git a/src/mongo/db/index/2d_access_method.cpp b/src/mongo/db/index/2d_access_method.cpp
index 75dd52ad3de..d81a9f6ea30 100644
--- a/src/mongo/db/index/2d_access_method.cpp
+++ b/src/mongo/db/index/2d_access_method.cpp
@@ -43,7 +43,7 @@ namespace mongo {
TwoDAccessMethod::TwoDAccessMethod(IndexCatalogEntry* btreeState,
std::unique_ptr<SortedDataInterface> btree)
- : AbstractIndexAccessMethod(btreeState, std::move(btree)) {
+ : SortedDataIndexAccessMethod(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 7e4fc8ec003..e9621fcc7a2 100644
--- a/src/mongo/db/index/2d_access_method.h
+++ b/src/mongo/db/index/2d_access_method.h
@@ -40,7 +40,7 @@ class IndexCatalogEntry;
class IndexDescriptor;
struct TwoDIndexingParams;
-class TwoDAccessMethod : public AbstractIndexAccessMethod {
+class TwoDAccessMethod : public SortedDataIndexAccessMethod {
public:
TwoDAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<SortedDataInterface> btree);
diff --git a/src/mongo/db/index/btree_access_method.cpp b/src/mongo/db/index/btree_access_method.cpp
index df3500ceb8f..149596739d8 100644
--- a/src/mongo/db/index/btree_access_method.cpp
+++ b/src/mongo/db/index/btree_access_method.cpp
@@ -45,7 +45,7 @@ using std::vector;
// Standard Btree implementation below.
BtreeAccessMethod::BtreeAccessMethod(IndexCatalogEntry* btreeState,
std::unique_ptr<SortedDataInterface> btree)
- : AbstractIndexAccessMethod(btreeState, std::move(btree)) {
+ : SortedDataIndexAccessMethod(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 0df1032591c..8f0e6304d20 100644
--- a/src/mongo/db/index/btree_access_method.h
+++ b/src/mongo/db/index/btree_access_method.h
@@ -43,7 +43,7 @@ class IndexDescriptor;
* The IndexAccessMethod for a Btree index.
* Any index created with {field: 1} or {field: -1} uses this.
*/
-class BtreeAccessMethod : public AbstractIndexAccessMethod {
+class BtreeAccessMethod : public SortedDataIndexAccessMethod {
public:
BtreeAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<SortedDataInterface> btree);
diff --git a/src/mongo/db/index/fts_access_method.cpp b/src/mongo/db/index/fts_access_method.cpp
index 7f688fd2854..4fbda54dae9 100644
--- a/src/mongo/db/index/fts_access_method.cpp
+++ b/src/mongo/db/index/fts_access_method.cpp
@@ -36,7 +36,7 @@ namespace mongo {
FTSAccessMethod::FTSAccessMethod(IndexCatalogEntry* btreeState,
std::unique_ptr<SortedDataInterface> btree)
- : AbstractIndexAccessMethod(btreeState, std::move(btree)),
+ : SortedDataIndexAccessMethod(btreeState, std::move(btree)),
_ftsSpec(btreeState->descriptor()->infoObj()) {}
void FTSAccessMethod::doGetKeys(OperationContext* opCtx,
diff --git a/src/mongo/db/index/fts_access_method.h b/src/mongo/db/index/fts_access_method.h
index 35b3a8937f4..a1343553916 100644
--- a/src/mongo/db/index/fts_access_method.h
+++ b/src/mongo/db/index/fts_access_method.h
@@ -37,7 +37,7 @@
namespace mongo {
-class FTSAccessMethod : public AbstractIndexAccessMethod {
+class FTSAccessMethod : public SortedDataIndexAccessMethod {
public:
FTSAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<SortedDataInterface> btree);
diff --git a/src/mongo/db/index/hash_access_method.cpp b/src/mongo/db/index/hash_access_method.cpp
index 681fcebb18f..ec7b05b3665 100644
--- a/src/mongo/db/index/hash_access_method.cpp
+++ b/src/mongo/db/index/hash_access_method.cpp
@@ -38,7 +38,7 @@ namespace mongo {
HashAccessMethod::HashAccessMethod(IndexCatalogEntry* btreeState,
std::unique_ptr<SortedDataInterface> btree)
- : AbstractIndexAccessMethod(btreeState, std::move(btree)) {
+ : SortedDataIndexAccessMethod(btreeState, std::move(btree)) {
const IndexDescriptor* descriptor = btreeState->descriptor();
uassert(16764,
diff --git a/src/mongo/db/index/hash_access_method.h b/src/mongo/db/index/hash_access_method.h
index 2384f180537..851c841dbe2 100644
--- a/src/mongo/db/index/hash_access_method.h
+++ b/src/mongo/db/index/hash_access_method.h
@@ -44,7 +44,7 @@ class CollatorInterface;
/**
* This is the access method for "hashed" indices.
*/
-class HashAccessMethod : public AbstractIndexAccessMethod {
+class HashAccessMethod : public SortedDataIndexAccessMethod {
public:
HashAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<SortedDataInterface> btree);
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index a9ac15e953a..b75d6711ae9 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -110,8 +110,8 @@ struct BtreeExternalSortComparison {
}
};
-AbstractIndexAccessMethod::AbstractIndexAccessMethod(const IndexCatalogEntry* btreeState,
- std::unique_ptr<SortedDataInterface> btree)
+SortedDataIndexAccessMethod::SortedDataIndexAccessMethod(const IndexCatalogEntry* btreeState,
+ std::unique_ptr<SortedDataInterface> btree)
: _indexCatalogEntry(btreeState),
_descriptor(btreeState->descriptor()),
_newInterface(std::move(btree)) {
@@ -119,14 +119,14 @@ AbstractIndexAccessMethod::AbstractIndexAccessMethod(const IndexCatalogEntry* bt
}
// Find the keys for obj, put them in the tree pointing to loc.
-Status AbstractIndexAccessMethod::insert(OperationContext* opCtx,
- SharedBufferFragmentBuilder& pooledBufferBuilder,
- const CollectionPtr& coll,
- const BSONObj& obj,
- const RecordId& loc,
- const InsertDeleteOptions& options,
- KeyHandlerFn&& onDuplicateKey,
- int64_t* numInserted) {
+Status SortedDataIndexAccessMethod::insert(OperationContext* opCtx,
+ SharedBufferFragmentBuilder& pooledBufferBuilder,
+ const CollectionPtr& coll,
+ const BSONObj& obj,
+ const RecordId& loc,
+ const InsertDeleteOptions& options,
+ KeyHandlerFn&& onDuplicateKey,
+ int64_t* numInserted) {
invariant(options.fromIndexBuilder || !_indexCatalogEntry->isHybridBuilding());
auto& executionCtx = StorageExecutionContext::get(opCtx);
@@ -157,7 +157,7 @@ Status AbstractIndexAccessMethod::insert(OperationContext* opCtx,
numInserted);
}
-Status AbstractIndexAccessMethod::insertKeysAndUpdateMultikeyPaths(
+Status SortedDataIndexAccessMethod::insertKeysAndUpdateMultikeyPaths(
OperationContext* opCtx,
const CollectionPtr& coll,
const KeyStringSet& keys,
@@ -185,13 +185,13 @@ Status AbstractIndexAccessMethod::insertKeysAndUpdateMultikeyPaths(
return Status::OK();
}
-Status AbstractIndexAccessMethod::insertKeys(OperationContext* opCtx,
- const CollectionPtr& coll,
- const KeyStringSet& keys,
- const RecordId& loc,
- const InsertDeleteOptions& options,
- KeyHandlerFn&& onDuplicateKey,
- int64_t* numInserted) {
+Status SortedDataIndexAccessMethod::insertKeys(OperationContext* opCtx,
+ const CollectionPtr& coll,
+ const KeyStringSet& keys,
+ const RecordId& loc,
+ const InsertDeleteOptions& options,
+ KeyHandlerFn&& onDuplicateKey,
+ int64_t* numInserted) {
// Initialize the 'numInserted' out-parameter to zero in case the caller did not already do so.
if (numInserted) {
*numInserted = 0;
@@ -248,10 +248,10 @@ Status AbstractIndexAccessMethod::insertKeys(OperationContext* opCtx,
return Status::OK();
}
-void AbstractIndexAccessMethod::removeOneKey(OperationContext* opCtx,
- const KeyString::Value& keyString,
- const RecordId& loc,
- bool dupsAllowed) {
+void SortedDataIndexAccessMethod::removeOneKey(OperationContext* opCtx,
+ const KeyString::Value& keyString,
+ const RecordId& loc,
+ bool dupsAllowed) {
try {
_newInterface->unindex(opCtx, keyString, dupsAllowed);
@@ -270,21 +270,21 @@ void AbstractIndexAccessMethod::removeOneKey(OperationContext* opCtx,
}
}
-std::unique_ptr<SortedDataInterface::Cursor> AbstractIndexAccessMethod::newCursor(
+std::unique_ptr<SortedDataInterface::Cursor> SortedDataIndexAccessMethod::newCursor(
OperationContext* opCtx, bool isForward) const {
return _newInterface->newCursor(opCtx, isForward);
}
-std::unique_ptr<SortedDataInterface::Cursor> AbstractIndexAccessMethod::newCursor(
+std::unique_ptr<SortedDataInterface::Cursor> SortedDataIndexAccessMethod::newCursor(
OperationContext* opCtx) const {
return newCursor(opCtx, true);
}
-Status AbstractIndexAccessMethod::removeKeys(OperationContext* opCtx,
- const KeyStringSet& keys,
- const RecordId& loc,
- const InsertDeleteOptions& options,
- int64_t* numDeleted) {
+Status SortedDataIndexAccessMethod::removeKeys(OperationContext* opCtx,
+ const KeyStringSet& keys,
+ const RecordId& loc,
+ const InsertDeleteOptions& options,
+ int64_t* numDeleted) {
for (const auto& key : keys) {
removeOneKey(opCtx, key, loc, options.dupsAllowed);
@@ -294,13 +294,13 @@ Status AbstractIndexAccessMethod::removeKeys(OperationContext* opCtx,
return Status::OK();
}
-Status AbstractIndexAccessMethod::initializeAsEmpty(OperationContext* opCtx) {
+Status SortedDataIndexAccessMethod::initializeAsEmpty(OperationContext* opCtx) {
return _newInterface->initAsEmpty(opCtx);
}
-RecordId AbstractIndexAccessMethod::findSingle(OperationContext* opCtx,
- const CollectionPtr& collection,
- const BSONObj& requestedKey) const {
+RecordId SortedDataIndexAccessMethod::findSingle(OperationContext* opCtx,
+ const CollectionPtr& collection,
+ const BSONObj& requestedKey) const {
// Generate the key for this index.
KeyString::Value actualKey = [&]() {
if (_indexCatalogEntry->getCollator()) {
@@ -341,29 +341,29 @@ RecordId AbstractIndexAccessMethod::findSingle(OperationContext* opCtx,
return RecordId();
}
-void AbstractIndexAccessMethod::validate(OperationContext* opCtx,
- int64_t* numKeys,
- IndexValidateResults* fullResults) const {
+void SortedDataIndexAccessMethod::validate(OperationContext* opCtx,
+ int64_t* numKeys,
+ IndexValidateResults* fullResults) const {
long long keys = 0;
_newInterface->fullValidate(opCtx, &keys, fullResults);
*numKeys = keys;
}
-bool AbstractIndexAccessMethod::appendCustomStats(OperationContext* opCtx,
- BSONObjBuilder* output,
- double scale) const {
+bool SortedDataIndexAccessMethod::appendCustomStats(OperationContext* opCtx,
+ BSONObjBuilder* output,
+ double scale) const {
return _newInterface->appendCustomStats(opCtx, output, scale);
}
-long long AbstractIndexAccessMethod::getSpaceUsedBytes(OperationContext* opCtx) const {
+long long SortedDataIndexAccessMethod::getSpaceUsedBytes(OperationContext* opCtx) const {
return _newInterface->getSpaceUsedBytes(opCtx);
}
-long long AbstractIndexAccessMethod::getFreeStorageBytes(OperationContext* opCtx) const {
+long long SortedDataIndexAccessMethod::getFreeStorageBytes(OperationContext* opCtx) const {
return _newInterface->getFreeStorageBytes(opCtx);
}
-pair<KeyStringSet, KeyStringSet> AbstractIndexAccessMethod::setDifference(
+pair<KeyStringSet, KeyStringSet> SortedDataIndexAccessMethod::setDifference(
const KeyStringSet& left, const KeyStringSet& right) {
// Two iterators to traverse the two sets in sorted order.
auto leftIt = left.begin();
@@ -402,14 +402,14 @@ pair<KeyStringSet, KeyStringSet> AbstractIndexAccessMethod::setDifference(
return {{std::move(outLeft)}, {std::move(outRight)}};
}
-void AbstractIndexAccessMethod::prepareUpdate(OperationContext* opCtx,
- const CollectionPtr& collection,
- const IndexCatalogEntry* index,
- const BSONObj& from,
- const BSONObj& to,
- const RecordId& record,
- const InsertDeleteOptions& options,
- UpdateTicket* ticket) const {
+void SortedDataIndexAccessMethod::prepareUpdate(OperationContext* opCtx,
+ const CollectionPtr& collection,
+ const IndexCatalogEntry* index,
+ const BSONObj& from,
+ const BSONObj& to,
+ const RecordId& record,
+ const InsertDeleteOptions& options,
+ UpdateTicket* ticket) const {
SharedBufferFragmentBuilder pooledBuilder(KeyString::HeapBuilder::kHeapAllocatorDefaultBytes);
const MatchExpression* indexFilter = index->getFilterExpression();
if (!indexFilter || indexFilter->matchesBSON(from)) {
@@ -455,11 +455,11 @@ void AbstractIndexAccessMethod::prepareUpdate(OperationContext* opCtx,
ticket->_isValid = true;
}
-Status AbstractIndexAccessMethod::update(OperationContext* opCtx,
- const CollectionPtr& coll,
- const UpdateTicket& ticket,
- int64_t* numInserted,
- int64_t* numDeleted) {
+Status SortedDataIndexAccessMethod::update(OperationContext* opCtx,
+ const CollectionPtr& coll,
+ const UpdateTicket& ticket,
+ int64_t* numInserted,
+ int64_t* numDeleted) {
invariant(!_indexCatalogEntry->isHybridBuilding());
invariant(ticket.newKeys.size() ==
ticket.oldKeys.size() + ticket.added.size() - ticket.removed.size());
@@ -500,11 +500,11 @@ Status AbstractIndexAccessMethod::update(OperationContext* opCtx,
return Status::OK();
}
-Status AbstractIndexAccessMethod::compact(OperationContext* opCtx) {
+Status SortedDataIndexAccessMethod::compact(OperationContext* opCtx) {
return this->_newInterface->compact(opCtx);
}
-class AbstractIndexAccessMethod::BulkBuilderImpl : public IndexAccessMethod::BulkBuilder {
+class SortedDataIndexAccessMethod::BulkBuilderImpl : public IndexAccessMethod::BulkBuilder {
public:
BulkBuilderImpl(const IndexCatalogEntry* indexCatalogEntry,
size_t maxMemoryUsageBytes,
@@ -566,7 +566,7 @@ private:
KeyStringSet _multikeyMetadataKeys;
};
-std::unique_ptr<IndexAccessMethod::BulkBuilder> AbstractIndexAccessMethod::initiateBulk(
+std::unique_ptr<IndexAccessMethod::BulkBuilder> SortedDataIndexAccessMethod::initiateBulk(
size_t maxMemoryUsageBytes,
const boost::optional<IndexStateInfo>& stateInfo,
StringData dbName) {
@@ -576,15 +576,15 @@ std::unique_ptr<IndexAccessMethod::BulkBuilder> AbstractIndexAccessMethod::initi
: std::make_unique<BulkBuilderImpl>(_indexCatalogEntry, maxMemoryUsageBytes, dbName);
}
-AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(const IndexCatalogEntry* index,
- size_t maxMemoryUsageBytes,
- StringData dbName)
+SortedDataIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(const IndexCatalogEntry* index,
+ size_t maxMemoryUsageBytes,
+ StringData dbName)
: _indexCatalogEntry(index), _sorter(_makeSorter(maxMemoryUsageBytes, dbName)) {}
-AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(const IndexCatalogEntry* index,
- size_t maxMemoryUsageBytes,
- const IndexStateInfo& stateInfo,
- StringData dbName)
+SortedDataIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(const IndexCatalogEntry* index,
+ size_t maxMemoryUsageBytes,
+ const IndexStateInfo& stateInfo,
+ StringData dbName)
: _indexCatalogEntry(index),
_sorter(
_makeSorter(maxMemoryUsageBytes, dbName, stateInfo.getFileName(), stateInfo.getRanges())),
@@ -592,7 +592,7 @@ AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(const IndexCatalogEn
_isMultiKey(stateInfo.getIsMultikey()),
_indexMultikeyPaths(createMultikeyPaths(stateInfo.getMultikeyPaths())) {}
-Status AbstractIndexAccessMethod::BulkBuilderImpl::insert(
+Status SortedDataIndexAccessMethod::BulkBuilderImpl::insert(
OperationContext* opCtx,
const CollectionPtr& collection,
SharedBufferFragmentBuilder& pooledBuilder,
@@ -667,31 +667,31 @@ Status AbstractIndexAccessMethod::BulkBuilderImpl::insert(
return Status::OK();
}
-const MultikeyPaths& AbstractIndexAccessMethod::BulkBuilderImpl::getMultikeyPaths() const {
+const MultikeyPaths& SortedDataIndexAccessMethod::BulkBuilderImpl::getMultikeyPaths() const {
return _indexMultikeyPaths;
}
-bool AbstractIndexAccessMethod::BulkBuilderImpl::isMultikey() const {
+bool SortedDataIndexAccessMethod::BulkBuilderImpl::isMultikey() const {
return _isMultiKey;
}
IndexAccessMethod::BulkBuilder::Sorter::Iterator*
-AbstractIndexAccessMethod::BulkBuilderImpl::done() {
+SortedDataIndexAccessMethod::BulkBuilderImpl::done() {
_insertMultikeyMetadataKeysIntoSorter();
return _sorter->done();
}
-int64_t AbstractIndexAccessMethod::BulkBuilderImpl::getKeysInserted() const {
+int64_t SortedDataIndexAccessMethod::BulkBuilderImpl::getKeysInserted() const {
return _keysInserted;
}
-AbstractIndexAccessMethod::BulkBuilder::Sorter::PersistedState
-AbstractIndexAccessMethod::BulkBuilderImpl::persistDataForShutdown() {
+SortedDataIndexAccessMethod::BulkBuilder::Sorter::PersistedState
+SortedDataIndexAccessMethod::BulkBuilderImpl::persistDataForShutdown() {
_insertMultikeyMetadataKeysIntoSorter();
return _sorter->persistDataForShutdown();
}
-void AbstractIndexAccessMethod::BulkBuilderImpl::_insertMultikeyMetadataKeysIntoSorter() {
+void SortedDataIndexAccessMethod::BulkBuilderImpl::_insertMultikeyMetadataKeysIntoSorter() {
for (const auto& keyString : _multikeyMetadataKeys) {
_sorter->add(keyString, mongo::NullValue());
++_keysInserted;
@@ -702,15 +702,15 @@ void AbstractIndexAccessMethod::BulkBuilderImpl::_insertMultikeyMetadataKeysInto
_multikeyMetadataKeys.clear();
}
-AbstractIndexAccessMethod::BulkBuilderImpl::Sorter::Settings
-AbstractIndexAccessMethod::BulkBuilderImpl::_makeSorterSettings() const {
+SortedDataIndexAccessMethod::BulkBuilderImpl::Sorter::Settings
+SortedDataIndexAccessMethod::BulkBuilderImpl::_makeSorterSettings() const {
return std::pair<KeyString::Value::SorterDeserializeSettings,
mongo::NullValue::SorterDeserializeSettings>(
{_indexCatalogEntry->accessMethod()->getSortedDataInterface()->getKeyStringVersion()}, {});
}
-AbstractIndexAccessMethod::BulkBuilderImpl::Sorter*
-AbstractIndexAccessMethod::BulkBuilderImpl::_makeSorter(
+SortedDataIndexAccessMethod::BulkBuilderImpl::Sorter*
+SortedDataIndexAccessMethod::BulkBuilderImpl::_makeSorter(
size_t maxMemoryUsageBytes,
StringData dbName,
boost::optional<StringData> fileName,
@@ -725,9 +725,9 @@ AbstractIndexAccessMethod::BulkBuilderImpl::_makeSorter(
_makeSorterSettings());
}
-void AbstractIndexAccessMethod::_yieldBulkLoad(OperationContext* opCtx,
- const Yieldable* yieldable,
- const NamespaceString& ns) const {
+void SortedDataIndexAccessMethod::_yieldBulkLoad(OperationContext* opCtx,
+ const Yieldable* yieldable,
+ const NamespaceString& ns) const {
// Releasing locks means a new snapshot should be acquired when restored.
opCtx->recoveryUnit()->abandonSnapshot();
yieldable->yield();
@@ -757,13 +757,13 @@ void AbstractIndexAccessMethod::_yieldBulkLoad(OperationContext* opCtx,
yieldable->restore();
}
-Status AbstractIndexAccessMethod::commitBulk(OperationContext* opCtx,
- const CollectionPtr& collection,
- BulkBuilder* bulk,
- bool dupsAllowed,
- int32_t yieldIterations,
- const KeyHandlerFn& onDuplicateKeyInserted,
- const RecordIdHandlerFn& onDuplicateRecord) {
+Status SortedDataIndexAccessMethod::commitBulk(OperationContext* opCtx,
+ const CollectionPtr& collection,
+ BulkBuilder* bulk,
+ bool dupsAllowed,
+ int32_t yieldIterations,
+ const KeyHandlerFn& onDuplicateKeyInserted,
+ const RecordIdHandlerFn& onDuplicateRecord) {
Timer timer;
auto ns = _indexCatalogEntry->getNSSFromCatalog(opCtx);
@@ -886,24 +886,24 @@ Status AbstractIndexAccessMethod::commitBulk(OperationContext* opCtx,
return Status::OK();
}
-void AbstractIndexAccessMethod::setIndexIsMultikey(OperationContext* opCtx,
- const CollectionPtr& collection,
- KeyStringSet multikeyMetadataKeys,
- MultikeyPaths paths) {
+void SortedDataIndexAccessMethod::setIndexIsMultikey(OperationContext* opCtx,
+ const CollectionPtr& collection,
+ KeyStringSet multikeyMetadataKeys,
+ MultikeyPaths paths) {
_indexCatalogEntry->setMultikey(opCtx, collection, multikeyMetadataKeys, paths);
}
-void AbstractIndexAccessMethod::getKeys(OperationContext* opCtx,
- const CollectionPtr& collection,
- SharedBufferFragmentBuilder& pooledBufferBuilder,
- const BSONObj& obj,
- GetKeysMode mode,
- GetKeysContext context,
- KeyStringSet* keys,
- KeyStringSet* multikeyMetadataKeys,
- MultikeyPaths* multikeyPaths,
- boost::optional<RecordId> id,
- OnSuppressedErrorFn&& onSuppressedError) const {
+void SortedDataIndexAccessMethod::getKeys(OperationContext* opCtx,
+ const CollectionPtr& collection,
+ SharedBufferFragmentBuilder& pooledBufferBuilder,
+ const BSONObj& obj,
+ GetKeysMode mode,
+ GetKeysContext context,
+ KeyStringSet* keys,
+ KeyStringSet* multikeyMetadataKeys,
+ MultikeyPaths* multikeyPaths,
+ boost::optional<RecordId> id,
+ OnSuppressedErrorFn&& onSuppressedError) const {
invariant(!id || _newInterface->rsKeyFormat() != KeyFormat::String || id->isStr(),
fmt::format("RecordId is not in the same string format as its RecordStore; id: {}",
id->toString()));
@@ -958,18 +958,18 @@ void AbstractIndexAccessMethod::getKeys(OperationContext* opCtx,
}
}
-bool AbstractIndexAccessMethod::shouldMarkIndexAsMultikey(
+bool SortedDataIndexAccessMethod::shouldMarkIndexAsMultikey(
size_t numberOfKeys,
const KeyStringSet& multikeyMetadataKeys,
const MultikeyPaths& multikeyPaths) const {
return numberOfKeys > 1 || isMultikeyFromPaths(multikeyPaths);
}
-void AbstractIndexAccessMethod::validateDocument(const CollectionPtr& collection,
- const BSONObj& obj,
- const BSONObj& keyPattern) const {}
+void SortedDataIndexAccessMethod::validateDocument(const CollectionPtr& collection,
+ const BSONObj& obj,
+ const BSONObj& keyPattern) const {}
-SortedDataInterface* AbstractIndexAccessMethod::getSortedDataInterface() const {
+SortedDataInterface* SortedDataIndexAccessMethod::getSortedDataInterface() const {
return _newInterface.get();
}
@@ -990,9 +990,10 @@ std::string nextFileName() {
<< randomSuffix;
}
-Status AbstractIndexAccessMethod::_handleDuplicateKey(OperationContext* opCtx,
- const KeyString::Value& dataKey,
- const RecordIdHandlerFn& onDuplicateRecord) {
+Status SortedDataIndexAccessMethod::_handleDuplicateKey(
+ OperationContext* opCtx,
+ const KeyString::Value& dataKey,
+ const RecordIdHandlerFn& onDuplicateRecord) {
RecordId recordId = (KeyFormat::Long == _newInterface->rsKeyFormat())
? KeyString::decodeRecordIdLongAtEnd(dataKey.getBuffer(), dataKey.getSize())
: KeyString::decodeRecordIdStrAtEnd(dataKey.getBuffer(), dataKey.getSize());
diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h
index 30d5c9131fc..f9988b7d191 100644
--- a/src/mongo/db/index/index_access_method.h
+++ b/src/mongo/db/index/index_access_method.h
@@ -476,9 +476,9 @@ struct InsertDeleteOptions {
* for the initialization and core functionality of this abstract class. To avoid any circular
* dependencies, it is important that IndexAccessMethod remain an interface.
*/
-class AbstractIndexAccessMethod : public IndexAccessMethod {
- AbstractIndexAccessMethod(const AbstractIndexAccessMethod&) = delete;
- AbstractIndexAccessMethod& operator=(const AbstractIndexAccessMethod&) = delete;
+class SortedDataIndexAccessMethod : public IndexAccessMethod {
+ SortedDataIndexAccessMethod(const SortedDataIndexAccessMethod&) = delete;
+ SortedDataIndexAccessMethod& operator=(const SortedDataIndexAccessMethod&) = delete;
public:
/**
@@ -492,8 +492,8 @@ public:
static std::pair<KeyStringSet, KeyStringSet> setDifference(const KeyStringSet& left,
const KeyStringSet& right);
- AbstractIndexAccessMethod(const IndexCatalogEntry* btreeState,
- std::unique_ptr<SortedDataInterface> btree);
+ SortedDataIndexAccessMethod(const IndexCatalogEntry* btreeState,
+ std::unique_ptr<SortedDataInterface> btree);
Status insert(OperationContext* opCtx,
SharedBufferFragmentBuilder& pooledBufferBuilder,
diff --git a/src/mongo/db/index/s2_access_method.cpp b/src/mongo/db/index/s2_access_method.cpp
index b1c0fdcbe2a..0bced692f3c 100644
--- a/src/mongo/db/index/s2_access_method.cpp
+++ b/src/mongo/db/index/s2_access_method.cpp
@@ -49,7 +49,7 @@ static const string kIndexVersionFieldName("2dsphereIndexVersion");
S2AccessMethod::S2AccessMethod(IndexCatalogEntry* btreeState,
std::unique_ptr<SortedDataInterface> btree)
- : AbstractIndexAccessMethod(btreeState, std::move(btree)) {
+ : SortedDataIndexAccessMethod(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 7f4f595e5d8..c25a8b47ce1 100644
--- a/src/mongo/db/index/s2_access_method.h
+++ b/src/mongo/db/index/s2_access_method.h
@@ -38,7 +38,7 @@
namespace mongo {
-class S2AccessMethod : public AbstractIndexAccessMethod {
+class S2AccessMethod : public SortedDataIndexAccessMethod {
public:
S2AccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<SortedDataInterface> btree);
diff --git a/src/mongo/db/index/s2_bucket_access_method.cpp b/src/mongo/db/index/s2_bucket_access_method.cpp
index 13fafad331d..f838ad2a5e8 100644
--- a/src/mongo/db/index/s2_bucket_access_method.cpp
+++ b/src/mongo/db/index/s2_bucket_access_method.cpp
@@ -49,7 +49,7 @@ static const string kIndexVersionFieldName("2dsphereIndexVersion");
S2BucketAccessMethod::S2BucketAccessMethod(IndexCatalogEntry* btreeState,
std::unique_ptr<SortedDataInterface> btree)
- : AbstractIndexAccessMethod(btreeState, std::move(btree)) {
+ : SortedDataIndexAccessMethod(btreeState, std::move(btree)) {
const IndexDescriptor* descriptor = btreeState->descriptor();
ExpressionParams::initialize2dsphereParams(
diff --git a/src/mongo/db/index/s2_bucket_access_method.h b/src/mongo/db/index/s2_bucket_access_method.h
index b2214269cff..8996bfe78a5 100644
--- a/src/mongo/db/index/s2_bucket_access_method.h
+++ b/src/mongo/db/index/s2_bucket_access_method.h
@@ -38,7 +38,7 @@
namespace mongo {
-class S2BucketAccessMethod : public AbstractIndexAccessMethod {
+class S2BucketAccessMethod : public SortedDataIndexAccessMethod {
public:
S2BucketAccessMethod(IndexCatalogEntry* btreeState, std::unique_ptr<SortedDataInterface> btree);
diff --git a/src/mongo/db/index/wildcard_access_method.cpp b/src/mongo/db/index/wildcard_access_method.cpp
index 4bbd36149e2..4ea3cfc261c 100644
--- a/src/mongo/db/index/wildcard_access_method.cpp
+++ b/src/mongo/db/index/wildcard_access_method.cpp
@@ -39,7 +39,7 @@ namespace mongo {
WildcardAccessMethod::WildcardAccessMethod(IndexCatalogEntry* wildcardState,
std::unique_ptr<SortedDataInterface> btree)
- : AbstractIndexAccessMethod(wildcardState, std::move(btree)),
+ : SortedDataIndexAccessMethod(wildcardState, std::move(btree)),
_keyGen(_descriptor->keyPattern(),
_descriptor->pathProjection(),
_indexCatalogEntry->getCollator(),
diff --git a/src/mongo/db/index/wildcard_access_method.h b/src/mongo/db/index/wildcard_access_method.h
index bdc02f8dc9b..a82e7e616c2 100644
--- a/src/mongo/db/index/wildcard_access_method.h
+++ b/src/mongo/db/index/wildcard_access_method.h
@@ -43,7 +43,7 @@ namespace mongo {
* $** indexes store a special metadata key for each path in the index that is multikey. This class
* provides an interface to access the multikey metadata: see getMultikeyPaths().
*/
-class WildcardAccessMethod final : public AbstractIndexAccessMethod {
+class WildcardAccessMethod final : public SortedDataIndexAccessMethod {
public:
WildcardAccessMethod(IndexCatalogEntry* wildcardState,
std::unique_ptr<SortedDataInterface> btree);
diff --git a/src/mongo/dbtests/index_access_method_test.cpp b/src/mongo/dbtests/index_access_method_test.cpp
index 7b849051399..04015b6787a 100644
--- a/src/mongo/dbtests/index_access_method_test.cpp
+++ b/src/mongo/dbtests/index_access_method_test.cpp
@@ -55,7 +55,7 @@ KeyStringSet makeKeyStringSet(std::initializer_list<BSONObj> objs) {
TEST(IndexAccessMethodSetDifference, EmptyInputsShouldHaveNoDifference) {
KeyStringSet left;
KeyStringSet right;
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQ(0UL, diff.first.size());
ASSERT_EQ(0UL, diff.second.size());
}
@@ -64,7 +64,7 @@ TEST(IndexAccessMethodSetDifference, EmptyLeftShouldHaveNoDifference) {
KeyStringSet left;
auto right = makeKeyStringSet({BSON("" << 0)});
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQ(0UL, diff.first.size());
ASSERT_EQ(1UL, diff.second.size());
}
@@ -73,7 +73,7 @@ TEST(IndexAccessMethodSetDifference, EmptyRightShouldReturnAllOfLeft) {
auto left = makeKeyStringSet({BSON("" << 0), BSON("" << 1)});
KeyStringSet right;
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQ(2UL, diff.first.size());
ASSERT_EQ(0UL, diff.second.size());
}
@@ -88,7 +88,7 @@ TEST(IndexAccessMethodSetDifference, IdenticalSetsShouldHaveNoDifference) {
<< "string"),
BSON("" << BSONNULL)});
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQ(0UL, diff.first.size());
ASSERT_EQ(0UL, diff.second.size());
}
@@ -100,7 +100,7 @@ TEST(IndexAccessMethodSetDifference, IdenticalSetsShouldHaveNoDifference) {
void assertDistinct(BSONObj left, BSONObj right) {
auto leftSet = makeKeyStringSet({left});
auto rightSet = makeKeyStringSet({right});
- auto diff = AbstractIndexAccessMethod::setDifference(leftSet, rightSet);
+ auto diff = SortedDataIndexAccessMethod::setDifference(leftSet, rightSet);
ASSERT_EQ(1UL, diff.first.size());
ASSERT_EQ(1UL, diff.second.size());
}
@@ -153,7 +153,7 @@ TEST(IndexAccessMethodSetDifference, ShouldDetectOneDifferenceAmongManySimilarit
BSON("" << BSON("sub"
<< "document")),
BSON("" << BSON_ARRAY(1 << "hi" << 42))});
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQUALS(1UL, diff.first.size());
ASSERT_EQUALS(1UL, diff.second.size());
}
@@ -161,7 +161,7 @@ TEST(IndexAccessMethodSetDifference, ShouldDetectOneDifferenceAmongManySimilarit
TEST(IndexAccessMethodSetDifference, SingleObjInLeftShouldFindCorrespondingObjInRight) {
auto left = makeKeyStringSet({BSON("" << 2)});
auto right = makeKeyStringSet({BSON("" << 1), BSON("" << 2), BSON("" << 3)});
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQUALS(0UL, diff.first.size());
ASSERT_EQUALS(2UL, diff.second.size());
}
@@ -169,7 +169,7 @@ TEST(IndexAccessMethodSetDifference, SingleObjInLeftShouldFindCorrespondingObjIn
TEST(IndexAccessMethodSetDifference, SingleObjInRightShouldFindCorrespondingObjInLeft) {
auto left = makeKeyStringSet({BSON("" << 1), BSON("" << 2), BSON("" << 3)});
auto right = makeKeyStringSet({BSON("" << 2)});
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQUALS(2UL, diff.first.size());
ASSERT_EQUALS(0UL, diff.second.size());
}
@@ -177,7 +177,7 @@ TEST(IndexAccessMethodSetDifference, SingleObjInRightShouldFindCorrespondingObjI
TEST(IndexAccessMethodSetDifference, LeftSetAllSmallerThanRightShouldBeDisjoint) {
auto left = makeKeyStringSet({BSON("" << 1), BSON("" << 2), BSON("" << 3)});
auto right = makeKeyStringSet({BSON("" << 4), BSON("" << 5), BSON("" << 6)});
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQUALS(3UL, diff.first.size());
ASSERT_EQUALS(3UL, diff.second.size());
for (auto&& obj : diff.first) {
@@ -191,7 +191,7 @@ TEST(IndexAccessMethodSetDifference, LeftSetAllSmallerThanRightShouldBeDisjoint)
TEST(IndexAccessMethodSetDifference, LeftSetAllLargerThanRightShouldBeDisjoint) {
auto left = makeKeyStringSet({BSON("" << 4), BSON("" << 5), BSON("" << 6)});
auto right = makeKeyStringSet({BSON("" << 1), BSON("" << 2), BSON("" << 3)});
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQUALS(3UL, diff.first.size());
ASSERT_EQUALS(3UL, diff.second.size());
for (auto&& obj : diff.first) {
@@ -206,7 +206,7 @@ TEST(IndexAccessMethodSetDifference, ShouldNotReportOverlapsFromNonDisjointSets)
auto left = makeKeyStringSet({BSON("" << 0), BSON("" << 1), BSON("" << 4), BSON("" << 6)});
auto right = makeKeyStringSet(
{BSON("" << -1), BSON("" << 1), BSON("" << 3), BSON("" << 4), BSON("" << 7)});
- auto diff = AbstractIndexAccessMethod::setDifference(left, right);
+ auto diff = SortedDataIndexAccessMethod::setDifference(left, right);
ASSERT_EQUALS(2UL, diff.first.size()); // 0, 6.
ASSERT_EQUALS(3UL, diff.second.size()); // -1, 3, 7.
for (auto&& keyString : diff.first) {