summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSvilen Mihaylov <svilen.mihaylov@mongodb.com>2022-04-13 13:23:21 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-13 14:11:46 +0000
commit626ecededd30e64636003dd434e25d69551fdc30 (patch)
treed1032e420035e2ceb266ca03c29f7fa554e3dcab
parent3956cbffd669f9ceeeb0733730aa0b643e3bcc35 (diff)
downloadmongo-626ecededd30e64636003dd434e25d69551fdc30.tar.gz
SERVER-65419 Fix generation of ABT hashes for types with unordered maps
-rw-r--r--src/mongo/db/pipeline/abt/field_map_builder.cpp4
-rw-r--r--src/mongo/db/query/optimizer/explain.cpp20
-rw-r--r--src/mongo/db/query/optimizer/index_bounds.h2
-rw-r--r--src/mongo/db/query/optimizer/rewrites/path.cpp2
-rw-r--r--src/mongo/db/query/optimizer/syntax/path.h4
-rw-r--r--src/mongo/db/query/optimizer/utils/utils.cpp8
-rw-r--r--src/mongo/db/query/optimizer/utils/utils.h3
7 files changed, 10 insertions, 33 deletions
diff --git a/src/mongo/db/pipeline/abt/field_map_builder.cpp b/src/mongo/db/pipeline/abt/field_map_builder.cpp
index eb585e7c8a1..e69bf8d938a 100644
--- a/src/mongo/db/pipeline/abt/field_map_builder.cpp
+++ b/src/mongo/db/pipeline/abt/field_map_builder.cpp
@@ -92,10 +92,10 @@ ABT FieldMapBuilder::generateABTForField(const FieldMapEntry& entry) const {
maybeComposePath(result, make<PathObj>());
}
if (!keepSet.empty()) {
- maybeComposePath(result, make<PathKeep>(toUnorderedFieldNameSet(std::move(keepSet))));
+ maybeComposePath(result, make<PathKeep>(std::move(keepSet)));
}
if (!dropSet.empty()) {
- maybeComposePath(result, make<PathDrop>(toUnorderedFieldNameSet(std::move(dropSet))));
+ maybeComposePath(result, make<PathDrop>(std::move(dropSet)));
}
for (const auto& varMapEntry : varMap) {
diff --git a/src/mongo/db/query/optimizer/explain.cpp b/src/mongo/db/query/optimizer/explain.cpp
index 30491bcaabe..f98c016cf94 100644
--- a/src/mongo/db/query/optimizer/explain.cpp
+++ b/src/mongo/db/query/optimizer/explain.cpp
@@ -1050,14 +1050,9 @@ public:
static_assert("Unknown version");
}
- std::set<std::string> orderedIndexDefName;
- for (const auto& entry : node.getCandidateIndexMap()) {
- orderedIndexDefName.insert(entry.first);
- }
-
std::vector<ExplainPrinter> candidateIndexesPrinters;
size_t candidateIndex = 0;
- for (const auto& indexDefName : orderedIndexDefName) {
+ for (const auto& [indexDefName, candidateIndexEntry] : node.getCandidateIndexMap()) {
candidateIndex++;
ExplainPrinter local;
local.fieldName("candidateId")
@@ -1067,7 +1062,6 @@ public:
.print(indexDefName)
.separator(", ");
- const auto& candidateIndexEntry = node.getCandidateIndexMap().at(indexDefName);
local.separator("{");
printFieldProjectionMap(local, candidateIndexEntry._fieldProjectionMap);
local.separator("}, {");
@@ -2029,16 +2023,10 @@ public:
return printer;
}
- static void printPathProjections(ExplainPrinter& printer,
- const opt::unordered_set<std::string>& names) {
- std::set<std::string> ordered;
- for (const std::string& s : names) {
- ordered.insert(s);
- }
-
+ static void printPathProjections(ExplainPrinter& printer, const std::set<std::string>& names) {
if constexpr (version < ExplainVersion::V3) {
bool first = true;
- for (const std::string& s : ordered) {
+ for (const std::string& s : names) {
if (first) {
first = false;
} else {
@@ -2048,7 +2036,7 @@ public:
}
} else if constexpr (version == ExplainVersion::V3) {
std::vector<ExplainPrinter> printers;
- for (const std::string& s : ordered) {
+ for (const std::string& s : names) {
ExplainPrinter local;
local.print(s);
printers.push_back(std::move(local));
diff --git a/src/mongo/db/query/optimizer/index_bounds.h b/src/mongo/db/query/optimizer/index_bounds.h
index 010285172e0..7acdeec5767 100644
--- a/src/mongo/db/query/optimizer/index_bounds.h
+++ b/src/mongo/db/query/optimizer/index_bounds.h
@@ -174,7 +174,7 @@ struct CandidateIndexEntry {
size_t _intervalPrefixSize;
};
-using CandidateIndexMap = opt::unordered_map<std::string /*index name*/, CandidateIndexEntry>;
+using CandidateIndexMap = std::map<std::string /*index name*/, CandidateIndexEntry>;
class IndexSpecification {
public:
diff --git a/src/mongo/db/query/optimizer/rewrites/path.cpp b/src/mongo/db/query/optimizer/rewrites/path.cpp
index a7af2f59d8b..d74c5c05fc8 100644
--- a/src/mongo/db/query/optimizer/rewrites/path.cpp
+++ b/src/mongo/db/query/optimizer/rewrites/path.cpp
@@ -315,7 +315,7 @@ void PathFusion::tryFuseComposition(ABT& n, const ABT& input) {
opt::unordered_map<FieldNameType, ABT> fieldMap;
// Used to preserve the relative order in which fields are set on the result.
FieldPathType orderedFieldNames;
- boost::optional<opt::unordered_set<FieldNameType>> toKeep;
+ boost::optional<std::set<FieldNameType>> toKeep;
Type inputType = Type::any;
if (auto constPtr = input.cast<Constant>(); constPtr != nullptr && constPtr->isObject()) {
diff --git a/src/mongo/db/query/optimizer/syntax/path.h b/src/mongo/db/query/optimizer/syntax/path.h
index 4f6ec8775b4..bcfea8ae07d 100644
--- a/src/mongo/db/query/optimizer/syntax/path.h
+++ b/src/mongo/db/query/optimizer/syntax/path.h
@@ -156,7 +156,7 @@ public:
*/
class PathDrop final : public Operator<PathDrop, 0>, public PathSyntaxSort {
public:
- using NameSet = opt::unordered_set<std::string>;
+ using NameSet = std::set<std::string>;
PathDrop(NameSet inNames) : _names(std::move(inNames)) {}
@@ -178,7 +178,7 @@ private:
*/
class PathKeep final : public Operator<PathKeep, 0>, public PathSyntaxSort {
public:
- using NameSet = opt::unordered_set<std::string>;
+ using NameSet = std::set<std::string>;
PathKeep(NameSet inNames) : _names(std::move(inNames)) {}
diff --git a/src/mongo/db/query/optimizer/utils/utils.cpp b/src/mongo/db/query/optimizer/utils/utils.cpp
index 933dda604fd..9b4f581a1fc 100644
--- a/src/mongo/db/query/optimizer/utils/utils.cpp
+++ b/src/mongo/db/query/optimizer/utils/utils.cpp
@@ -81,14 +81,6 @@ ProjectionNameOrderedSet convertToOrderedSet(ProjectionNameSet unordered) {
return ordered;
}
-opt::unordered_set<FieldNameType> toUnorderedFieldNameSet(std::set<FieldNameType> set) {
- opt::unordered_set<FieldNameType> result;
- for (auto&& fieldName : set) {
- result.emplace(std::move(fieldName));
- }
- return result;
-}
-
void combineLimitSkipProperties(properties::LimitSkipRequirement& aboveProp,
const properties::LimitSkipRequirement& belowProp) {
using namespace properties;
diff --git a/src/mongo/db/query/optimizer/utils/utils.h b/src/mongo/db/query/optimizer/utils/utils.h
index 12efe684882..a42fd47714b 100644
--- a/src/mongo/db/query/optimizer/utils/utils.h
+++ b/src/mongo/db/query/optimizer/utils/utils.h
@@ -96,9 +96,6 @@ private:
ProjectionNameOrderedSet convertToOrderedSet(ProjectionNameSet unordered);
-opt::unordered_set<FieldNameType> toUnorderedFieldNameSet(std::set<FieldNameType> set);
-
-
void combineLimitSkipProperties(properties::LimitSkipRequirement& aboveProp,
const properties::LimitSkipRequirement& belowProp);