KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.rts.RealUnionResultSetStatistics
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.io.StoredFormatIds;
25
26 import org.apache.derby.iapi.services.i18n.MessageService;
27 import org.apache.derby.iapi.reference.SQLState;
28
29 import org.apache.derby.iapi.services.io.FormatableHashtable;
30
31 import java.io.ObjectOutput JavaDoc;
32 import java.io.ObjectInput JavaDoc;
33 import java.io.IOException JavaDoc;
34
35 /**
36   ResultSetStatistics implemenation for UnionResultSet.
37
38   @author jerry
39
40 */

41 public class RealUnionResultSetStatistics
42     extends RealNoPutResultSetStatistics
43 {
44
45     /* Leave these fields public for object inspectors */
46     public int rowsSeenLeft;
47     public int rowsSeenRight;
48     public int rowsReturned;
49     public ResultSetStatistics leftResultSetStatistics;
50     public ResultSetStatistics rightResultSetStatistics;
51
52     // CONSTRUCTORS
53

54     /**
55      *
56      *
57      */

58     public RealUnionResultSetStatistics(
59                                 int numOpens,
60                                 int rowsSeen,
61                                 int rowsFiltered,
62                                 long constructorTime,
63                                 long openTime,
64                                 long nextTime,
65                                 long closeTime,
66                                 int resultSetNumber,
67                                 int rowsSeenLeft,
68                                 int rowsSeenRight,
69                                 int rowsReturned,
70                                 double optimizerEstimatedRowCount,
71                                 double optimizerEstimatedCost,
72                                 ResultSetStatistics leftResultSetStatistics,
73                                 ResultSetStatistics rightResultSetStatistics
74                                 )
75     {
76         super(
77             numOpens,
78             rowsSeen,
79             rowsFiltered,
80             constructorTime,
81             openTime,
82             nextTime,
83             closeTime,
84             resultSetNumber,
85             optimizerEstimatedRowCount,
86             optimizerEstimatedCost
87             );
88         this.rowsSeenLeft = rowsSeenLeft;
89         this.rowsSeenRight = rowsSeenRight;
90         this.rowsReturned = rowsReturned;
91         this.leftResultSetStatistics = leftResultSetStatistics;
92         this.rightResultSetStatistics = rightResultSetStatistics;
93     }
94
95     // ResultSetStatistics methods
96

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

104     public String JavaDoc getStatementExecutionPlanText(int depth)
105     {
106         initFormatInfo(depth);
107
108         return
109             indent + MessageService.getTextMessage(SQLState.RTS_UNION_RS) +
110                 ":\n" +
111             indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) +
112                 " = " + numOpens + "\n" +
113             indent + MessageService.getTextMessage(
114                                                 SQLState.RTS_ROWS_SEEN_LEFT) +
115                 " = " + rowsSeenLeft + "\n" +
116             indent + MessageService.getTextMessage(
117                                                 SQLState.RTS_ROWS_SEEN_RIGHT) +
118                 " = " + rowsSeenRight + "\n" +
119             indent + MessageService.getTextMessage(
120                                                 SQLState.RTS_ROWS_RETURNED) +
121                 " = " + rowsReturned + "\n" +
122             dumpTimeStats(indent, subIndent) + "\n" +
123             dumpEstimatedCosts(subIndent) + "\n" +
124             indent + MessageService.getTextMessage(SQLState.RTS_LEFT_RS) +
125                 ":\n" +
126             leftResultSetStatistics.getStatementExecutionPlanText(sourceDepth) +
127                 "\n" +
128             indent + MessageService.getTextMessage(SQLState.RTS_RIGHT_RS) +
129                 ":\n" +
130             rightResultSetStatistics.getStatementExecutionPlanText(
131                                                                 sourceDepth) +
132                 "\n";
133     }
134
135     /**
136      * Return information on the scan nodes from the statement execution
137      * plan as a String.
138      *
139      * @param depth Indentation level.
140      * @param tableName if not NULL then print information for this table only
141      *
142      * @return String The information on the scan nodes from the
143      * statement execution plan as a String.
144      */

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

154     public String JavaDoc toString()
155     {
156         return getStatementExecutionPlanText(0);
157     }
158   public java.util.Vector JavaDoc getChildren(){
159     java.util.Vector JavaDoc children = new java.util.Vector JavaDoc();
160     children.addElement(leftResultSetStatistics);
161     children.addElement(rightResultSetStatistics);
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_UNION);
170   }
171 }
172
Popular Tags