KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.rts.RealDeleteCascadeResultSetStatistics
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.i18n.MessageService;
25 import org.apache.derby.iapi.reference.SQLState;
26
27 /**
28   ResultSetStatistics implemenation for DeleteCascadeResultSet.
29
30   @author suresht
31
32 */

33 public class RealDeleteCascadeResultSetStatistics
34     extends RealDeleteResultSetStatistics
35 {
36
37     /* Leave these fields public for object inspectors */
38     public ResultSetStatistics[] dependentTrackingArray;
39
40     // CONSTRUCTORS
41

42     /**
43      *
44      *
45      */

46     public RealDeleteCascadeResultSetStatistics(
47                                 int rowCount,
48                                 boolean deferred,
49                                 int indexesUpdated,
50                                 boolean tableLock,
51                                 long executeTime,
52                                 ResultSetStatistics sourceResultSetStatistics,
53                                 ResultSetStatistics[] dependentTrackingArray
54                                 )
55     {
56         super(rowCount, deferred, indexesUpdated, tableLock, executeTime, sourceResultSetStatistics);
57         this.dependentTrackingArray = dependentTrackingArray;
58     }
59
60
61
62     // ResultSetStatistics interface
63

64     /**
65      * Return the statement execution plan as a String.
66      *
67      * @param depth Indentation level.
68      *
69      * @return String The statement execution plan as a String.
70      */

71     public String JavaDoc getStatementExecutionPlanText(int depth)
72     {
73
74         String JavaDoc dependentInfo = "";
75
76         initFormatInfo(depth);
77
78         /* Dump out the statistics for any depedent table for referential actions */
79         if (dependentTrackingArray != null)
80         {
81             boolean foundAttached = false;
82
83             for (int index = 0; index < dependentTrackingArray.length; index++)
84             {
85                 if (dependentTrackingArray[index] != null)
86                 {
87                     /* Only print referential actions on dependents message once */
88                     if (! foundAttached)
89                     {
90                         dependentInfo = indent + "\n" +
91                             MessageService.getTextMessage(
92                                                 SQLState.RTS_REFACTION_DEPENDENT) +
93                                 ":\n";
94                         foundAttached = true;
95                     }
96                     dependentInfo = dependentInfo +
97                         dependentTrackingArray[index].getStatementExecutionPlanText(sourceDepth);
98                 }
99             }
100         }
101
102         return
103             indent +
104               MessageService.getTextMessage(SQLState.RTS_DELETE_CASCADE_RS_USING) +
105                 " " +
106                 MessageService.getTextMessage(
107                     ((tableLock) ?
108                         SQLState.RTS_TABLE_LOCKING : SQLState.RTS_ROW_LOCKING))
109                 + ":\n" +
110             indent + MessageService.getTextMessage(SQLState.RTS_DEFERRED) +
111                 ": " + deferred + "\n" +
112             indent +
113                 MessageService.getTextMessage(SQLState.RTS_ROWS_DELETED) +
114                 " = " + rowCount + "\n" +
115             indent +
116                 MessageService.getTextMessage(SQLState.RTS_INDEXES_UPDATED) +
117                 " = " + indexesUpdated + "\n" +
118             dumpTimeStats(indent) + ((sourceResultSetStatistics == null) ? "" :
119             sourceResultSetStatistics.getStatementExecutionPlanText(1)) +
120             dependentInfo;
121     }
122
123     /**
124      * Return information on the scan nodes from the statement execution
125      * plan as a String.
126      *
127      * @param depth Indentation level.
128      * @param tableName if not NULL then print information for this table only
129      * @return String The information on the scan nodes from the
130      * statement execution plan as a String.
131      */

132     public String JavaDoc getScanStatisticsText(String JavaDoc tableName, int depth)
133     {
134         String JavaDoc dependentInfo = "";
135
136
137         /* Dump out the statistics for any depedent table scans for referential actions */
138         if (dependentTrackingArray != null)
139         {
140             for (int index = 0; index < dependentTrackingArray.length; index++)
141             {
142                 if (dependentTrackingArray[index] != null)
143                 {
144                     dependentInfo = dependentInfo +
145                                    "\n" +
146                                     MessageService.getTextMessage(
147                                                 SQLState.RTS_BEGIN_DEPENDENT_NUMBER) +
148                                     " " + index + "\n" +
149                         dependentTrackingArray[index].getScanStatisticsText(tableName, depth) +
150                         MessageService.getTextMessage(
151                                                 SQLState.RTS_END_DEPENDENT_NUMBER) +
152                         " " + index + "\n\n";
153                 }
154             }
155         }
156
157         return dependentInfo
158             + ((sourceResultSetStatistics == null) ? "" :
159                sourceResultSetStatistics.getScanStatisticsText(tableName, depth));
160     }
161
162
163  
164     /**
165    * Format for display, a name for this node.
166      *
167      */

168   public String JavaDoc getNodeName(){
169     return MessageService.getTextMessage(SQLState.RTS_DELETE_CASCADE);
170   }
171 }
172
173
174
175
176
177
178
Popular Tags