KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.NormalizeResultSetNode
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 import org.apache.derby.iapi.reference.ClassName;
38
39 import org.apache.derby.iapi.sql.Activation;
40 import org.apache.derby.iapi.sql.ResultSet;
41
42 import org.apache.derby.iapi.error.StandardException;
43
44 import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
45
46 import org.apache.derby.iapi.services.compiler.MethodBuilder;
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 NormalizeResultSetNode represents a normalization result set for any
57  * child result set that needs one.
58  *
59  * @author Jerry Brenner
60  */

61
62 public class NormalizeResultSetNode extends SingleChildResultSetNode
63 {
64     /**
65      * this indicates if the normalize is being performed for an Update
66      * statement or not. The row passed to update also has
67      * before values of the columns being updated-- we need not
68      * normalize these values.
69      */

70     private boolean forUpdate;
71
72     /**
73      * Initializer for a NormalizeResultSetNode.
74      *
75      * @param childResult The child ResultSetNode
76      * @param rcl The RCL for the node
77      * @param tableProperties Properties list associated with the table
78      * @param forUpdate tells us if the normalize operation is being
79      * performed on behalf of an update statement.
80      */

81
82     public void init(
83                             Object JavaDoc childResult,
84                             Object JavaDoc rcl,
85                             Object JavaDoc tableProperties,
86                             Object JavaDoc forUpdate)
87     {
88         super.init(childResult, tableProperties);
89         resultColumns = (ResultColumnList) rcl;
90         this.forUpdate = ((Boolean JavaDoc)forUpdate).booleanValue();
91     }
92
93
94     /**
95      *
96      *
97      * @exception StandardException Thrown on error
98      */

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

111         assignResultSetNumber();
112
113         // build up the tree.
114

115         // Generate the child ResultSet
116

117         // Get the cost estimate for the child
118
costEstimate = childResult.getFinalCostEstimate();
119
120         erdNumber = acb.addItem(makeResultDescription());
121
122         acb.pushGetResultSetFactoryExpression(mb);
123         childResult.generate(acb, mb);
124         mb.push(resultSetNumber);
125         mb.push(erdNumber);
126         mb.push(costEstimate.rowCount());
127         mb.push(costEstimate.getEstimatedCost());
128         mb.push(forUpdate);
129
130         mb.callMethod(VMOpcode.INVOKEINTERFACE, (String JavaDoc) null, "getNormalizeResultSet",
131                     ClassName.NoPutResultSet, 6);
132     }
133
134     /**
135      * set the Information gathered from the parent table that is
136      * required to peform a referential action on dependent table.
137      */

138     public void setRefActionInfo(long fkIndexConglomId,
139                                  int[]fkColArray,
140                                  String JavaDoc parentResultSetId,
141                                  boolean dependentScan)
142     {
143         childResult.setRefActionInfo(fkIndexConglomId,
144                                    fkColArray,
145                                    parentResultSetId,
146                                    dependentScan);
147     }
148
149
150 }
151
Popular Tags