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