001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.compile.ScrollInsensitiveResultSetNode
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.compile;
023:
024: import org.apache.derby.iapi.services.context.ContextManager;
025:
026: import org.apache.derby.iapi.sql.compile.CostEstimate;
027: import org.apache.derby.iapi.sql.compile.Optimizable;
028: import org.apache.derby.iapi.sql.compile.OptimizableList;
029: import org.apache.derby.iapi.sql.compile.OptimizablePredicate;
030: import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
031: import org.apache.derby.iapi.sql.compile.Optimizer;
032: import org.apache.derby.iapi.sql.compile.Visitable;
033: import org.apache.derby.iapi.sql.compile.Visitor;
034: import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
035:
036: import org.apache.derby.iapi.sql.dictionary.DataDictionary;
037:
038: import org.apache.derby.iapi.sql.Activation;
039: import org.apache.derby.iapi.sql.ResultSet;
040:
041: import org.apache.derby.iapi.error.StandardException;
042:
043: import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
044:
045: import org.apache.derby.iapi.services.compiler.MethodBuilder;
046: import org.apache.derby.iapi.reference.ClassName;
047:
048: import org.apache.derby.iapi.services.sanity.SanityManager;
049:
050: import org.apache.derby.iapi.util.JBitSet;
051: import org.apache.derby.iapi.services.classfile.VMOpcode;
052:
053: import java.util.Properties;
054:
055: /**
056: * A ScrollInsensitiveResultSetNode represents the insensitive scrolling cursor
057: * functionality for any
058: * child result set that needs one.
059: *
060: * @author Jerry Brenner
061: */
062:
063: public class ScrollInsensitiveResultSetNode extends
064: SingleChildResultSetNode {
065: /**
066: * Initializer for a ScrollInsensitiveResultSetNode.
067: *
068: * @param childResult The child ResultSetNode
069: * @param rcl The RCL for the node
070: * @param tableProperties Properties list associated with the table
071: */
072:
073: public void init(Object childResult, Object rcl,
074: Object tableProperties) {
075: init(childResult, tableProperties);
076: resultColumns = (ResultColumnList) rcl;
077: }
078:
079: /**
080: *
081: *
082: * @exception StandardException Thrown on error
083: */
084: public void generate(ActivationClassBuilder acb, MethodBuilder mb)
085: throws StandardException {
086: if (SanityManager.DEBUG)
087: SanityManager.ASSERT(resultColumns != null,
088: "Tree structure bad");
089:
090: /* Get the next ResultSet #, so that we can number this ResultSetNode, its
091: * ResultColumnList and ResultSet.
092: */
093: assignResultSetNumber();
094:
095: // build up the tree.
096:
097: // Generate the child ResultSet
098:
099: // Get the cost estimate for the child
100: costEstimate = childResult.getFinalCostEstimate();
101:
102: int erdNumber = acb.addItem(makeResultDescription());
103:
104: acb.pushGetResultSetFactoryExpression(mb);
105:
106: childResult.generate(acb, mb);
107: acb.pushThisAsActivation(mb);
108: mb.push(resultSetNumber);
109: mb.push(resultColumns.size());
110:
111: mb.pushThis();
112: mb.callMethod(VMOpcode.INVOKEVIRTUAL, ClassName.BaseActivation,
113: "getScrollable", "boolean", 0);
114:
115: mb.push(costEstimate.rowCount());
116: mb.push(costEstimate.getEstimatedCost());
117:
118: mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null,
119: "getScrollInsensitiveResultSet",
120: ClassName.NoPutResultSet, 7);
121: }
122: }
|