001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealIndexRowToBaseRowStatistics
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.execute.rts;
023:
024: import org.apache.derby.iapi.services.io.StoredFormatIds;
025:
026: import org.apache.derby.iapi.services.i18n.MessageService;
027: import org.apache.derby.iapi.reference.SQLState;
028:
029: import org.apache.derby.iapi.services.io.FormatableBitSet;
030: import org.apache.derby.iapi.services.io.FormatableHashtable;
031:
032: import java.io.ObjectOutput;
033: import java.io.ObjectInput;
034: import java.io.IOException;
035:
036: /**
037: ResultSetStatistics implemenation for IndexRowToBaseRowResultSet.
038:
039: @author jerry
040:
041: */
042: public class RealIndexRowToBaseRowStatistics extends
043: RealNoPutResultSetStatistics {
044:
045: /* Leave these fields public for object inspectors */
046: public String tableName;
047: public ResultSetStatistics childResultSetStatistics;
048: public String colsAccessedFromHeap;
049:
050: // CONSTRUCTORS
051:
052: /**
053: *
054: *
055: */
056: public RealIndexRowToBaseRowStatistics(int numOpens, int rowsSeen,
057: int rowsFiltered, long constructorTime, long openTime,
058: long nextTime, long closeTime, int resultSetNumber,
059: String tableName, FormatableBitSet colsAccessedFromHeap,
060: double optimizerEstimatedRowCount,
061: double optimizerEstimatedCost,
062: ResultSetStatistics childResultSetStatistics) {
063: super (numOpens, rowsSeen, rowsFiltered, constructorTime,
064: openTime, nextTime, closeTime, resultSetNumber,
065: optimizerEstimatedRowCount, optimizerEstimatedCost);
066: this .tableName = tableName;
067: this .colsAccessedFromHeap = (colsAccessedFromHeap == null) ? "{"
068: + MessageService.getTextMessage(SQLState.RTS_ALL) + "}"
069: : colsAccessedFromHeap.toString();
070: this .childResultSetStatistics = childResultSetStatistics;
071: }
072:
073: // ResultSetStatistics interface
074:
075: /**
076: * Return the statement execution plan as a String.
077: *
078: * @param depth Indentation level.
079: *
080: * @return String The statement execution plan as a String.
081: */
082: public String getStatementExecutionPlanText(int depth) {
083: initFormatInfo(depth);
084:
085: return indent
086: + MessageService.getTextMessage(SQLState.RTS_IRTBR_RS,
087: tableName)
088: + ":"
089: + "\n"
090: + indent
091: + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS)
092: + " = "
093: + numOpens
094: + "\n"
095: + indent
096: + MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN)
097: + " = "
098: + rowsSeen
099: + "\n"
100: + indent
101: + MessageService
102: .getTextMessage(SQLState.RTS_COLS_ACCESSED_FROM_HEAP)
103: + " = "
104: + colsAccessedFromHeap
105: + "\n"
106: + dumpTimeStats(indent, subIndent)
107: + "\n"
108: + dumpEstimatedCosts(subIndent)
109: + "\n"
110: + childResultSetStatistics
111: .getStatementExecutionPlanText(sourceDepth)
112: + "\n";
113: }
114:
115: /**
116: * Return information on the scan nodes from the statement execution
117: * plan as a String.
118: *
119: * @param depth Indentation level.
120: * @param tableName if not NULL then print information for this table only
121: *
122: * @return String The information on the scan nodes from the
123: * statement execution plan as a String.
124: */
125: public String getScanStatisticsText(String tableName, int depth) {
126: if ((tableName == null) || (tableName.equals(this .tableName)))
127: return getStatementExecutionPlanText(depth);
128: else
129: return (String) "";
130: }
131:
132: // Class implementation
133:
134: public String toString() {
135: return getStatementExecutionPlanText(0);
136: }
137:
138: public java.util.Vector getChildren() {
139: java.util.Vector children = new java.util.Vector();
140: children.addElement(childResultSetStatistics);
141: return children;
142: }
143:
144: /**
145: * If this node is on a database item (like a table or an index), then provide a
146: * string that describes the on item.
147: *
148: */
149: public String getNodeOn() {
150: return MessageService.getTextMessage(SQLState.RTS_FOR_TAB_NAME,
151: tableName);
152: }
153:
154: /**
155: * Format for display, a name for this node.
156: *
157: */
158: public String getNodeName() {
159: return MessageService.getTextMessage(SQLState.RTS_IRTBR);
160: }
161:
162: /**
163: * Return the ResultSetStatistics for the child of this node.
164: *
165: * @return The ResultSetStatistics for the child of this node.
166: */
167: ResultSetStatistics getChildResultSetStatistics() {
168: return childResultSetStatistics;
169: }
170: }
|