This is an automated email from the ASF dual-hosted git repository. xingtanzjr pushed a commit to branch yanshi in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 30f047ed8f7ae9307217e9da2c927182bc0d7328 Author: Jinrui.Zhang <[email protected]> AuthorDate: Tue Mar 29 17:46:15 2022 +0800 fix the bug of PlanNodeVisualizer --- .../sql/planner/plan/node/PlanNodeVisualizer.java | 42 +++++++++++----------- .../planner/plan/node/process/TimeJoinNode.java | 2 +- .../iotdb/db/mpp/sql/plan/QueryPlannerTest.java | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/PlanNodeVisualizer.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/PlanNodeVisualizer.java index 8dc7220..cc2e137 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/PlanNodeVisualizer.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/PlanNodeVisualizer.java @@ -42,8 +42,9 @@ public class PlanNodeVisualizer { private int boxWidth; private int lineWidth; private List<String> lines; - private int leftIndent; - private int lastCharPosition; + private int startPosition; + private int endPosition; + private int midPosition; public Box(PlanNode node) { this.node = node; @@ -114,8 +115,9 @@ public class PlanNodeVisualizer { } childrenWidth += box.children.size() > 1 ? box.children.size() - 1 : 0; box.lineWidth = Math.max(box.boxWidth, childrenWidth); - box.leftIndent = (box.lineWidth - box.boxWidth) / 2; - box.lastCharPosition = box.leftIndent + box.boxWidth - 1; + box.startPosition = (box.lineWidth - box.boxWidth) / 2; + box.endPosition = box.startPosition + box.boxWidth - 1; + box.midPosition = box.lineWidth / 2 - 1; } private static void buildBoxLines(Box box) { @@ -124,20 +126,20 @@ public class PlanNodeVisualizer { for (String valueLine : box.node.getBoxString()) { StringBuilder line = new StringBuilder(); for (int i = 0; i < box.lineWidth; i++) { - if (i < box.leftIndent) { + if (i < box.startPosition) { line.append(INDENT); continue; } - if (i > box.lastCharPosition) { + if (i > box.endPosition) { line.append(INDENT); continue; } - if (i == box.leftIndent || i == box.lastCharPosition) { + if (i == box.startPosition || i == box.endPosition) { line.append(SHU); continue; } - if (i - box.leftIndent - 1 < valueLine.length()) { - line.append(valueLine.charAt(i - box.leftIndent - 1)); + if (i - box.startPosition - 1 < valueLine.length()) { + line.append(valueLine.charAt(i - box.startPosition - 1)); } else { line.append(INDENT); } @@ -152,12 +154,11 @@ public class PlanNodeVisualizer { } // Print Connection Line - int shangPosition = box.lineWidth / 2 - 1; if (box.children.size() == 1) { for (int i = 0; i < 2; i++) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < box.lineWidth; j ++) { - if (j == shangPosition) { + if (j == box.midPosition) { sb.append(SHU); } else { sb.append(INDENT); @@ -167,7 +168,7 @@ public class PlanNodeVisualizer { } } else { Map<Integer, String> symbolMap = new HashMap<>(); - symbolMap.put(shangPosition, SHANG); + symbolMap.put(box.midPosition, SHANG); for (int i = 0; i < box.children.size(); i++) { symbolMap.put(getChildMidPosition(box, i), i == 0 ? LEFT_TOP : i == box.children.size() - 1 ? RIGHT_TOP : XIA); } @@ -196,7 +197,7 @@ public class PlanNodeVisualizer { line2.append(INDENT); continue; } - if (symbolMap.containsKey(i) && i != shangPosition) { + if (symbolMap.containsKey(i) && i != box.midPosition) { line2.append(SHU); } else { line2.append(INDENT); @@ -213,7 +214,9 @@ public class PlanNodeVisualizer { StringBuilder line = new StringBuilder(); for (int j = 0; j < box.childCount(); j++) { line.append(box.getChild(j).getLine(i)); - line.append(INDENT); + if (j != box.childCount() - 1) { + line.append(INDENT); + } } box.lines.add(line.toString()); } @@ -238,24 +241,21 @@ public class PlanNodeVisualizer { } private static String printBoxEdge(Box box, boolean top) { - int leftIndent = (box.lineWidth - box.boxWidth) / 2; StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < box.lineWidth; i++) { - if (i < leftIndent) { + if (i < box.startPosition) { sb.append(INDENT); continue; } - if (i > box.lastCharPosition) { + if (i > box.endPosition) { sb.append(INDENT); continue; } - if (i == leftIndent) { + if (i == box.startPosition) { sb.append(top ? LEFT_TOP : LEFT_BOTTOM); continue; } - if (i == box.lastCharPosition) { + if (i == box.endPosition) { sb.append(top ? RIGHT_TOP : RIGHT_BOTTOM); continue; } diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/process/TimeJoinNode.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/process/TimeJoinNode.java index a613e0f..1aa020d 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/process/TimeJoinNode.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/process/TimeJoinNode.java @@ -145,7 +145,7 @@ public class TimeJoinNode extends ProcessNode { public List<String> getBoxString() { List<String> ret = new ArrayList<>(); ret.add(String.format("TimeJoinNode-%s", getId().getId())); -// ret.add(String.format("Order: %s", mergeOrder)); + ret.add(String.format("Order: %s", mergeOrder)); return ret; } } diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/QueryPlannerTest.java b/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/QueryPlannerTest.java index 298b18e..088078a 100644 --- a/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/QueryPlannerTest.java +++ b/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/QueryPlannerTest.java @@ -40,7 +40,7 @@ public class QueryPlannerTest { @Test public void TestSqlToDistributedPlan() { - String querySql = "SELECT d1.* FROM root.sg order by time desc LIMIT 10"; + String querySql = "SELECT * FROM root.sg order by time desc LIMIT 10"; Statement stmt = StatementGenerator.createStatement(querySql, ZoneId.systemDefault());
