2121
2222import org .apache .iotdb .common .rpc .thrift .TRegionReplicaSet ;
2323import org .apache .iotdb .commons .partition .DataPartition ;
24+ import org .apache .iotdb .db .mpp .plan .expression .Expression ;
2425import org .apache .iotdb .db .mpp .plan .planner .plan .node .process .AggregationNode ;
2526import org .apache .iotdb .db .mpp .plan .planner .plan .node .process .DeviceMergeNode ;
2627import org .apache .iotdb .db .mpp .plan .planner .plan .node .process .DeviceViewNode ;
3334import org .apache .iotdb .db .mpp .plan .planner .plan .node .process .SlidingWindowAggregationNode ;
3435import org .apache .iotdb .db .mpp .plan .planner .plan .node .process .SortNode ;
3536import org .apache .iotdb .db .mpp .plan .planner .plan .node .process .TimeJoinNode ;
37+ import org .apache .iotdb .db .mpp .plan .planner .plan .node .process .TransformNode ;
3638import org .apache .iotdb .db .mpp .plan .planner .plan .node .sink .FragmentSinkNode ;
3739import org .apache .iotdb .db .mpp .plan .planner .plan .node .source .AlignedSeriesAggregationScanNode ;
3840import org .apache .iotdb .db .mpp .plan .planner .plan .node .source .AlignedSeriesScanNode ;
5052public class PlanGraphPrinter extends PlanVisitor <List <String >, PlanGraphPrinter .GraphContext > {
5153
5254 private static final String INDENT = " " ;
53- private static final String HENG = "─" ;
54- private static final String SHU = "│" ;
55+ private static final String HORIZONTAL = "─" ;
56+ private static final String VERTICAL = "│" ;
5557 private static final String LEFT_BOTTOM = "└" ;
5658 private static final String RIGHT_BOTTOM = "┘" ;
5759 private static final String LEFT_TOP = "┌" ;
5860 private static final String RIGHT_TOP = "┐" ;
59- private static final String SHANG = "┴" ;
60- private static final String XIA = "┬" ;
61+ private static final String UP = "┴" ;
62+ private static final String DOWN = "┬" ;
6163 private static final String CROSS = "┼" ;
6264
6365 private static final int BOX_MARGIN = 1 ;
@@ -247,6 +249,18 @@ public List<String> visitFragmentSink(FragmentSinkNode node, GraphContext contex
247249 return render (node , boxValue , context );
248250 }
249251
252+ @ Override
253+ public List <String > visitTransform (TransformNode node , GraphContext context ) {
254+ List <String > boxValue = new ArrayList <>();
255+ boxValue .add (String .format ("Transform-%s" , node .getPlanNodeId ().getId ()));
256+ for (int i = 0 ; i < node .getOutputExpressions ().length ; i ++) {
257+ Expression exp = node .getOutputExpressions ()[i ];
258+ boxValue .add (
259+ String .format ("Exp-%d[%s]: %s" , i , exp .getExpressionType (), exp .getExpressionString ()));
260+ }
261+ return render (node , boxValue , context );
262+ }
263+
250264 private String printRegion (TRegionReplicaSet regionReplicaSet ) {
251265 return String .format (
252266 "Partition: %s" ,
@@ -276,7 +290,7 @@ private List<String> render(PlanNode node, List<String> nodeBoxString, GraphCont
276290 continue ;
277291 }
278292 if (i == box .startPosition || i == box .endPosition ) {
279- line .append (SHU );
293+ line .append (VERTICAL );
280294 continue ;
281295 }
282296 if (i - box .startPosition - 1 < valueLine .length ()) {
@@ -298,14 +312,14 @@ private List<String> render(PlanNode node, List<String> nodeBoxString, GraphCont
298312 for (int i = 0 ; i < CONNECTION_LINE_HEIGHT ; i ++) {
299313 StringBuilder line = new StringBuilder ();
300314 for (int j = 0 ; j < box .lineWidth ; j ++) {
301- line .append (j == box .midPosition ? SHU : INDENT );
315+ line .append (j == box .midPosition ? VERTICAL : INDENT );
302316 }
303317 box .lines .add (line .toString ());
304318 }
305319 } else {
306320 Map <Integer , String > symbolMap = new HashMap <>();
307321 Map <Integer , Boolean > childMidPositionMap = new HashMap <>();
308- symbolMap .put (box .midPosition , SHANG );
322+ symbolMap .put (box .midPosition , UP );
309323 for (int i = 0 ; i < children .size (); i ++) {
310324 int childMidPosition = getChildMidPosition (children , i );
311325 childMidPositionMap .put (childMidPosition , true );
@@ -314,7 +328,7 @@ private List<String> render(PlanNode node, List<String> nodeBoxString, GraphCont
314328 continue ;
315329 }
316330 symbolMap .put (
317- childMidPosition , i == 0 ? LEFT_TOP : i == children .size () - 1 ? RIGHT_TOP : XIA );
331+ childMidPosition , i == 0 ? LEFT_TOP : i == children .size () - 1 ? RIGHT_TOP : DOWN );
318332 }
319333 StringBuilder line1 = new StringBuilder ();
320334 for (int i = 0 ; i < box .lineWidth ; i ++) {
@@ -323,14 +337,14 @@ private List<String> render(PlanNode node, List<String> nodeBoxString, GraphCont
323337 line1 .append (INDENT );
324338 continue ;
325339 }
326- line1 .append (symbolMap .getOrDefault (i , HENG ));
340+ line1 .append (symbolMap .getOrDefault (i , HORIZONTAL ));
327341 }
328342 box .lines .add (line1 .toString ());
329343
330344 for (int row = 1 ; row < CONNECTION_LINE_HEIGHT ; row ++) {
331345 StringBuilder nextLine = new StringBuilder ();
332346 for (int i = 0 ; i < box .lineWidth ; i ++) {
333- nextLine .append (childMidPositionMap .containsKey (i ) ? SHU : INDENT );
347+ nextLine .append (childMidPositionMap .containsKey (i ) ? VERTICAL : INDENT );
334348 }
335349 box .lines .add (nextLine .toString ());
336350 }
@@ -363,7 +377,7 @@ private String printBoxEdge(Box box, boolean isTopEdge) {
363377 } else if (i == box .endPosition ) {
364378 line .append (isTopEdge ? RIGHT_TOP : RIGHT_BOTTOM );
365379 } else {
366- line .append (HENG );
380+ line .append (HORIZONTAL );
367381 }
368382 }
369383 return line .toString ();
0 commit comments