KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.rts.RealLastIndexKeyScanStatistics
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 import org.apache.derby.iapi.services.io.FormatableProperties;
31
32 import java.io.ObjectOutput JavaDoc;
33 import java.io.ObjectInput JavaDoc;
34 import java.io.IOException JavaDoc;
35
36 import java.util.Enumeration JavaDoc;
37 import java.util.Properties JavaDoc;
38
39
40 /**
41   ResultSetStatistics implemenation for RealLastIndexKeyScanResultSet.
42
43   @author jamie
44
45 */

46 public class RealLastIndexKeyScanStatistics
47     extends RealNoPutResultSetStatistics
48 {
49
50     /* Leave these fields public for object inspectors */
51     public String JavaDoc isolationLevel;
52     public String JavaDoc tableName;
53     public String JavaDoc indexName;
54     public String JavaDoc lockString;
55
56     // CONSTRUCTORS
57

58     /**
59      *
60      *
61      */

62     public RealLastIndexKeyScanStatistics(int numOpens,
63                                     long constructorTime,
64                                     long openTime,
65                                     long nextTime,
66                                     long closeTime,
67                                     int resultSetNumber,
68                                     String JavaDoc tableName,
69                                     String JavaDoc indexName,
70                                     String JavaDoc isolationLevel,
71                                     String JavaDoc lockString,
72                                     double optimizerEstimatedRowCount,
73                                     double optimizerEstimatedCost
74                                     )
75     {
76         super(
77             numOpens,
78             1,
79             0,
80             constructorTime,
81             openTime,
82             nextTime,
83             closeTime,
84             resultSetNumber,
85             optimizerEstimatedRowCount,
86             optimizerEstimatedCost
87             );
88         this.tableName = tableName;
89         this.indexName = indexName;
90         this.isolationLevel = isolationLevel;
91         this.lockString = lockString;
92     }
93
94     // ResultSetStatistics methods
95

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

103     public String JavaDoc getStatementExecutionPlanText(int depth)
104     {
105         String JavaDoc header;
106         String JavaDoc isolationString = null;
107
108         initFormatInfo(depth);
109
110         header =
111                 indent + MessageService.getTextMessage(
112                                                 SQLState.RTS_LKIS_RS,
113                                                 tableName,
114                                                 indexName);
115
116         header = header + MessageService.getTextMessage(
117                                                 SQLState.RTS_LOCKING_OPTIMIZER,
118                                                 isolationLevel,
119                                                 lockString);
120
121         header = header + "\n";
122
123         return
124             header +
125             indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) +
126                     " = " + numOpens + "\n" +
127             indent + MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN) +
128                     " = " + numOpens + "\n" +
129             dumpTimeStats(indent, subIndent) + "\n" +
130             ((rowsSeen > 0)
131                 ?
132                     subIndent + MessageService.getTextMessage(
133                                                     SQLState.RTS_NEXT_TIME) +
134                         " = " + (nextTime / numOpens) + "\n"
135                 :
136                     "") + "\n" +
137             // RESOLVE - estimated row count and cost will eventually
138
// be displayed for all nodes
139
dumpEstimatedCosts(subIndent);
140     }
141
142     /**
143      * Return information on the scan nodes from the statement execution
144      * plan as a String.
145      *
146      * @param depth Indentation level.
147      * @param tableName if not NULL then print information for this table only
148      *
149      * @return String The information on the scan nodes from the
150      * statement execution plan as a String.
151      */

152     public String JavaDoc getScanStatisticsText(String JavaDoc tableName, int depth)
153     {
154         if ((tableName == null) || (tableName.equals(this.tableName)))
155             return getStatementExecutionPlanText(depth);
156         else
157             return (String JavaDoc)"";
158     }
159
160     // Class implementation
161

162     public String JavaDoc toString()
163     {
164         return getStatementExecutionPlanText(0);
165     }
166
167     /**
168    * Format for display, a name for this node.
169      *
170      */

171   public String JavaDoc getNodeName(){
172     return MessageService.getTextMessage(
173                                 indexName == null ?
174                                     SQLState.RTS_TABLE_SCAN :
175                                     SQLState.RTS_INDEX_SCAN);
176   }
177
178     /**
179      * If this node is on a database item (like a table or an index), then provide a
180    * string that describes the on item.
181    *
182      */

183   public String JavaDoc getNodeOn(){
184     if (indexName == null)
185       return MessageService.getTextMessage(SQLState.RTS_ON, tableName);
186     else
187       return MessageService.getTextMessage(
188                                         SQLState.RTS_ON_USING,
189                                         tableName,
190                                         indexName);
191   }
192 }
193
Popular Tags