summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorauto-revert-processor <dev-prod-dag@mongodb.com>2022-09-23 02:04:36 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-23 02:34:41 +0000
commit7645dbbe88354f09ee8d84dc393a899cd067bc71 (patch)
tree6ddd366d24ac43cf04c5426a5aaed6795d65c2b5
parent2d74f2a4806bbf113ed13a3cbbd022e628664420 (diff)
downloadmongo-7645dbbe88354f09ee8d84dc393a899cd067bc71.tar.gz
Revert "SERVER-69149 Make debug print of SBE expressions more readable"
This reverts commit fd15b0d0ef92e32bc3ce60742ffe6a5337269bff.
-rw-r--r--src/mongo/db/exec/sbe/expressions/expression.cpp47
-rw-r--r--src/mongo/db/exec/sbe/stages/union.cpp15
-rw-r--r--src/mongo/db/exec/sbe/util/debug_print.cpp11
3 files changed, 24 insertions, 49 deletions
diff --git a/src/mongo/db/exec/sbe/expressions/expression.cpp b/src/mongo/db/exec/sbe/expressions/expression.cpp
index 7176ce3e56a..d337cd8fa14 100644
--- a/src/mongo/db/exec/sbe/expressions/expression.cpp
+++ b/src/mongo/db/exec/sbe/expressions/expression.cpp
@@ -239,7 +239,6 @@ std::vector<DebugPrinter::Block> EPrimBinary::debugPrint() const {
invariant(!hasCollatorArg || isComparisonOp(_op));
- ret.emplace_back("(`");
DebugPrinter::addBlocks(ret, _nodes[0]->debugPrint());
switch (_op) {
@@ -293,7 +292,6 @@ std::vector<DebugPrinter::Block> EPrimBinary::debugPrint() const {
}
DebugPrinter::addBlocks(ret, _nodes[1]->debugPrint());
- ret.emplace_back("`)");
return ret;
}
@@ -337,9 +335,7 @@ std::vector<DebugPrinter::Block> EPrimUnary::debugPrint() const {
MONGO_UNREACHABLE;
}
- ret.emplace_back("`(`");
DebugPrinter::addBlocks(ret, _nodes[0]->debugPrint());
- ret.emplace_back("`)");
return ret;
}
@@ -737,7 +733,7 @@ std::vector<DebugPrinter::Block> EFunction::debugPrint() const {
std::vector<DebugPrinter::Block> ret;
DebugPrinter::addKeyword(ret, _name);
- ret.emplace_back("`(`");
+ ret.emplace_back("(`");
for (size_t idx = 0; idx < _nodes.size(); ++idx) {
if (idx) {
ret.emplace_back("`,");
@@ -784,24 +780,20 @@ vm::CodeFragment EIf::compileDirect(CompileCtx& ctx) const {
std::vector<DebugPrinter::Block> EIf::debugPrint() const {
std::vector<DebugPrinter::Block> ret;
+ DebugPrinter::addKeyword(ret, "if");
- ret.emplace_back(DebugPrinter::Block::cmdIncIndent);
+ ret.emplace_back("(`");
// Print the condition.
- DebugPrinter::addKeyword(ret, "if");
DebugPrinter::addBlocks(ret, _nodes[0]->debugPrint());
- DebugPrinter::addNewLine(ret);
-
+ ret.emplace_back("`,");
// Print thenBranch.
- DebugPrinter::addKeyword(ret, "then");
DebugPrinter::addBlocks(ret, _nodes[1]->debugPrint());
- DebugPrinter::addNewLine(ret);
-
+ ret.emplace_back("`,");
// Print elseBranch.
- DebugPrinter::addKeyword(ret, "else");
DebugPrinter::addBlocks(ret, _nodes[2]->debugPrint());
- ret.emplace_back(DebugPrinter::Block::cmdDecIndent);
+ ret.emplace_back("`)");
return ret;
}
@@ -844,30 +836,22 @@ vm::CodeFragment ELocalBind::compileDirect(CompileCtx& ctx) const {
std::vector<DebugPrinter::Block> ELocalBind::debugPrint() const {
std::vector<DebugPrinter::Block> ret;
- ret.emplace_back(DebugPrinter::Block::cmdIncIndent);
-
DebugPrinter::addKeyword(ret, "let");
- ret.emplace_back("[`");
- ret.emplace_back(DebugPrinter::Block::cmdIncIndent);
+ ret.emplace_back("[`");
for (size_t idx = 0; idx < _nodes.size() - 1; ++idx) {
if (idx != 0) {
- DebugPrinter::addNewLine(ret);
+ ret.emplace_back("`,");
}
DebugPrinter::addIdentifier(ret, _frameId, idx);
ret.emplace_back("=");
DebugPrinter::addBlocks(ret, _nodes[idx]->debugPrint());
}
- ret.emplace_back(DebugPrinter::Block::cmdDecIndent);
- ret.emplace_back("]");
- DebugPrinter::addNewLine(ret);
+ ret.emplace_back("`]");
- DebugPrinter::addKeyword(ret, "in");
DebugPrinter::addBlocks(ret, _nodes.back()->debugPrint());
- ret.emplace_back(DebugPrinter::Block::cmdDecIndent);
-
return ret;
}
@@ -912,13 +896,10 @@ vm::CodeFragment ELocalLambda::compileDirect(CompileCtx& ctx) const {
std::vector<DebugPrinter::Block> ELocalLambda::debugPrint() const {
std::vector<DebugPrinter::Block> ret;
- DebugPrinter::addKeyword(ret, "lambda");
- ret.emplace_back("`(`");
+ DebugPrinter::addKeyword(ret, "\\");
DebugPrinter::addIdentifier(ret, _frameId, 0);
- ret.emplace_back("`)");
- ret.emplace_back("{");
+ ret.emplace_back(".");
DebugPrinter::addBlocks(ret, _nodes.back()->debugPrint());
- ret.emplace_back("}");
return ret;
}
@@ -949,13 +930,11 @@ std::vector<DebugPrinter::Block> EFail::debugPrint() const {
std::vector<DebugPrinter::Block> ret;
DebugPrinter::addKeyword(ret, "fail");
- ret.emplace_back("`(`");
+ ret.emplace_back("(");
ret.emplace_back(std::to_string(_code));
- ret.emplace_back("`,");
- ret.emplace_back("\"`");
+ ret.emplace_back(",`");
ret.emplace_back(getStringView(_messageTag, _messageVal));
- ret.emplace_back("`\"`");
ret.emplace_back("`)");
diff --git a/src/mongo/db/exec/sbe/stages/union.cpp b/src/mongo/db/exec/sbe/stages/union.cpp
index 9d619f2f505..2fd6d0b4fc5 100644
--- a/src/mongo/db/exec/sbe/stages/union.cpp
+++ b/src/mongo/db/exec/sbe/stages/union.cpp
@@ -27,9 +27,9 @@
* it in the license file.
*/
-#include "mongo/db/exec/sbe/stages/union.h"
+#include "mongo/platform/basic.h"
-#include <fmt/format.h>
+#include "mongo/db/exec/sbe/stages/union.h"
#include "mongo/db/exec/sbe/expressions/expression.h"
#include "mongo/db/exec/sbe/size_estimator.h"
@@ -197,10 +197,9 @@ std::vector<DebugPrinter::Block> UnionStage::debugPrint() const {
}
ret.emplace_back(DebugPrinter::Block("`]"));
+ ret.emplace_back(DebugPrinter::Block("[`"));
ret.emplace_back(DebugPrinter::Block::cmdIncIndent);
for (size_t childNum = 0; childNum < _children.size(); childNum++) {
- DebugPrinter::addKeyword(ret, "branch{}"_format(childNum));
-
ret.emplace_back(DebugPrinter::Block("[`"));
for (size_t idx = 0; idx < _inputVals[childNum].size(); idx++) {
if (idx) {
@@ -210,11 +209,15 @@ std::vector<DebugPrinter::Block> UnionStage::debugPrint() const {
}
ret.emplace_back(DebugPrinter::Block("`]"));
- ret.emplace_back(DebugPrinter::Block::cmdIncIndent);
DebugPrinter::addBlocks(ret, _children[childNum]->debugPrint());
- ret.emplace_back(DebugPrinter::Block::cmdDecIndent);
+
+ if (childNum + 1 < _children.size()) {
+ ret.emplace_back(DebugPrinter::Block(","));
+ DebugPrinter::addNewLine(ret);
+ }
}
ret.emplace_back(DebugPrinter::Block::cmdDecIndent);
+ ret.emplace_back(DebugPrinter::Block("`]"));
return ret;
}
diff --git a/src/mongo/db/exec/sbe/util/debug_print.cpp b/src/mongo/db/exec/sbe/util/debug_print.cpp
index c4b210e9a7a..e3d831b5ab5 100644
--- a/src/mongo/db/exec/sbe/util/debug_print.cpp
+++ b/src/mongo/db/exec/sbe/util/debug_print.cpp
@@ -38,7 +38,6 @@ namespace sbe {
std::string DebugPrinter::print(const std::vector<Block>& blocks) {
std::string ret;
int ident = 0;
- size_t blockIndex = 0;
for (auto& b : blocks) {
bool addSpace = true;
switch (b.cmd) {
@@ -49,13 +48,8 @@ std::string DebugPrinter::print(const std::vector<Block>& blocks) {
break;
case Block::cmdDecIndent:
--ident;
- // Avoid unnecessary whitespace if there are multiple adjacent "decrement indent"
- // tokens.
- if (blockIndex == blocks.size() ||
- blocks[blockIndex + 1].cmd != Block::cmdDecIndent) {
- ret.append("\n");
- addIndent(ident, ret);
- }
+ ret.append("\n");
+ addIndent(ident, ret);
break;
case Block::cmdNewLine:
ret.append("\n");
@@ -117,7 +111,6 @@ std::string DebugPrinter::print(const std::vector<Block>& blocks) {
}
}
}
- ++blockIndex;
}
return ret;