1 21 22 package org.apache.derby.impl.sql.execute.rts; 23 24 import org.apache.derby.iapi.services.io.StoredFormatIds; 25 import org.apache.derby.iapi.util.PropertyUtil; 26 27 import org.apache.derby.iapi.services.i18n.MessageService; 28 import org.apache.derby.iapi.reference.SQLState; 29 30 import org.apache.derby.iapi.services.io.FormatableHashtable; 31 import org.apache.derby.iapi.services.io.FormatableProperties; 32 33 import java.io.ObjectOutput ; 34 import java.io.ObjectInput ; 35 import java.io.IOException ; 36 37 import java.util.Enumeration ; 38 import java.util.Hashtable ; 39 import java.util.Properties ; 40 41 42 48 public class RealHashScanStatistics 49 extends RealNoPutResultSetStatistics 50 { 51 52 53 public boolean isConstraint; 54 public int hashtableSize; 55 public int[] hashKeyColumns; 56 public String isolationLevel; 57 public String lockString; 58 public String tableName; 59 public String indexName; 60 public String nextQualifiers; 61 public String scanQualifiers; 62 public String startPosition = null; 63 public String stopPosition = null; 64 public FormatableProperties scanProperties; 65 66 68 72 public RealHashScanStatistics( 73 int numOpens, 74 int rowsSeen, 75 int rowsFiltered, 76 long constructorTime, 77 long openTime, 78 long nextTime, 79 long closeTime, 80 int resultSetNumber, 81 String tableName, 82 String indexName, 83 boolean isConstraint, 84 int hashtableSize, 85 int[] hashKeyColumns, 86 String scanQualifiers, 87 String nextQualifiers, 88 Properties scanProperties, 89 String startPosition, 90 String stopPosition, 91 String isolationLevel, 92 String lockString, 93 double optimizerEstimatedRowCount, 94 double optimizerEstimatedCost 95 ) 96 { 97 super( 98 numOpens, 99 rowsSeen, 100 rowsFiltered, 101 constructorTime, 102 openTime, 103 nextTime, 104 closeTime, 105 resultSetNumber, 106 optimizerEstimatedRowCount, 107 optimizerEstimatedCost 108 ); 109 this.tableName = tableName; 110 this.indexName = indexName; 111 this.isConstraint = isConstraint; 112 this.hashtableSize = hashtableSize; 113 this.hashKeyColumns = hashKeyColumns; 114 this.scanQualifiers = scanQualifiers; 115 this.nextQualifiers = nextQualifiers; 116 this.scanProperties = new FormatableProperties(); 117 if (scanProperties != null) 118 { 119 for (Enumeration e = scanProperties.keys(); e.hasMoreElements(); ) 120 { 121 String key = (String )e.nextElement(); 122 this.scanProperties.put(key, scanProperties.get(key)); 123 } 124 } 125 this.startPosition = startPosition; 126 this.stopPosition = stopPosition; 127 this.isolationLevel = isolationLevel; 128 this.lockString = lockString; 129 } 130 131 133 140 public String getStatementExecutionPlanText(int depth) 141 { 142 String header; 143 String isolationString = null; 144 145 initFormatInfo(depth); 146 147 if (indexName != null) 148 { 149 header = 150 indent + 151 MessageService.getTextMessage( 152 SQLState.RTS_HASH_SCAN_RS_USING, 153 tableName, 154 MessageService.getTextMessage( 155 isConstraint ? 156 SQLState.RTS_CONSTRAINT : 157 SQLState.RTS_INDEX), 158 indexName); 159 } 160 else 161 { 162 header = 163 indent + 164 MessageService.getTextMessage(SQLState.RTS_HASH_SCAN_RS, 165 tableName); 166 } 167 168 header = header + " " + 169 MessageService.getTextMessage( 170 SQLState.RTS_LOCKING, 171 isolationLevel, 172 lockString) + 173 ": \n"; 174 175 String scanInfo = 176 indent + 177 MessageService.getTextMessage(SQLState.RTS_SCAN_INFO) + 178 ": \n" + 179 PropertyUtil.sortProperties(scanProperties, subIndent); 180 181 String hashKeyColumnString; 182 if (hashKeyColumns.length == 1) 183 { 184 hashKeyColumnString = MessageService.getTextMessage( 185 SQLState.RTS_HASH_KEY) + 186 " " + hashKeyColumns[0]; 187 } 188 else 189 { 190 hashKeyColumnString = MessageService.getTextMessage( 191 SQLState.RTS_HASH_KEYS) + 192 " (" + hashKeyColumns[0]; 193 for (int index = 1; index < hashKeyColumns.length; index++) 194 { 195 hashKeyColumnString = hashKeyColumnString + "," + hashKeyColumns[index]; 196 } 197 hashKeyColumnString = hashKeyColumnString + ")"; 198 } 199 200 return 201 header + 202 indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) + 203 " = " + numOpens + "\n" + 204 indent + MessageService.getTextMessage( 205 SQLState.RTS_HASH_TABLE_SIZE) + 206 " = " + hashtableSize + "\n" + 207 indent + hashKeyColumnString + "\n" + 208 indent + MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN) + 209 " = " + rowsSeen + "\n" + 210 indent + MessageService.getTextMessage( 211 SQLState.RTS_ROWS_FILTERED) + 212 " = " + rowsFiltered + "\n" + 213 dumpTimeStats(indent, subIndent) + "\n" + 214 ((rowsSeen > 0) 215 ? 216 subIndent + MessageService.getTextMessage( 217 SQLState.RTS_NEXT_TIME) + 218 " = " + (nextTime / rowsSeen) + "\n" 219 : 220 "") + "\n" + 221 scanInfo + 222 subIndent + MessageService.getTextMessage( 223 SQLState.RTS_START_POSITION) + 224 ": \n" + startPosition + 225 subIndent + MessageService.getTextMessage( 226 SQLState.RTS_STOP_POSITION) + 227 ": \n" + stopPosition + 228 subIndent + MessageService.getTextMessage( 229 SQLState.RTS_SCAN_QUALS) + 230 ":\n" + scanQualifiers + "\n" + 231 subIndent + MessageService.getTextMessage( 232 SQLState.RTS_NEXT_QUALS) + 233 ":\n" + nextQualifiers + "\n" + 234 dumpEstimatedCosts(subIndent); 237 } 238 239 249 public String getScanStatisticsText(String tableName, int depth) 250 { 251 if ((tableName == null) || (tableName.equals(this.tableName))) 252 return getStatementExecutionPlanText(depth); 253 else 254 return (String )""; 255 } 256 257 258 259 261 public String toString() 262 { 263 return getStatementExecutionPlanText(0); 264 } 265 270 public String getNodeOn(){ 271 return MessageService.getTextMessage( 272 SQLState.RTS_ON_USING, 273 tableName, 274 indexName); 275 } 276 280 public String getNodeName(){ 281 return MessageService.getTextMessage(SQLState.RTS_HASH_SCAN); 282 } 283 } 284 | Popular Tags |