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