001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealAnyResultSetStatistics
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 AnyResultSet.
037:
038: @author jerry
039:
040: */
041: public class RealAnyResultSetStatistics 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 RealAnyResultSetStatistics(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 interface
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: : (" ("
082: + MessageService
083: .getTextMessage(SQLState.RTS_ATTACHED_TO)
084: + " " + pointOfAttachment + "):");
085: initFormatInfo(depth);
086:
087: return indent
088: + MessageService
089: .getTextMessage(SQLState.RTS_BEGIN_SQ_NUMBER)
090: + " "
091: + subqueryNumber
092: + "\n"
093: + indent
094: + MessageService.getTextMessage(SQLState.RTS_ANY_RS)
095: + " "
096: + attachmentString
097: + "\n"
098: + indent
099: + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS)
100: + " = "
101: + numOpens
102: + "\n"
103: + indent
104: + MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN)
105: + " = "
106: + rowsSeen
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: + indent
119: + MessageService
120: .getTextMessage(SQLState.RTS_END_SQ_NUMBER)
121: + " " + subqueryNumber + "\n";
122: }
123:
124: /**
125: * Return information on the scan nodes from the statement execution
126: * plan as a String.
127: *
128: * @param tableName if not-NULL then return information for this table only
129: * @param depth Indentation level.
130: *
131: * @return String The information on the scan nodes from the
132: * statement execution plan as a String.
133: */
134: public String getScanStatisticsText(String tableName, int depth) {
135: return childResultSetStatistics.getScanStatisticsText(
136: tableName, depth);
137: }
138:
139: // Class implementation
140:
141: public String toString() {
142: return getStatementExecutionPlanText(0);
143: }
144:
145: public java.util.Vector getChildren() {
146: java.util.Vector children = new java.util.Vector();
147: children.addElement(childResultSetStatistics);
148: return children;
149: }
150:
151: /**
152: * Format for display, a name for this node.
153: *
154: */
155: public String getNodeName() {
156: return MessageService.getTextMessage(SQLState.RTS_ANY_RS);
157: }
158: }
|