001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealUpdateResultSetStatistics
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.execute.rts;
023:
024: import org.apache.derby.iapi.services.io.StoredFormatIds;
025:
026: import org.apache.derby.iapi.services.i18n.MessageService;
027: import org.apache.derby.iapi.reference.SQLState;
028:
029: import org.apache.derby.iapi.services.io.FormatableHashtable;
030:
031: import java.io.ObjectOutput;
032: import java.io.ObjectInput;
033: import java.io.IOException;
034:
035: /**
036: ResultSetStatistics implemenation for UpdateResultSet.
037:
038: @author jerry
039:
040: */
041: public class RealUpdateResultSetStatistics extends
042: RealNoRowsResultSetStatistics {
043:
044: /* Leave these fields public for object inspectors */
045: public int rowCount;
046: public boolean deferred;
047: public boolean tableLock;
048: public int indexesUpdated;
049:
050: // CONSTRUCTORS
051:
052: /**
053: *
054: *
055: */
056: public RealUpdateResultSetStatistics(int rowCount,
057: boolean deferred, int indexesUpdated, boolean tableLock,
058: long executeTime,
059: ResultSetStatistics sourceResultSetStatistics) {
060: super (executeTime, sourceResultSetStatistics);
061: this .rowCount = rowCount;
062: this .deferred = deferred;
063: this .indexesUpdated = indexesUpdated;
064: this .tableLock = tableLock;
065: this .sourceResultSetStatistics = sourceResultSetStatistics;
066: }
067:
068: // ResultSetStatistics interface
069:
070: /**
071: * Return the statement execution plan as a String.
072: *
073: * @param depth Indentation level.
074: *
075: * @return String The statement execution plan as a String.
076: */
077: public String getStatementExecutionPlanText(int depth) {
078: initFormatInfo(depth);
079:
080: return indent
081: + MessageService
082: .getTextMessage(
083: SQLState.RTS_UPDATE_RS_USING,
084: MessageService
085: .getTextMessage(tableLock ? SQLState.LANG_TABLE
086: : SQLState.LANG_ROW))
087: + ":\n"
088: + indent
089: + MessageService.getTextMessage(SQLState.RTS_DEFERRED)
090: + ": "
091: + deferred
092: + "\n"
093: + indent
094: + MessageService
095: .getTextMessage(SQLState.RTS_ROWS_UPDATED)
096: + " = "
097: + rowCount
098: + "\n"
099: + indent
100: + MessageService
101: .getTextMessage(SQLState.RTS_INDEXES_UPDATED)
102: + " = "
103: + indexesUpdated
104: + "\n"
105: + dumpTimeStats(indent)
106: + ((sourceResultSetStatistics == null) ? ""
107: : sourceResultSetStatistics
108: .getStatementExecutionPlanText(1));
109: }
110:
111: /**
112: * Return information on the scan nodes from the statement execution
113: * plan as a String.
114: *
115: * @param depth Indentation level.
116: * @param tableName if not NULL then print information for this table only
117: *
118: * @return String The information on the scan nodes from the
119: * statement execution plan as a String.
120: */
121: public String getScanStatisticsText(String tableName, int depth) {
122: if (sourceResultSetStatistics == null)
123: return "";
124:
125: return sourceResultSetStatistics.getScanStatisticsText(
126: tableName, depth);
127: }
128:
129: // Formatable methods
130:
131: // Class implementation
132:
133: public String toString() {
134: return getStatementExecutionPlanText(0);
135: }
136:
137: /**
138: * Format for display, a name for this node.
139: *
140: */
141: public String getNodeName() {
142: return MessageService.getTextMessage(SQLState.RTS_UPDATE);
143: }
144: }
|