KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.rts.RealAnyResultSetStatistics
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 AnyResultSet.
37
38   @author jerry
39
40 */

41 public class RealAnyResultSetStatistics
42     extends RealNoPutResultSetStatistics
43 {
44
45     /* Leave these fields public for object inspectors */
46     public int subqueryNumber;
47     public int pointOfAttachment;
48     public ResultSetStatistics childResultSetStatistics;
49
50     // CONSTRUCTORS
51

52     /**
53      *
54      *
55      */

56     public RealAnyResultSetStatistics(
57                                 int numOpens,
58                                 int rowsSeen,
59                                 int rowsFiltered,
60                                 long constructorTime,
61                                 long openTime,
62                                 long nextTime,
63                                 long closeTime,
64                                 int resultSetNumber,
65                                 int subqueryNumber,
66                                 int pointOfAttachment,
67                                 double optimizerEstimatedRowCount,
68                                 double optimizerEstimatedCost,
69                                 ResultSetStatistics childResultSetStatistics)
70     {
71         super(
72             numOpens,
73             rowsSeen,
74             rowsFiltered,
75             constructorTime,
76             openTime,
77             nextTime,
78             closeTime,
79             resultSetNumber,
80             optimizerEstimatedRowCount,
81             optimizerEstimatedCost
82             );
83         this.subqueryNumber = subqueryNumber;
84         this.pointOfAttachment = pointOfAttachment;
85         this.childResultSetStatistics = childResultSetStatistics;
86     }
87
88     // ResultSetStatistics interface
89

90     /**
91      * Return the statement execution plan as a String.
92      *
93      * @param depth Indentation level.
94      *
95      * @return String The statement execution plan as a String.
96      */

97     public String JavaDoc getStatementExecutionPlanText(int depth)
98     {
99         String JavaDoc attachmentString = (pointOfAttachment == -1) ? ":" :
100                 (" (" +
101                     MessageService.getTextMessage(SQLState.RTS_ATTACHED_TO)
102                     + " " + pointOfAttachment + "):");
103         initFormatInfo(depth);
104
105         return
106             indent +
107                 MessageService.getTextMessage(SQLState.RTS_BEGIN_SQ_NUMBER) +
108                 " " + subqueryNumber + "\n" +
109             indent +
110                 MessageService.getTextMessage(SQLState.RTS_ANY_RS) +
111                 " " + attachmentString + "\n" +
112             indent +
113                 MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) +
114                 " = " + numOpens + "\n" +
115             indent +
116                 MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN) +
117                 " = " + rowsSeen + "\n" +
118             dumpTimeStats(indent, subIndent) + "\n" +
119             dumpEstimatedCosts(subIndent) + "\n" +
120             indent +
121                 MessageService.getTextMessage(SQLState.RTS_SOURCE_RS) +
122                 ":\n" +
123             childResultSetStatistics.getStatementExecutionPlanText(sourceDepth) + "\n" +
124             indent +
125                 MessageService.getTextMessage(SQLState.RTS_END_SQ_NUMBER) +
126                 " " + subqueryNumber + "\n";
127     }
128
129     /**
130      * Return information on the scan nodes from the statement execution
131      * plan as a String.
132      *
133      * @param tableName if not-NULL then return information for this table only
134      * @param depth Indentation level.
135      *
136      * @return String The information on the scan nodes from the
137      * statement execution plan as a String.
138      */

139     public String JavaDoc getScanStatisticsText(String JavaDoc tableName, int depth)
140     {
141         return childResultSetStatistics.getScanStatisticsText(tableName, depth);
142     }
143
144
145     // Class implementation
146

147     public String JavaDoc toString()
148     {
149         return getStatementExecutionPlanText(0);
150     }
151   public java.util.Vector JavaDoc getChildren(){
152     java.util.Vector JavaDoc children = new java.util.Vector JavaDoc();
153     children.addElement(childResultSetStatistics);
154     return children;
155   }
156     /**
157    * Format for display, a name for this node.
158      *
159      */

160   public String JavaDoc getNodeName(){
161     return MessageService.getTextMessage(SQLState.RTS_ANY_RS);
162   }
163 }
164
Popular Tags