KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > rts > RealGroupedAggregateStatistics


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.rts.RealGroupedAggregateStatistics
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.execute.rts;
23
24 import org.apache.derby.iapi.services.i18n.MessageService;
25 import org.apache.derby.iapi.reference.SQLState;
26
27 import org.apache.derby.iapi.util.PropertyUtil;
28
29 import java.util.Enumeration JavaDoc;
30 import java.util.Properties JavaDoc;
31
32 /**
33   ResultSetStatistics implemenation for GroupedAggregateResultSet.
34
35   @author jerry
36
37 */

38 public class RealGroupedAggregateStatistics
39     extends RealNoPutResultSetStatistics
40 {
41
42     /* Leave these fields public for object inspectors */
43     public int rowsInput;
44     public boolean hasDistinctAggregate;
45     public boolean inSortedOrder;
46     public ResultSetStatistics childResultSetStatistics;
47     public Properties JavaDoc sortProperties;
48
49     // CONSTRUCTORS
50

51     /**
52      *
53      *
54      */

55     public RealGroupedAggregateStatistics(
56                         int numOpens,
57                         int rowsSeen,
58                         int rowsFiltered,
59                         long constructorTime,
60                         long openTime,
61                         long nextTime,
62                         long closeTime,
63                         int resultSetNumber,
64                         int rowsInput,
65                         boolean hasDistinctAggregate,
66                         boolean inSortedOrder,
67                         Properties JavaDoc sortProperties,
68                         double optimizerEstimatedRowCount,
69                         double optimizerEstimatedCost,
70                         ResultSetStatistics childResultSetStatistics
71                         )
72     {
73         super(
74             numOpens,
75             rowsSeen,
76             rowsFiltered,
77             constructorTime,
78             openTime,
79             nextTime,
80             closeTime,
81             resultSetNumber,
82             optimizerEstimatedRowCount,
83             optimizerEstimatedCost
84             );
85         this.rowsInput = rowsInput;
86         this.hasDistinctAggregate = hasDistinctAggregate;
87         this.inSortedOrder = inSortedOrder;
88         this.childResultSetStatistics = childResultSetStatistics;
89         this.sortProperties = new Properties JavaDoc();
90         for (Enumeration JavaDoc e = sortProperties.keys(); e.hasMoreElements(); )
91         {
92             String JavaDoc key = (String JavaDoc)e.nextElement();
93             this.sortProperties.put(key, sortProperties.get(key));
94         }
95     }
96
97     // ResultSetStatistics methods
98

99     /**
100      * Return the statement execution plan as a String.
101      *
102      * @param depth Indentation level.
103      *
104      * @return String The statement execution plan as a String.
105      */

106     public String JavaDoc getStatementExecutionPlanText(int depth)
107     {
108         initFormatInfo(depth);
109
110         String JavaDoc sortInfo = (inSortedOrder) ? "" :
111             indent + MessageService.getTextMessage(SQLState.RTS_SORT_INFO) +
112             ": \n" + PropertyUtil.sortProperties(sortProperties, subIndent);
113
114         return
115             indent + MessageService.getTextMessage(
116                                                 SQLState.RTS_GROUPED_AGG_RS) +
117                         ":\n" +
118             indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) +
119                         " = " + numOpens + "\n" +
120             indent + MessageService.getTextMessage(
121                                                 SQLState.RTS_ROWS_INPUT) +
122                         " = " + rowsInput + "\n" +
123             indent + MessageService.getTextMessage(
124                                                 SQLState.RTS_HAS_DISTINCT_AGG) +
125                         " = " + hasDistinctAggregate + "\n" +
126             indent + MessageService.getTextMessage(
127                                                 SQLState.RTS_IN_SORTED_ORDER) +
128                         " = " + inSortedOrder + "\n" +
129             sortInfo +
130             dumpTimeStats(indent, subIndent) + "\n" +
131             dumpEstimatedCosts(subIndent) + "\n" +
132             indent + MessageService.getTextMessage(SQLState.RTS_SOURCE_RS) +
133                         ":\n" +
134             childResultSetStatistics.getStatementExecutionPlanText(sourceDepth) + "\n";
135     }
136
137     /**
138      * Return information on the scan nodes from the statement execution
139      * plan as a String.
140      *
141      * @param depth Indentation level.
142      *
143      * @return String The information on the scan nodes from the
144      * statement execution plan as a String.
145      */

146     public String JavaDoc getScanStatisticsText(String JavaDoc tableName, int depth)
147     {
148         return childResultSetStatistics.getScanStatisticsText(tableName, depth);
149     }
150
151
152
153     // Class implementation
154

155     public String JavaDoc toString()
156     {
157         return getStatementExecutionPlanText(0);
158     }
159   public java.util.Vector JavaDoc getChildren(){
160     java.util.Vector JavaDoc children = new java.util.Vector JavaDoc();
161     children.addElement(childResultSetStatistics);
162     return children;
163   }
164     /**
165    * Format for display, a name for this node.
166      *
167      */

168   public String JavaDoc getNodeName(){
169     return MessageService.getTextMessage(SQLState.RTS_GROUPED_AGG);
170   }
171 }
172
Popular Tags