KickJava   Java API By Example, From Geeks To Geeks.

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


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

41 public class RealInsertResultSetStatistics
42     extends RealNoRowsResultSetStatistics
43 {
44
45     /* Leave these fields public for object inspectors */
46     public int rowCount;
47     public boolean deferred;
48     public int indexesUpdated;
49     public boolean userSpecifiedBulkInsert;
50     public boolean bulkInsertPerformed;
51     public boolean tableLock;
52
53     // CONSTRUCTORS
54

55     /**
56      *
57      *
58      */

59     public RealInsertResultSetStatistics(
60                                 int rowCount,
61                                 boolean deferred,
62                                 int indexesUpdated,
63                                 boolean userSpecifiedBulkInsert,
64                                 boolean bulkInsertPerformed,
65                                 boolean tableLock,
66                                 long executeTime,
67                                 ResultSetStatistics sourceResultSetStatistics
68                                 )
69     {
70         super(executeTime, sourceResultSetStatistics);
71         this.rowCount = rowCount;
72         this.deferred = deferred;
73         this.indexesUpdated = indexesUpdated;
74         this.userSpecifiedBulkInsert = userSpecifiedBulkInsert;
75         this.bulkInsertPerformed = bulkInsertPerformed;
76         this.tableLock = tableLock;
77         this.sourceResultSetStatistics = sourceResultSetStatistics;
78     }
79
80     // ResultSetStatistics interface
81

82     /**
83      * Return the statement execution plan as a String.
84      *
85      * @param depth Indentation level.
86      *
87      * @return String The statement execution plan as a String.
88      */

89     public String JavaDoc getStatementExecutionPlanText(int depth)
90     {
91         initFormatInfo(depth);
92
93         String JavaDoc insertMode;
94
95         
96         if (userSpecifiedBulkInsert)
97         {
98             if (bulkInsertPerformed)
99             {
100                 insertMode = indent + MessageService.getTextMessage(
101                                             SQLState.RTS_INSERT_MODE_BULK);
102             }
103             else
104             {
105                 insertMode = indent + MessageService.getTextMessage(
106                                             SQLState.RTS_INSERT_MODE_NOT_BULK);
107             }
108         }
109         else
110         {
111             insertMode = indent + MessageService.getTextMessage(
112                                             SQLState.RTS_INSERT_MODE_NORMAL);
113         }
114
115         insertMode += "\n";
116
117         return
118             indent + MessageService.getTextMessage(
119                                             SQLState.RTS_INSERT_USING) +
120                     " " +
121                     MessageService.getTextMessage(
122                                                 tableLock ?
123                                                     SQLState.RTS_TABLE_LOCKING :
124                                                     SQLState.RTS_ROW_LOCKING) +
125                     ":\n" +
126             indent + MessageService.getTextMessage(SQLState.RTS_DEFERRED) +
127                     ": " + deferred + "\n" +
128             insertMode +
129             indent + MessageService.getTextMessage(
130                                                 SQLState.RTS_ROWS_INSERTED) +
131                     " = " + rowCount + "\n" +
132             indent + MessageService.getTextMessage(
133                                                 SQLState.RTS_INDEXES_UPDATED) +
134                     " = " + indexesUpdated + "\n" +
135             dumpTimeStats(indent) + ((sourceResultSetStatistics == null)? null :
136             sourceResultSetStatistics.getStatementExecutionPlanText(1));
137     }
138
139     /**
140      * Return information on the scan nodes from the statement execution
141      * plan as a String.
142      *
143      * @param depth Indentation level.
144      * @param tableName if not NULL then print information for this table only
145      *
146      * @return String The information on the scan nodes from the
147      * statement execution plan as a String.
148      */

149     public String JavaDoc getScanStatisticsText(String JavaDoc tableName, int depth)
150     {
151         if (sourceResultSetStatistics == null)
152             return null;
153
154         return sourceResultSetStatistics.getScanStatisticsText(tableName, depth);
155     }
156
157
158     // Class implementation
159

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

168   public String JavaDoc getNodeName(){
169     return MessageService.getTextMessage(SQLState.RTS_INSERT);
170   }
171 }
172
Popular Tags