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 RealProjectRestrictStatistics 42 extends RealNoPutResultSetStatistics 43 { 44 45 46 public boolean doesProjection; 47 public boolean restriction; 48 public long restrictionTime; 49 public long projectionTime; 50 public ResultSetStatistics childResultSetStatistics; 51 public ResultSetStatistics[] subqueryTrackingArray; 52 53 55 59 public RealProjectRestrictStatistics( 60 int numOpens, 61 int rowsSeen, 62 int rowsFiltered, 63 long constructorTime, 64 long openTime, 65 long nextTime, 66 long closeTime, 67 int resultSetNumber, 68 long restrictionTime, 69 long projectionTime, 70 ResultSetStatistics[] subqueryTrackingArray, 71 boolean restriction, 72 boolean doesProjection, 73 double optimizerEstimatedRowCount, 74 double optimizerEstimatedCost, 75 ResultSetStatistics childResultSetStatistics 76 ) 77 { 78 super( 79 numOpens, 80 rowsSeen, 81 rowsFiltered, 82 constructorTime, 83 openTime, 84 nextTime, 85 closeTime, 86 resultSetNumber, 87 optimizerEstimatedRowCount, 88 optimizerEstimatedCost 89 ); 90 this.restriction = restriction; 91 this.doesProjection = doesProjection; 92 this.restrictionTime = restrictionTime; 93 this.projectionTime = projectionTime; 94 this.subqueryTrackingArray = subqueryTrackingArray; 95 this.childResultSetStatistics = childResultSetStatistics; 96 } 97 98 100 107 public String getStatementExecutionPlanText(int depth) 108 { 109 String subqueryInfo = ""; 110 111 initFormatInfo(depth); 112 113 114 115 if (subqueryTrackingArray != null) 116 { 117 boolean foundAttached = false; 118 119 for (int index = 0; index < subqueryTrackingArray.length; index++) 120 { 121 if (subqueryTrackingArray[index] != null) 122 { 123 124 if (! foundAttached) 125 { 126 subqueryInfo = indent + 127 MessageService.getTextMessage( 128 SQLState.RTS_ATTACHED_SQS) + 129 ":\n"; 130 foundAttached = true; 131 } 132 subqueryInfo = subqueryInfo + 133 subqueryTrackingArray[index].getStatementExecutionPlanText(sourceDepth); 134 } 135 } 136 } 137 138 return 139 subqueryInfo + 140 indent + MessageService.getTextMessage(SQLState.RTS_PR_RS) + 141 " (" + resultSetNumber + "):" + "\n" + 142 indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) + 143 " = " + numOpens + "\n" + 144 indent + MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN) + 145 " = " + rowsSeen + "\n" + 146 indent + MessageService.getTextMessage( 147 SQLState.RTS_ROWS_FILTERED) + 148 " = " + rowsFiltered + "\n" + 149 indent + MessageService.getTextMessage( 150 SQLState.RTS_RESTRICTION) + 151 " = " + restriction + "\n" + 152 indent + MessageService.getTextMessage(SQLState.RTS_PROJECTION) + 153 " = " + doesProjection + "\n" + 154 dumpTimeStats(indent, subIndent) + "\n" + 155 subIndent + MessageService.getTextMessage( 156 SQLState.RTS_RESTRICTION_TIME) + 157 " = " + restrictionTime + "\n" + 158 subIndent + MessageService.getTextMessage( 159 SQLState.RTS_PROJECTION_TIME) + 160 " = " + projectionTime + "\n" + 161 dumpEstimatedCosts(subIndent) + "\n" + 162 indent + MessageService.getTextMessage(SQLState.RTS_SOURCE_RS) + 163 ":" + "\n" + 164 childResultSetStatistics.getStatementExecutionPlanText(sourceDepth); 165 } 166 167 177 public String getScanStatisticsText(String tableName, int depth) 178 { 179 String subqueryInfo = ""; 180 181 182 183 193 194 if (subqueryTrackingArray != null) 195 { 196 for (int index = 0; index < subqueryTrackingArray.length; index++) 197 { 198 if (subqueryTrackingArray[index] != null) 199 { 200 subqueryInfo = subqueryInfo + 201 "\n" + 202 MessageService.getTextMessage( 203 SQLState.RTS_BEGIN_SQ_NUMBER) + 204 " " + index + "\n" + 205 subqueryTrackingArray[index].getScanStatisticsText(tableName, depth) + 206 MessageService.getTextMessage( 207 SQLState.RTS_END_SQ_NUMBER) + 208 " " + index + "\n\n"; 209 } 210 } 211 } 212 213 return subqueryInfo 214 + childResultSetStatistics.getScanStatisticsText(tableName, depth); 215 } 216 217 218 219 221 public String toString() 222 { 223 return getStatementExecutionPlanText(0); 224 } 225 public java.util.Vector getChildren(){ 226 java.util.Vector children = new java.util.Vector (); 227 children.addElement(childResultSetStatistics); 228 229 if (subqueryTrackingArray != null) 231 { 232 for (int index = 0; index < subqueryTrackingArray.length; index++) 233 { 234 if (subqueryTrackingArray[index] != null) 235 { 236 children.addElement(subqueryTrackingArray[index]); 237 } 238 } 239 } 240 return children; 241 } 242 246 public String getNodeName(){ 247 return MessageService.getTextMessage(SQLState.RTS_PR); 248 } 249 } 250 | Popular Tags |