summaryrefslogtreecommitdiff
path: root/src/mongo/db/query
diff options
context:
space:
mode:
authorHirday Gupta <hirday.gupta@mongodb.com>2020-07-15 19:58:13 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-15 21:06:43 +0000
commitccb6a8f132dd7de2ae614f339d0e6feec89e8ef2 (patch)
tree3a96a280f41d271e2f1f7896b76fd0cf85a4f687 /src/mongo/db/query
parent539174781bb60161004d0e6b65321cb8d2de5452 (diff)
downloadmongo-ccb6a8f132dd7de2ae614f339d0e6feec89e8ef2.tar.gz
SERVER-49124 translate $not to SBE expression
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r--src/mongo/db/query/sbe_stage_builder_expression.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/mongo/db/query/sbe_stage_builder_expression.cpp b/src/mongo/db/query/sbe_stage_builder_expression.cpp
index 4a6312ad707..4ed687eac13 100644
--- a/src/mongo/db/query/sbe_stage_builder_expression.cpp
+++ b/src/mongo/db/query/sbe_stage_builder_expression.cpp
@@ -183,8 +183,8 @@ struct ExpressionVisitorContext {
/**
* Generate an EExpression that converts a value (contained in a variable bound to 'branchRef') that
- * can be of any type to a Boolean value based on MQL's definition of truth for the branch of a
- * "$and" or "$or" expression.
+ * can be of any type to a Boolean value based on MQL's definition of truth for the branch of any
+ * logical expression.
*/
std::unique_ptr<sbe::EExpression> generateExpressionForLogicBranch(sbe::EVariable branchRef) {
// Make an expression that compares the value in 'branchRef' to the result of evaluating the
@@ -199,7 +199,7 @@ std::unique_ptr<sbe::EExpression> generateExpressionForLogicBranch(sbe::EVariabl
};
// If any of these are false, the branch is considered false for the purposes of the
- // $and/$or.
+ // any logical expression.
auto checkExists = sbe::makeE<sbe::EFunction>("exists", sbe::makeEs(branchRef.clone()));
auto checkNotNull = sbe::makeE<sbe::EPrimUnary>(
sbe::EPrimUnary::logicNot,
@@ -952,7 +952,14 @@ public:
unsupportedExpression(expr->getOpName());
}
void visit(ExpressionNot* expr) final {
- unsupportedExpression(expr->getOpName());
+ auto frameId = _context->frameIdGenerator->generate();
+ auto binds = sbe::makeEs(_context->popExpr());
+
+ auto notExpr = sbe::makeE<sbe::EPrimUnary>(sbe::EPrimUnary::logicNot,
+ generateExpressionForLogicBranch({frameId, 0}));
+
+ _context->pushExpr(
+ sbe::makeE<sbe::ELocalBind>(frameId, std::move(binds), std::move(notExpr)));
}
void visit(ExpressionObject* expr) final {
unsupportedExpression("$object");