diff options
author | Kevin Cherkauer <kevin.cherkauer@mongodb.com> | 2022-12-22 20:08:43 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-01-19 03:13:34 +0000 |
commit | 210f9cbb2a8759db1d9161ee21cf3b596d02d028 (patch) | |
tree | a672761e5f95c340af8fd93b74d3644e3622185f /src/mongo/db/index/index_access_method.cpp | |
parent | a2dc5577e42ef8ce6734f4f9a6a46e6972ae873b (diff) | |
download | mongo-210f9cbb2a8759db1d9161ee21cf3b596d02d028.tar.gz |
SERVER-67446 Ensure consistent wildcardProjection specs in catalog
Diffstat (limited to 'src/mongo/db/index/index_access_method.cpp')
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index 5d3d226bb23..9ec1d3aec72 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -27,10 +27,9 @@ * it in the license file. */ - #include "mongo/platform/basic.h" -#include "mongo/db/index/btree_access_method.h" +#include "mongo/db/index/index_access_method.h" #include <utility> #include <vector> @@ -43,15 +42,24 @@ #include "mongo/db/commands/server_status.h" #include "mongo/db/concurrency/exception_util.h" #include "mongo/db/curop.h" +#include "mongo/db/index/2d_access_method.h" +#include "mongo/db/index/btree_access_method.h" #include "mongo/db/index/bulk_builder_common.h" +#include "mongo/db/index/columns_access_method.h" +#include "mongo/db/index/fts_access_method.h" +#include "mongo/db/index/hash_access_method.h" #include "mongo/db/index/index_build_interceptor.h" #include "mongo/db/index/index_descriptor.h" +#include "mongo/db/index/s2_access_method.h" +#include "mongo/db/index/s2_bucket_access_method.h" +#include "mongo/db/index/wildcard_access_method.h" #include "mongo/db/jsobj.h" #include "mongo/db/keypattern.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/repl/timestamp_block.h" #include "mongo/db/storage/execution_context.h" +#include "mongo/db/storage/kv/kv_engine.h" #include "mongo/db/storage/storage_options.h" #include "mongo/logv2/log.h" #include "mongo/platform/atomic_word.h" @@ -72,6 +80,50 @@ MONGO_FAIL_POINT_DEFINE(hangIndexBuildDuringBulkLoadPhaseSecond); MONGO_FAIL_POINT_DEFINE(hangDuringIndexBuildBulkLoadYield); MONGO_FAIL_POINT_DEFINE(hangDuringIndexBuildBulkLoadYieldSecond); +/** + * Static factory method that constructs and returns an appropriate IndexAccessMethod depending on + * the type of the index. + */ +std::unique_ptr<IndexAccessMethod> IndexAccessMethod::make( + OperationContext* opCtx, + const NamespaceString& nss, + const CollectionOptions& collectionOptions, + IndexCatalogEntry* entry, + StringData ident) { + + auto engine = opCtx->getServiceContext()->getStorageEngine()->getEngine(); + auto desc = entry->descriptor(); + auto makeSDI = [&] { + return engine->getSortedDataInterface(opCtx, nss, collectionOptions, ident, desc); + }; + auto makeCS = [&] { + return engine->getColumnStore(opCtx, nss, collectionOptions, ident, desc); + }; + const std::string& type = desc->getAccessMethodName(); + + if ("" == type) + return std::make_unique<BtreeAccessMethod>(entry, makeSDI()); + else if (IndexNames::HASHED == type) + return std::make_unique<HashAccessMethod>(entry, makeSDI()); + else if (IndexNames::GEO_2DSPHERE == type) + return std::make_unique<S2AccessMethod>(entry, makeSDI()); + else if (IndexNames::GEO_2DSPHERE_BUCKET == type) + return std::make_unique<S2BucketAccessMethod>(entry, makeSDI()); + else if (IndexNames::TEXT == type) + return std::make_unique<FTSAccessMethod>(entry, makeSDI()); + else if (IndexNames::GEO_2D == type) + return std::make_unique<TwoDAccessMethod>(entry, makeSDI()); + else if (IndexNames::WILDCARD == type) + return std::make_unique<WildcardAccessMethod>(entry, makeSDI()); + else if (IndexNames::COLUMN == type) + return std::make_unique<ColumnStoreAccessMethod>(entry, makeCS()); + LOGV2(20688, + "Can't find index for keyPattern {keyPattern}", + "Can't find index for keyPattern", + "keyPattern"_attr = desc->keyPattern()); + fassertFailed(31021); +} + namespace { /** |