KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.rts.RealIndexRowToBaseRowStatistics
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.FormatableBitSet;
30 import org.apache.derby.iapi.services.io.FormatableHashtable;
31
32 import java.io.ObjectOutput JavaDoc;
33 import java.io.ObjectInput JavaDoc;
34 import java.io.IOException JavaDoc;
35
36 /**
37   ResultSetStatistics implemenation for IndexRowToBaseRowResultSet.
38
39   @author jerry
40
41 */

42 public class RealIndexRowToBaseRowStatistics
43     extends RealNoPutResultSetStatistics
44 {
45
46     /* Leave these fields public for object inspectors */
47     public String JavaDoc tableName;
48     public ResultSetStatistics childResultSetStatistics;
49     public String JavaDoc colsAccessedFromHeap;
50
51     // CONSTRUCTORS
52

53     /**
54      *
55      *
56      */

57     public RealIndexRowToBaseRowStatistics(
58                                 int numOpens,
59                                 int rowsSeen,
60                                 int rowsFiltered,
61                                 long constructorTime,
62                                 long openTime,
63                                 long nextTime,
64                                 long closeTime,
65                                 int resultSetNumber,
66                                 String JavaDoc tableName,
67                                 FormatableBitSet colsAccessedFromHeap,
68                                 double optimizerEstimatedRowCount,
69                                 double optimizerEstimatedCost,
70                                 ResultSetStatistics childResultSetStatistics
71                                 )
72     {
73         super(
74             numOpens,
75             rowsSeen,
76             rowsFiltered,
77             constructorTime,
78             openTime,
79             nextTime,
80             closeTime,
81             resultSetNumber,
82             optimizerEstimatedRowCount,
83             optimizerEstimatedCost
84             );
85         this.tableName = tableName;
86         this.colsAccessedFromHeap = (colsAccessedFromHeap == null) ?
87                                         "{" +
88                                         MessageService.getTextMessage(
89                                                             SQLState.RTS_ALL) +
90                                         "}" :
91                                     colsAccessedFromHeap.toString();
92         this.childResultSetStatistics = childResultSetStatistics;
93     }
94
95     // ResultSetStatistics interface
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(
110                             SQLState.RTS_IRTBR_RS,
111                             tableName) +
112                             ":" + "\n" +
113             indent + MessageService.getTextMessage(
114                             SQLState.RTS_NUM_OPENS) +
115                             " = " + numOpens + "\n" +
116             indent + MessageService.getTextMessage(
117                             SQLState.RTS_ROWS_SEEN) +
118                             " = " + rowsSeen + "\n" +
119             indent + MessageService.getTextMessage(
120                             SQLState.RTS_COLS_ACCESSED_FROM_HEAP) +
121                             " = " + colsAccessedFromHeap + "\n" +
122             dumpTimeStats(indent, subIndent) + "\n" +
123             dumpEstimatedCosts(subIndent) + "\n" +
124             childResultSetStatistics.getStatementExecutionPlanText(sourceDepth) + "\n";
125     }
126
127     /**
128      * Return information on the scan nodes from the statement execution
129      * plan as a String.
130      *
131      * @param depth Indentation level.
132      * @param tableName if not NULL then print information for this table only
133      *
134      * @return String The information on the scan nodes from the
135      * statement execution plan as a String.
136      */

137     public String JavaDoc getScanStatisticsText(String JavaDoc tableName, int depth)
138     {
139         if ((tableName == null) ||
140             (tableName.equals(this.tableName)))
141             return getStatementExecutionPlanText(depth);
142         else
143             return (String JavaDoc)"";
144     }
145
146
147     // Class implementation
148

149     public String JavaDoc toString()
150     {
151         return getStatementExecutionPlanText(0);
152     }
153   public java.util.Vector JavaDoc getChildren(){
154     java.util.Vector JavaDoc children = new java.util.Vector JavaDoc();
155     children.addElement(childResultSetStatistics);
156     return children;
157   }
158
159     /**
160      * If this node is on a database item (like a table or an index), then provide a
161    * string that describes the on item.
162    *
163      */

164   public String JavaDoc getNodeOn(){
165     return MessageService.getTextMessage(
166                                     SQLState.RTS_FOR_TAB_NAME,
167                                     tableName);
168   }
169     /**
170    * Format for display, a name for this node.
171      *
172      */

173   public String JavaDoc getNodeName(){
174     return MessageService.getTextMessage(SQLState.RTS_IRTBR);
175   }
176
177     /**
178      * Return the ResultSetStatistics for the child of this node.
179      *
180      * @return The ResultSetStatistics for the child of this node.
181      */

182     ResultSetStatistics getChildResultSetStatistics()
183     {
184         return childResultSetStatistics;
185     }
186 }
187
Popular Tags