KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.rts.RealSetOpResultSetStatistics
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.impl.sql.compile.IntersectOrExceptNode;
28
29 /**
30   ResultSetStatistics implementation for SetOpResultSet.
31
32   @author yip
33
34 */

35 public class RealSetOpResultSetStatistics
36     extends RealNoPutResultSetStatistics
37 {
38     
39     /* Leave these fields public for object inspectors */
40     public int opType;
41     public int rowsSeenLeft;
42     public int rowsSeenRight;
43     public int rowsReturned;
44     public ResultSetStatistics leftResultSetStatistics;
45     public ResultSetStatistics rightResultSetStatistics;
46
47     // CONSTRUCTORS
48

49     /**
50      * Constructs a new <code>RealSetOpResultSetStatistics</code> object
51      * to represent the runtime statistics for <code>SetOpResultSet</code>.
52      *
53      * @param opType set operation type
54      * @param numOpens number of open
55      * @param rowsSeen rows seen
56      * @param rowsFiltered rows filtered
57      * @param constructorTime the time for construction
58      * @param openTime the time for open operation
59      * @param nextTime the time for next operation
60      * @param closeTime the time for close operation
61      * @param resultSetNumber the result set number
62      * @param rowsSeenLeft rows seen by left source input
63      * @param rowsSeenRight rows seen by right source input
64      * @param rowsReturned rows returned
65      * @param optimizerEstimatedRowCount optimizer estimated row count
66      * @param optimizerEstimatedCost optimizer estimated cost
67      * @param leftResultSetStatistics left source runtime statistics
68      * @param rightResultSetStatistics right source runtime statistics
69      *
70      * @see org.apache.derby.impl.sql.execute.SetOpResultSet
71      */

72     public RealSetOpResultSetStatistics(
73                                  int opType,
74                                  int numOpens,
75                                  int rowsSeen,
76                                  int rowsFiltered,
77                                  long constructorTime,
78                                  long openTime,
79                                  long nextTime,
80                                  long closeTime,
81                                  int resultSetNumber,
82                                  int rowsSeenLeft,
83                                  int rowsSeenRight,
84                                  int rowsReturned,
85                                  double optimizerEstimatedRowCount,
86                                  double optimizerEstimatedCost,
87                                  ResultSetStatistics leftResultSetStatistics,
88                                  ResultSetStatistics rightResultSetStatistics
89                                 )
90     {
91         super(
92             numOpens,
93             rowsSeen,
94             rowsFiltered,
95             constructorTime,
96             openTime,
97             nextTime,
98             closeTime,
99             resultSetNumber,
100             optimizerEstimatedRowCount,
101             optimizerEstimatedCost
102             );
103         
104         this.opType = opType;
105         this.rowsSeenLeft = rowsSeenLeft;
106         this.rowsSeenRight = rowsSeenRight;
107         this.rowsReturned = rowsReturned;
108         this.leftResultSetStatistics = leftResultSetStatistics;
109         this.rightResultSetStatistics = rightResultSetStatistics;
110     }
111
112     // ResultSetStatistics methods
113

114     /**
115      * Return the statement execution plan as a <code>String</code>.
116      *
117      * @param depth Indentation level.
118      *
119      * @return the statement execution plan as a <code>String</code>.
120      */

121     public String JavaDoc getStatementExecutionPlanText(int depth) {
122         initFormatInfo(depth);
123
124         String JavaDoc rs = (opType == IntersectOrExceptNode.INTERSECT_OP)
125                 ? (SQLState.RTS_INTERSECT_RS) : (SQLState.RTS_EXCEPT_RS);
126          
127         return
128             indent + MessageService.getTextMessage(rs) +
129                 ":\n" +
130             indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) +
131                 " = " + numOpens + "\n" +
132             indent + MessageService.getTextMessage(
133                                             SQLState.RTS_ROWS_SEEN_LEFT) +
134                 " = " + rowsSeenLeft + "\n" +
135             indent + MessageService.getTextMessage(
136                                             SQLState.RTS_ROWS_SEEN_RIGHT) +
137                 " = " + rowsSeenRight + "\n" +
138             indent + MessageService.getTextMessage(
139                                             SQLState.RTS_ROWS_RETURNED) +
140                 " = " + rowsReturned + "\n" +
141             dumpTimeStats(indent, subIndent) + "\n" +
142             dumpEstimatedCosts(subIndent) + "\n" +
143             indent + MessageService.getTextMessage(SQLState.RTS_LEFT_RS) +
144                 ":\n" +
145             leftResultSetStatistics.getStatementExecutionPlanText(sourceDepth) +
146                 "\n" +
147             indent + MessageService.getTextMessage(SQLState.RTS_RIGHT_RS) +
148                 ":\n" +
149             rightResultSetStatistics.getStatementExecutionPlanText(
150                                                                   sourceDepth) +
151                 "\n";
152     }
153
154     /**
155      * Return information on the scan nodes from the statement execution
156      * plan as a <code>String</code>.
157      *
158      * @param depth Indentation level.
159      * @param tableName if not NULL then print information for this table only
160      *
161      * @return String The information on the scan nodes from the
162      * statement execution plan as a <code>String</code>.
163      */

164     public String JavaDoc getScanStatisticsText(String JavaDoc tableName, int depth) {
165         return leftResultSetStatistics.getScanStatisticsText(tableName, depth)
166             + rightResultSetStatistics.getScanStatisticsText(tableName, depth);
167     }
168
169     // Class implementation
170

171     /**
172      * Return the runtime statistics of this object in textual representation
173      *
174      * @return the runtime statistics of this object in textual representation
175      * as a <code>String</code>.
176      */

177     public String JavaDoc toString() {
178         return getStatementExecutionPlanText(0);
179     }
180
181     /**
182      * Retrieves the children runtime statistics of this <code>
183      * RealSetOpResultSetStatistics</code> object
184      *
185      * @return the children runtime statistics of this <code>
186      * RealSetOpResultSetStatistics</code> object stored in a <code>
187      * Vector</code>.
188      *
189      */

190     public java.util.Vector JavaDoc getChildren() {
191         java.util.Vector JavaDoc children = new java.util.Vector JavaDoc();
192         children.addElement(leftResultSetStatistics);
193         children.addElement(rightResultSetStatistics);
194         return children;
195     }
196
197     /**
198      * Format for display, a name for this node.
199      *
200      * @return the name of the node as a <code>String</code>.
201      */

202     public String JavaDoc getNodeName() {
203         String JavaDoc nodeName =
204             (opType == IntersectOrExceptNode.INTERSECT_OP)
205                 ? (SQLState.RTS_INTERSECT) : (SQLState.RTS_EXCEPT);
206         
207         return MessageService.getTextMessage(nodeName);
208     }
209 }
210
Popular Tags