--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.sql.execute.rts.RealProjectRestrictStatistics\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.sql.execute.rts;\r
+\r
+import org.apache.derby.iapi.services.io.StoredFormatIds;\r
+\r
+import org.apache.derby.iapi.services.i18n.MessageService;\r
+import org.apache.derby.iapi.reference.SQLState;\r
+\r
+import org.apache.derby.iapi.services.io.FormatableHashtable;\r
+\r
+import java.io.ObjectOutput;\r
+import java.io.ObjectInput;\r
+import java.io.IOException;\r
+\r
+/**\r
+ ResultSetStatistics implemenation for ProjectRestrictResultSet.\r
+\r
+\r
+*/\r
+public class RealProjectRestrictStatistics \r
+ extends RealNoPutResultSetStatistics\r
+{\r
+\r
+ /* Leave these fields public for object inspectors */\r
+ public boolean doesProjection;\r
+ public boolean restriction;\r
+ public long restrictionTime;\r
+ public long projectionTime;\r
+ public ResultSetStatistics childResultSetStatistics;\r
+ public ResultSetStatistics[] subqueryTrackingArray;\r
+\r
+ // CONSTRUCTORS\r
+\r
+ /**\r
+ * \r
+ *\r
+ */\r
+ public RealProjectRestrictStatistics(\r
+ int numOpens,\r
+ int rowsSeen,\r
+ int rowsFiltered,\r
+ long constructorTime,\r
+ long openTime,\r
+ long nextTime,\r
+ long closeTime,\r
+ int resultSetNumber,\r
+ long restrictionTime,\r
+ long projectionTime,\r
+ ResultSetStatistics[] subqueryTrackingArray,\r
+ boolean restriction,\r
+ boolean doesProjection,\r
+ double optimizerEstimatedRowCount,\r
+ double optimizerEstimatedCost,\r
+ ResultSetStatistics childResultSetStatistics\r
+ )\r
+ {\r
+ super(\r
+ numOpens,\r
+ rowsSeen,\r
+ rowsFiltered,\r
+ constructorTime,\r
+ openTime,\r
+ nextTime,\r
+ closeTime,\r
+ resultSetNumber,\r
+ optimizerEstimatedRowCount,\r
+ optimizerEstimatedCost\r
+ );\r
+ this.restriction = restriction;\r
+ this.doesProjection = doesProjection;\r
+ this.restrictionTime = restrictionTime;\r
+ this.projectionTime = projectionTime;\r
+ this.subqueryTrackingArray = subqueryTrackingArray;\r
+ this.childResultSetStatistics = childResultSetStatistics;\r
+ }\r
+\r
+ // ResultSetStatistics methods\r
+\r
+ /**\r
+ * Return the statement execution plan as a String.\r
+ *\r
+ * @param depth Indentation level.\r
+ *\r
+ * @return String The statement execution plan as a String.\r
+ */\r
+ public String getStatementExecutionPlanText(int depth)\r
+ {\r
+ String subqueryInfo = "";\r
+\r
+ initFormatInfo(depth);\r
+\r
+ /* Dump out the statistics for any subqueries */\r
+\r
+ if (subqueryTrackingArray != null)\r
+ {\r
+ boolean foundAttached = false;\r
+\r
+ for (int index = 0; index < subqueryTrackingArray.length; index++)\r
+ {\r
+ if (subqueryTrackingArray[index] != null)\r
+ {\r
+ /* Only print attached subqueries message once */\r
+ if (! foundAttached)\r
+ {\r
+ subqueryInfo = indent +\r
+ MessageService.getTextMessage(\r
+ SQLState.RTS_ATTACHED_SQS) +\r
+ ":\n";\r
+ foundAttached = true;\r
+ }\r
+ subqueryInfo = subqueryInfo +\r
+ subqueryTrackingArray[index].getStatementExecutionPlanText(sourceDepth);\r
+ }\r
+ }\r
+ }\r
+\r
+ return\r
+ subqueryInfo +\r
+ indent + MessageService.getTextMessage(SQLState.RTS_PR_RS) +\r
+ " (" + resultSetNumber + "):" + "\n" +\r
+ indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) +\r
+ " = " + numOpens + "\n" +\r
+ indent + MessageService.getTextMessage(SQLState.RTS_ROWS_SEEN) +\r
+ " = " + rowsSeen + "\n" +\r
+ indent + MessageService.getTextMessage(\r
+ SQLState.RTS_ROWS_FILTERED) +\r
+ " = " + rowsFiltered + "\n" +\r
+ indent + MessageService.getTextMessage(\r
+ SQLState.RTS_RESTRICTION) +\r
+ " = " + restriction + "\n" +\r
+ indent + MessageService.getTextMessage(SQLState.RTS_PROJECTION) +\r
+ " = " + doesProjection + "\n" +\r
+ dumpTimeStats(indent, subIndent) + "\n" +\r
+ subIndent + MessageService.getTextMessage(\r
+ SQLState.RTS_RESTRICTION_TIME) +\r
+ " = " + restrictionTime + "\n" +\r
+ subIndent + MessageService.getTextMessage(\r
+ SQLState.RTS_PROJECTION_TIME) +\r
+ " = " + projectionTime + "\n" +\r
+ dumpEstimatedCosts(subIndent) + "\n" +\r
+ indent + MessageService.getTextMessage(SQLState.RTS_SOURCE_RS) +\r
+ ":" + "\n" +\r
+ childResultSetStatistics.getStatementExecutionPlanText(sourceDepth);\r
+ }\r
+\r
+ /**\r
+ * Return information on the scan nodes from the statement execution \r
+ * plan as a String.\r
+ *\r
+ * @param depth Indentation level.\r
+ * @param tableName if not NULL then print information for this table only\r
+ *\r
+ * @return String The information on the scan nodes from the \r
+ * statement execution plan as a String.\r
+ */\r
+ public String getScanStatisticsText(String tableName, int depth)\r
+ {\r
+ String subqueryInfo = "";\r
+\r
+ /* Dump out the statistics for any subqueries */\r
+\r
+ /* RESOLVE - until we externalize RunTimeStats, we just use\r
+ * this.subqueryTrackingArray since we are currently getting called\r
+ * on a close() and the StatementContext has changed and doesn't have\r
+ * a pointer to the top result set. When we externalize RunTimeStats,\r
+ * the JDBC Driver will have to push a new context and we will have\r
+ * to assign the top resultset there. (Not sure what to do about\r
+ * insert/update/delete.)\r
+ *\r
+ NoPutResultSet[] subqueryTrackingArray = sc.getSubqueryTrackingArray();\r
+ */ \r
+\r
+ if (subqueryTrackingArray != null)\r
+ {\r
+ for (int index = 0; index < subqueryTrackingArray.length; index++)\r
+ {\r
+ if (subqueryTrackingArray[index] != null)\r
+ {\r
+ subqueryInfo = subqueryInfo +\r
+ "\n" +\r
+ MessageService.getTextMessage(\r
+ SQLState.RTS_BEGIN_SQ_NUMBER) +\r
+ " " + index + "\n" +\r
+ subqueryTrackingArray[index].getScanStatisticsText(tableName, depth) +\r
+ MessageService.getTextMessage(\r
+ SQLState.RTS_END_SQ_NUMBER) +\r
+ " " + index + "\n\n";\r
+ }\r
+ }\r
+ }\r
+\r
+ return subqueryInfo \r
+ + childResultSetStatistics.getScanStatisticsText(tableName, depth);\r
+ }\r
+\r
+\r
+\r
+ // Class implementation\r
+ \r
+ public String toString()\r
+ {\r
+ return getStatementExecutionPlanText(0);\r
+ }\r
+ public java.util.Vector getChildren(){\r
+ java.util.Vector children = new java.util.Vector();\r
+ children.addElement(childResultSetStatistics);\r
+\r
+ // get all of our subqueries\r
+ if (subqueryTrackingArray != null)\r
+ {\r
+ for (int index = 0; index < subqueryTrackingArray.length; index++)\r
+ {\r
+ if (subqueryTrackingArray[index] != null)\r
+ {\r
+ children.addElement(subqueryTrackingArray[index]);\r
+ }\r
+ }\r
+ }\r
+ return children;\r
+ }\r
+ /**\r
+ * Format for display, a name for this node.\r
+ *\r
+ */\r
+ public String getNodeName(){\r
+ return MessageService.getTextMessage(SQLState.RTS_PR);\r
+ }\r
+}\r