diff options
author | James Wahlin <james@mongodb.com> | 2017-09-28 12:21:30 -0400 |
---|---|---|
committer | James Wahlin <james@mongodb.com> | 2017-10-10 16:39:06 -0400 |
commit | 2f3b96e636329b68809bc63b681a862e3d3bccd5 (patch) | |
tree | 93294474137e9607b145c3a9abab01dc84543110 /src/mongo/db/matcher/rewrite_expr.cpp | |
parent | 0ef1d6ec05798f3dae9b838ad8a8fffdd7ec4990 (diff) | |
download | mongo-2f3b96e636329b68809bc63b681a862e3d3bccd5.tar.gz |
SERVER-30989 Add Expression rewrite to ExprMatchExpression
Diffstat (limited to 'src/mongo/db/matcher/rewrite_expr.cpp')
-rw-r--r-- | src/mongo/db/matcher/rewrite_expr.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mongo/db/matcher/rewrite_expr.cpp b/src/mongo/db/matcher/rewrite_expr.cpp index d5d0e4605ac..304a850f592 100644 --- a/src/mongo/db/matcher/rewrite_expr.cpp +++ b/src/mongo/db/matcher/rewrite_expr.cpp @@ -40,20 +40,20 @@ namespace mongo { using CmpOp = ExpressionCompare::CmpOp; -RewriteExpr::RewriteResult RewriteExpr::rewrite( - const boost::intrusive_ptr<Expression>& expression) { +RewriteExpr::RewriteResult RewriteExpr::rewrite(const boost::intrusive_ptr<Expression>& expression, + const CollatorInterface* collator) { LOG(5) << "Expression prior to rewrite: " << expression->serialize(false); - RewriteExpr rewriteExpr; + RewriteExpr rewriteExpr(collator); std::unique_ptr<MatchExpression> matchExpression; if (auto matchTree = rewriteExpr._rewriteExpression(expression)) { matchExpression = std::move(matchTree); LOG(5) << "Post-rewrite MatchExpression: " << matchExpression->toString(); + matchExpression = MatchExpression::optimize(std::move(matchExpression)); + LOG(5) << "Post-rewrite/post-optimized MatchExpression: " << matchExpression->toString(); } - // TODO SERVER-30989: Optimize via MatchExpression::optimize(). - return {std::move(matchExpression), std::move(rewriteExpr._matchExprStringStorage), std::move(rewriteExpr._matchExprElemStorage)}; @@ -151,6 +151,7 @@ std::unique_ptr<MatchExpression> RewriteExpr::_rewriteInExpression( inValues.elems(elementList); auto matchInExpr = stdx::make_unique<InMatchExpression>(); + matchInExpr->setCollator(_collator); uassertStatusOK(matchInExpr->init(fieldPath)); uassertStatusOK(matchInExpr->setEqualities(elementList)); @@ -254,6 +255,7 @@ std::unique_ptr<MatchExpression> RewriteExpr::_buildComparisonMatchExpression( } uassertStatusOK(compMatchExpr->init(fieldAndValue.fieldName(), fieldAndValue)); + compMatchExpr->setCollator(_collator); if (notMatchExpr) { uassertStatusOK(notMatchExpr->init(compMatchExpr.release())); |