2828
2929class TablePlanFormatter {
3030
31- private static final String UNNAMED_PATTERN_STRING = " (UNNAMED|FRESHID|AGGREGATION)(\\ d+)" ;
31+ private static final String UNNAMED_PATTERN_STRING = " (UNNAMED|FRESHID|AGGREGATION|NODE|REL )(\\ d+)" ;
3232 private static final Pattern UNNAMED_PATTERN = Pattern .compile (UNNAMED_PATTERN_STRING );
3333 private static final String OPERATOR = "Operator" ;
3434 private static final String ESTIMATED_ROWS = "Estimated Rows" ;
@@ -40,14 +40,16 @@ class TablePlanFormatter {
4040 private static final String MEMORY = "Memory (Bytes)" ;
4141 private static final String IDENTIFIERS = "Identifiers" ;
4242 private static final String OTHER = "Other" ;
43+ private static final String DETAILS = "Details" ;
4344 private static final String SEPARATOR = ", " ;
4445 private static final Pattern DEDUP_PATTERN = Pattern .compile ("\\ s*(\\ S+)@\\ d+" );
46+ public static final int MAX_DETAILS_COLUMN_WIDTH = 100 ;
4547
46- private static final List <String > HEADERS = asList (OPERATOR , ESTIMATED_ROWS , ROWS , HITS , PAGE_CACHE , TIME , MEMORY , IDENTIFIERS , ORDER , OTHER );
48+ private static final List <String > HEADERS = asList (OPERATOR , DETAILS , ESTIMATED_ROWS , ROWS , HITS , PAGE_CACHE , TIME , MEMORY , IDENTIFIERS , ORDER , OTHER );
4749
4850 private static final Set <String > IGNORED_ARGUMENTS = new LinkedHashSet <>(
4951 asList ( "Rows" , "DbHits" , "EstimatedRows" , "planner" , "planner-impl" , "planner-version" , "version" , "runtime" , "runtime-impl" , "runtime-version" ,
50- "time" , "source-code" , "PageCacheMisses" , "PageCacheHits" , "PageCacheHitRatio" , "Order" , "Memory" , "GlobalMemory" ) );
52+ "time" , "source-code" , "PageCacheMisses" , "PageCacheHits" , "PageCacheHitRatio" , "Order" , "Memory" , "GlobalMemory" , "Details" ) );
5153 public static final Value ZERO_VALUE = Values .value (0 );
5254
5355 private int width (@ Nonnull String header , @ Nonnull Map <String , Integer > columns ) {
@@ -161,6 +163,8 @@ private String serialize(@Nonnull String key, @Nonnull Value v) {
161163 return v .asString ();
162164 case "PageCacheMisses" :
163165 return v .asNumber ().toString ();
166+ case "Details" :
167+ return v .asString ();
164168 default :
165169 return v .asObject ().toString ();
166170 }
@@ -208,6 +212,8 @@ private Map<String, Justified> details(@Nonnull Plan plan, @Nonnull Map<String,
208212 return mapping (TIME , new Right (String .format ("%.3f" , value .asLong () / 1000000.0d )), columns );
209213 case "Order" :
210214 return mapping ( ORDER , new Left ( String .format ( "%s" , value .asString () ) ), columns );
215+ case "Details" :
216+ return mapping ( DETAILS , new Left ( truncate (value .asString ()) ), columns );
211217 case "Memory" :
212218 return mapping ( MEMORY , new Right ( String .format ( "%s" , value .asNumber ().toString () ) ), columns );
213219 default :
@@ -439,4 +445,12 @@ public static <T1, T2> Pair<T1, T2> of(T1 _1, T2 _2) {
439445 return new Pair <>(_1 , _2 );
440446 }
441447 }
448+
449+ private String truncate ( String original ) {
450+ if (original .length () <= MAX_DETAILS_COLUMN_WIDTH ){
451+ return original ;
452+ }
453+
454+ return original .substring ( 0 , MAX_DETAILS_COLUMN_WIDTH - 3 ) + "..." ;
455+ }
442456}
0 commit comments