001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealDistinctScalarAggregateStatistics
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.i18n.MessageService;
025: import org.apache.derby.iapi.reference.SQLState;
026:
027: /**
028: ResultSetStatistics implemenation for DistinctScalarAggregateResultSet.
029:
030: @author jerry
031:
032: */
033: public class RealDistinctScalarAggregateStatistics extends
034: RealScalarAggregateStatistics {
035:
036: /* Leave these fields public for object inspectors */
037: public int rowsInput;
038:
039: // CONSTRUCTORS
040:
041: /**
042: *
043: *
044: */
045: public RealDistinctScalarAggregateStatistics(int numOpens,
046: int rowsSeen, int rowsFiltered, long constructorTime,
047: long openTime, long nextTime, long closeTime,
048: int resultSetNumber, int rowsInput,
049: double optimizerEstimatedRowCount,
050: double optimizerEstimatedCost,
051: ResultSetStatistics childResultSetStatistics) {
052: super (numOpens, rowsSeen, rowsFiltered, constructorTime,
053: openTime, nextTime, closeTime, resultSetNumber,
054: false, // No min optimization when a distinct aggregate exits
055: rowsInput, optimizerEstimatedRowCount,
056: optimizerEstimatedCost, childResultSetStatistics);
057: }
058:
059: // ResultSetStatistics methods
060:
061: /**
062: * Return the statement execution plan as a String.
063: *
064: * @param depth Indentation level.
065: *
066: * @return String The statement execution plan as a String.
067: */
068: public String getStatementExecutionPlanText(int depth) {
069: initFormatInfo(depth);
070:
071: return indent
072: + MessageService.getTextMessage(SQLState.RTS_DSARS)
073: + ":\n"
074: + indent
075: + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS)
076: + " = "
077: + numOpens
078: + "\n"
079: + indent
080: + MessageService
081: .getTextMessage(SQLState.RTS_ROWS_INPUT)
082: + " = "
083: + rowsInput
084: + "\n"
085: + dumpTimeStats(indent, subIndent)
086: + "\n"
087: + dumpEstimatedCosts(subIndent)
088: + "\n"
089: + indent
090: + MessageService.getTextMessage(SQLState.RTS_SOURCE_RS)
091: + ":\n"
092: + childResultSetStatistics
093: .getStatementExecutionPlanText(sourceDepth)
094: + "\n";
095: }
096:
097: /**
098: * Return information on the scan nodes from the statement execution
099: * plan as a String.
100: *
101: * @param depth Indentation level.
102: * @param tableName if not NULL then print information for this table only
103: *
104: * @return String The information on the scan nodes from the
105: * statement execution plan as a String.
106: */
107: public String getScanStatisticsText(String tableName, int depth) {
108: return childResultSetStatistics.getScanStatisticsText(
109: tableName, depth);
110: }
111:
112: // Class implementation
113:
114: public String toString() {
115: return getStatementExecutionPlanText(0);
116: }
117:
118: public java.util.Vector getChildren() {
119: java.util.Vector children = new java.util.Vector();
120: children.addElement(childResultSetStatistics);
121: return children;
122: }
123:
124: /**
125: * Format for display, a name for this node.
126: *
127: */
128: public String getNodeName() {
129: return MessageService
130: .getTextMessage(SQLState.RTS_DISTINCT_SCALAR_AGG);
131: }
132: }
|