Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / sql / compile / NormalizeResultSetNode.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
new file mode 100644 (file)
index 0000000..ca261e0
--- /dev/null
@@ -0,0 +1,149 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.sql.compile.NormalizeResultSetNode\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.compile;\r
+\r
+import org.apache.derby.iapi.services.context.ContextManager;\r
+\r
+import org.apache.derby.iapi.sql.compile.CostEstimate;\r
+import org.apache.derby.iapi.sql.compile.Optimizable;\r
+import org.apache.derby.iapi.sql.compile.OptimizableList;\r
+import org.apache.derby.iapi.sql.compile.OptimizablePredicate;\r
+import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;\r
+import org.apache.derby.iapi.sql.compile.Optimizer;\r
+import org.apache.derby.iapi.sql.compile.Visitable;\r
+import org.apache.derby.iapi.sql.compile.Visitor;\r
+import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;\r
+\r
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;\r
+import org.apache.derby.iapi.reference.ClassName;\r
+\r
+import org.apache.derby.iapi.sql.Activation;\r
+import org.apache.derby.iapi.sql.ResultSet;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.impl.sql.compile.ActivationClassBuilder;\r
+\r
+import org.apache.derby.iapi.services.compiler.MethodBuilder;\r
+\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+\r
+import org.apache.derby.iapi.util.JBitSet;\r
+import org.apache.derby.iapi.services.classfile.VMOpcode;\r
+\r
+import java.util.Properties;\r
+\r
+/**\r
+ * A NormalizeResultSetNode represents a normalization result set for any \r
+ * child result set that needs one.\r
+ *\r
+ */\r
+\r
+public class NormalizeResultSetNode extends SingleChildResultSetNode\r
+{\r
+       /**\r
+        * this indicates if the normalize is being performed for an Update\r
+        * statement or not. The row passed to update also has\r
+        * before values of the columns being updated-- we need not \r
+        * normalize these values. \r
+        */\r
+       private boolean forUpdate;\r
+\r
+       /**\r
+        * Initializer for a NormalizeResultSetNode.\r
+        *\r
+        * @param childResult   The child ResultSetNode\r
+        * @param rcl                   The RCL for the node\r
+        * @param tableProperties       Properties list associated with the table\r
+        * @param forUpdate     tells us if the normalize operation is being\r
+        * performed on behalf of an update statement. \r
+        */\r
+\r
+       public void init(\r
+                                                       Object childResult,\r
+                                                       Object rcl,\r
+                                                       Object tableProperties,\r
+                                                       Object forUpdate)\r
+       {\r
+               super.init(childResult, tableProperties);\r
+               resultColumns = (ResultColumnList) rcl;\r
+               this.forUpdate = ((Boolean)forUpdate).booleanValue();\r
+       }\r
+\r
+\r
+    /**\r
+     *\r
+        *\r
+        * @exception StandardException         Thrown on error\r
+     */\r
+       public void generate(ActivationClassBuilder acb,\r
+                                                               MethodBuilder mb)\r
+                                                       throws StandardException\r
+       {\r
+               int                             erdNumber;\r
+\r
+               if (SanityManager.DEBUG)\r
+        SanityManager.ASSERT(resultColumns != null, "Tree structure bad");\r
+\r
+               /* Get the next ResultSet #, so that we can number this ResultSetNode, its\r
+                * ResultColumnList and ResultSet.\r
+                */\r
+               assignResultSetNumber();\r
+\r
+               // build up the tree.\r
+\r
+               // Generate the child ResultSet\r
+\r
+               // Get the cost estimate for the child\r
+               costEstimate = childResult.getFinalCostEstimate();\r
+\r
+               erdNumber = acb.addItem(makeResultDescription());\r
+\r
+               acb.pushGetResultSetFactoryExpression(mb);\r
+               childResult.generate(acb, mb);\r
+               mb.push(resultSetNumber);\r
+               mb.push(erdNumber);\r
+               mb.push(costEstimate.rowCount());\r
+               mb.push(costEstimate.getEstimatedCost());\r
+               mb.push(forUpdate);\r
+\r
+               mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getNormalizeResultSet",\r
+                                       ClassName.NoPutResultSet, 6);\r
+       }\r
+\r
+       /**\r
+        * set the Information gathered from the parent table that is \r
+        * required to peform a referential action on dependent table.\r
+        */\r
+       public void setRefActionInfo(long fkIndexConglomId, \r
+                                                                int[]fkColArray, \r
+                                                                String parentResultSetId,\r
+                                                                boolean dependentScan)\r
+       {\r
+               childResult.setRefActionInfo(fkIndexConglomId,\r
+                                                                  fkColArray,\r
+                                                                  parentResultSetId,\r
+                                                                  dependentScan);\r
+       }\r
+\r
+\r
+}\r