--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.sql.compile.MaterializeResultSetNode\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.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
+\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
+import org.apache.derby.iapi.reference.ClassName;\r
+\r
+import org.apache.derby.iapi.services.classfile.VMOpcode;\r
+\r
+import java.util.Properties;\r
+\r
+/**\r
+ * A MaterializeResultSetNode represents a materialization result set for any \r
+ * child result set that needs one.\r
+ *\r
+ */\r
+\r
+public class MaterializeResultSetNode extends SingleChildResultSetNode\r
+{\r
+ /**\r
+ * Initializer for a MaterializeResultSetNode.\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
+ */\r
+\r
+ public void init(Object childResult,\r
+ Object rcl,\r
+ Object tableProperties)\r
+ {\r
+ super.init(childResult, tableProperties);\r
+ resultColumns = (ResultColumnList) rcl;\r
+ }\r
+\r
+ /**\r
+ * Prints the sub-nodes of this object. See QueryTreeNode.java for\r
+ * how tree printing is supposed to work.\r
+ *\r
+ * @param depth The depth of this node in the tree\r
+ */\r
+\r
+ public void printSubNodes(int depth)\r
+ {\r
+ if (SanityManager.DEBUG)\r
+ {\r
+ super.printSubNodes(depth);\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
+ 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
+ // Get the cost estimate from the child if we don't have one yet\r
+ costEstimate = childResult.getFinalCostEstimate();\r
+\r
+ // build up the tree.\r
+\r
+ // Generate the child ResultSet\r
+ acb.pushGetResultSetFactoryExpression(mb);\r
+\r
+ childResult.generate(acb, mb);\r
+ mb.push(resultSetNumber);\r
+ mb.push(costEstimate.rowCount());\r
+ mb.push(costEstimate.getEstimatedCost());\r
+\r
+ mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getMaterializedResultSet",\r
+ ClassName.NoPutResultSet, 4);\r
+ }\r
+}\r