001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealMaterializedResultSetStatistics
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.FormatableHashtable;
030:
031: import java.io.ObjectOutput;
032: import java.io.ObjectInput;
033: import java.io.IOException;
034:
035: /**
036: ResultSetStatistics implemenation for MaterializedResultSet.
037:
038: @author jerry
039:
040: */
041: public class RealMaterializedResultSetStatistics extends
042: RealNoPutResultSetStatistics {
043:
044: /* Leave these fields public for object inspectors */
045: public ResultSetStatistics childResultSetStatistics;
046: public long createTCTime;
047: public long fetchTCTime;
048:
049: // CONSTRUCTORS
050: /**
051: *
052: *
053: */
054: public RealMaterializedResultSetStatistics(int numOpens,
055: int rowsSeen, int rowsFiltered, long constructorTime,
056: long openTime, long nextTime, long closeTime,
057: long createTCTime, long fetchTCTime, int resultSetNumber,
058: double optimizerEstimatedRowCount,
059: double optimizerEstimatedCost,
060: ResultSetStatistics childResultSetStatistics) {
061: super (numOpens, rowsSeen, rowsFiltered, constructorTime,
062: openTime, nextTime, closeTime, resultSetNumber,
063: optimizerEstimatedRowCount, optimizerEstimatedCost);
064: this .createTCTime = createTCTime;
065: this .fetchTCTime = fetchTCTime;
066: this .childResultSetStatistics = childResultSetStatistics;
067: }
068:
069: // ResultSetStatistics methods
070:
071: /**
072: * Return the statement execution plan as a String.
073: *
074: * @param depth Indentation level.
075: *
076: * @return String The statement execution plan as a String.
077: */
078: public String getStatementExecutionPlanText(int depth) {
079: initFormatInfo(depth);
080:
081: return indent
082: + MessageService
083: .getTextMessage(SQLState.RTS_MATERIALIZED_RS)
084: + ":\n"
085: + indent
086: + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS)
087: + " = "
088: + numOpens
089: + "\n"
090: + indent
091: + MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN)
092: + " = "
093: + rowsSeen
094: + "\n"
095: + dumpTimeStats(indent, subIndent)
096: + "\n"
097: + dumpEstimatedCosts(subIndent)
098: + "\n"
099: + subIndent
100: + MessageService
101: .getTextMessage(SQLState.RTS_TEMP_CONGLOM_CREATE_TIME)
102: + " = "
103: + createTCTime
104: + "\n"
105: + subIndent
106: + MessageService
107: .getTextMessage(SQLState.RTS_TEMP_CONGLOM_FETCH_TIME)
108: + " = "
109: + fetchTCTime
110: + "\n"
111: + indent
112: + MessageService.getTextMessage(SQLState.RTS_SOURCE_RS)
113: + ":\n"
114: + childResultSetStatistics
115: .getStatementExecutionPlanText(sourceDepth)
116: + "\n";
117: }
118:
119: /**
120: * Return information on the scan nodes from the statement execution
121: * plan as a String.
122: *
123: * @param depth Indentation level.
124: * @param tableName if not NULL then print information for this table only
125: *
126: * @return String The information on the scan nodes from the
127: * statement execution plan as a String.
128: */
129: public String getScanStatisticsText(String tableName, int depth) {
130: return childResultSetStatistics.getScanStatisticsText(
131: tableName, depth);
132: }
133:
134: // Class implementation
135:
136: public String toString() {
137: return getStatementExecutionPlanText(0);
138: }
139:
140: public java.util.Vector getChildren() {
141: java.util.Vector children = new java.util.Vector();
142: children.addElement(childResultSetStatistics);
143: return children;
144: }
145:
146: /**
147: * Format for display, a name for this node.
148: *
149: */
150: public String getNodeName() {
151: return MessageService
152: .getTextMessage(SQLState.RTS_MATERIALIZED_RS);
153: }
154: }
|