Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / sql / execute / rts / RealSetOpResultSetStatistics.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/execute/rts/RealSetOpResultSetStatistics.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/execute/rts/RealSetOpResultSetStatistics.java
new file mode 100644 (file)
index 0000000..a61cd0c
--- /dev/null
@@ -0,0 +1,208 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.sql.execute.rts.RealSetOpResultSetStatistics\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.i18n.MessageService;\r
+import org.apache.derby.iapi.reference.SQLState;\r
+\r
+import org.apache.derby.impl.sql.compile.IntersectOrExceptNode;\r
+\r
+/**\r
+  ResultSetStatistics implementation for SetOpResultSet.\r
+\r
+\r
+*/\r
+public class RealSetOpResultSetStatistics \r
+    extends RealNoPutResultSetStatistics\r
+{\r
+       \r
+    /* Leave these fields public for object inspectors */\r
+    public int opType;\r
+    public int rowsSeenLeft;\r
+    public int rowsSeenRight;\r
+    public int rowsReturned;\r
+    public ResultSetStatistics leftResultSetStatistics;\r
+    public ResultSetStatistics rightResultSetStatistics;\r
+\r
+    // CONSTRUCTORS\r
+\r
+    /**\r
+     *  Constructs a new <code>RealSetOpResultSetStatistics</code> object \r
+     *  to represent the runtime statistics for <code>SetOpResultSet</code>.  \r
+     * \r
+     *  @param   opType                       set operation type \r
+     *  @param   numOpens                     number of open\r
+     *  @param   rowsSeen                     rows seen\r
+     *  @param   rowsFiltered                 rows filtered\r
+     *  @param   constructorTime              the time for construction\r
+     *  @param   openTime                     the time for open operation\r
+     *  @param   nextTime                     the time for next operation\r
+     *  @param   closeTime                    the time for close operation\r
+     *  @param   resultSetNumber              the result set number\r
+     *  @param   rowsSeenLeft                 rows seen by left source input\r
+     *  @param   rowsSeenRight                rows seen by right source input\r
+     *  @param   rowsReturned                 rows returned\r
+     *  @param   optimizerEstimatedRowCount   optimizer estimated row count\r
+     *  @param   optimizerEstimatedCost       optimizer estimated cost\r
+     *  @param   leftResultSetStatistics      left source runtime statistics\r
+     *  @param   rightResultSetStatistics     right source runtime statistics\r
+     *  \r
+     *  @see     org.apache.derby.impl.sql.execute.SetOpResultSet  \r
+     */\r
+    public     RealSetOpResultSetStatistics(\r
+                                 int opType,\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
+                                 int rowsSeenLeft,\r
+                                 int rowsSeenRight,\r
+                                 int rowsReturned,\r
+                                 double optimizerEstimatedRowCount,\r
+                                 double optimizerEstimatedCost,\r
+                                 ResultSetStatistics leftResultSetStatistics,\r
+                                 ResultSetStatistics rightResultSetStatistics \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
+               \r
+        this.opType = opType;\r
+        this.rowsSeenLeft = rowsSeenLeft;\r
+        this.rowsSeenRight = rowsSeenRight;\r
+        this.rowsReturned = rowsReturned;\r
+        this.leftResultSetStatistics = leftResultSetStatistics;\r
+        this.rightResultSetStatistics = rightResultSetStatistics;\r
+    }\r
+\r
+    // ResultSetStatistics methods\r
+\r
+    /**\r
+     * Return the statement execution plan as a <code>String</code>.\r
+     *\r
+     * @param depth    Indentation level.\r
+     *\r
+     * @return the statement execution plan as a <code>String</code>.\r
+     */\r
+    public String getStatementExecutionPlanText(int depth) {\r
+        initFormatInfo(depth);\r
+\r
+        String rs = (opType == IntersectOrExceptNode.INTERSECT_OP) \r
+                ? (SQLState.RTS_INTERSECT_RS) : (SQLState.RTS_EXCEPT_RS);\r
+         \r
+        return\r
+            indent + MessageService.getTextMessage(rs) + \r
+                ":\n" +\r
+            indent + MessageService.getTextMessage(SQLState.RTS_NUM_OPENS) + \r
+                " = " + numOpens + "\n" +\r
+            indent + MessageService.getTextMessage(\r
+                                            SQLState.RTS_ROWS_SEEN_LEFT) +\r
+                " = " + rowsSeenLeft + "\n" + \r
+            indent + MessageService.getTextMessage(\r
+                                            SQLState.RTS_ROWS_SEEN_RIGHT) + \r
+                " = " + rowsSeenRight + "\n" +\r
+            indent + MessageService.getTextMessage(\r
+                                            SQLState.RTS_ROWS_RETURNED) +\r
+                " = " + rowsReturned + "\n" + \r
+            dumpTimeStats(indent, subIndent) + "\n" +\r
+            dumpEstimatedCosts(subIndent) + "\n" +\r
+            indent + MessageService.getTextMessage(SQLState.RTS_LEFT_RS) +\r
+                ":\n" + \r
+            leftResultSetStatistics.getStatementExecutionPlanText(sourceDepth) +\r
+                "\n" + \r
+            indent + MessageService.getTextMessage(SQLState.RTS_RIGHT_RS) +\r
+                ":\n" + \r
+            rightResultSetStatistics.getStatementExecutionPlanText(\r
+                                                                     sourceDepth) + \r
+                "\n";\r
+    }\r
+\r
+    /**\r
+     * Return information on the scan nodes from the statement execution \r
+     * plan as a <code>String</code>.\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 <code>String</code>.\r
+     */\r
+    public String getScanStatisticsText(String tableName, int depth) {\r
+        return leftResultSetStatistics.getScanStatisticsText(tableName, depth)\r
+            + rightResultSetStatistics.getScanStatisticsText(tableName, depth);\r
+    }\r
+\r
+    // Class implementation\r
+\r
+    /**\r
+     * Return the runtime statistics of this object in textual representation\r
+     *\r
+     * @return the runtime statistics of this object in textual representation \r
+     *         as a <code>String</code>.\r
+     */\r
+    public String toString() {\r
+        return getStatementExecutionPlanText(0);\r
+    }\r
+\r
+    /**\r
+     * Retrieves the children runtime statistics of this <code>\r
+     * RealSetOpResultSetStatistics</code> object \r
+     *\r
+     * @return the children runtime statistics of this <code>\r
+     *         RealSetOpResultSetStatistics</code> object stored in a <code>\r
+     *         Vector</code>. \r
+     *         \r
+     */\r
+    public java.util.Vector getChildren() {\r
+        java.util.Vector children = new java.util.Vector();\r
+        children.addElement(leftResultSetStatistics);\r
+        children.addElement(rightResultSetStatistics);\r
+        return children;\r
+    }\r
+\r
+    /**\r
+     * Format for display, a name for this node.\r
+     *\r
+     * @return the name of the node as a <code>String</code>.\r
+     */\r
+    public String getNodeName() {\r
+        String nodeName = \r
+            (opType == IntersectOrExceptNode.INTERSECT_OP) \r
+                ? (SQLState.RTS_INTERSECT) : (SQLState.RTS_EXCEPT);\r
+               \r
+        return MessageService.getTextMessage(nodeName);\r
+    }\r
+} \r