KickJava   Java API By Example, From Geeks To Geeks.

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


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

41 public class RealOnceResultSetStatistics
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 RealOnceResultSetStatistics(
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     {
72         super(
73             numOpens,
74             rowsSeen,
75             rowsFiltered,
76             constructorTime,
77             openTime,
78             nextTime,
79             closeTime,
80             resultSetNumber,
81             optimizerEstimatedRowCount,
82             optimizerEstimatedCost
83             );
84         this.subqueryNumber = subqueryNumber;
85         this.pointOfAttachment = pointOfAttachment;
86         this.childResultSetStatistics = childResultSetStatistics;
87     }
88
89     // ResultSetStatistics methods
90

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

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

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

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

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