summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_solution.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/query_solution.cpp')
-rw-r--r--src/mongo/db/query/query_solution.cpp48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/mongo/db/query/query_solution.cpp b/src/mongo/db/query/query_solution.cpp
index 80dc94b6b64..4f7c9b161e5 100644
--- a/src/mongo/db/query/query_solution.cpp
+++ b/src/mongo/db/query/query_solution.cpp
@@ -899,27 +899,39 @@ std::set<std::string> extractEqualityFields(
// If we have an IET for this field in our index bounds, we determine whether it
// guarantees that, upon evaluation, we will have point bounds for the corresponding
- // field in our index. In particular, if the IET evaluates to a ConstNode or an equality
- // EvalNode, then this field represents an equality.
+ // field in our index. In particular, if the IET evaluates to a ConstNode, an equality
+ // EvalNode, or an ExplodeNode, then this field represents an equality.
if (iets && !iets->empty()) {
const auto& iet = (*iets)[i];
- const auto* constNodePtr = iet.cast<interval_evaluation_tree::ConstNode>();
- const auto* evalNodePtr = iet.cast<interval_evaluation_tree::EvalNode>();
- const auto isEquality =
- evalNodePtr && evalNodePtr->matchType() == MatchExpression::MatchType::EQ;
- if (!constNodePtr && !isEquality)
- continue;
+ auto mustBePointInterval = [&]() {
+ if (const auto* constNode = iet.cast<interval_evaluation_tree::ConstNode>();
+ constNode) {
+ // If we have 'constNodePtr', it must be the case that the interval that it
+ // contains is the same as 'ival'.
+ tassert(7426201,
+ "'constNode' must have a single interval",
+ constNode->oil.intervals.size() == 1);
+ tassert(
+ 7426202,
+ "'constNode' must have the same point interval as the one in 'bounds'",
+ constNode->oil.intervals[0].equals(ival));
+ return true;
+ } else if (const auto* evalNode =
+ iet.cast<interval_evaluation_tree::EvalNode>();
+ evalNode) {
+ if (evalNode->matchType() == MatchExpression::MatchType::EQ) {
+ return true;
+ }
+ } else if (const auto* explodeNode =
+ iet.cast<interval_evaluation_tree::ExplodeNode>();
+ explodeNode) {
+ return true;
+ }
+ return false;
+ }();
- // If we have 'constNodePtr', it must be the case that the interval that it contains
- // is the same as 'ival'.
- if (constNodePtr) {
- tassert(7426201,
- "'constNodePtr' must have a single interval",
- constNodePtr->oil.intervals.size() == 1);
- tassert(
- 7426202,
- "'constNodePtr' must have the same point interval as the one in 'bounds'",
- constNodePtr->oil.intervals[0].equals(ival));
+ if (!mustBePointInterval) {
+ continue;
}
}
equalityFields.insert(oil.name);