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 import org.apache.derby.iapi.services.io.FormatableProperties; 31 32 import java.io.ObjectOutput ; 33 import java.io.ObjectInput ; 34 import java.io.IOException ; 35 36 import java.util.Enumeration ; 37 import java.util.Properties ; 38 39 40 46 public class RealHashTableStatistics 47 extends RealNoPutResultSetStatistics 48 { 49 50 51 public int hashtableSize; 52 public int[] hashKeyColumns; 53 public String isolationLevel; 54 public String nextQualifiers; 55 public FormatableProperties scanProperties; 56 public ResultSetStatistics childResultSetStatistics; 57 public ResultSetStatistics[] subqueryTrackingArray; 58 59 61 65 public RealHashTableStatistics( 66 int numOpens, 67 int rowsSeen, 68 int rowsFiltered, 69 long constructorTime, 70 long openTime, 71 long nextTime, 72 long closeTime, 73 int resultSetNumber, 74 int hashtableSize, 75 int[] hashKeyColumns, 76 String nextQualifiers, 77 Properties scanProperties, 78 double optimizerEstimatedRowCount, 79 double optimizerEstimatedCost, 80 ResultSetStatistics[] subqueryTrackingArray, 81 ResultSetStatistics childResultSetStatistics 82 ) 83 { 84 super( 85 numOpens, 86 rowsSeen, 87 rowsFiltered, 88 constructorTime, 89 openTime, 90 nextTime, 91 closeTime, 92 resultSetNumber, 93 optimizerEstimatedRowCount, 94 optimizerEstimatedCost 95 ); 96 this.hashtableSize = hashtableSize; 97 this.hashKeyColumns = hashKeyColumns; 98 this.nextQualifiers = nextQualifiers; 99 this.scanProperties = new FormatableProperties(); 100 if (scanProperties != null) 101 { 102 for (Enumeration e = scanProperties.keys(); e.hasMoreElements(); ) 103 { 104 String key = (String )e.nextElement(); 105 this.scanProperties.put(key, scanProperties.get(key)); 106 } 107 } 108 this.subqueryTrackingArray = subqueryTrackingArray; 109 this.childResultSetStatistics = childResultSetStatistics; 110 } 111 112 114 121 public String getStatementExecutionPlanText(int depth) 122 { 123 String subqueryInfo = ""; 124 125 initFormatInfo(depth); 126 127 128 129 if (subqueryTrackingArray != null) 130 { 131 boolean foundAttached = false; 132 133 for (int index = 0; index < subqueryTrackingArray.length; index++) 134 { 135 if (subqueryTrackingArray[index] != null) 136 { 137 138 if (! foundAttached) 139 { 140 subqueryInfo = indent + 141 MessageService.getTextMessage( 142 SQLState.RTS_ATTACHED_SQS) + 143 ":\n"; 144 foundAttached = true; 145 } 146 subqueryInfo = subqueryInfo + 147 subqueryTrackingArray[index].getStatementExecutionPlanText(sourceDepth); 148 } 149 } 150 } 151 152 initFormatInfo(depth); 153 154 String hashKeyColumnString; 155 if (hashKeyColumns.length == 1) 156 { 157 hashKeyColumnString = 158 MessageService.getTextMessage(SQLState.RTS_HASH_KEY) + 159 " " + 160 hashKeyColumns[0]; 161 } 162 else 163 { 164 hashKeyColumnString = 165 MessageService.getTextMessage(SQLState.RTS_HASH_KEYS) + 166 " (" + hashKeyColumns[0]; 167 for (int index = 1; index < hashKeyColumns.length; index++) 168 { 169 hashKeyColumnString = hashKeyColumnString + "," + hashKeyColumns[index]; 170 } 171 hashKeyColumnString = hashKeyColumnString + ")"; 172 } 173 174 return 175 indent + MessageService.getTextMessage( 176 SQLState.RTS_HASH_TABLE_RS) + 177 " (" + resultSetNumber + "):" + "\n" + 178 indent + MessageService.getTextMessage( 179 SQLState.RTS_NUM_OPENS) + 180 " = " + numOpens + "\n" + 181 indent + MessageService.getTextMessage( 182 SQLState.RTS_HASH_TABLE_SIZE) + 183 " = " + hashtableSize + "\n" + 184 indent + hashKeyColumnString + "\n" + 185 indent + MessageService.getTextMessage( 186 SQLState.RTS_ROWS_SEEN) + 187 " = " + rowsSeen + "\n" + 188 indent + MessageService.getTextMessage( 189 SQLState.RTS_ROWS_FILTERED) + 190 " = " + rowsFiltered + "\n" + 191 dumpTimeStats(indent, subIndent) + "\n" + 192 dumpEstimatedCosts(subIndent) + "\n" + 193 ((rowsSeen > 0) 194 ? 195 subIndent + 196 MessageService.getTextMessage(SQLState.RTS_NEXT_TIME) + 197 " = " + (nextTime / rowsSeen) + "\n" 198 : 199 "") + "\n" + 200 subIndent + MessageService.getTextMessage( 201 SQLState.RTS_NEXT_QUALS) + 202 ":\n" + nextQualifiers + "\n" + 203 indent + MessageService.getTextMessage(SQLState.RTS_SOURCE_RS) + 204 ":\n" + 205 childResultSetStatistics.getStatementExecutionPlanText(sourceDepth); 206 } 207 208 218 public String getScanStatisticsText(String tableName, int depth) 219 { 220 if (tableName == null) 221 return getStatementExecutionPlanText(depth); 222 else 223 return (String )null; 224 } 225 226 227 229 public String toString() 230 { 231 return getStatementExecutionPlanText(0); 232 } 233 238 public String getNodeOn(){ 239 return ""; 240 } 241 245 public String getNodeName(){ 246 return MessageService.getTextMessage(SQLState.RTS_HASH_TABLE); 247 } 248 } 249 | Popular Tags |