diff options
author | Benety Goh <benety@mongodb.com> | 2019-11-22 11:18:43 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-22 11:18:43 +0000 |
commit | a94c8741d694691471579bb082875c7be83206fb (patch) | |
tree | 27b4ee898b6368d634b325713818d00b130d8dbe | |
parent | e40ac3ae0c9986532cd3e4fd0c780bde562b6c4f (diff) | |
download | mongo-a94c8741d694691471579bb082875c7be83206fb.tar.gz |
SERVER-43642 move IndexLegacy::adjustIndexSpecObject() into IndexCatalogImpl implementation
-rw-r--r-- | src/mongo/SConscript | 3 | ||||
-rw-r--r-- | src/mongo/db/SConscript | 11 | ||||
-rw-r--r-- | src/mongo/db/catalog/SConscript | 2 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.cpp | 27 | ||||
-rw-r--r-- | src/mongo/db/index_legacy.cpp | 58 | ||||
-rw-r--r-- | src/mongo/db/index_legacy.h | 57 | ||||
-rw-r--r-- | src/mongo/db/query/collection_query_info.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/repl/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/dbtests/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/embedded/SConscript | 1 |
10 files changed, 32 insertions, 130 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript index 8cbe6309cd8..b085df33adf 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -466,6 +466,9 @@ mongod = env.Program( 'util/version_impl', 'watchdog/watchdog_mongod', ], + LIBDEPS_PRIVATE=[ + 'db/index/index_access_methods', + ], AIB_COMPONENT="servers", AIB_COMPONENTS_EXTRA=[ "dist", diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index f49da245bac..96d0d60b91d 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -857,16 +857,6 @@ env.Library( ) env.Library( - target="index_d", - source=[ - "index_legacy.cpp", - ], - LIBDEPS=[ - 'index/index_access_methods', - ], -) - -env.Library( target="introspect", source=[ "introspect.cpp", @@ -1590,6 +1580,7 @@ env.Library( LIBDEPS_PRIVATE=[ 'catalog/catalog_impl', 'commands/mongod', + 'index/index_access_methods', 'index_builds_coordinator_mongod', 'service_context_d', 'storage/devnull/storage_devnull', diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript index d2c7b9ec1e5..642a0ffa115 100644 --- a/src/mongo/db/catalog/SConscript +++ b/src/mongo/db/catalog/SConscript @@ -331,7 +331,6 @@ env.Library( '$BUILD_DIR/mongo/db/db_raii', '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/index/index_access_method_factory', - '$BUILD_DIR/mongo/db/index_d', '$BUILD_DIR/mongo/db/op_observer', '$BUILD_DIR/mongo/db/repl/drop_pending_collection_reaper', '$BUILD_DIR/mongo/db/repl/oplog', @@ -350,6 +349,7 @@ env.Library( '$BUILD_DIR/mongo/db/catalog/collection_catalog_helper', '$BUILD_DIR/mongo/db/commands/server_status_core', '$BUILD_DIR/mongo/db/index/index_build_interceptor', + '$BUILD_DIR/mongo/db/index/index_access_methods', '$BUILD_DIR/mongo/db/logical_clock', '$BUILD_DIR/mongo/db/repl/repl_settings', '$BUILD_DIR/mongo/db/storage/storage_engine_common', diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index fc123296941..c06724c85c4 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -49,9 +49,10 @@ #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/curop.h" #include "mongo/db/field_ref.h" +#include "mongo/db/fts/fts_spec.h" #include "mongo/db/index/index_access_method.h" #include "mongo/db/index/index_descriptor.h" -#include "mongo/db/index_legacy.h" +#include "mongo/db/index/s2_access_method.h" #include "mongo/db/index_names.h" #include "mongo/db/jsobj.h" #include "mongo/db/keypattern.h" @@ -466,6 +467,28 @@ Status _checkValidFilterExpressions(MatchExpression* expression, int level = 0) << expression->debugString()); } } + +/** + * Adjust the provided index spec BSONObj depending on the type of index obj describes. + * + * This is a no-op unless the object describes a TEXT or a GEO_2DSPHERE index. TEXT and + * GEO_2DSPHERE provide additional validation on the index spec, and tweak the index spec + * object to conform to their expected format. + */ +StatusWith<BSONObj> adjustIndexSpecObject(const BSONObj& obj) { + std::string pluginName = IndexNames::findPluginName(obj.getObjectField("key")); + + if (IndexNames::TEXT == pluginName) { + return fts::FTSSpec::fixSpec(obj); + } + + if (IndexNames::GEO_2DSPHERE == pluginName) { + return S2AccessMethod::fixSpec(obj); + } + + return obj; +} + } // namespace Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec) const { @@ -1594,7 +1617,7 @@ void IndexCatalogImpl::indexBuildSuccess(OperationContext* opCtx, IndexCatalogEn StatusWith<BSONObj> IndexCatalogImpl::_fixIndexSpec(OperationContext* opCtx, Collection* collection, const BSONObj& spec) const { - auto statusWithSpec = IndexLegacy::adjustIndexSpecObject(spec); + auto statusWithSpec = adjustIndexSpecObject(spec); if (!statusWithSpec.isOK()) { return statusWithSpec; } diff --git a/src/mongo/db/index_legacy.cpp b/src/mongo/db/index_legacy.cpp deleted file mode 100644 index a18d4a9dc52..00000000000 --- a/src/mongo/db/index_legacy.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (C) 2018-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_legacy.h" - -#include <string> - -#include "mongo/db/fts/fts_spec.h" -#include "mongo/db/index/s2_access_method.h" -#include "mongo/db/index_names.h" -#include "mongo/db/jsobj.h" - -namespace mongo { - -// static -StatusWith<BSONObj> IndexLegacy::adjustIndexSpecObject(const BSONObj& obj) { - std::string pluginName = IndexNames::findPluginName(obj.getObjectField("key")); - - if (IndexNames::TEXT == pluginName) { - return fts::FTSSpec::fixSpec(obj); - } - - if (IndexNames::GEO_2DSPHERE == pluginName) { - return S2AccessMethod::fixSpec(obj); - } - - return obj; -} - -} // namespace mongo diff --git a/src/mongo/db/index_legacy.h b/src/mongo/db/index_legacy.h deleted file mode 100644 index 7ac6f8eb983..00000000000 --- a/src/mongo/db/index_legacy.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (C) 2018-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/base/status_with.h" -#include "mongo/db/jsobj.h" - -namespace mongo { - -/** - * There has been some behavior concerning indexed access patterns -- both pre and post-index - * construction -- that does not quite fit in the access pattern model implemented in - * index/index_access_pattern.h. Such behavior can't be changed in the current implementation of - * the code. - * - * We grouped such exception/legacy behavior here. - */ -class IndexLegacy { -public: - /** - * Adjust the provided index spec BSONObj depending on the type of index obj describes. - * - * This is a no-op unless the object describes a TEXT or a GEO_2DSPHERE index. TEXT and - * GEO_2DSPHERE provide additional validation on the index spec, and tweak the index spec - * object to conform to their expected format. - */ - static StatusWith<BSONObj> adjustIndexSpecObject(const BSONObj& obj); -}; - -} // namespace mongo diff --git a/src/mongo/db/query/collection_query_info.cpp b/src/mongo/db/query/collection_query_info.cpp index ccf86e6a759..9f24696ff21 100644 --- a/src/mongo/db/query/collection_query_info.cpp +++ b/src/mongo/db/query/collection_query_info.cpp @@ -44,7 +44,6 @@ #include "mongo/db/fts/fts_spec.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/index/wildcard_access_method.h" -#include "mongo/db/index_legacy.h" #include "mongo/db/query/get_executor.h" #include "mongo/db/query/plan_cache.h" #include "mongo/db/query/planner_ixselect.h" diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index c1a85567db0..ca6c5536583 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -52,7 +52,6 @@ env.Library( '$BUILD_DIR/mongo/db/db_raii', '$BUILD_DIR/mongo/db/dbdirectclient', '$BUILD_DIR/mongo/db/dbhelpers', - '$BUILD_DIR/mongo/db/index_d', '$BUILD_DIR/mongo/db/op_observer', '$BUILD_DIR/mongo/db/stats/counters', '$BUILD_DIR/mongo/db/stats/server_read_concern_write_concern_metrics', diff --git a/src/mongo/dbtests/SConscript b/src/mongo/dbtests/SConscript index 3ab33da12de..ab5707a053e 100644 --- a/src/mongo/dbtests/SConscript +++ b/src/mongo/dbtests/SConscript @@ -32,6 +32,7 @@ env.Library( LIBDEPS=[ '$BUILD_DIR/mongo/db/catalog/catalog_impl', '$BUILD_DIR/mongo/db/dbdirectclient', + '$BUILD_DIR/mongo/db/index/index_access_methods', '$BUILD_DIR/mongo/db/index_builds_coordinator_mongod', '$BUILD_DIR/mongo/db/op_observer', '$BUILD_DIR/mongo/db/service_context_d', diff --git a/src/mongo/embedded/SConscript b/src/mongo/embedded/SConscript index ef81c856a30..09da019b4a8 100644 --- a/src/mongo/embedded/SConscript +++ b/src/mongo/embedded/SConscript @@ -94,6 +94,7 @@ env.Library( '$BUILD_DIR/mongo/db/commands/mongod_fcv', '$BUILD_DIR/mongo/db/commands/standalone', '$BUILD_DIR/mongo/db/concurrency/lock_manager', + '$BUILD_DIR/mongo/db/index/index_access_methods', '$BUILD_DIR/mongo/db/index_builds_coordinator_interface', '$BUILD_DIR/mongo/db/logical_session_cache', '$BUILD_DIR/mongo/db/logical_session_cache_impl', |