1 21 22 package org.apache.derby.impl.sql.execute.rts; 23 24 import org.apache.derby.iapi.util.PropertyUtil; 25 26 import org.apache.derby.iapi.services.i18n.MessageService; 27 import org.apache.derby.iapi.reference.SQLState; 28 29 import java.util.Enumeration ; 30 import java.util.Hashtable ; 31 import java.util.Properties ; 32 33 34 40 public class RealDistinctScanStatistics 41 extends RealHashScanStatistics 42 { 43 44 46 50 public RealDistinctScanStatistics( 51 int numOpens, 52 int rowsSeen, 53 int rowsFiltered, 54 long constructorTime, 55 long openTime, 56 long nextTime, 57 long closeTime, 58 int resultSetNumber, 59 String tableName, 60 String indexName, 61 boolean isConstraint, 62 int hashtableSize, 63 int[] hashKeyColumns, 64 String scanQualifiers, 65 String nextQualifiers, 66 Properties scanProperties, 67 String startPosition, 68 String stopPosition, 69 String isolationLevel, 70 String lockString, 71 double optimizerEstimatedRowCount, 72 double optimizerEstimatedCost 73 ) 74 { 75 super( 76 numOpens, 77 rowsSeen, 78 rowsFiltered, 79 constructorTime, 80 openTime, 81 nextTime, 82 closeTime, 83 resultSetNumber, 84 tableName, 85 indexName, 86 isConstraint, 87 hashtableSize, 88 hashKeyColumns, 89 scanQualifiers, 90 nextQualifiers, 91 scanProperties, 92 startPosition, 93 stopPosition, 94 isolationLevel, 95 lockString, 96 optimizerEstimatedRowCount, 97 optimizerEstimatedCost 98 ); 99 } 100 101 103 110 public String getStatementExecutionPlanText(int depth) 111 { 112 String header; 113 String isolationString = null; 114 115 initFormatInfo(depth); 116 117 if (indexName != null) 118 { 119 header = 120 indent + MessageService.getTextMessage( 121 SQLState.RTS_DISTINCT_SCAN_RS_USING, 122 tableName, 123 isConstraint ? 124 MessageService.getTextMessage(SQLState.RTS_CONSTRAINT) : 125 MessageService.getTextMessage(SQLState.RTS_INDEX), 126 indexName); 127 } 128 else 129 { 130 header = 131 indent + 132 MessageService.getTextMessage( 133 SQLState.RTS_DISTINCT_SCAN_RS, 134 tableName); 135 } 136 137 header = header + " " + 138 MessageService.getTextMessage( 139 SQLState.RTS_LOCKING, 140 isolationLevel, 141 lockString) + 142 ": \n"; 143 144 String scanInfo = 145 indent + 146 MessageService.getTextMessage(SQLState.RTS_SCAN_INFO) + 147 ": \n" + 148 PropertyUtil.sortProperties(scanProperties, subIndent); 149 150 String hashKeyColumnString; 151 if (hashKeyColumns.length == 1) 152 { 153 hashKeyColumnString = MessageService.getTextMessage( 154 SQLState.RTS_DISTINCT_COL) + 155 " " + hashKeyColumns[0]; 156 } 157 else 158 { 159 hashKeyColumnString = MessageService.getTextMessage( 160 SQLState.RTS_DISTINCT_COLS) + 161 " (" + hashKeyColumns[0]; 162 for (int index = 1; index < hashKeyColumns.length; index++) 163 { 164 hashKeyColumnString = hashKeyColumnString + "," + hashKeyColumns[index]; 165 } 166 hashKeyColumnString = hashKeyColumnString + ")"; 167 } 168 169 return 170 header + 171 indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) + 172 " = " + numOpens + "\n" + 173 indent + MessageService.getTextMessage( 174 SQLState.RTS_HASH_TABLE_SIZE) + 175 " = " + hashtableSize + "\n" + 176 indent + hashKeyColumnString + "\n" + 177 indent + MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN) + 178 " = " + rowsSeen + "\n" + 179 indent + MessageService.getTextMessage( 180 SQLState.RTS_ROWS_FILTERED) + 181 " = " + rowsFiltered + "\n" + 182 dumpTimeStats(indent, subIndent) + "\n" + 183 dumpEstimatedCosts(subIndent) + "\n" + 184 ((rowsSeen > 0) 185 ? 186 subIndent + 187 MessageService.getTextMessage( 188 SQLState.RTS_NEXT_TIME) + 189 " = " + (nextTime / rowsSeen) + "\n" 190 : 191 "") + "\n" + 192 scanInfo + 193 subIndent + MessageService.getTextMessage( 194 SQLState.RTS_START_POSITION) + 195 ":\n" + startPosition + 196 subIndent + MessageService.getTextMessage( 197 SQLState.RTS_STOP_POSITION) + 198 ":\n" + stopPosition + 199 subIndent + MessageService.getTextMessage( 200 SQLState.RTS_SCAN_QUALS) + 201 ":\n" + scanQualifiers + "\n" + 202 subIndent + 203 MessageService.getTextMessage( 204 SQLState.RTS_NEXT_QUALS) + 205 ":\n" + nextQualifiers + "\n" + 206 dumpEstimatedCosts(subIndent); 209 } 210 211 221 public String getScanStatisticsText(String tableName, int depth) 222 { 223 if ((tableName == null) || tableName.equals(this.tableName)) 224 return getStatementExecutionPlanText(depth); 225 else 226 return (String )""; 227 } 228 229 231 232 234 public String toString() 235 { 236 return getStatementExecutionPlanText(0); 237 } 238 243 public String getNodeOn() 244 { 245 return MessageService.getTextMessage( 246 SQLState.RTS_ON_USING, 247 tableName, 248 indexName); 249 } 250 254 public String getNodeName() 255 { 256 return MessageService.getTextMessage(SQLState.RTS_DISTINCT_SCAN); 257 } 258 } 259 | Popular Tags |