summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/rewrite_expr.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/matcher/rewrite_expr.h')
-rw-r--r--src/mongo/db/matcher/rewrite_expr.h35
1 files changed, 7 insertions, 28 deletions
diff --git a/src/mongo/db/matcher/rewrite_expr.h b/src/mongo/db/matcher/rewrite_expr.h
index 08e7d82d23d..1752c9726b8 100644
--- a/src/mongo/db/matcher/rewrite_expr.h
+++ b/src/mongo/db/matcher/rewrite_expr.h
@@ -42,20 +42,14 @@ namespace mongo {
class RewriteExpr final {
public:
/**
- * Holds the result of an Expression rewrite operation. $expr expressions can't take advantage
- * of indexes. When we rewrite the expressions as a conjunction of internal match expressions,
- * the query planner can now use the internal match expressions to potentially generate an index
- * scan. We use internal match expressions that are non-type bracketed to match non-type
- * bracketed comparison operators inside $expr.
+ * Holds the result of an Expression rewrite operation.
*/
class RewriteResult final {
public:
RewriteResult(std::unique_ptr<MatchExpression> matchExpression,
- std::vector<BSONObj> matchExprElemStorage,
- bool allSubExpressionsRewritten)
+ std::vector<BSONObj> matchExprElemStorage)
: _matchExpression(std::move(matchExpression)),
- _matchExprElemStorage(std::move(matchExprElemStorage)),
- _allSubExpressionsRewritten(allSubExpressionsRewritten) {}
+ _matchExprElemStorage(std::move(matchExprElemStorage)) {}
MatchExpression* matchExpression() const {
return _matchExpression.get();
@@ -67,11 +61,7 @@ public:
RewriteResult clone() const {
auto clonedMatch = _matchExpression ? _matchExpression->shallowClone() : nullptr;
- return {std::move(clonedMatch), _matchExprElemStorage, _allSubExpressionsRewritten};
- }
-
- bool allSubExpressionsRewritten() {
- return _allSubExpressionsRewritten;
+ return {std::move(clonedMatch), _matchExprElemStorage};
}
private:
@@ -81,22 +71,12 @@ public:
// owned and expected to outlive the MatchExpression. '_matchExprElemStorage' holds the
// underlying BSONObj storage for these arguments.
std::vector<BSONObj> _matchExprElemStorage;
-
- // Defaults to true, is false if there is a child in an $or/$and expression that
- // contains children that cannot be rewritten to a MatchExpression.
- bool _allSubExpressionsRewritten = true;
};
/**
- * Attempts to construct a MatchExpression that will match against either an identical set
- * or a superset of the documents matched by 'expr'. Due to semantic differences the
- * rewritten MatchExpression might match more documents than the ExprMatchExpression. For
- * example,
- * $_internalExprEq in MatchExpression reaches into arrays, and $eq in ExprMatchExpression
- * does not. However, $_internalExprLt/$_internalExprGt are non-type bracketed for
- * MatchExpression, just like ExprMatchExpressions. Returns the MatchExpression as a
- * RewriteResult. If a rewrite is not possible, RewriteResult::matchExpression() will return
- * a nullptr.
+ * Attempts to construct a MatchExpression that will match against either an identical set or a
+ * superset of the documents matched by 'expr'. Returns the MatchExpression as a RewriteResult.
+ * If a rewrite is not possible, RewriteResult::matchExpression() will return a nullptr.
*/
static RewriteResult rewrite(const boost::intrusive_ptr<Expression>& expr,
const CollatorInterface* collator);
@@ -127,7 +107,6 @@ private:
std::vector<BSONObj> _matchExprElemStorage;
const CollatorInterface* _collator;
- bool _allSubExpressionsRewritten = true;
};
} // namespace mongo