001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealScalarAggregateStatistics
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 ScalarAggregateResultSet.
037:
038: @author jerry
039:
040: */
041: public class RealScalarAggregateStatistics extends
042: RealNoPutResultSetStatistics {
043:
044: /* Leave these fields public for object inspectors */
045: public int rowsInput = 0;
046: public boolean indexKeyOptimization;
047: public ResultSetStatistics childResultSetStatistics;
048:
049: // CONSTRUCTORS
050:
051: /**
052: *
053: *
054: */
055: public RealScalarAggregateStatistics(int numOpens, int rowsSeen,
056: int rowsFiltered, long constructorTime, long openTime,
057: long nextTime, long closeTime, int resultSetNumber,
058: boolean indexKeyOptimization, int rowsInput,
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 .indexKeyOptimization = indexKeyOptimization;
066: this .rowsInput = rowsInput;
067: this .childResultSetStatistics = childResultSetStatistics;
068: }
069:
070: // ResultSetStatistics methods
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: initFormatInfo(depth);
081:
082: return indent
083: + MessageService
084: .getTextMessage(SQLState.RTS_SCALAR_AGG_RS)
085: + ":\n"
086: + indent
087: + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS)
088: + " = "
089: + numOpens
090: + "\n"
091: + indent
092: + MessageService
093: .getTextMessage(SQLState.RTS_ROWS_INPUT)
094: + " = "
095: + rowsInput
096: + "\n"
097: + dumpTimeStats(indent, subIndent)
098: + "\n"
099: + dumpEstimatedCosts(subIndent)
100: + "\n"
101: + indent
102: + MessageService
103: .getTextMessage(SQLState.RTS_INDEX_KEY_OPT)
104: + " = "
105: + indexKeyOptimization
106: + "\n"
107: + indent
108: + MessageService.getTextMessage(SQLState.RTS_SOURCE_RS)
109: + ":\n"
110: + childResultSetStatistics
111: .getStatementExecutionPlanText(sourceDepth)
112: + "\n";
113: }
114:
115: /**
116: * Return information on the scan nodes from the statement execution
117: * plan as a String.
118: *
119: * @param depth Indentation level.
120: * @param tableName if not NULL then print information for this table only
121: *
122: * @return String The information on the scan nodes from the
123: * statement execution plan as a String.
124: */
125: public String getScanStatisticsText(String tableName, int depth) {
126: return childResultSetStatistics.getScanStatisticsText(
127: tableName, depth);
128: }
129:
130: // Class implementation
131:
132: public String toString() {
133: return getStatementExecutionPlanText(0);
134: }
135:
136: public java.util.Vector getChildren() {
137: java.util.Vector children = new java.util.Vector();
138: children.addElement(childResultSetStatistics);
139: return children;
140: }
141:
142: /**
143: * Format for display, a name for this node.
144: *
145: */
146: public String getNodeName() {
147: return MessageService.getTextMessage(SQLState.RTS_SCALAR_AGG);
148: }
149: }
|