summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorKevin Cherkauer <kevin.cherkauer@mongodb.com>2022-12-22 20:08:43 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-19 03:13:34 +0000
commit210f9cbb2a8759db1d9161ee21cf3b596d02d028 (patch)
treea672761e5f95c340af8fd93b74d3644e3622185f /src/mongo/db
parenta2dc5577e42ef8ce6734f4f9a6a46e6972ae873b (diff)
downloadmongo-210f9cbb2a8759db1d9161ee21cf3b596d02d028.tar.gz
SERVER-67446 Ensure consistent wildcardProjection specs in catalog
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/SConscript15
-rw-r--r--src/mongo/db/auth/SConscript2
-rw-r--r--src/mongo/db/catalog/SConscript12
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp4
-rw-r--r--src/mongo/db/commands/SConscript2
-rw-r--r--src/mongo/db/cst/SConscript2
-rw-r--r--src/mongo/db/exec/SConscript2
-rw-r--r--src/mongo/db/exec/sbe/SConscript2
-rw-r--r--src/mongo/db/index/SConscript120
-rw-r--r--src/mongo/db/index/columns_access_method.cpp10
-rw-r--r--src/mongo/db/index/index_access_method.cpp56
-rw-r--r--src/mongo/db/index/index_access_method.h27
-rw-r--r--src/mongo/db/index/index_access_method_factory.cpp53
-rw-r--r--src/mongo/db/index/index_access_method_factory_impl.cpp91
-rw-r--r--src/mongo/db/index/index_access_method_factory_impl.h50
-rw-r--r--src/mongo/db/index/index_descriptor.cpp43
-rw-r--r--src/mongo/db/index/index_descriptor.h44
-rw-r--r--src/mongo/db/index/wildcard_access_method.cpp10
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp49
-rw-r--r--src/mongo/db/mongod_main.cpp2
-rw-r--r--src/mongo/db/op_msg_fuzzer_fixture.cpp3
-rw-r--r--src/mongo/db/op_observer/SConscript6
-rw-r--r--src/mongo/db/pipeline/SConscript4
-rw-r--r--src/mongo/db/query/SConscript2
-rw-r--r--src/mongo/db/repl/SConscript6
-rw-r--r--src/mongo/db/s/SConscript2
-rw-r--r--src/mongo/db/service_context_d_test_fixture.cpp2
-rw-r--r--src/mongo/db/storage/SConscript2
-rw-r--r--src/mongo/db/storage/wiredtiger/SConscript4
29 files changed, 196 insertions, 431 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index eca762f88e8..0200b98ec07 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -1486,7 +1486,6 @@ env.Library(
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/auth/auth_checks',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
'$BUILD_DIR/mongo/scripting/scripting',
'$BUILD_DIR/mongo/util/background_job',
'$BUILD_DIR/mongo/util/elapsed_tracker',
@@ -1509,8 +1508,7 @@ env.Library(
'exec/sort_executor',
'exec/working_set',
'fts/base_fts',
- 'index/index_descriptor',
- 'index/key_generator',
+ 'index/index_access_method',
'matcher/expressions_mongod_only',
'ops/parsed_update',
'pipeline/pipeline',
@@ -2062,8 +2060,7 @@ env.Library(
'$BUILD_DIR/mongo/db/catalog/catalog_impl',
'$BUILD_DIR/mongo/db/catalog/database_holder',
'$BUILD_DIR/mongo/db/commands/mongod',
- '$BUILD_DIR/mongo/db/index/index_access_method_factory',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/s/sharding_runtime_d',
'$BUILD_DIR/mongo/db/storage/devnull/storage_devnull',
'$BUILD_DIR/mongo/db/storage/storage_control',
@@ -2269,8 +2266,6 @@ env.Library(
'ftdc/ftdc_mongod',
'fts/ftsmongod',
'index/index_access_method',
- 'index/index_access_methods',
- 'index/index_descriptor',
'index_builds_coordinator_mongod',
'introspect',
'keys_collection_client_direct',
@@ -2387,8 +2382,7 @@ env.Library(
'fle_crud_mongod',
'free_mon/free_mon_mongod',
'ftdc/ftdc_mongod',
- 'index/index_access_method_factory',
- 'index/index_access_methods',
+ 'index/index_access_method',
'index_builds_coordinator_mongod',
'keys_collection_client_direct',
'log_process_details',
@@ -2497,8 +2491,7 @@ env.Library(
'$BUILD_DIR/mongo/db/auth/authmocks',
'$BUILD_DIR/mongo/db/catalog/catalog_impl',
'$BUILD_DIR/mongo/db/catalog/database_holder',
- '$BUILD_DIR/mongo/db/index/index_access_method_factory',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/op_observer/op_observer',
'$BUILD_DIR/mongo/db/repl/replmocks',
'$BUILD_DIR/mongo/db/s/sharding_api_d',
diff --git a/src/mongo/db/auth/SConscript b/src/mongo/db/auth/SConscript
index cf887691f21..ab506eecac8 100644
--- a/src/mongo/db/auth/SConscript
+++ b/src/mongo/db/auth/SConscript
@@ -77,7 +77,7 @@ env.Library(
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/audit',
'$BUILD_DIR/mongo/db/catalog/collection_options',
- '$BUILD_DIR/mongo/db/index/index_descriptor',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/op_observer/op_observer',
'$BUILD_DIR/mongo/db/op_observer/op_observer_util',
'$BUILD_DIR/mongo/db/repl/oplog_entry',
diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript
index b79fae26381..82ee1fa3bdd 100644
--- a/src/mongo/db/catalog/SConscript
+++ b/src/mongo/db/catalog/SConscript
@@ -161,9 +161,7 @@ env.Library(
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/common',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
- '$BUILD_DIR/mongo/db/index/index_descriptor',
- '$BUILD_DIR/mongo/db/index/key_generator',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/query/collation/collator_factory_interface',
'$BUILD_DIR/mongo/db/query_expressions',
'$BUILD_DIR/mongo/db/server_base',
@@ -202,7 +200,6 @@ env.Library(
'$BUILD_DIR/mongo/db/collection_index_usage_tracker',
'$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/db/index/index_access_method',
- '$BUILD_DIR/mongo/db/index/index_descriptor',
'$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
'$BUILD_DIR/mongo/db/server_base',
'$BUILD_DIR/mongo/db/ttl_collection_cache',
@@ -242,9 +239,6 @@ env.Library(
'collection.cpp',
'collection_operation_source.cpp',
],
- LIBDEPS=[
- '$BUILD_DIR/mongo/db/s/sharding_api_d',
- ],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/server_base',
],
@@ -398,8 +392,6 @@ env.Library(
'$BUILD_DIR/mongo/db/dbcommands_idl',
'$BUILD_DIR/mongo/db/index/column_store_index',
'$BUILD_DIR/mongo/db/index/index_access_method',
- '$BUILD_DIR/mongo/db/index/index_access_method_factory',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
'$BUILD_DIR/mongo/db/multitenancy',
'$BUILD_DIR/mongo/db/op_observer/op_observer',
'$BUILD_DIR/mongo/db/record_id_helpers',
@@ -473,7 +465,6 @@ env.Library(
'$BUILD_DIR/mongo/db/concurrency/exception_util',
'$BUILD_DIR/mongo/db/curop',
'$BUILD_DIR/mongo/db/index/index_access_method',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
'$BUILD_DIR/mongo/db/multi_key_path_tracker',
'$BUILD_DIR/mongo/db/record_id_helpers',
'$BUILD_DIR/mongo/db/server_base',
@@ -696,7 +687,6 @@ if wiredtiger:
'$BUILD_DIR/mongo/db/auth/authmocks',
'$BUILD_DIR/mongo/db/commands/test_commands_enabled',
'$BUILD_DIR/mongo/db/index/index_access_method',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
'$BUILD_DIR/mongo/db/index_builds_coordinator_mongod',
'$BUILD_DIR/mongo/db/multitenancy',
'$BUILD_DIR/mongo/db/op_observer/op_observer',
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index ed48ba36774..bd71cc7524f 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -612,7 +612,7 @@ IndexCatalogEntry* IndexCatalogImpl::createIndexEntry(OperationContext* opCtx,
}
if (!frozen) {
- entry->setAccessMethod(IndexAccessMethodFactory::get(opCtx)->make(
+ entry->setAccessMethod(IndexAccessMethod::make(
opCtx, collection->ns(), collection->getCollectionOptions(), entry.get(), ident));
}
@@ -1371,7 +1371,7 @@ Status IndexCatalogImpl::resetUnfinishedIndexForRecovery(OperationContext* opCtx
// Update the index entry state in preparation to rebuild the index.
if (!released->accessMethod()) {
- released->setAccessMethod(IndexAccessMethodFactory::get(opCtx)->make(
+ released->setAccessMethod(IndexAccessMethod::make(
opCtx, collection->ns(), collection->getCollectionOptions(), released.get(), ident));
}
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index af1ad29dcec..591b50b3047 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -775,7 +775,7 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/db/commands/servers',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/pipeline/process_interface/mongo_process_interface',
'$BUILD_DIR/mongo/db/pipeline/process_interface/mongod_process_interface_factory',
'$BUILD_DIR/mongo/db/query/map_reduce_output_format',
diff --git a/src/mongo/db/cst/SConscript b/src/mongo/db/cst/SConscript
index 09c46385bf1..fbb9634cfd3 100644
--- a/src/mongo/db/cst/SConscript
+++ b/src/mongo/db/cst/SConscript
@@ -39,7 +39,7 @@ env.CppUnitTest(
],
LIBDEPS=[
# $text depends on FTSAccessMethod.
- '$BUILD_DIR/mongo/db/index/index_access_methods',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/matcher/expressions_mongod_only',
'$BUILD_DIR/mongo/db/query/query_test_service_context',
'cst',
diff --git a/src/mongo/db/exec/SConscript b/src/mongo/db/exec/SConscript
index 7efd7ab3441..392582a08f9 100644
--- a/src/mongo/db/exec/SConscript
+++ b/src/mongo/db/exec/SConscript
@@ -111,7 +111,7 @@ env.Library(
'stagedebug_cmd.cpp',
],
LIBDEPS=[
- "$BUILD_DIR/mongo/db/index/index_access_methods",
+ "$BUILD_DIR/mongo/db/index/index_access_method",
"$BUILD_DIR/mongo/db/query_exec",
],
LIBDEPS_PRIVATE=[
diff --git a/src/mongo/db/exec/sbe/SConscript b/src/mongo/db/exec/sbe/SConscript
index 8db4da10105..2660bb29659 100644
--- a/src/mongo/db/exec/sbe/SConscript
+++ b/src/mongo/db/exec/sbe/SConscript
@@ -24,7 +24,7 @@ env.Library(
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/exec/js_function',
'$BUILD_DIR/mongo/db/fts/base_fts',
- '$BUILD_DIR/mongo/db/index/key_generator',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/query/collation/collator_interface',
'$BUILD_DIR/mongo/db/query/datetime/date_time_support',
'$BUILD_DIR/mongo/db/query/query_index_bounds',
diff --git a/src/mongo/db/index/SConscript b/src/mongo/db/index/SConscript
index 0795d88a76c..1edde90c0d4 100644
--- a/src/mongo/db/index/SConscript
+++ b/src/mongo/db/index/SConscript
@@ -4,54 +4,12 @@ Import("env")
env = env.Clone()
-env.Library(
- target='index_descriptor',
- source=[
- 'index_descriptor.cpp',
- ],
- LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/db/catalog/index_catalog',
- '$BUILD_DIR/mongo/db/query/collation/collator_factory_interface',
- '$BUILD_DIR/mongo/db/query_expressions',
- '$BUILD_DIR/mongo/db/server_base',
- ],
-)
-
-env.Library(
- target='key_generator',
- source=[
- 'btree_key_generator.cpp',
- 'column_key_generator.cpp',
- 'expression_keys_private.cpp',
- 'sort_key_generator.cpp',
- 'wildcard_key_generator.cpp',
- ],
- LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/db/bson/dotted_path_support',
- '$BUILD_DIR/mongo/db/exec/projection_executor',
- '$BUILD_DIR/mongo/db/exec/working_set',
- '$BUILD_DIR/mongo/db/fts/base_fts',
- '$BUILD_DIR/mongo/db/geo/geoparser',
- '$BUILD_DIR/mongo/db/mongohasher',
- '$BUILD_DIR/mongo/db/pipeline/document_path_support',
- '$BUILD_DIR/mongo/db/query/collation/collator_interface',
- '$BUILD_DIR/mongo/db/query/projection_ast',
- '$BUILD_DIR/mongo/db/query/sort_pattern',
- '$BUILD_DIR/mongo/db/record_id_helpers',
- '$BUILD_DIR/mongo/db/server_base',
- '$BUILD_DIR/mongo/db/timeseries/timeseries_conversion_util',
- '$BUILD_DIR/third_party/s2/s2',
- 'expression_params',
- 'index_descriptor',
- ],
-)
-
env.Benchmark(
target='key_gen_bm',
source='key_gen_bm.cpp',
LIBDEPS=[
'$BUILD_DIR/mongo/base',
- 'key_generator',
+ 'index_access_method',
],
)
@@ -70,33 +28,51 @@ env.Library(
],
)
-env.Library(
- target='index_access_method_factory',
- source=[
- 'index_access_method_factory.cpp',
- ],
- LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/db/server_base',
- ],
-)
-
iamEnv = env.Clone()
iamEnv.InjectThirdParty(libraries=['snappy'])
iamEnv.Library(
target="index_access_method",
source=[
+ '2d_access_method.cpp',
+ 'btree_access_method.cpp',
+ 'btree_key_generator.cpp',
+ 'column_key_generator.cpp',
+ 'columns_access_method.cpp',
'duplicate_key_tracker.cpp',
+ 'expression_keys_private.cpp',
+ 'fts_access_method.cpp',
+ 'hash_access_method.cpp',
'index_access_method.cpp',
'index_build_interceptor.cpp',
'index_build_interceptor.idl',
+ 'index_descriptor.cpp',
+ 's2_access_method.cpp',
+ 's2_bucket_access_method.cpp',
'skipped_record_tracker.cpp',
+ 'sort_key_generator.cpp',
+ 'wildcard_access_method.cpp',
+ 'wildcard_key_generator.cpp',
],
LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/db/bson/dotted_path_support',
'$BUILD_DIR/mongo/db/catalog/collection',
+ '$BUILD_DIR/mongo/db/catalog/index_catalog',
'$BUILD_DIR/mongo/db/catalog/index_catalog_entry',
'$BUILD_DIR/mongo/db/concurrency/exception_util',
'$BUILD_DIR/mongo/db/curop',
+ '$BUILD_DIR/mongo/db/exec/projection_executor',
+ '$BUILD_DIR/mongo/db/exec/working_set',
+ '$BUILD_DIR/mongo/db/fts/base_fts',
+ '$BUILD_DIR/mongo/db/geo/geoparser',
+ '$BUILD_DIR/mongo/db/mongohasher',
'$BUILD_DIR/mongo/db/multi_key_path_tracker',
+ '$BUILD_DIR/mongo/db/pipeline/document_path_support',
+ '$BUILD_DIR/mongo/db/query/collation/collator_factory_interface',
+ '$BUILD_DIR/mongo/db/query/collation/collator_interface',
+ '$BUILD_DIR/mongo/db/query/projection_ast',
+ '$BUILD_DIR/mongo/db/query/sort_pattern',
+ '$BUILD_DIR/mongo/db/query_expressions',
+ '$BUILD_DIR/mongo/db/record_id_helpers',
'$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
'$BUILD_DIR/mongo/db/resumable_index_builds_idl',
'$BUILD_DIR/mongo/db/server_base',
@@ -109,10 +85,13 @@ iamEnv.Library(
'$BUILD_DIR/mongo/db/storage/key_string',
'$BUILD_DIR/mongo/db/storage/record_store_base',
'$BUILD_DIR/mongo/db/storage/storage_options',
+ '$BUILD_DIR/mongo/db/timeseries/timeseries_conversion_util',
'$BUILD_DIR/mongo/db/vector_clock',
'$BUILD_DIR/mongo/util/progress_meter',
+ '$BUILD_DIR/third_party/s2/s2',
'$BUILD_DIR/third_party/shim_snappy',
- 'index_descriptor',
+ 'column_store_index',
+ 'expression_params',
],
)
@@ -133,35 +112,6 @@ iamEnv.Library(
],
)
-env.Library(
- target='index_access_methods',
- source=[
- '2d_access_method.cpp',
- 'columns_access_method.cpp',
- 'btree_access_method.cpp',
- 'fts_access_method.cpp',
- 'hash_access_method.cpp',
- 'index_access_method_factory_impl.cpp',
- 's2_access_method.cpp',
- 's2_bucket_access_method.cpp',
- 'wildcard_access_method.cpp',
- ],
- LIBDEPS=[
- 'index_access_method',
- ],
- LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/db/concurrency/exception_util',
- '$BUILD_DIR/mongo/db/curop',
- '$BUILD_DIR/mongo/db/fts/base_fts',
- '$BUILD_DIR/mongo/db/resumable_index_builds_idl',
- '$BUILD_DIR/mongo/db/server_base',
- '$BUILD_DIR/mongo/db/storage/execution_context',
- 'column_store_index',
- 'expression_params',
- 'key_generator',
- ],
-)
-
indexTestEnv = env.Clone()
indexTestEnv.InjectThirdParty(libraries=['snappy'])
indexTestEnv.CppUnitTest(
@@ -184,7 +134,6 @@ indexTestEnv.CppUnitTest(
'$BUILD_DIR/mongo/db/catalog/catalog_test_fixture',
'$BUILD_DIR/mongo/db/exec/document_value/document_value_test_util',
'$BUILD_DIR/mongo/db/exec/working_set',
- '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/mongohasher',
'$BUILD_DIR/mongo/db/query/collation/collator_interface_mock',
'$BUILD_DIR/mongo/db/query/query_test_service_context',
@@ -195,7 +144,6 @@ indexTestEnv.CppUnitTest(
'$BUILD_DIR/mongo/db/sorter/sorter_stats',
'column_store_index',
'expression_params',
- 'index_access_methods',
- 'key_generator',
+ 'index_access_method',
],
)
diff --git a/src/mongo/db/index/columns_access_method.cpp b/src/mongo/db/index/columns_access_method.cpp
index 52a92c7da73..f894117fb97 100644
--- a/src/mongo/db/index/columns_access_method.cpp
+++ b/src/mongo/db/index/columns_access_method.cpp
@@ -68,15 +68,7 @@ ColumnStoreAccessMethod::ColumnStoreAccessMethod(IndexCatalogEntry* ice,
: _store(std::move(store)),
_indexCatalogEntry(ice),
_descriptor(ice->descriptor()),
- _keyGen(_descriptor->keyPattern(), _descriptor->pathProjection()) {
- // Normalize the 'columnstoreProjection' index option to facilitate its comparison as part of
- // index signature.
- if (!_descriptor->pathProjection().isEmpty()) {
- auto* projExec = getColumnstoreProjection()->exec();
- ice->descriptor()->_setNormalizedPathProjection(
- projExec->serializeTransformation(boost::none).toBson());
- }
-}
+ _keyGen(_descriptor->keyPattern(), _descriptor->pathProjection()) {}
class ColumnStoreAccessMethod::BulkBuilder final
: public BulkBuilderCommon<ColumnStoreAccessMethod::BulkBuilder> {
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 {
/**
diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h
index 8e9391f4c29..8819e11912f 100644
--- a/src/mongo/db/index/index_access_method.h
+++ b/src/mongo/db/index/index_access_method.h
@@ -74,6 +74,12 @@ public:
IndexAccessMethod() = default;
virtual ~IndexAccessMethod() = default;
+ static std::unique_ptr<IndexAccessMethod> make(OperationContext* opCtx,
+ const NamespaceString& nss,
+ const CollectionOptions& collectionOptions,
+ IndexCatalogEntry* entry,
+ StringData ident);
+
/**
* Equivalent to (but shorter and faster than): dynamic_cast<SortedDataIndexAccessMethod*>(this)
*/
@@ -275,27 +281,6 @@ public:
};
/**
- * Factory class that constructs an IndexAccessMethod depending on the type of index.
- */
-class IndexAccessMethodFactory {
-public:
- IndexAccessMethodFactory() = default;
- virtual ~IndexAccessMethodFactory() = default;
-
- static IndexAccessMethodFactory* get(ServiceContext* service);
- static IndexAccessMethodFactory* get(OperationContext* opCtx);
- static void set(ServiceContext* service,
- std::unique_ptr<IndexAccessMethodFactory> collectionFactory);
-
-
- virtual std::unique_ptr<IndexAccessMethod> make(OperationContext* opCtx,
- const NamespaceString& nss,
- const CollectionOptions& collectionOptions,
- IndexCatalogEntry* entry,
- StringData ident) = 0;
-};
-
-/**
* Updates are two steps: verify that it's a valid update, and perform it.
* prepareUpdate fills out the UpdateStatus and update actually applies it.
*/
diff --git a/src/mongo/db/index/index_access_method_factory.cpp b/src/mongo/db/index/index_access_method_factory.cpp
deleted file mode 100644
index 986ed2d8967..00000000000
--- a/src/mongo/db/index/index_access_method_factory.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Copyright (C) 2019-present MongoDB, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the Server Side Public License, version 1,
- * as published by MongoDB, Inc.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Server Side Public License for more details.
- *
- * You should have received a copy of the Server Side Public License
- * along with this program. If not, see
- * <http://www.mongodb.com/licensing/server-side-public-license>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the Server Side Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/db/index/index_access_method.h"
-
-namespace mongo {
-namespace {
-const auto getFactory =
- ServiceContext::declareDecoration<std::unique_ptr<IndexAccessMethodFactory>>();
-} // namespace
-
-IndexAccessMethodFactory* IndexAccessMethodFactory::get(ServiceContext* service) {
- return getFactory(service).get();
-}
-
-IndexAccessMethodFactory* IndexAccessMethodFactory::get(OperationContext* opCtx) {
- return getFactory(opCtx->getServiceContext()).get();
-}
-
-void IndexAccessMethodFactory::set(ServiceContext* service,
- std::unique_ptr<IndexAccessMethodFactory> newFactory) {
- auto& factory = getFactory(service);
- factory = std::move(newFactory);
-}
-} // namespace mongo
diff --git a/src/mongo/db/index/index_access_method_factory_impl.cpp b/src/mongo/db/index/index_access_method_factory_impl.cpp
deleted file mode 100644
index e027154ba9e..00000000000
--- a/src/mongo/db/index/index_access_method_factory_impl.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Copyright (C) 2019-present MongoDB, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the Server Side Public License, version 1,
- * as published by MongoDB, Inc.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Server Side Public License for more details.
- *
- * You should have received a copy of the Server Side Public License
- * along with this program. If not, see
- * <http://www.mongodb.com/licensing/server-side-public-license>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the Server Side Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/db/index/index_access_method_factory_impl.h"
-
-#include "mongo/db/index/2d_access_method.h"
-#include "mongo/db/index/btree_access_method.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/s2_access_method.h"
-#include "mongo/db/index/s2_bucket_access_method.h"
-#include "mongo/db/index/wildcard_access_method.h"
-#include "mongo/db/storage/kv/kv_engine.h"
-#include "mongo/logv2/log.h"
-
-#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kIndex
-
-
-namespace mongo {
-
-std::unique_ptr<IndexAccessMethod> IndexAccessMethodFactoryImpl::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 mongo
diff --git a/src/mongo/db/index/index_access_method_factory_impl.h b/src/mongo/db/index/index_access_method_factory_impl.h
deleted file mode 100644
index 639ee1c320d..00000000000
--- a/src/mongo/db/index/index_access_method_factory_impl.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (C) 2019-present MongoDB, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the Server Side Public License, version 1,
- * as published by MongoDB, Inc.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Server Side Public License for more details.
- *
- * You should have received a copy of the Server Side Public License
- * along with this program. If not, see
- * <http://www.mongodb.com/licensing/server-side-public-license>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the Server Side Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#pragma once
-
-#include "mongo/db/index/index_access_method.h"
-
-namespace mongo {
-
-struct CollectionOptions;
-
-class IndexAccessMethodFactoryImpl : public IndexAccessMethodFactory {
-public:
- IndexAccessMethodFactoryImpl() = default;
- ~IndexAccessMethodFactoryImpl() = default;
-
- std::unique_ptr<IndexAccessMethod> make(OperationContext* opCtx,
- const NamespaceString& nss,
- const CollectionOptions& collectionOptions,
- IndexCatalogEntry* entry,
- StringData ident) final;
-};
-
-} // namespace mongo
diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp
index a5b4214ee43..e98a2cced88 100644
--- a/src/mongo/db/index/index_descriptor.cpp
+++ b/src/mongo/db/index/index_descriptor.cpp
@@ -27,7 +27,6 @@
* it in the license file.
*/
-
#include "mongo/platform/basic.h"
#include "mongo/db/index/index_descriptor.h"
@@ -37,6 +36,9 @@
#include "mongo/bson/simple_bsonelement_comparator.h"
#include "mongo/bson/unordered_fields_bsonobj_comparator.h"
#include "mongo/db/catalog/index_catalog_entry.h"
+#include "mongo/db/exec/index_path_projection.h"
+#include "mongo/db/index/column_key_generator.h"
+#include "mongo/db/index/wildcard_key_generator.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/query/collation/collator_factory_interface.h"
#include "mongo/db/server_options.h"
@@ -115,6 +117,11 @@ constexpr StringData IndexDescriptor::kWeightsFieldName;
constexpr StringData IndexDescriptor::kPrepareUniqueFieldName;
constexpr StringData IndexDescriptor::kColumnStoreCompressorFieldName;
+/**
+ * Constructs an IndexDescriptor object. Arguments:
+ * accessMethodName - one of the 'IndexNames::XXX' constants from index_names.cpp
+ * infoObj - options information
+ */
IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj infoObj)
: _accessMethodName(accessMethodName),
_indexType(IndexNames::nameToType(accessMethodName)),
@@ -156,6 +163,27 @@ IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj in
} else {
_compressor = boost::none;
}
+
+ // If there is a wildcardProjection or columnstoreProjection, compute and store the normalized
+ // version in '_normalizedProjection'.
+ BSONElement wildcardProjection = infoObj[IndexDescriptor::kWildcardProjectionFieldName];
+ BSONElement columnStoreProjection = infoObj[IndexDescriptor::kColumnStoreProjectionFieldName];
+ tassert(6744600,
+ "Can't enable both wildcardProjection and columnstoreProjection",
+ !(wildcardProjection && columnStoreProjection));
+ if (wildcardProjection) {
+ IndexPathProjection indexPathProjection =
+ static_cast<IndexPathProjection>(WildcardKeyGenerator::createProjectionExecutor(
+ BSON("$**" << 1), wildcardProjection.Obj()));
+ _normalizedProjection =
+ indexPathProjection.exec()->serializeTransformation(boost::none).toBson();
+ } else if (columnStoreProjection) {
+ IndexPathProjection indexPathProjection = static_cast<IndexPathProjection>(
+ column_keygen::ColumnKeyGenerator::createProjectionExecutor(
+ BSON("$**" << IndexNames::COLUMN), columnStoreProjection.Obj()));
+ _normalizedProjection =
+ indexPathProjection.exec()->serializeTransformation(boost::none).toBson();
+ }
}
bool IndexDescriptor::isIndexVersionSupported(IndexVersion indexVersion) {
@@ -175,10 +203,6 @@ IndexDescriptor::Comparison IndexDescriptor::compareIndexOptions(
OperationContext* opCtx,
const NamespaceString& ns,
const IndexCatalogEntry* existingIndex) const {
- // The compareIndexOptions method can only be reliably called on a candidate index which is
- // being compared against an index that already exists in the catalog.
- tassert(4765900, "This object must be a candidate index", !getEntry());
-
auto existingIndexDesc = existingIndex->descriptor();
// We first check whether the key pattern is identical for both indexes.
@@ -187,8 +211,15 @@ IndexDescriptor::Comparison IndexDescriptor::compareIndexOptions(
return Comparison::kDifferent;
}
+ // If the candidate has a wildcardProjection or columnstoreProjection, we must compare the
+ // normalized versions, not the versions from the catalog which are kept as the user gave them
+ // and thus may be semantically identical to but syntactically different from the normalized
+ // form. There are no other types of index projections. Thus, if there is no projection, both
+ // the original and normalized projections will be empty BSON objects, so we can still do the
+ // comparison based on the normalized projection.
static const UnorderedFieldsBSONObjComparator kUnorderedBSONCmp;
- if (kUnorderedBSONCmp.evaluate(_projection != existingIndexDesc->_normalizedProjection)) {
+ if (kUnorderedBSONCmp.evaluate(_normalizedProjection !=
+ existingIndexDesc->_normalizedProjection)) {
return Comparison::kDifferent;
}
diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h
index 702b6e3f029..349f79bd9a2 100644
--- a/src/mongo/db/index/index_descriptor.h
+++ b/src/mongo/db/index/index_descriptor.h
@@ -122,15 +122,40 @@ public:
}
/**
- * Return the path projection spec, if one exists. This is only applicable for '$**' indexes.
+ * Return the path projection spec, if one exists. This is only applicable for wildcard ('$**')
+ * and columnstore indexes. It is kept as originally specified by the createIndex() call, not
+ * normalized.
+ *
+ * It contains only the projection object that was contained in one of the fields listed below
+ * from the original createIndex() parameters object, but it does NOT preserve the field name:
+ * - "wildcardProjection" (IndexDescriptor::kWildcardProjectionFieldName)
+ * - "columnstoreProjection" (IndexDescriptor::kColumnStoreProjectionFieldName)
+ *
+ * This is set by the IndexDescriptor constructor and never changes after that.
+ *
+ * Example: db.a.createIndex({"$**":1}, {"name": "i1", "wildcardProjection": {"a.b": 1}})
+ * return (unnormalized) object: {"a.b":{"$numberDouble":"1"}}
*/
const BSONObj& pathProjection() const {
return _projection;
}
/**
- * Returns the normalized path projection spec, if one exists. This is only applicable for '$**'
- * indexes.
+ * Returns the normalized path projection spec, if one exists. This is only applicable for
+ * wildcard ('$**') and columnstore indexes. It is the normalized version of the path projection
+ * and is used to determine whether a new index candidate from createIndex() duplicates an
+ * existing index.
+ *
+ * It contains the normalized projection object based on the original object that was contained
+ * in one of the fields listed below from the original createIndex() parameters object, but it
+ * does NOT preserve the field name:
+ * - "wildcardProjection" (IndexDescriptor::kWildcardProjectionFieldName)
+ * - "columnstoreProjection" (IndexDescriptor::kColumnStoreProjectionFieldName)
+ *
+ * This is set by the IndexDescriptor constructor and never changes after that.
+ *
+ * Example: db.a.createIndex({"$**":1}, {"name": "i1", "wildcardProjection": {"a.b": 1}})
+ * return (normalized) object: {"a":{"b":true},"_id":false}
*/
const BSONObj& normalizedPathProjection() const {
return _normalizedProjection;
@@ -271,13 +296,6 @@ public:
}
private:
- // This method should only ever be called by WildcardAccessMethod or ColumnstoreAccessMethod, to
- // set the '_normalizedProjection' for descriptors associated with an existing
- // IndexCatalogEntry.
- void _setNormalizedPathProjection(BSONObj&& proj) {
- _normalizedProjection = std::move(proj);
- }
-
/**
* Returns wildcardProjection or columnstoreProjection projection
*/
@@ -305,8 +323,8 @@ private:
int64_t _numFields; // How many fields are indexed?
BSONObj _keyPattern;
- BSONObj _projection;
- BSONObj _normalizedProjection;
+ BSONObj _projection; // for wildcardProjection / columnstoreProjection; never changes
+ BSONObj _normalizedProjection; // for wildcardProjection / columnstoreProjection; never changes
std::string _indexName;
bool _isIdIndex;
bool _sparse;
@@ -326,8 +344,6 @@ private:
friend class IndexCatalog;
friend class IndexCatalogEntryImpl;
friend class IndexCatalogEntryContainer;
- friend class WildcardAccessMethod;
- friend class ColumnStoreAccessMethod;
};
} // namespace mongo
diff --git a/src/mongo/db/index/wildcard_access_method.cpp b/src/mongo/db/index/wildcard_access_method.cpp
index 0631158e40d..a3b66caa1d2 100644
--- a/src/mongo/db/index/wildcard_access_method.cpp
+++ b/src/mongo/db/index/wildcard_access_method.cpp
@@ -45,15 +45,7 @@ WildcardAccessMethod::WildcardAccessMethod(IndexCatalogEntry* wildcardState,
_indexCatalogEntry->getCollator(),
getSortedDataInterface()->getKeyStringVersion(),
getSortedDataInterface()->getOrdering(),
- getSortedDataInterface()->rsKeyFormat()) {
- // Normalize the 'wildcardProjection' index option to facilitate its comparison as part of
- // index signature.
- if (!_descriptor->pathProjection().isEmpty()) {
- auto* projExec = getWildcardProjection()->exec();
- wildcardState->descriptor()->_setNormalizedPathProjection(
- projExec->serializeTransformation(boost::none).toBson());
- }
-}
+ getSortedDataInterface()->rsKeyFormat()) {}
bool WildcardAccessMethod::shouldMarkIndexAsMultikey(size_t numberOfKeys,
const KeyStringSet& multikeyMetadataKeys,
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index ff6c170457d..b005f776468 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -3159,6 +3159,7 @@ std::vector<BSONObj> IndexBuildsCoordinator::prepareSpecListForCreate(
return resultSpecs;
}
+// Returns normalized versions of 'indexSpecs' for the catalog.
std::vector<BSONObj> IndexBuildsCoordinator::normalizeIndexSpecs(
OperationContext* opCtx,
const CollectionPtr& collection,
@@ -3180,47 +3181,13 @@ std::vector<BSONObj> IndexBuildsCoordinator::normalizeIndexSpecs(
// for clients to validate (via the listIndexes output) whether a given partialFilterExpression
// is equivalent to the filter that they originally submitted. Omitting this normalization does
// not impact our internal index comparison semantics, since we compare based on the parsed
- // MatchExpression trees rather than the serialized BSON specs. See SERVER-54357.
-
- // If any of the specs describe wildcard or columnstore indexes, normalize the respective
- // projections if present. This will change all specs of the form {"a.b.c": 1} to normalized
- // form {a: {b: {c : 1}}}.
- std::transform(normalSpecs.begin(), normalSpecs.end(), normalSpecs.begin(), [](auto& spec) {
- BSONObj pathProjectionSpec;
- bool isWildcard = false;
- auto wildcardProjection = spec[IndexDescriptor::kWildcardProjectionFieldName];
- auto columnStoreProjection = spec[IndexDescriptor::kColumnStoreProjectionFieldName];
- if (wildcardProjection) {
- pathProjectionSpec = wildcardProjection.Obj();
- invariant(!spec[IndexDescriptor::kColumnStoreProjectionFieldName]);
- isWildcard = true;
- } else if (columnStoreProjection) {
- pathProjectionSpec = columnStoreProjection.Obj();
- invariant(!spec[IndexDescriptor::kWildcardProjectionFieldName]);
- } else {
- // No projection to normalize.
- return spec;
- }
- uassert(ErrorCodes::InvalidIndexSpecificationOption,
- "Can't enable both wildcardProjection and columnstoreProjection",
- !(wildcardProjection && columnStoreProjection));
-
- // Exactly one of wildcardProjection or columnstoreProjection is enabled
- const auto projectionName = isWildcard ? IndexDescriptor::kWildcardProjectionFieldName
- : IndexDescriptor::kColumnStoreProjectionFieldName;
- static const auto kFieldSetKeyPattern = isWildcard ? BSON("$**" << 1)
- : BSON("$**"
- << "columnstore");
- auto indexPathProjection = isWildcard
- ? static_cast<IndexPathProjection>(WildcardKeyGenerator::createProjectionExecutor(
- kFieldSetKeyPattern, pathProjectionSpec))
- : static_cast<IndexPathProjection>(
- column_keygen::ColumnKeyGenerator::createProjectionExecutor(kFieldSetKeyPattern,
- pathProjectionSpec));
- auto normalizedProjection =
- indexPathProjection.exec()->serializeTransformation(boost::none).toBson();
- return spec.addField(BSON(projectionName << normalizedProjection).firstElement());
- });
+ // MatchExpression trees rather than the serialized BSON specs.
+ //
+ // For similar reasons we do not normalize index projection objects here, if any, so their
+ // original forms get persisted in the catalog. Projection normalization to detect whether a
+ // candidate new index would duplicate an existing index is done only in the memory-only
+ // 'IndexDescriptor._normalizedProjection' field.
+
return normalSpecs;
}
diff --git a/src/mongo/db/mongod_main.cpp b/src/mongo/db/mongod_main.cpp
index 3c5cf6f2933..cfc74bda427 100644
--- a/src/mongo/db/mongod_main.cpp
+++ b/src/mongo/db/mongod_main.cpp
@@ -83,7 +83,6 @@
#include "mongo/db/ftdc/ftdc_mongod.h"
#include "mongo/db/ftdc/util.h"
#include "mongo/db/global_settings.h"
-#include "mongo/db/index/index_access_method_factory_impl.h"
#include "mongo/db/index_builds_coordinator_mongod.h"
#include "mongo/db/index_names.h"
#include "mongo/db/initialize_server_global_state.h"
@@ -1117,7 +1116,6 @@ void setUpCollectionShardingState(ServiceContext* serviceContext) {
void setUpCatalog(ServiceContext* serviceContext) {
DatabaseHolder::set(serviceContext, std::make_unique<DatabaseHolderImpl>());
- IndexAccessMethodFactory::set(serviceContext, std::make_unique<IndexAccessMethodFactoryImpl>());
Collection::Factory::set(serviceContext, std::make_unique<CollectionImpl::FactoryImpl>());
}
diff --git a/src/mongo/db/op_msg_fuzzer_fixture.cpp b/src/mongo/db/op_msg_fuzzer_fixture.cpp
index d0a7be22ca3..546ee039675 100644
--- a/src/mongo/db/op_msg_fuzzer_fixture.cpp
+++ b/src/mongo/db/op_msg_fuzzer_fixture.cpp
@@ -37,7 +37,6 @@
#include "mongo/db/catalog/database_holder_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/index/index_access_method.h"
-#include "mongo/db/index/index_access_method_factory_impl.h"
#include "mongo/db/op_observer/op_observer_registry.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/repl_client_info.h"
@@ -111,8 +110,6 @@ OpMsgFuzzerFixture::OpMsgFuzzerFixture(bool skipGlobalInitializers)
_serviceContext,
std::make_unique<CollectionShardingStateFactoryStandalone>(_serviceContext));
DatabaseHolder::set(_serviceContext, std::make_unique<DatabaseHolderImpl>());
- IndexAccessMethodFactory::set(_serviceContext,
- std::make_unique<IndexAccessMethodFactoryImpl>());
Collection::Factory::set(_serviceContext, std::make_unique<CollectionImpl::FactoryImpl>());
// Setup the repl coordinator in standalone mode so we don't need an oplog etc.
diff --git a/src/mongo/db/op_observer/SConscript b/src/mongo/db/op_observer/SConscript
index 072f19bba74..77d0fbbb99c 100644
--- a/src/mongo/db/op_observer/SConscript
+++ b/src/mongo/db/op_observer/SConscript
@@ -24,7 +24,8 @@ env.Library(
'$BUILD_DIR/mongo/db/bson/dotted_path_support',
'$BUILD_DIR/mongo/db/catalog/collection',
'$BUILD_DIR/mongo/db/catalog/collection_options',
- '$BUILD_DIR/mongo/db/index/index_descriptor',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
+ '$BUILD_DIR/mongo/db/s/sharding_api_d',
],
)
@@ -118,9 +119,8 @@ env.Library(
'op_observer',
],
LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/db/catalog/collection',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
+ '$BUILD_DIR/mongo/db/s/sharding_api_d',
'$BUILD_DIR/mongo/db/s/user_writes_recoverable_critical_section',
],
)
diff --git a/src/mongo/db/pipeline/SConscript b/src/mongo/db/pipeline/SConscript
index 699b8b2dd79..ff10cf0b784 100644
--- a/src/mongo/db/pipeline/SConscript
+++ b/src/mongo/db/pipeline/SConscript
@@ -142,7 +142,7 @@ env.Library(
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/exec/sort_executor',
- '$BUILD_DIR/mongo/db/index/key_generator',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/idl/idl_parser',
],
)
@@ -353,7 +353,7 @@ pipelineEnv.Library(
'$BUILD_DIR/mongo/db/exec/scoped_timer',
'$BUILD_DIR/mongo/db/exec/sort_executor',
'$BUILD_DIR/mongo/db/generic_cursor',
- '$BUILD_DIR/mongo/db/index/key_generator',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/pipeline/change_stream_error_extra_info',
'$BUILD_DIR/mongo/db/pipeline/lite_parsed_document_source',
'$BUILD_DIR/mongo/db/query/collation/collator_factory_interface',
diff --git a/src/mongo/db/query/SConscript b/src/mongo/db/query/SConscript
index 305bff56717..f48a1bcd5a4 100644
--- a/src/mongo/db/query/SConscript
+++ b/src/mongo/db/query/SConscript
@@ -69,7 +69,7 @@ env.Library(
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/commands/server_status_core',
'$BUILD_DIR/mongo/db/fts/base_fts',
- '$BUILD_DIR/mongo/db/index/key_generator',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/record_id_helpers',
'$BUILD_DIR/mongo/db/server_base',
'query_plan_cache',
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 3d308581d3f..2919f96439f 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -138,7 +138,7 @@ env.Library(
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/dbhelpers',
- '$BUILD_DIR/mongo/db/index/index_descriptor',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/query_exec',
'$BUILD_DIR/mongo/db/shard_role',
'$BUILD_DIR/mongo/util/fail_point',
@@ -738,7 +738,7 @@ env.Library(
'$BUILD_DIR/mongo/db/commands/mongod_fcv',
'$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
- '$BUILD_DIR/mongo/db/index/index_descriptor',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/mongod_options',
'$BUILD_DIR/mongo/db/prepare_conflict_tracker',
'$BUILD_DIR/mongo/db/server_options_core',
@@ -1734,7 +1734,7 @@ if wiredtiger:
'$BUILD_DIR/mongo/db/commands/mongod_fcv',
'$BUILD_DIR/mongo/db/commands/txn_cmd_request',
'$BUILD_DIR/mongo/db/dbdirectclient',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/index_build_entry_helpers',
'$BUILD_DIR/mongo/db/index_builds_coordinator_mongod',
'$BUILD_DIR/mongo/db/multitenancy',
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index cf8e695ba70..3f79473d512 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -34,7 +34,7 @@ env.Library(
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/catalog/index_catalog',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
- '$BUILD_DIR/mongo/db/index/index_descriptor',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/server_base',
'$BUILD_DIR/mongo/db/write_block_bypass',
],
diff --git a/src/mongo/db/service_context_d_test_fixture.cpp b/src/mongo/db/service_context_d_test_fixture.cpp
index cad9b4dfa62..bfd9ec98db1 100644
--- a/src/mongo/db/service_context_d_test_fixture.cpp
+++ b/src/mongo/db/service_context_d_test_fixture.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/catalog/database_holder_impl.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/global_settings.h"
-#include "mongo/db/index/index_access_method_factory_impl.h"
#include "mongo/db/index_builds_coordinator_mongod.h"
#include "mongo/db/op_observer/op_observer_registry.h"
#include "mongo/db/repl/repl_settings.h"
@@ -142,7 +141,6 @@ ServiceContextMongoDTest::ServiceContextMongoDTest(Options options)
StorageControl::startStorageControls(serviceContext, true /*forTestOnly*/);
DatabaseHolder::set(serviceContext, std::make_unique<DatabaseHolderImpl>());
- IndexAccessMethodFactory::set(serviceContext, std::make_unique<IndexAccessMethodFactoryImpl>());
Collection::Factory::set(serviceContext, std::make_unique<CollectionImpl::FactoryImpl>());
IndexBuildsCoordinator::set(serviceContext, std::make_unique<IndexBuildsCoordinatorMongod>());
CollectionShardingStateFactory::set(
diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript
index f2e1725333f..8a2e6659316 100644
--- a/src/mongo/db/storage/SConscript
+++ b/src/mongo/db/storage/SConscript
@@ -546,7 +546,7 @@ env.Library(
'$BUILD_DIR/mongo/bson/util/bson_extract',
'$BUILD_DIR/mongo/db/catalog/collection_catalog',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
- '$BUILD_DIR/mongo/db/index/index_descriptor',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'bson_collection_catalog_entry',
],
LIBDEPS_PRIVATE=[
diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript
index 5b17fafe450..59b8e893feb 100644
--- a/src/mongo/db/storage/wiredtiger/SConscript
+++ b/src/mongo/db/storage/wiredtiger/SConscript
@@ -55,7 +55,7 @@ wtEnv.Library(
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
'$BUILD_DIR/mongo/db/curop',
'$BUILD_DIR/mongo/db/global_settings',
- '$BUILD_DIR/mongo/db/index/index_descriptor',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/prepare_conflict_tracker',
'$BUILD_DIR/mongo/db/record_id_helpers',
'$BUILD_DIR/mongo/db/repl/repl_settings',
@@ -142,7 +142,7 @@ wtEnv.CppUnitTest(
],
LIBDEPS=[
'$BUILD_DIR/mongo/db/auth/authmocks',
- '$BUILD_DIR/mongo/db/index/index_access_methods',
+ '$BUILD_DIR/mongo/db/index/index_access_method',
'$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
'$BUILD_DIR/mongo/db/repl/replmocks',
'$BUILD_DIR/mongo/db/service_context',