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.services.io.Formatable; 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 32 import java.util.Vector ; 33 34 import java.io.ObjectOutput ; 35 import java.io.ObjectInput ; 36 import java.io.IOException ; 37 38 import java.text.DecimalFormat ; 39 40 41 47 abstract class RealBasicNoPutResultSetStatistics 48 implements ResultSetStatistics 49 { 50 51 52 public int numOpens; 53 public int rowsSeen; 54 public int rowsFiltered; 55 public long constructorTime; 56 public long openTime; 57 public long nextTime; 58 public long closeTime; 59 public long inspectOverall; 60 public long inspectNum; 61 public String inspectDesc; 62 public double optimizerEstimatedRowCount; 63 public double optimizerEstimatedCost; 64 65 67 71 public RealBasicNoPutResultSetStatistics( 72 int numOpens, 73 int rowsSeen, 74 int rowsFiltered, 75 long constructorTime, 76 long openTime, 77 long nextTime, 78 long closeTime, 79 double optimizerEstimatedRowCount, 80 double optimizerEstimatedCost 81 ) 82 { 83 this.numOpens = numOpens; 84 this.rowsSeen = rowsSeen; 85 this.rowsFiltered = rowsFiltered; 86 this.constructorTime = constructorTime; 87 this.openTime = openTime; 88 this.nextTime = nextTime; 89 this.closeTime = closeTime; 90 this.optimizerEstimatedRowCount = optimizerEstimatedRowCount; 91 this.optimizerEstimatedCost = optimizerEstimatedCost; 92 } 93 94 95 96 102 protected final String dumpTimeStats(String indent, String subIndent) 103 { 104 return 105 112 subIndent + 113 MessageService.getTextMessage(SQLState.LANG_CONSTRUCTOR_TIME) + 114 " " + constructorTime + "\n" + 115 subIndent + 116 MessageService.getTextMessage(SQLState.LANG_OPEN_TIME) + 117 " " + openTime + "\n" + 118 subIndent + 119 MessageService.getTextMessage(SQLState.LANG_NEXT_TIME) + 120 " " + nextTime + "\n" + 121 subIndent + 122 MessageService.getTextMessage(SQLState.LANG_CLOSE_TIME) + 123 " " + closeTime; 124 } 125 126 131 protected final String dumpEstimatedCosts(String subIndent) 132 { 133 return subIndent + 134 MessageService.getTextMessage(SQLState.RTS_OPT_EST_RC) + 135 ": " + 136 formatDouble(optimizerEstimatedRowCount) + "\n" + 137 subIndent + 138 MessageService.getTextMessage(SQLState.RTS_OPT_EST_COST) + 139 ": " + 140 formatDouble(optimizerEstimatedCost) + "\n"; 141 } 142 143 147 private static DecimalFormat df = null; 148 private String formatDouble(double toFormat) 149 { 150 if (df == null) 151 { 152 df = new DecimalFormat ("###########0.00"); 155 df.setMinimumIntegerDigits(1); 156 } 157 158 String retval = df.format(toFormat); 159 160 if (retval.length() < 15) 161 { 162 retval = 163 " ".substring(0, 15 - retval.length()) + retval; 164 } 165 166 return retval; 167 } 168 169 176 public Vector getChildren(){ 177 return new Vector (); 178 } 179 184 public long getTotalTime(){ 185 return openTime + nextTime + closeTime; 189 } 190 191 195 public long getChildrenTime(){ 196 long childrenTime = 0; 197 java.util.Enumeration e = getChildren().elements(); 198 while (e.hasMoreElements()){ 199 childrenTime = childrenTime + ((RealBasicNoPutResultSetStatistics)e.nextElement()).getTotalTime(); 200 } 201 return childrenTime; 202 } 203 204 209 public long getNodeTime(){ 210 return getTotalTime() - getChildrenTime(); 211 } 212 213 217 public abstract String getNodeName(); 218 219 224 public String getNodeOn(){ 225 return ""; 226 } 227 228 229 236 public double getEstimatedRowCount() 237 { 238 return optimizerEstimatedRowCount; 239 } 240 } 241 | Popular Tags |