diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2019-02-20 13:47:50 +0000 |
---|---|---|
committer | Sara Golemon <sara.golemon@mongodb.com> | 2019-02-22 23:57:25 +0000 |
commit | be68e9b78da63075c9b82304ea27ae4725fe894c (patch) | |
tree | aac25ab5b3d1e460ec9966627d66860b63ebda15 /src/mongo/db/query | |
parent | e52798e022f0c46624e6ddebbbc17200d7cc6a80 (diff) | |
download | mongo-be68e9b78da63075c9b82304ea27ae4725fe894c.tar.gz |
SERVER-39537 Migrate expression_index_knobs to IDL
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r-- | src/mongo/db/query/SConscript | 6 | ||||
-rw-r--r-- | src/mongo/db/query/expression_index.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/query/expression_index_knobs.cpp | 45 | ||||
-rw-r--r-- | src/mongo/db/query/expression_index_knobs.h | 63 | ||||
-rw-r--r-- | src/mongo/db/query/expression_index_knobs.idl | 63 | ||||
-rw-r--r-- | src/mongo/db/query/index_bounds_builder.cpp | 4 |
6 files changed, 73 insertions, 116 deletions
diff --git a/src/mongo/db/query/SConscript b/src/mongo/db/query/SConscript index 4f386a8659a..16d3baecff1 100644 --- a/src/mongo/db/query/SConscript +++ b/src/mongo/db/query/SConscript @@ -30,7 +30,6 @@ env.Library( "planner_ixselect.cpp", "query_planner.cpp", "expression_index.cpp", - "expression_index_knobs.cpp", "index_bounds.cpp", "index_bounds_builder.cpp", "index_entry.cpp", @@ -38,6 +37,7 @@ env.Library( "query_planner_common.cpp", "query_settings.cpp", "query_solution.cpp", + env.Idlc("expression_index_knobs.idl")[0], ], LIBDEPS=[ "$BUILD_DIR/mongo/base", @@ -47,12 +47,14 @@ env.Library( "$BUILD_DIR/mongo/db/index_names", "$BUILD_DIR/mongo/db/matcher/expressions", "$BUILD_DIR/mongo/db/mongohasher", - "$BUILD_DIR/mongo/db/server_parameters", "collation/collator_factory_interface", "collation/collator_interface", "command_request_response", "query_knobs", ], + LIBDEPS_PRIVATE=[ + "$BUILD_DIR/mongo/idl/server_parameter", + ], ) env.CppUnitTest( diff --git a/src/mongo/db/query/expression_index.cpp b/src/mongo/db/query/expression_index.cpp index 9d563d918e6..0e37c62567e 100644 --- a/src/mongo/db/query/expression_index.cpp +++ b/src/mongo/db/query/expression_index.cpp @@ -36,7 +36,7 @@ #include "mongo/db/geo/r2_region_coverer.h" #include "mongo/db/hasher.h" #include "mongo/db/index/expression_params.h" -#include "mongo/db/query/expression_index_knobs.h" +#include "mongo/db/query/expression_index_knobs_gen.h" #include "mongo/db/server_parameters.h" #include "third_party/s2/s2cellid.h" #include "third_party/s2/s2region.h" @@ -110,8 +110,8 @@ void ExpressionMapping::cover2d(const R2Region& region, } std::vector<S2CellId> ExpressionMapping::get2dsphereCovering(const S2Region& region) { - auto minLevel = internalQueryS2GeoCoarsestLevel.load(); - auto maxLevel = internalQueryS2GeoFinestLevel.load(); + auto minLevel = gInternalQueryS2GeoCoarsestLevel.load(); + auto maxLevel = gInternalQueryS2GeoFinestLevel.load(); uassert(28739, "Geo coarsest level must be in range [0,30]", 0 <= minLevel && minLevel <= 30); uassert(28740, "Geo finest level must be in range [0,30]", 0 <= maxLevel && maxLevel <= 30); @@ -120,7 +120,7 @@ std::vector<S2CellId> ExpressionMapping::get2dsphereCovering(const S2Region& reg S2RegionCoverer coverer; coverer.set_min_level(minLevel); coverer.set_max_level(maxLevel); - coverer.set_max_cells(internalQueryS2GeoMaxCells.load()); + coverer.set_max_cells(gInternalQueryS2GeoMaxCells.load()); std::vector<S2CellId> cover; coverer.GetCovering(region, &cover); diff --git a/src/mongo/db/query/expression_index_knobs.cpp b/src/mongo/db/query/expression_index_knobs.cpp deleted file mode 100644 index 800172c18ba..00000000000 --- a/src/mongo/db/query/expression_index_knobs.cpp +++ /dev/null @@ -1,45 +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/db/query/expression_index_knobs.h" -#include "mongo/db/server_options.h" -#include "mongo/db/server_parameters.h" - -namespace mongo { - -MONGO_EXPORT_SERVER_PARAMETER(internalGeoPredicateQuery2DMaxCoveringCells, int, 16); - -MONGO_EXPORT_SERVER_PARAMETER(internalGeoNearQuery2DMaxCoveringCells, int, 16); - -// At level 23 the average cell length is about 1m. -MONGO_EXPORT_SERVER_PARAMETER(internalQueryS2GeoFinestLevel, int, 23); -MONGO_EXPORT_SERVER_PARAMETER(internalQueryS2GeoCoarsestLevel, int, 0); -MONGO_EXPORT_SERVER_PARAMETER(internalQueryS2GeoMaxCells, int, 20); - -} // namespace mongo diff --git a/src/mongo/db/query/expression_index_knobs.h b/src/mongo/db/query/expression_index_knobs.h deleted file mode 100644 index a7e348e98a7..00000000000 --- a/src/mongo/db/query/expression_index_knobs.h +++ /dev/null @@ -1,63 +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/platform/atomic_word.h" - -namespace mongo { - -// -// Geo Query knobs -// - -/** - * The maximum number of cells to use for 2D geo query covering for predicate queries - */ -extern AtomicWord<int> internalGeoPredicateQuery2DMaxCoveringCells; - -/** - * The maximum number of cells to use for 2D geo query covering for predicate queries - */ -extern AtomicWord<int> internalGeoNearQuery2DMaxCoveringCells; - -// -// Geo query. -// - -// What is the finest level we will cover a queried region or geoNear annulus? -extern AtomicWord<int> internalQueryS2GeoFinestLevel; - -// What is the coarsest level we will cover a queried region or geoNear annulus? -extern AtomicWord<int> internalQueryS2GeoCoarsestLevel; - -// What is the maximum cell count that we want? (advisory, not a hard threshold) -extern AtomicWord<int> internalQueryS2GeoMaxCells; - -} // namespace mongo diff --git a/src/mongo/db/query/expression_index_knobs.idl b/src/mongo/db/query/expression_index_knobs.idl new file mode 100644 index 00000000000..6255ea8c2c7 --- /dev/null +++ b/src/mongo/db/query/expression_index_knobs.idl @@ -0,0 +1,63 @@ +# 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. +# + +global: + cpp_namespace: "mongo" + +server_parameters: + internalGeoPredicateQuery2DMaxCoveringCells: + description: 'Maximum number of cells to use for 2D geo query covering for predicate queries' + set_at: [ startup, runtime ] + cpp_vartype: 'AtomicWord<int>' + cpp_varname: gInternalGeoPredicateQuery2DMaxCoveringCells + default: 16 + internalGeoNearQuery2DMaxCoveringCells: + description: 'Maximum number of cells to use for 2D geo query covering for near queries' + set_at: [ startup, runtime ] + cpp_vartype: 'AtomicWord<int>' + cpp_varname: gInternalGeoNearQuery2DMaxCoveringCells + default: 16 + internalQueryS2GeoFinestLevel: + description: 'Finest level we will cover a queried region or geoNear annulus' + set_at: [ startup, runtime ] + cpp_vartype: 'AtomicWord<int>' + cpp_varname: gInternalQueryS2GeoFinestLevel + default: 23 + internalQueryS2GeoCoarsestLevel: + description: 'Coarsest level we will cover a queried region or geoNear annulus' + set_at: [ startup, runtime ] + cpp_vartype: 'AtomicWord<int>' + cpp_varname: gInternalQueryS2GeoCoarsestLevel + default: 0 + internalQueryS2GeoMaxCells: + description: 'Maximum cell count that we want? (advisory, not a hard threshold)' + set_at: [ startup, runtime ] + cpp_vartype: 'AtomicWord<int>' + cpp_varname: gInternalQueryS2GeoMaxCells + default: 20 + diff --git a/src/mongo/db/query/index_bounds_builder.cpp b/src/mongo/db/query/index_bounds_builder.cpp index 9f0d452eb68..f6e1a3841dc 100644 --- a/src/mongo/db/query/index_bounds_builder.cpp +++ b/src/mongo/db/query/index_bounds_builder.cpp @@ -44,7 +44,7 @@ #include "mongo/db/query/collation/collation_index_key.h" #include "mongo/db/query/collation/collator_interface.h" #include "mongo/db/query/expression_index.h" -#include "mongo/db/query/expression_index_knobs.h" +#include "mongo/db/query/expression_index_knobs_gen.h" #include "mongo/db/query/indexability.h" #include "mongo/db/query/planner_ixselect.h" #include "mongo/db/query/planner_wildcard_helpers.h" @@ -729,7 +729,7 @@ void IndexBoundsBuilder::_translatePredicate(const MatchExpression* expr, const R2Region& region = gme->getGeoExpression().getGeometry().getR2Region(); ExpressionMapping::cover2d( - region, index.infoObj, internalGeoPredicateQuery2DMaxCoveringCells.load(), oilOut); + region, index.infoObj, gInternalGeoPredicateQuery2DMaxCoveringCells.load(), oilOut); *tightnessOut = IndexBoundsBuilder::INEXACT_FETCH; } else { |