KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > compile > MaterializeResultSetNode


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.MaterializeResultSetNode
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.compile;
23
24 import org.apache.derby.iapi.services.context.ContextManager;
25
26 import org.apache.derby.iapi.sql.compile.Optimizable;
27 import org.apache.derby.iapi.sql.compile.OptimizableList;
28 import org.apache.derby.iapi.sql.compile.OptimizablePredicate;
29 import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
30 import org.apache.derby.iapi.sql.compile.Optimizer;
31 import org.apache.derby.iapi.sql.compile.Visitable;
32 import org.apache.derby.iapi.sql.compile.Visitor;
33 import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
34
35 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
36
37 import org.apache.derby.iapi.sql.Activation;
38 import org.apache.derby.iapi.sql.ResultSet;
39
40 import org.apache.derby.iapi.error.StandardException;
41
42 import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
43
44 import org.apache.derby.iapi.services.compiler.MethodBuilder;
45
46 import org.apache.derby.iapi.services.sanity.SanityManager;
47 import org.apache.derby.iapi.reference.ClassName;
48
49 import org.apache.derby.iapi.services.classfile.VMOpcode;
50
51 import java.util.Properties JavaDoc;
52
53 /**
54  * A MaterializeResultSetNode represents a materialization result set for any
55  * child result set that needs one.
56  *
57  * @author Jerry Brenner
58  */

59
60 public class MaterializeResultSetNode extends SingleChildResultSetNode
61 {
62     /**
63      * Initializer for a MaterializeResultSetNode.
64      *
65      * @param childResult The child ResultSetNode
66      * @param rcl The RCL for the node
67      * @param tableProperties Properties list associated with the table
68      */

69
70     public void init(Object JavaDoc childResult,
71                                 Object JavaDoc rcl,
72                                 Object JavaDoc tableProperties)
73     {
74         super.init(childResult, tableProperties);
75         resultColumns = (ResultColumnList) rcl;
76     }
77
78     /**
79      * Prints the sub-nodes of this object. See QueryTreeNode.java for
80      * how tree printing is supposed to work.
81      *
82      * @param depth The depth of this node in the tree
83      */

84
85     public void printSubNodes(int depth)
86     {
87         if (SanityManager.DEBUG)
88         {
89             super.printSubNodes(depth);
90         }
91     }
92
93     /**
94      *
95      *
96      * @exception StandardException Thrown on error
97      */

98     public void generate(ActivationClassBuilder acb,
99                                 MethodBuilder mb)
100                             throws StandardException
101     {
102         if (SanityManager.DEBUG)
103         SanityManager.ASSERT(resultColumns != null, "Tree structure bad");
104
105         /* Get the next ResultSet #, so that we can number this ResultSetNode, its
106          * ResultColumnList and ResultSet.
107          */

108         assignResultSetNumber();
109
110         // Get the cost estimate from the child if we don't have one yet
111
costEstimate = childResult.getFinalCostEstimate();
112
113         // build up the tree.
114

115         // Generate the child ResultSet
116
acb.pushGetResultSetFactoryExpression(mb);
117
118         childResult.generate(acb, mb);
119         mb.push(resultSetNumber);
120         mb.push(costEstimate.rowCount());
121         mb.push(costEstimate.getEstimatedCost());
122
123         mb.callMethod(VMOpcode.INVOKEINTERFACE, (String JavaDoc) null, "getMaterializedResultSet",
124                         ClassName.NoPutResultSet, 4);
125     }
126 }
127
Popular Tags