KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.ScrollInsensitiveResultSetNode
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.CostEstimate;
27 import org.apache.derby.iapi.sql.compile.Optimizable;
28 import org.apache.derby.iapi.sql.compile.OptimizableList;
29 import org.apache.derby.iapi.sql.compile.OptimizablePredicate;
30 import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
31 import org.apache.derby.iapi.sql.compile.Optimizer;
32 import org.apache.derby.iapi.sql.compile.Visitable;
33 import org.apache.derby.iapi.sql.compile.Visitor;
34 import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
35
36 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
37
38 import org.apache.derby.iapi.sql.Activation;
39 import org.apache.derby.iapi.sql.ResultSet;
40
41 import org.apache.derby.iapi.error.StandardException;
42
43 import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
44
45 import org.apache.derby.iapi.services.compiler.MethodBuilder;
46 import org.apache.derby.iapi.reference.ClassName;
47
48 import org.apache.derby.iapi.services.sanity.SanityManager;
49
50 import org.apache.derby.iapi.util.JBitSet;
51 import org.apache.derby.iapi.services.classfile.VMOpcode;
52
53 import java.util.Properties JavaDoc;
54
55 /**
56  * A ScrollInsensitiveResultSetNode represents the insensitive scrolling cursor
57  * functionality for any
58  * child result set that needs one.
59  *
60  * @author Jerry Brenner
61  */

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

72
73     public void init(
74                             Object JavaDoc childResult,
75                             Object JavaDoc rcl,
76                             Object JavaDoc tableProperties)
77     {
78         init(childResult, tableProperties);
79         resultColumns = (ResultColumnList) rcl;
80     }
81
82     /**
83      *
84      *
85      * @exception StandardException Thrown on error
86      */

87     public void generate(ActivationClassBuilder acb,
88                                 MethodBuilder mb)
89                             throws StandardException
90     {
91         if (SanityManager.DEBUG)
92         SanityManager.ASSERT(resultColumns != null, "Tree structure bad");
93
94         /* Get the next ResultSet #, so that we can number this ResultSetNode, its
95          * ResultColumnList and ResultSet.
96          */

97         assignResultSetNumber();
98
99         // build up the tree.
100

101         // Generate the child ResultSet
102

103         // Get the cost estimate for the child
104
costEstimate = childResult.getFinalCostEstimate();
105
106         int erdNumber = acb.addItem(makeResultDescription());
107
108         acb.pushGetResultSetFactoryExpression(mb);
109
110         childResult.generate(acb, mb);
111         acb.pushThisAsActivation(mb);
112         mb.push(resultSetNumber);
113         mb.push(resultColumns.size());
114
115         mb.pushThis();
116         mb.callMethod(VMOpcode.INVOKEVIRTUAL, ClassName.BaseActivation, "getScrollable",
117                         "boolean", 0);
118
119         mb.push(costEstimate.rowCount());
120         mb.push(costEstimate.getEstimatedCost());
121
122         mb.callMethod(VMOpcode.INVOKEINTERFACE, (String JavaDoc) null, "getScrollInsensitiveResultSet",
123                         ClassName.NoPutResultSet, 7);
124     }
125 }
126
Popular Tags