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