001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealGroupedAggregateStatistics
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: import org.apache.derby.iapi.util.PropertyUtil;
028:
029: import java.util.Enumeration;
030: import java.util.Properties;
031:
032: /**
033: ResultSetStatistics implemenation for GroupedAggregateResultSet.
034:
035: @author jerry
036:
037: */
038: public class RealGroupedAggregateStatistics extends
039: RealNoPutResultSetStatistics {
040:
041: /* Leave these fields public for object inspectors */
042: public int rowsInput;
043: public boolean hasDistinctAggregate;
044: public boolean inSortedOrder;
045: public ResultSetStatistics childResultSetStatistics;
046: public Properties sortProperties;
047:
048: // CONSTRUCTORS
049:
050: /**
051: *
052: *
053: */
054: public RealGroupedAggregateStatistics(int numOpens, int rowsSeen,
055: int rowsFiltered, long constructorTime, long openTime,
056: long nextTime, long closeTime, int resultSetNumber,
057: int rowsInput, boolean hasDistinctAggregate,
058: boolean inSortedOrder, Properties sortProperties,
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 .rowsInput = rowsInput;
066: this .hasDistinctAggregate = hasDistinctAggregate;
067: this .inSortedOrder = inSortedOrder;
068: this .childResultSetStatistics = childResultSetStatistics;
069: this .sortProperties = new Properties();
070: for (Enumeration e = sortProperties.keys(); e.hasMoreElements();) {
071: String key = (String) e.nextElement();
072: this .sortProperties.put(key, sortProperties.get(key));
073: }
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: String sortInfo = (inSortedOrder) ? "" : indent
089: + MessageService.getTextMessage(SQLState.RTS_SORT_INFO)
090: + ": \n"
091: + PropertyUtil
092: .sortProperties(sortProperties, subIndent);
093:
094: return indent
095: + MessageService
096: .getTextMessage(SQLState.RTS_GROUPED_AGG_RS)
097: + ":\n"
098: + indent
099: + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS)
100: + " = "
101: + numOpens
102: + "\n"
103: + indent
104: + MessageService
105: .getTextMessage(SQLState.RTS_ROWS_INPUT)
106: + " = "
107: + rowsInput
108: + "\n"
109: + indent
110: + MessageService
111: .getTextMessage(SQLState.RTS_HAS_DISTINCT_AGG)
112: + " = "
113: + hasDistinctAggregate
114: + "\n"
115: + indent
116: + MessageService
117: .getTextMessage(SQLState.RTS_IN_SORTED_ORDER)
118: + " = "
119: + inSortedOrder
120: + "\n"
121: + sortInfo
122: + dumpTimeStats(indent, subIndent)
123: + "\n"
124: + dumpEstimatedCosts(subIndent)
125: + "\n"
126: + indent
127: + MessageService.getTextMessage(SQLState.RTS_SOURCE_RS)
128: + ":\n"
129: + childResultSetStatistics
130: .getStatementExecutionPlanText(sourceDepth)
131: + "\n";
132: }
133:
134: /**
135: * Return information on the scan nodes from the statement execution
136: * plan as a String.
137: *
138: * @param depth Indentation level.
139: *
140: * @return String The information on the scan nodes from the
141: * statement execution plan as a String.
142: */
143: public String getScanStatisticsText(String tableName, int depth) {
144: return childResultSetStatistics.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(childResultSetStatistics);
157: return children;
158: }
159:
160: /**
161: * Format for display, a name for this node.
162: *
163: */
164: public String getNodeName() {
165: return MessageService.getTextMessage(SQLState.RTS_GROUPED_AGG);
166: }
167: }
|