1 21 22 package org.apache.derby.impl.sql.execute.rts; 23 24 import org.apache.derby.iapi.services.io.StoredFormatIds; 25 26 import org.apache.derby.iapi.services.i18n.MessageService; 27 import org.apache.derby.iapi.reference.SQLState; 28 29 import org.apache.derby.iapi.services.io.FormatableHashtable; 30 31 import java.io.ObjectOutput ; 32 import java.io.ObjectInput ; 33 import java.io.IOException ; 34 35 41 public class RealNestedLoopJoinStatistics 42 extends RealJoinResultSetStatistics 43 { 44 45 46 public boolean oneRowRightSide; 47 public ResultSetStatistics leftResultSetStatistics; 48 public ResultSetStatistics rightResultSetStatistics; 49 50 53 protected String nodeName ; 54 protected String resultSetName; 55 56 58 62 public RealNestedLoopJoinStatistics( 63 int numOpens, 64 int rowsSeen, 65 int rowsFiltered, 66 long constructorTime, 67 long openTime, 68 long nextTime, 69 long closeTime, 70 int resultSetNumber, 71 int rowsSeenLeft, 72 int rowsSeenRight, 73 int rowsReturned, 74 long restrictionTime, 75 boolean oneRowRightSide, 76 double optimizerEstimatedRowCount, 77 double optimizerEstimatedCost, 78 String userSuppliedOptimizerOverrides, 79 ResultSetStatistics leftResultSetStatistics, 80 ResultSetStatistics rightResultSetStatistics 81 ) 82 { 83 super( 84 numOpens, 85 rowsSeen, 86 rowsFiltered, 87 constructorTime, 88 openTime, 89 nextTime, 90 closeTime, 91 resultSetNumber, 92 rowsSeenLeft, 93 rowsSeenRight, 94 rowsReturned, 95 restrictionTime, 96 optimizerEstimatedRowCount, 97 optimizerEstimatedCost, 98 userSuppliedOptimizerOverrides 99 ); 100 this.oneRowRightSide = oneRowRightSide; 101 this.leftResultSetStatistics = leftResultSetStatistics; 102 this.rightResultSetStatistics = rightResultSetStatistics; 103 104 setNames(); 105 } 106 107 109 116 public String getStatementExecutionPlanText(int depth) 117 { 118 initFormatInfo(depth); 119 120 String header = ""; 121 if (userSuppliedOptimizerOverrides != null) 122 { 123 header = 124 indent + MessageService.getTextMessage(SQLState.RTS_USER_SUPPLIED_OPTIMIZER_OVERRIDES_FOR_JOIN, 125 userSuppliedOptimizerOverrides); 126 header = header + "\n"; 127 } 128 129 return 130 header + 131 indent + resultSetName + ":\n" + 132 indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) + 133 " = " + numOpens + "\n" + 134 indent + MessageService.getTextMessage( 135 SQLState.RTS_ROWS_SEEN_LEFT) + 136 " = " + rowsSeenLeft + "\n" + 137 indent + MessageService.getTextMessage( 138 SQLState.RTS_ROWS_SEEN_RIGHT) + 139 " = " + rowsSeenRight + "\n" + 140 indent + MessageService.getTextMessage( 141 SQLState.RTS_ROWS_FILTERED) + 142 " = " + rowsFiltered + "\n" + 143 indent + MessageService.getTextMessage( 144 SQLState.RTS_ROWS_RETURNED) + 145 " = " + rowsReturned + "\n" + 146 dumpTimeStats(indent, subIndent) + "\n" + 147 dumpEstimatedCosts(subIndent) + "\n" + 148 indent + MessageService.getTextMessage( 149 SQLState.RTS_LEFT_RS) + 150 ":\n" + 151 leftResultSetStatistics.getStatementExecutionPlanText(sourceDepth) + 152 "\n" + 153 indent + MessageService.getTextMessage(SQLState.RTS_RIGHT_RS) + 154 ":\n" + 155 rightResultSetStatistics.getStatementExecutionPlanText(sourceDepth) + "\n"; 156 } 157 158 159 169 public String getScanStatisticsText(String tableName, int depth) 170 { 171 return leftResultSetStatistics.getScanStatisticsText(tableName, depth) 172 + rightResultSetStatistics.getScanStatisticsText(tableName, depth); 173 } 174 175 176 177 179 public String toString() 180 { 181 return getStatementExecutionPlanText(0); 182 } 183 184 public java.util.Vector getChildren() 185 { 186 java.util.Vector children = new java.util.Vector (); 187 children.addElement(leftResultSetStatistics); 188 children.addElement(rightResultSetStatistics); 189 return children; 190 } 191 192 196 public String getNodeName() 197 { 198 return nodeName; 199 } 200 201 protected void setNames() 202 { 203 if (nodeName == null) 204 { 205 if (oneRowRightSide) 206 { 207 nodeName = MessageService.getTextMessage( 208 SQLState.RTS_NESTED_LOOP_EXISTS_JOIN); 209 resultSetName = MessageService.getTextMessage( 210 SQLState.RTS_NESTED_LOOP_EXISTS_JOIN_RS); 211 } 212 else 213 { 214 nodeName = MessageService.getTextMessage( 215 SQLState.RTS_NESTED_LOOP_JOIN); 216 resultSetName = MessageService.getTextMessage( 217 SQLState.RTS_NESTED_LOOP_JOIN_RS); 218 } 219 } 220 } 221 } 222 | Popular Tags |