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