You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by da...@apache.org on 2013/06/21 09:47:52 UTC
svn commit: r1495305 [9/21] - in /db/derby/code/trunk:
java/engine/org/apache/derby/ java/engine/org/apache/derby/catalog/types/
java/engine/org/apache/derby/iapi/services/io/
java/engine/org/apache/derby/iapi/sql/
java/engine/org/apache/derby/iapi/sql...
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java Fri Jun 21 07:47:47 2013
@@ -22,16 +22,16 @@
package org.apache.derby.impl.sql.compile;
import java.util.ArrayList;
-import java.util.Comparator;
import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
-
import org.apache.derby.catalog.IndexDescriptor;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.reference.ClassName;
import org.apache.derby.iapi.reference.SQLState;
import org.apache.derby.iapi.services.classfile.VMOpcode;
import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.io.FormatableArrayHolder;
import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.LanguageFactory;
@@ -51,7 +51,6 @@ import org.apache.derby.iapi.store.acces
import org.apache.derby.impl.sql.execute.AggregatorInfo;
import org.apache.derby.impl.sql.execute.AggregatorInfoList;
-
/**
* A GroupByNode represents a result set for a grouping operation
* on a select. Note that this includes a SELECT with aggregates
@@ -72,7 +71,7 @@ import org.apache.derby.impl.sql.execute
*
*
*/
-public class GroupByNode extends SingleChildResultSetNode
+class GroupByNode extends SingleChildResultSetNode
{
/**
* The GROUP BY list
@@ -83,7 +82,7 @@ public class GroupByNode extends SingleC
* The list of all aggregates in the query block
* that contains this group by.
*/
- private List aggregates;
+ private List<AggregateNode> aggregates;
/**
* Information that is used at execution time to
@@ -111,42 +110,42 @@ public class GroupByNode extends SingleC
private SubqueryList havingSubquerys;
/**
- * Intializer for a GroupByNode.
+ * Constructor for a GroupByNode.
*
- * @param bottomPR The child FromTable
+ * @param bottomPR The child FromTable
* @param groupingList The groupingList
* @param aggregates The list of aggregates from
* the query block. Since aggregation is done
* at the same time as grouping, we need them
* here.
- * @param havingClause The having clause.
+ * @param havingClause The having clause.
* @param havingSubquerys subqueries in the having clause.
- * @param tableProperties Properties list associated with the table
- * @param nestingLevel nestingLevel of this group by node. This is used for
+ * @param nestingLevel NestingLevel of this group by node. This is used for
* error checking of group by queries with having clause.
+ * @param cm The context manager
* @exception StandardException Thrown on error
*/
- public void init(
- Object bottomPR,
- Object groupingList,
- Object aggregates,
- Object havingClause,
- Object havingSubquerys,
- Object tableProperties,
- Object nestingLevel)
+ GroupByNode(ResultSetNode bottomPR,
+ GroupByList groupingList,
+ List<AggregateNode> aggregates,
+ ValueNode havingClause,
+ SubqueryList havingSubquerys,
+ int nestingLevel,
+ ContextManager cm)
throws StandardException
{
- super.init(bottomPR, tableProperties);
- setLevel(((Integer)nestingLevel).intValue());
- this.havingClause = (ValueNode)havingClause;
- this.havingSubquerys = (SubqueryList)havingSubquerys;
+ super(bottomPR, null /* tableProperties */, cm);
+ setNodeType(C_NodeTypes.GROUP_BY_NODE);
+ setLevel(nestingLevel);
+ this.havingClause = havingClause;
+ this.havingSubquerys = havingSubquerys;
/* Group by without aggregates gets xformed into distinct */
if (SanityManager.DEBUG)
{
-// Aggregates can be null if we have a having clause.
-// select c1 from t1 group by c1 having c1 > 1;
-// SanityManager.ASSERT(((List) aggregates).size() > 0,
-// "aggregates expected to be non-empty");
+ // Aggregates can be null if we have a having clause.
+ // select c1 from t1 group by c1 having c1 > 1;
+ // SanityManager.ASSERT(((List) aggregates).size() > 0,
+ // "aggregates expected to be non-empty");
if (!(childResult instanceof Optimizable))
{
SanityManager.THROWASSERT("childResult, " + childResult.getClass().getName() +
@@ -160,8 +159,8 @@ public class GroupByNode extends SingleC
}
ResultColumnList newBottomRCL;
- this.groupingList = (GroupByList) groupingList;
- this.aggregates = (List) aggregates;
+ this.groupingList = groupingList;
+ this.aggregates = aggregates;
this.parent = this;
/*
@@ -264,7 +263,7 @@ public class GroupByNode extends SingleC
int count = aggInfo.size();
for (int i = 0; i < count; i++)
{
- agg = (AggregatorInfo) aggInfo.elementAt(i);
+ agg = aggInfo.elementAt(i);
if (agg.isDistinct())
{
break;
@@ -293,9 +292,7 @@ public class GroupByNode extends SingleC
/*
** Get the new PR, put above the GroupBy.
*/
- ResultColumnList rclNew = (ResultColumnList)getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager());
+ ResultColumnList rclNew = new ResultColumnList((getContextManager()));
int sz = resultColumns.size();
for (int i = 0; i < sz; i++)
{
@@ -310,8 +307,7 @@ public class GroupByNode extends SingleC
// have to be projected out upstream.
rclNew.copyOrderBySelect(resultColumns);
- parent = (FromTable) getNodeFactory().getNode(
- C_NodeTypes.PROJECT_RESTRICT_NODE,
+ parent = new ProjectRestrictNode(
this, // child
rclNew,
null, //havingClause,
@@ -325,17 +321,12 @@ public class GroupByNode extends SingleC
/*
** Reset the bottom RCL to be empty.
*/
- childResult.setResultColumns((ResultColumnList)
- getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager()));
+ childResult.setResultColumns(new ResultColumnList(getContextManager()));
/*
** Set the group by RCL to be empty
*/
- resultColumns = (ResultColumnList) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager());
+ resultColumns = new ResultColumnList((getContextManager()));
}
@@ -363,9 +354,8 @@ public class GroupByNode extends SingleC
for (int i = 0; i < sz; i++)
{
GroupByColumn gbc = (GroupByColumn) groupingList.elementAt(i);
- ResultColumn newRC = (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
- "##UnaggColumn",
+ ResultColumn newRC = new ResultColumn(
+ "##UnaggColumn",
gbc.getColumnExpression(),
getContextManager());
@@ -376,12 +366,12 @@ public class GroupByNode extends SingleC
newRC.setVirtualColumnId(bottomRCL.size());
// now add this column to the groupbylist
- ResultColumn gbRC = (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
- "##UnaggColumn",
+ ResultColumn gbRC = new ResultColumn(
+ "##UnaggColumn",
gbc.getColumnExpression(),
getContextManager());
- groupByRCL.addElement(gbRC);
+
+ groupByRCL.addElement(gbRC);
gbRC.markGenerated();
gbRC.bindResultColumnToExpression();
gbRC.setVirtualColumnId(groupByRCL.size());
@@ -390,11 +380,10 @@ public class GroupByNode extends SingleC
** Reset the original node to point to the
** Group By result set.
*/
- VirtualColumnNode vc = (VirtualColumnNode) getNodeFactory().getNode(
- C_NodeTypes.VIRTUAL_COLUMN_NODE,
+ VirtualColumnNode vc = new VirtualColumnNode(
this, // source result set.
gbRC,
- new Integer(groupByRCL.size()),
+ groupByRCL.size(),
getContextManager());
// we replace each group by expression
@@ -561,8 +550,7 @@ public class GroupByNode extends SingleC
// having clause.
if (havingRefsToSubstitute != null) {
for (int r = 0; r < havingRefsToSubstitute.size(); r++) {
- havingClause.accept(
- (SubstituteExpressionVisitor)havingRefsToSubstitute.get(r));
+ havingClause.accept(havingRefsToSubstitute.get(r));
}
}
@@ -624,9 +612,7 @@ public class GroupByNode extends SingleC
ReplaceAggregatesWithCRVisitor replaceAggsVisitor =
new ReplaceAggregatesWithCRVisitor(
- (ResultColumnList) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager()),
+ new ResultColumnList((getContextManager())),
((FromTable) childResult).getTableNumber(),
ResultSetNode.class);
parent.getResultColumns().accept(replaceAggsVisitor);
@@ -636,9 +622,7 @@ public class GroupByNode extends SingleC
{
// replace aggregates in the having clause with column references.
replaceAggsVisitor = new ReplaceAggregatesWithCRVisitor(
- (ResultColumnList) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager()),
+ new ResultColumnList((getContextManager())),
((FromTable)childResult).getTableNumber());
havingClause.accept(replaceAggsVisitor);
// make having clause a restriction list in the parent
@@ -654,15 +638,14 @@ public class GroupByNode extends SingleC
int alSize = aggregates.size();
for (int index = 0; index < alSize; index++)
{
- AggregateNode aggregate = (AggregateNode) aggregates.get(index);
+ AggregateNode aggregate = aggregates.get(index);
/*
** AGG RESULT: Set the aggregate result to null in the
** bottom project restrict.
*/
- newRC = (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
- "##aggregate result",
+ newRC = new ResultColumn(
+ "##aggregate result",
aggregate.getNewNullResultExpression(),
getContextManager());
newRC.markGenerated();
@@ -677,16 +660,13 @@ public class GroupByNode extends SingleC
** was created when we called
** ReplaceAggregatesWithCRVisitor()
*/
- newColumnRef = (ColumnReference) getNodeFactory().getNode(
- C_NodeTypes.COLUMN_REFERENCE,
- newRC.getName(),
- null,
- getContextManager());
+ newColumnRef = new ColumnReference(newRC.getName(),
+ null,
+ getContextManager());
newColumnRef.setSource(newRC);
newColumnRef.setNestingLevel(this.getLevel());
newColumnRef.setSourceLevel(this.getLevel());
- tmpRC = (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
+ tmpRC = new ResultColumn(
newRC.getColumnName(),
newColumnRef,
getContextManager());
@@ -713,11 +693,10 @@ public class GroupByNode extends SingleC
bottomRCL.addElement(newRC);
newRC.setVirtualColumnId(bottomRCL.size());
aggInputVColId = newRC.getVirtualColumnId();
- aggResultRC = (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
- "##aggregate expression",
- aggregate.getNewNullResultExpression(),
- getContextManager());
+ aggResultRC = new ResultColumn(
+ "##aggregate expression",
+ aggregate.getNewNullResultExpression(),
+ getContextManager());
/*
** Add a reference to this column into the
@@ -751,9 +730,7 @@ public class GroupByNode extends SingleC
** to generate a proper result description for input
** to this agg if it is a user agg.
*/
- aggRCL = (ResultColumnList) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager());
+ aggRCL = new ResultColumnList((getContextManager()));
aggRCL.addElement(aggResultRC);
/*
@@ -794,6 +771,7 @@ public class GroupByNode extends SingleC
*
* @exception StandardException Thrown on error
*/
+ @Override
public CostEstimate optimizeIt(
Optimizer optimizer,
OptimizablePredicateList predList,
@@ -823,6 +801,7 @@ public class GroupByNode extends SingleC
*
* @exception StandardException Thrown on error
*/
+ @Override
public CostEstimate estimateCost(OptimizablePredicateList predList,
ConglomerateDescriptor cd,
CostEstimate outerCost,
@@ -840,12 +819,12 @@ public class GroupByNode extends SingleC
optimizer,
rowOrdering);
- CostEstimate costEstimate = getCostEstimate(optimizer);
- costEstimate.setCost(childCost.getEstimatedCost(),
+ CostEstimate costEst = getCostEstimate(optimizer);
+ costEst.setCost(childCost.getEstimatedCost(),
childCost.rowCount(),
childCost.singleScanRowCount());
- return costEstimate;
+ return costEst;
}
/**
@@ -854,6 +833,7 @@ public class GroupByNode extends SingleC
* @exception StandardException Thrown on error
*/
+ @Override
public boolean pushOptPredicate(OptimizablePredicate optimizablePredicate)
throws StandardException
{
@@ -866,7 +846,7 @@ public class GroupByNode extends SingleC
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -886,7 +866,8 @@ public class GroupByNode extends SingleC
*
* @param depth The depth of this node in the tree
*/
- public void printSubNodes(int depth) {
+ @Override
+ void printSubNodes(int depth) {
if (SanityManager.DEBUG)
{
super.printSubNodes(depth);
@@ -894,7 +875,7 @@ public class GroupByNode extends SingleC
printLabel(depth, "aggregates:\n");
for (int i = 0; i < aggregates.size(); i++) {
- AggregateNode agg = (AggregateNode) aggregates.get(i);
+ AggregateNode agg = aggregates.get(i);
debugPrint(formatNodeString("[" + i + "]:", depth + 1));
agg.treePrint(depth + 1);
}
@@ -930,7 +911,8 @@ public class GroupByNode extends SingleC
*
* @return boolean Whether or not the FromSubquery is flattenable.
*/
- public boolean flattenableInFromSubquery(FromList fromList)
+ @Override
+ boolean flattenableInFromSubquery(FromList fromList)
{
/* Can't flatten a GroupByNode */
return false;
@@ -948,8 +930,8 @@ public class GroupByNode extends SingleC
*
* @exception StandardException Thrown on error
*/
-
- public ResultSetNode optimize(DataDictionary dataDictionary,
+ @Override
+ ResultSetNode optimize(DataDictionary dataDictionary,
PredicateList predicates,
double outerRows)
throws StandardException
@@ -957,22 +939,19 @@ public class GroupByNode extends SingleC
/* We need to implement this method since a PRN can appear above a
* SelectNode in a query tree.
*/
- childResult = (ResultSetNode) childResult.optimize(
- dataDictionary,
- predicates,
- outerRows);
- Optimizer optimizer = getOptimizer(
- (FromList) getNodeFactory().getNode(
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
- getContextManager()),
- predicates,
- dataDictionary,
- (RequiredRowOrdering) null);
+ childResult = childResult.optimize(dataDictionary,
+ predicates,
+ outerRows);
+ Optimizer opt = getOptimizer(
+ new FromList(getOptimizerFactory().doJoinOrderOptimization(),
+ getContextManager()),
+ predicates,
+ dataDictionary,
+ (RequiredRowOrdering) null);
// RESOLVE: NEED TO FACTOR IN COST OF SORTING AND FIGURE OUT HOW
// MANY ROWS HAVE BEEN ELIMINATED.
- costEstimate = optimizer.newCostEstimate();
+ costEstimate = opt.newCostEstimate();
costEstimate.setCost(childResult.getCostEstimate().getEstimatedCost(),
childResult.getCostEstimate().rowCount(),
@@ -981,6 +960,7 @@ public class GroupByNode extends SingleC
return this;
}
+ @Override
ResultColumnDescriptor[] makeResultDescriptors()
{
return childResult.makeResultDescriptors();
@@ -995,7 +975,8 @@ public class GroupByNode extends SingleC
* @return Whether or not the underlying ResultSet tree will return a single row.
* @exception StandardException Thrown on error
*/
- public boolean isOneRowResultSet() throws StandardException
+ @Override
+ boolean isOneRowResultSet() throws StandardException
{
// Only consider scalar aggregates for now
return ((groupingList == null) || (groupingList.size() == 0));
@@ -1003,16 +984,15 @@ public class GroupByNode extends SingleC
/**
* generate the sort result set operating over the source
- * resultset. Adds distinct aggregates to the sort if
+ * result set. Adds distinct aggregates to the sort if
* necessary.
*
* @exception StandardException Thrown on error
*/
+ @Override
void generate(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
- int orderingItem = 0;
- int aggInfoItem = 0;
FormatableArrayHolder orderingHolder;
/* Get the next ResultSet#, so we can number this ResultSetNode, its
@@ -1044,7 +1024,7 @@ public class GroupByNode extends SingleC
{
if (SanityManager.DEBUG_ON("AggregateTrace"))
{
- StringBuffer s = new StringBuffer();
+ StringBuilder s = new StringBuilder();
s.append("Group by column ordering is (");
ColumnOrdering[] ordering =
@@ -1060,7 +1040,7 @@ public class GroupByNode extends SingleC
}
}
- orderingItem = acb.addItem(orderingHolder);
+ int orderingItem = acb.addItem(orderingHolder);
/*
** We have aggregates, so save the aggInfo
@@ -1071,7 +1051,7 @@ public class GroupByNode extends SingleC
SanityManager.ASSERT(aggInfo != null,
"aggInfo not set up as expected");
}
- aggInfoItem = acb.addItem(aggInfo);
+ int aggInfoItem = acb.addItem(aggInfo);
acb.pushGetResultSetFactoryExpression(mb);
@@ -1181,19 +1161,16 @@ public class GroupByNode extends SingleC
ColumnReference tmpColumnRef;
ResultColumn newRC;
- tmpColumnRef = (ColumnReference) getNodeFactory().getNode(
- C_NodeTypes.COLUMN_REFERENCE,
- targetRC.getName(),
- null,
- getContextManager());
+ tmpColumnRef = new ColumnReference(targetRC.getName(),
+ null,
+ getContextManager());
tmpColumnRef.setSource(targetRC);
tmpColumnRef.setNestingLevel(this.getLevel());
tmpColumnRef.setSourceLevel(this.getLevel());
- newRC = (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
- targetRC.getColumnName(),
- tmpColumnRef,
- getContextManager());
+ newRC = new ResultColumn(
+ targetRC.getColumnName(),
+ tmpColumnRef,
+ getContextManager());
newRC.markGenerated();
newRC.bindResultColumnToExpression();
return newRC;
@@ -1229,7 +1206,7 @@ public class GroupByNode extends SingleC
{
if (aggregates.size() == 1)
{
- AggregateNode an = (AggregateNode) aggregates.get(0);
+ AggregateNode an = aggregates.get(0);
AggregateDefinition ad = an.getAggregateDefinition();
if (ad instanceof MaxMinAggregateDefinition)
{
@@ -1289,8 +1266,7 @@ public class GroupByNode extends SingleC
}
}
- FromBaseTable fbt =
- (FromBaseTable) fbtHolder.get(0);
+ FromBaseTable fbt = fbtHolder.get(0);
MaxMinAggregateDefinition temp = (MaxMinAggregateDefinition)ad;
/* MAX ASC NULLABLE
@@ -1351,7 +1327,8 @@ public class GroupByNode extends SingleC
* we'll process those expressions in the order: a*(a+b),
* a+b+c, a+b, then a.
*/
- private static final class ExpressionSorter implements Comparator<SubstituteExpressionVisitor>
+ private static class ExpressionSorter
+ implements Comparator<SubstituteExpressionVisitor>
{
public int compare(SubstituteExpressionVisitor o1, SubstituteExpressionVisitor o2)
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java Fri Jun 21 07:47:47 2013
@@ -21,17 +21,15 @@
package org.apache.derby.impl.sql.compile;
+import java.util.Properties;
+import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.Optimizable;
import org.apache.derby.iapi.sql.compile.OptimizablePredicate;
-import org.apache.derby.iapi.sql.compile.CostEstimate;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.error.StandardException;
-
import org.apache.derby.iapi.util.JBitSet;
/**
@@ -41,13 +39,13 @@ import org.apache.derby.iapi.util.JBitSe
*
*/
-public class HalfOuterJoinNode extends JoinNode
+class HalfOuterJoinNode extends JoinNode
{
private boolean rightOuterJoin;
private boolean transformed = false;
/**
- * Initializer for a HalfOuterJoinNode.
+ * Constructor for a HalfOuterJoinNode.
*
* @param leftResult The ResultSetNode on the left side of this join
* @param rightResult The ResultSetNode on the right side of this join
@@ -56,28 +54,29 @@ public class HalfOuterJoinNode extends J
* @param rightOuterJoin Whether or not this node represents a user
* specified right outer join
* @param tableProperties Properties list associated with the table
+ * @param cm The context manager
*
* @exception StandardException Thrown on error
*/
-
- public void init(
- Object leftResult,
- Object rightResult,
- Object onClause,
- Object usingClause,
- Object rightOuterJoin,
- Object tableProperties)
+ HalfOuterJoinNode(ResultSetNode leftResult,
+ ResultSetNode rightResult,
+ ValueNode onClause,
+ ResultColumnList usingClause,
+ boolean rightOuterJoin,
+ Properties tableProperties,
+ ContextManager cm)
throws StandardException
{
- super.init(
- leftResult,
- rightResult,
- onClause,
- usingClause,
- null,
+ super( leftResult,
+ rightResult,
+ onClause,
+ usingClause,
+ null,
tableProperties,
- null);
- this.rightOuterJoin = ((Boolean) rightOuterJoin).booleanValue();
+ null,
+ cm);
+ setNodeType(C_NodeTypes.HALF_OUTER_JOIN_NODE);
+ this.rightOuterJoin = rightOuterJoin;
/* We can only flatten an outer join
* using the null intolerant predicate xform.
@@ -95,7 +94,7 @@ public class HalfOuterJoinNode extends J
*
* @exception StandardException Thrown on error
*/
-
+ @Override
public boolean pushOptPredicate(OptimizablePredicate optimizablePredicate)
throws StandardException
{
@@ -118,7 +117,7 @@ public class HalfOuterJoinNode extends J
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -157,7 +156,8 @@ public class HalfOuterJoinNode extends J
*
* @exception StandardException Thrown on error
*/
- public ResultSetNode preprocess(int numTables,
+ @Override
+ ResultSetNode preprocess(int numTables,
GroupByList gbl,
FromList fromList)
throws StandardException
@@ -199,7 +199,8 @@ public class HalfOuterJoinNode extends J
*
* @exception StandardException Thrown on error
*/
- public void pushExpressions(PredicateList outerPredicateList)
+ @Override
+ void pushExpressions(PredicateList outerPredicateList)
throws StandardException
{
FromTable leftFromTable = (FromTable) leftResultSet;
@@ -234,10 +235,7 @@ public class HalfOuterJoinNode extends J
}
/* Recurse down both sides of tree */
- PredicateList noPredicates =
- (PredicateList) getNodeFactory().getNode(
- C_NodeTypes.PREDICATE_LIST,
- getContextManager());
+ PredicateList noPredicates = new PredicateList(getContextManager());
leftFromTable.pushExpressions(getLeftPredicateList());
rightFromTable.pushExpressions(noPredicates);
}
@@ -284,7 +282,8 @@ public class HalfOuterJoinNode extends J
* so caller can know whether rebinding may be necessary
* @throws StandardException standard error policy
*/
- public boolean LOJ_reorderable(int numTables)
+ @Override
+ boolean LOJ_reorderable(int numTables)
throws StandardException
{
boolean anyChange = false;
@@ -463,10 +462,9 @@ public class HalfOuterJoinNode extends J
// ((HalfOuterJoinNode)logicalRightResultSet).transformed =
// local_transformed;
- FromList localFromList = (FromList) getNodeFactory().getNode(
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
- getContextManager());
+ FromList localFromList = new FromList(
+ getOptimizerFactory().doJoinOrderOptimization(),
+ getContextManager());
// switch OJ nodes: by handling the current OJ node
leftResultSet = logicalRightResultSet;
@@ -618,15 +616,15 @@ private boolean isNullRejecting (
// This method re-binds the result columns which may be referenced in the ON
// clause in this node.
- public boolean LOJ_bindResultColumns(boolean anyChange)
+ boolean LOJ_bindResultColumns(boolean anyChange)
throws StandardException
{
if (anyChange)
{
this.resultColumns = null;
- FromList localFromList = (FromList) getNodeFactory().getNode(C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
- getContextManager());
+ FromList localFromList = new FromList(
+ getOptimizerFactory().doJoinOrderOptimization(),
+ getContextManager());
((JoinNode)this).bindResultColumns(localFromList);
}
return anyChange;
@@ -644,6 +642,7 @@ private boolean isNullRejecting (
*
* @exception StandardException Thrown on error
*/
+ @Override
FromTable transformOuterJoins(ValueNode predicateTree, int numTables)
throws StandardException
{
@@ -719,9 +718,7 @@ private boolean isNullRejecting (
if (refMap.get(bit) && innerMap.get(bit))
{
// OJ -> IJ
- JoinNode ij = (JoinNode)
- getNodeFactory().getNode(
- C_NodeTypes.JOIN_NODE,
+ JoinNode ij = new JoinNode(
leftResultSet,
rightResultSet,
joinClause,
@@ -751,6 +748,7 @@ private boolean isNullRejecting (
}
/** @see JoinNode#adjustNumberOfRowsReturned */
+ @Override
protected void adjustNumberOfRowsReturned(CostEstimate costEstimate)
{
/*
@@ -773,6 +771,7 @@ private boolean isNullRejecting (
*
* @exception StandardException Thrown on error
*/
+ @Override
void generate(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -802,6 +801,7 @@ private boolean isNullRejecting (
*
* @exception StandardException Thrown on error
*/
+ @Override
int addOuterJoinArguments(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -817,12 +817,14 @@ private boolean isNullRejecting (
/**
* Return the number of arguments to the join result set.
*/
+ @Override
protected int getNumJoinArguments()
{
/* We add two more arguments than the superclass does */
return super.getNumJoinArguments() + 2;
}
+ @Override
void oneRowRightSide(ActivationClassBuilder acb, MethodBuilder mb)
{
// always return false for now
@@ -836,6 +838,7 @@ private boolean isNullRejecting (
* (For RIGHT OUTER JOIN, the left is the right
* and the right is the left and the JOIN is the NIOJ).
*/
+ @Override
ResultSetNode getLogicalLeftResultSet()
{
if (rightOuterJoin)
@@ -854,6 +857,7 @@ private boolean isNullRejecting (
* (For RIGHT OUTER JOIN, the left is the right
* and the right is the left and the JOIN is the NIOJ).
*/
+ @Override
ResultSetNode getLogicalRightResultSet()
{
if (rightOuterJoin)
@@ -870,7 +874,7 @@ private boolean isNullRejecting (
* Return true if right outer join or false if left outer join
* Used to set Nullability correctly in JoinNode
*/
- public boolean isRightOuterJoin()
+ boolean isRightOuterJoin()
{
return rightOuterJoin;
}
@@ -880,7 +884,8 @@ private boolean isNullRejecting (
* check if the passed ResultColumn is a join column. If yes, then
* ResultColumn should be marked such. DERBY-4631
*/
- public void isJoinColumnForRightOuterJoin(ResultColumn rc)
+ @Override
+ void isJoinColumnForRightOuterJoin(ResultColumn rc)
{
if (isRightOuterJoin() && usingClause != null &&
usingClause.getResultColumn(rc.getUnderlyingOrAliasName()) != null) {
@@ -890,13 +895,13 @@ private boolean isNullRejecting (
}
// return the Null-producing table references
- public JBitSet LOJgetNPReferencedTables(int numTables)
+ JBitSet LOJgetNPReferencedTables(int numTables)
throws StandardException
{
if (rightOuterJoin && !transformed)
- return (JBitSet) leftResultSet.LOJgetReferencedTables(numTables);
+ return leftResultSet.LOJgetReferencedTables(numTables);
else
- return (JBitSet) rightResultSet.LOJgetReferencedTables(numTables);
+ return rightResultSet.LOJgetReferencedTables(numTables);
}
// return the row-preserving table references
@@ -904,8 +909,8 @@ private boolean isNullRejecting (
throws StandardException
{
if (rightOuterJoin && !transformed)
- return (JBitSet) rightResultSet.LOJgetReferencedTables(numTables);
+ return rightResultSet.LOJgetReferencedTables(numTables);
else
- return (JBitSet) leftResultSet.LOJgetReferencedTables(numTables);
+ return leftResultSet.LOJgetReferencedTables(numTables);
}
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java Fri Jun 21 07:47:47 2013
@@ -21,27 +21,22 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.Visitable;
import org.apache.derby.iapi.sql.compile.Visitor;
-
-import org.apache.derby.iapi.store.access.Qualifier;
-import org.apache.derby.iapi.error.StandardException;
-
/**
* Find out if we have an correlated column reference
* anywhere below us. Stop traversal as soon as we find one.
*
*/
-public class HasCorrelatedCRsVisitor implements Visitor
+class HasCorrelatedCRsVisitor implements Visitor
{
private boolean hasCorrelatedCRs;
/**
* Construct a visitor
*/
- public HasCorrelatedCRsVisitor()
+ HasCorrelatedCRsVisitor()
{
}
@@ -122,7 +117,7 @@ public class HasCorrelatedCRsVisitor imp
*
* @return true/false
*/
- public boolean hasCorrelatedCRs()
+ boolean hasCorrelatedCRs()
{
return hasCorrelatedCRs;
}
@@ -132,7 +127,7 @@ public class HasCorrelatedCRsVisitor imp
*
* @param value true/false
*/
- public void setHasCorrelatedCRs(boolean value)
+ void setHasCorrelatedCRs(boolean value)
{
hasCorrelatedCRs = value;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java Fri Jun 21 07:47:47 2013
@@ -21,12 +21,9 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.Visitable;
import org.apache.derby.iapi.sql.compile.Visitor;
-import org.apache.derby.iapi.error.StandardException;
-
/**
* Find out if we have a particular node anywhere in the
* tree. Stop traversal as soon as we find one.
@@ -36,7 +33,7 @@ import org.apache.derby.iapi.error.Stand
* parameter.
*
*/
-public class HasNodeVisitor implements Visitor
+class HasNodeVisitor implements Visitor
{
protected boolean hasNode;
private Class nodeClass;
@@ -47,7 +44,7 @@ public class HasNodeVisitor implements V
* @param nodeClass the class of the node that
* we are looking for.
*/
- public HasNodeVisitor(Class nodeClass)
+ HasNodeVisitor(Class nodeClass)
{
this.nodeClass = nodeClass;
}
@@ -60,7 +57,7 @@ public class HasNodeVisitor implements V
* @param skipOverClass do not go below this
* node when searching for nodeClass.
*/
- public HasNodeVisitor(Class nodeClass, Class skipOverClass)
+ HasNodeVisitor(Class nodeClass, Class skipOverClass)
{
this.nodeClass = nodeClass;
this.skipOverClass = skipOverClass;
@@ -99,7 +96,7 @@ public class HasNodeVisitor implements V
}
/**
- * Don't visit childen under the skipOverClass
+ * Don't visit children under the skipOverClass
* node, if it isn't null.
*
* @return true/false
@@ -130,7 +127,7 @@ public class HasNodeVisitor implements V
*
* @return true/false
*/
- public boolean hasNode()
+ boolean hasNode()
{
return hasNode;
}
@@ -139,7 +136,7 @@ public class HasNodeVisitor implements V
* Reset the status so it can be run again.
*
*/
- public void reset()
+ void reset()
{
hasNode = false;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasTableFunctionVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasTableFunctionVisitor.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasTableFunctionVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasTableFunctionVisitor.java Fri Jun 21 07:47:47 2013
@@ -21,17 +21,13 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.Visitable;
-import org.apache.derby.iapi.sql.compile.Visitor;
-
-import org.apache.derby.iapi.error.StandardException;
/**
* Find out if we have a user-defined table function anywhere in the
* tree. Stop traversal as soon as we find one.
*/
-public class HasTableFunctionVisitor extends HasNodeVisitor
+class HasTableFunctionVisitor extends HasNodeVisitor
{
///////////////////////////////////////////////////////////////////////////////////
//
@@ -50,6 +46,7 @@ public class HasTableFunctionVisitor ext
//
///////////////////////////////////////////////////////////////////////////////////
+ @Override
public Visitable visit(Visitable node)
{
if ( node instanceof FromVTI )
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java Fri Jun 21 07:47:47 2013
@@ -21,13 +21,11 @@
package org.apache.derby.impl.sql.compile;
+import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.Visitable;
import org.apache.derby.iapi.sql.compile.Visitor;
-
-
import org.apache.derby.iapi.store.access.Qualifier;
-import org.apache.derby.iapi.error.StandardException;
/**
* Find out if we have a value node with variant type less than what the
@@ -47,7 +45,7 @@ import org.apache.derby.iapi.error.Stand
* @see org.apache.derby.iapi.store.access.Qualifier
*
*/
-public class HasVariantValueNodeVisitor implements Visitor
+class HasVariantValueNodeVisitor implements Visitor
{
private boolean hasVariant;
private int variantType;
@@ -57,7 +55,7 @@ public class HasVariantValueNodeVisitor
/**
* Construct a visitor
*/
- public HasVariantValueNodeVisitor()
+ HasVariantValueNodeVisitor()
{
this.variantType = Qualifier.VARIANT;
this.ignoreParameters = false;
@@ -82,7 +80,7 @@ public class HasVariantValueNodeVisitor
* variant
* @param ignoreParameters should I ignore parameter nodes?
*/
- public HasVariantValueNodeVisitor(int variantType, boolean ignoreParameters)
+ HasVariantValueNodeVisitor(int variantType, boolean ignoreParameters)
{
this.variantType = variantType;
this.ignoreParameters = ignoreParameters;
@@ -157,7 +155,7 @@ public class HasVariantValueNodeVisitor
*
* @return true/false
*/
- public boolean hasVariant()
+ boolean hasVariant()
{
return hasVariant;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java Fri Jun 21 07:47:47 2013
@@ -22,40 +22,30 @@
package org.apache.derby.impl.sql.compile;
import java.util.ArrayList;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.cache.ClassSize;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.io.ArrayUtil;
+import org.apache.derby.iapi.services.io.FormatableArrayHolder;
+import org.apache.derby.iapi.services.io.FormatableIntHolder;
+import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.ExpressionClassBuilderInterface;
import org.apache.derby.iapi.sql.compile.JoinStrategy;
import org.apache.derby.iapi.sql.compile.Optimizable;
-import org.apache.derby.iapi.sql.compile.Optimizer;
import org.apache.derby.iapi.sql.compile.OptimizablePredicate;
import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
-
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
+import org.apache.derby.iapi.sql.compile.Optimizer;
import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.store.access.StoreCostController;
import org.apache.derby.iapi.store.access.TransactionController;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.io.ArrayUtil;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.reference.SQLState;
-
-import org.apache.derby.iapi.services.cache.ClassSize;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.services.io.FormatableArrayHolder;
-import org.apache.derby.iapi.services.io.FormatableIntHolder;
-
import org.apache.derby.iapi.util.JBitSet;
import org.apache.derby.iapi.util.ReuseFactory;
-
-public class HashJoinStrategy extends BaseJoinStrategy {
- public HashJoinStrategy() {
+class HashJoinStrategy extends BaseJoinStrategy {
+ HashJoinStrategy() {
}
/**
@@ -69,8 +59,6 @@ public class HashJoinStrategy extends Ba
)
throws StandardException
{
- int[] hashKeyColumns = null;
-
ConglomerateDescriptor cd = null;
/* If the innerTable is a VTI, then we
@@ -130,10 +118,10 @@ public class HashJoinStrategy extends Ba
// Now get a list of all table numbers referenced by the
// join predicates that we'll be searching.
JBitSet pNums = new JBitSet(tNums.size());
- Predicate pred = null;
- for (int i = 0; i < predList.size(); i++)
+
+ for (int i = 0; i < predList.size(); i++)
{
- pred = (Predicate)predList.getOptPredicate(i);
+ Predicate pred = (Predicate)predList.getOptPredicate(i);
if (pred.isJoinPredicate())
pNums.or(pred.getReferencedSet());
}
@@ -155,10 +143,10 @@ public class HashJoinStrategy extends Ba
}
/* Look for equijoins in the predicate list */
- hashKeyColumns = findHashKeyColumns(
- innerTable,
- cd,
- predList);
+ int[] hashKeyColumns = findHashKeyColumns(
+ innerTable,
+ cd,
+ predList);
if (SanityManager.DEBUG)
{
@@ -184,6 +172,7 @@ public class HashJoinStrategy extends Ba
}
/** @see JoinStrategy#ignoreBulkFetch */
+ @Override
public boolean ignoreBulkFetch() {
return true;
}
@@ -357,10 +346,10 @@ public class HashJoinStrategy extends Ba
*/
if (SanityManager.DEBUG)
{
- Predicate pred = null;
for (int i = storeRestrictionList.size() - 1; i >= 0; i--)
{
- pred = (Predicate)storeRestrictionList.getOptPredicate(i);
+ Predicate pred =
+ (Predicate)storeRestrictionList.getOptPredicate(i);
if (pred.isInListProbePredicate())
{
SanityManager.THROWASSERT("Found IN-list probing " +
@@ -583,6 +572,7 @@ public class HashJoinStrategy extends Ba
/**
* @see JoinStrategy#isHashJoin
*/
+ @Override
public boolean isHashJoin()
{
return true;
@@ -623,7 +613,7 @@ public class HashJoinStrategy extends Ba
* an equijoin condition on it. We do essentially the same
* for heaps. (From column 1 through column n.)
*/
- int[] columns = null;
+ int[] columns;
if (cd == null)
{
columns = new int[innerTable.getNumColumnsReturned()];
@@ -666,11 +656,12 @@ public class HashJoinStrategy extends Ba
int[] keyCols = new int[hashKeys.size()];
for (int index = 0; index < keyCols.length; index++)
{
- keyCols[index] = ((Integer) hashKeys.get(index)).intValue();
+ keyCols[index] = hashKeys.get(index).intValue();
}
return keyCols;
}
+ @Override
public String toString() {
return getName();
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java Fri Jun 21 07:47:47 2013
@@ -21,32 +21,29 @@
package org.apache.derby.impl.sql.compile;
-
-import org.apache.derby.iapi.sql.compile.Optimizable;
-import org.apache.derby.iapi.sql.compile.Optimizer;
-import org.apache.derby.iapi.sql.compile.CostEstimate;
-import org.apache.derby.iapi.sql.compile.Visitor;
-import org.apache.derby.iapi.reference.ClassName;
-
+import java.util.Properties;
+import org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl;
import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.services.classfile.VMOpcode;
import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl;
-
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.io.FormatableArrayHolder;
import org.apache.derby.iapi.services.io.FormatableIntHolder;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.CostEstimate;
+import org.apache.derby.iapi.sql.compile.Optimizable;
+import org.apache.derby.iapi.sql.compile.Optimizer;
+import org.apache.derby.iapi.sql.compile.Visitor;
import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
/**
* A HashTableNode represents a result set where a hash table is built.
*
*/
-public class HashTableNode extends SingleChildResultSetNode
+class HashTableNode extends SingleChildResultSetNode
{
PredicateList searchPredicateList;
PredicateList joinPredicateList;
@@ -55,7 +52,7 @@ public class HashTableNode extends Singl
SubqueryList rSubqueryList;
/**
- * Initializer for a HashTableNode.
+ * Constructor for a HashTableNode.
*
* @param childResult The child result set
* @param tableProperties Properties list associated with the table
@@ -67,29 +64,30 @@ public class HashTableNode extends Singl
* @param pSubqueryList List of subqueries in RCL
* @param rSubqueryList List of subqueries in Predicate lists
* @param hashKeyColumns Hash key columns
+ * @param cm The context manager
*/
-
- public void init(
- Object childResult,
- Object tableProperties,
- Object resultColumns,
- Object searchPredicateList,
- Object joinPredicateList,
- Object accessPath,
- Object costEstimate,
- Object pSubqueryList,
- Object rSubqueryList,
- Object hashKeyColumns)
+ HashTableNode(ResultSetNode childResult,
+ Properties tableProperties,
+ ResultColumnList resultColumns,
+ PredicateList searchPredicateList,
+ PredicateList joinPredicateList,
+ AccessPathImpl accessPath,
+ CostEstimate costEstimate,
+ SubqueryList pSubqueryList,
+ SubqueryList rSubqueryList,
+ int[] hashKeyColumns,
+ ContextManager cm)
{
- super.init(childResult, tableProperties);
- this.resultColumns = (ResultColumnList) resultColumns;
- this.searchPredicateList = (PredicateList) searchPredicateList;
- this.joinPredicateList = (PredicateList) joinPredicateList;
- this.trulyTheBestAccessPath = (AccessPathImpl) accessPath;
- this.costEstimate = (CostEstimate) costEstimate;
- this.pSubqueryList = (SubqueryList) pSubqueryList;
- this.rSubqueryList = (SubqueryList) rSubqueryList;
- setHashKeyColumns((int[]) hashKeyColumns);
+ super(childResult, tableProperties, cm);
+ setNodeType(C_NodeTypes.HASH_TABLE_NODE);
+ this.resultColumns = resultColumns;
+ this.searchPredicateList = searchPredicateList;
+ this.joinPredicateList = joinPredicateList;
+ this.trulyTheBestAccessPath = accessPath;
+ this.costEstimate = costEstimate;
+ this.pSubqueryList = pSubqueryList;
+ this.rSubqueryList = rSubqueryList;
+ setHashKeyColumns(hashKeyColumns);
}
/*
@@ -113,8 +111,8 @@ public class HashTableNode extends Singl
*
* @param depth The depth of this node in the tree
*/
-
- public void printSubNodes(int depth)
+ @Override
+ void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
{
@@ -146,6 +144,7 @@ public class HashTableNode extends Singl
*
* @exception StandardException Thrown on error
*/
+ @Override
void generate(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -177,7 +176,7 @@ public class HashTableNode extends Singl
*
* @exception StandardException Thrown on error
*/
-
+ @Override
void generateResultSet(ExpressionClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -404,6 +403,7 @@ public class HashTableNode extends Singl
*
* @exception StandardException on error
*/
+ @Override
void acceptChildren(Visitor v)
throws StandardException
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java Fri Jun 21 07:47:47 2013
@@ -21,28 +21,20 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
+import java.lang.reflect.Modifier;
import org.apache.derby.iapi.error.StandardException;
-
import org.apache.derby.iapi.reference.ClassName;
-
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.DataValueDescriptor;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.classfile.VMOpcode;
import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.loader.ClassFactory;
import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.Optimizable;
-
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
-
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
-import java.lang.reflect.Modifier;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.types.TypeId;
/**
* An InListOperatorNode represents an IN list.
@@ -54,25 +46,27 @@ public final class InListOperatorNode ex
private boolean isOrdered;
private boolean sortDescending;
- /**
- * Initializer for a InListOperatorNode
- *
- * @param leftOperand The left operand of the node
- * @param rightOperandList The right operand list of the node
- */
-
- public void init(Object leftOperand, Object rightOperandList)
- {
- init(leftOperand, rightOperandList, "IN", "in");
- }
+ /**
+ * @param leftOperand The left operand of the node
+ * @param rightOperandList The right operand list of the node
+ * @param cm Context manager
+ * @throws StandardException
+ */
+ InListOperatorNode(
+ ValueNode leftOperand,
+ ValueNodeList rightOperandList,
+ ContextManager cm) throws StandardException {
+ super(leftOperand, rightOperandList, "IN", "in", cm);
+ setNodeType(C_NodeTypes.IN_LIST_OPERATOR_NODE);
+ }
- /**
+ /**
* Convert this object to a String. See comments in QueryTreeNode.java
* for how this should be done for tree printing.
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -93,9 +87,7 @@ public final class InListOperatorNode ex
*/
protected InListOperatorNode shallowCopy() throws StandardException
{
- InListOperatorNode ilon =
- (InListOperatorNode)getNodeFactory().getNode(
- C_NodeTypes.IN_LIST_OPERATOR_NODE,
+ InListOperatorNode ilon = new InListOperatorNode(
leftOperand,
rightOperandList,
getContextManager());
@@ -125,7 +117,8 @@ public final class InListOperatorNode ex
*
* @exception StandardException Thrown on error
*/
- public ValueNode preprocess(int numTables,
+ @Override
+ ValueNode preprocess(int numTables,
FromList outerFromList,
SubqueryList outerSubqueryList,
PredicateList outerPredicateList)
@@ -141,11 +134,11 @@ public final class InListOperatorNode ex
if (rightOperandList.size() == 1)
{
BinaryComparisonOperatorNode equal =
- (BinaryComparisonOperatorNode) getNodeFactory().getNode(
+ new BinaryRelationalOperatorNode(
C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
leftOperand,
(ValueNode) rightOperandList.elementAt(0),
- Boolean.FALSE,
+ false,
getContextManager());
/* Set type info for the operator node */
equal.bindComparisonOperator();
@@ -164,11 +157,8 @@ public final class InListOperatorNode ex
if ((leftOperand.getTypeServices().getTypeId().typePrecedence() !=
targetTypePrecedence) &&
!rightOperandList.allSamePrecendence(targetTypePrecedence)) {
- CastNode cn = (CastNode) getNodeFactory().getNode(
- C_NodeTypes.CAST_NODE,
- leftOperand,
- targetType,
- getContextManager());
+ CastNode cn =
+ new CastNode(leftOperand, targetType, getContextManager());
cn.bindCastNodeOnly();
leftOperand = cn;
}
@@ -284,11 +274,11 @@ public final class InListOperatorNode ex
if (judgeODV.equals(minODV, maxODV).equals(true))
{
BinaryComparisonOperatorNode equal =
- (BinaryComparisonOperatorNode)getNodeFactory().getNode(
+ new BinaryRelationalOperatorNode(
C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
leftOperand,
minValue,
- Boolean.FALSE,
+ false,
getContextManager());
/* Set type info for the operator node */
equal.bindComparisonOperator();
@@ -316,10 +306,8 @@ public final class InListOperatorNode ex
* big picture.
*/
ValueNode srcVal = (ValueNode) rightOperandList.elementAt(0);
- ParameterNode pNode =
- (ParameterNode) getNodeFactory().getNode(
- C_NodeTypes.PARAMETER_NODE,
- new Integer(0),
+ ParameterNode pNode = new ParameterNode(
+ 0,
null, // default value
getContextManager());
@@ -353,12 +341,12 @@ public final class InListOperatorNode ex
* to "this").
*/
BinaryComparisonOperatorNode equal =
- (BinaryComparisonOperatorNode) getNodeFactory().getNode(
+ new BinaryRelationalOperatorNode(
C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
leftOperand,
pNode,
this,
- Boolean.FALSE,
+ false,
getContextManager());
/* Set type info for the operator node */
@@ -412,10 +400,10 @@ public final class InListOperatorNode ex
*
* @exception StandardException Thrown on error
*/
+ @Override
ValueNode eliminateNots(boolean underNotNode)
throws StandardException
{
- AndNode newAnd = null;
BinaryComparisonOperatorNode leftBCO;
BinaryComparisonOperatorNode rightBCO;
int listSize = rightOperandList.size();
@@ -448,12 +436,11 @@ public final class InListOperatorNode ex
* requires each <> node to have a separate object.
*/
ValueNode leftClone = (leftOperand instanceof ColumnReference) ? leftOperand.getClone() : leftOperand;
- leftBCO = (BinaryComparisonOperatorNode)
- getNodeFactory().getNode(
+ leftBCO = new BinaryRelationalOperatorNode(
C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE,
leftClone,
- (ValueNode) rightOperandList.elementAt(0),
- Boolean.FALSE,
+ (ValueNode)rightOperandList.elementAt(0),
+ false,
getContextManager());
/* Set type info for the operator node */
leftBCO.bindComparisonOperator();
@@ -465,22 +452,18 @@ public final class InListOperatorNode ex
/* leftO <> rightOList.elementAt(elemsDone) */
leftClone = (leftOperand instanceof ColumnReference) ? leftOperand.getClone() : leftOperand;
- rightBCO = (BinaryComparisonOperatorNode)
- getNodeFactory().getNode(
+ rightBCO = new BinaryRelationalOperatorNode(
C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE,
leftClone,
(ValueNode) rightOperandList.elementAt(elemsDone),
- Boolean.FALSE,
+ false,
getContextManager());
/* Set type info for the operator node */
rightBCO.bindComparisonOperator();
/* Create the AND */
- newAnd = (AndNode) getNodeFactory().getNode(
- C_NodeTypes.AND_NODE,
- leftSide,
- rightBCO,
- getContextManager());
+ AndNode newAnd =
+ new AndNode(leftSide, rightBCO, getContextManager());
newAnd.postBindFixup();
leftSide = newAnd;
@@ -498,7 +481,7 @@ public final class InListOperatorNode ex
*
* @exception StandardException Thrown on error
*/
- public boolean selfReference(ColumnReference cr)
+ boolean selfReference(ColumnReference cr)
throws StandardException
{
int size = rightOperandList.size();
@@ -515,6 +498,7 @@ public final class InListOperatorNode ex
* The selectivity for an "IN" predicate is generally very small.
* This is an estimate applicable when in list are not all constants.
*/
+ @Override
public double selectivity(Optimizable optTable)
{
return 0.3d;
@@ -527,8 +511,8 @@ public final class InListOperatorNode ex
* @param mb The MethodBuilder the expression will go into
*
* @exception StandardException Thrown on error
- */
-
+ */
+ @Override
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -563,8 +547,6 @@ public final class InListOperatorNode ex
** to the new method.
*/
- receiver = leftOperand;
-
/* Figure out the result type name */
resultTypeName = getTypeCompiler().interfaceName();
@@ -754,14 +736,18 @@ public final class InListOperatorNode ex
/* decide to get min or max value
*/
- String methodName;
+ String methodNam;
if ((isAsc && isStartKey) || (! isAsc && ! isStartKey))
- methodName = "minValue";
+ methodNam = "minValue";
else
- methodName = "maxValue";
+ methodNam = "maxValue";
- mb.callMethod(VMOpcode.INVOKESTATIC, ClassName.BaseExpressionActivation, methodName, ClassName.DataValueDescriptor, 6);
-
+ mb.callMethod(
+ VMOpcode.INVOKESTATIC,
+ ClassName.BaseExpressionActivation,
+ methodNam,
+ ClassName.DataValueDescriptor,
+ 6);
}
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java Fri Jun 21 07:47:47 2013
@@ -22,35 +22,30 @@
package org.apache.derby.impl.sql.compile;
import java.util.List;
-
+import java.util.Properties;
+import org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.services.classfile.VMOpcode;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.io.FormatableBitSet;
import org.apache.derby.iapi.sql.compile.AccessPath;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.Optimizable;
import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
import org.apache.derby.iapi.sql.compile.Visitor;
-
import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
-import org.apache.derby.iapi.services.io.FormatableBitSet;
-
-import org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl;
-import org.apache.derby.iapi.reference.ClassName;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
-
/**
* This node type translates an index row to a base row. It takes a
* FromBaseTable as its source ResultSetNode, and generates an
* IndexRowToBaseRowResultSet that takes a TableScanResultSet on an
* index conglomerate as its source.
*/
-public class IndexToBaseRowNode extends FromTable
+class IndexToBaseRowNode extends FromTable
{
protected FromBaseTable source;
protected ConglomerateDescriptor baseCD;
@@ -62,26 +57,28 @@ public class IndexToBaseRowNode extends
private FormatableBitSet allReferencedCols;
private FormatableBitSet heapOnlyReferencedCols;
- public void init(
- Object source,
- Object baseCD,
- Object resultColumns,
- Object cursorTargetTable,
- Object heapReferencedCols,
- Object indexReferencedCols,
- Object restrictionList,
- Object forUpdate,
- Object tableProperties)
- {
- super.init(null, tableProperties);
- this.source = (FromBaseTable) source;
- this.baseCD = (ConglomerateDescriptor) baseCD;
- this.resultColumns = (ResultColumnList) resultColumns;
- this.cursorTargetTable = ((Boolean) cursorTargetTable).booleanValue();
- this.restrictionList = (PredicateList) restrictionList;
- this.forUpdate = ((Boolean) forUpdate).booleanValue();
- this.heapReferencedCols = (FormatableBitSet) heapReferencedCols;
- this.indexReferencedCols = (FormatableBitSet) indexReferencedCols;
+ IndexToBaseRowNode(
+ FromBaseTable source,
+ ConglomerateDescriptor baseCD,
+ ResultColumnList resultColumns,
+ boolean cursorTargetTable,
+ FormatableBitSet heapReferencedCols,
+ FormatableBitSet indexReferencedCols,
+ PredicateList restrictionList,
+ boolean forUpdate,
+ Properties tableProperties,
+ ContextManager cm)
+ {
+ super(null, tableProperties, cm);
+ setNodeType(C_NodeTypes.INDEX_TO_BASE_ROW_NODE);
+ this.source = source;
+ this.baseCD = baseCD;
+ this.resultColumns = resultColumns;
+ this.cursorTargetTable = cursorTargetTable;
+ this.restrictionList = restrictionList;
+ this.forUpdate = forUpdate;
+ this.heapReferencedCols = heapReferencedCols;
+ this.indexReferencedCols = indexReferencedCols;
if (this.indexReferencedCols == null) {
this.allReferencedCols = this.heapReferencedCols;
@@ -98,24 +95,28 @@ public class IndexToBaseRowNode extends
}
/** @see Optimizable#forUpdate */
+ @Override
public boolean forUpdate()
{
return source.forUpdate();
}
/** @see Optimizable#getTrulyTheBestAccessPath */
+ @Override
public AccessPath getTrulyTheBestAccessPath()
{
// Get AccessPath comes from base table.
return ((Optimizable) source).getTrulyTheBestAccessPath();
}
- public CostEstimate getCostEstimate()
+ @Override
+ CostEstimate getCostEstimate()
{
return source.getTrulyTheBestAccessPath().getCostEstimate();
}
- public CostEstimate getFinalCostEstimate()
+ @Override
+ CostEstimate getFinalCostEstimate()
{
return source.getFinalCostEstimate();
}
@@ -135,6 +136,7 @@ public class IndexToBaseRowNode extends
*
* @exception StandardException Thrown on error
*/
+ @Override
boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, List<FromBaseTable> fbtHolder)
throws StandardException
{
@@ -151,6 +153,7 @@ public class IndexToBaseRowNode extends
*
* @exception StandardException Thrown on error
*/
+ @Override
void generate(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -311,7 +314,8 @@ public class IndexToBaseRowNode extends
* @return Whether or not the underlying ResultSet tree will return a single row.
* @exception StandardException Thrown on error
*/
- public boolean isOneRowResultSet() throws StandardException
+ @Override
+ boolean isOneRowResultSet() throws StandardException
{
// Default is false
return source.isOneRowResultSet();
@@ -322,7 +326,8 @@ public class IndexToBaseRowNode extends
*
* @return Whether or not the underlying FBT is for NOT EXISTS.
*/
- public boolean isNotExists()
+ @Override
+ boolean isNotExists()
{
return source.isNotExists();
}
@@ -333,6 +338,7 @@ public class IndexToBaseRowNode extends
*
* @param decrement The amount to decrement by.
*/
+ @Override
void decrementLevel(int decrement)
{
source.decrementLevel(decrement);
@@ -345,7 +351,8 @@ public class IndexToBaseRowNode extends
*
* @return The lock mode
*/
- public int updateTargetLockMode()
+ @Override
+ int updateTargetLockMode()
{
return source.updateTargetLockMode();
}
@@ -353,6 +360,7 @@ public class IndexToBaseRowNode extends
/**
* @see ResultSetNode#adjustForSortElimination
*/
+ @Override
void adjustForSortElimination()
{
/* NOTE: We use a different method to tell a FBT that
@@ -366,6 +374,7 @@ public class IndexToBaseRowNode extends
/**
* @see ResultSetNode#adjustForSortElimination
*/
+ @Override
void adjustForSortElimination(RequiredRowOrdering rowOrdering)
throws StandardException
{
@@ -417,6 +426,7 @@ public class IndexToBaseRowNode extends
*
* @exception StandardException on error
*/
+ @Override
void acceptChildren(Visitor v)
throws StandardException
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java Fri Jun 21 07:47:47 2013
@@ -21,51 +21,36 @@
package org.apache.derby.impl.sql.compile;
-
-import org.apache.derby.iapi.reference.SQLState;
+import java.util.Properties;
+import org.apache.derby.catalog.UUID;
import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.classfile.VMOpcode;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.io.FormatableBitSet;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.StatementType;
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.sql.conn.Authorizer;
-
-import org.apache.derby.iapi.sql.compile.Visitor;
import org.apache.derby.iapi.sql.compile.CompilerContext;
-
-import org.apache.derby.iapi.reference.ClassName;
-
+import org.apache.derby.iapi.sql.compile.Visitor;
+import org.apache.derby.iapi.sql.conn.Authorizer;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList;
import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
import org.apache.derby.iapi.sql.dictionary.IndexLister;
-import org.apache.derby.iapi.sql.StatementType;
-
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
import org.apache.derby.iapi.sql.execute.ConstantAction;
-
+import org.apache.derby.iapi.sql.execute.ExecRowBuilder;
import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
import org.apache.derby.iapi.store.access.TransactionController;
import org.apache.derby.iapi.types.RowLocation;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.vti.DeferModification;
-
-import org.apache.derby.iapi.services.classfile.VMOpcode;
+import org.apache.derby.iapi.util.ReuseFactory;
import org.apache.derby.iapi.util.StringUtil;
-
-import org.apache.derby.catalog.UUID;
-
import org.apache.derby.impl.sql.execute.FKInfo;
-
-import java.util.Properties;
-
-import org.apache.derby.iapi.services.io.FormatableBitSet;
-import org.apache.derby.iapi.sql.execute.ExecRowBuilder;
-import org.apache.derby.iapi.util.ReuseFactory;
+import org.apache.derby.vti.DeferModification;
/**
* An InsertNode is the top node in a query tree for an
@@ -92,7 +77,7 @@ import org.apache.derby.iapi.util.ReuseF
public final class InsertNode extends DMLModStatementNode
{
public ResultColumnList targetColumnList;
- public boolean deferred;
+ boolean deferred;
public ValueNode checkConstraints;
public Properties targetProperties;
public FKInfo fkInfo;
@@ -105,49 +90,50 @@ public final class InsertNode extends DM
protected RowLocation[] autoincRowLocation;
/**
- * Initializer for an InsertNode.
+ * Constructor for an InsertNode.
*
- * @param targetName The name of the table/VTI to insert into
- * @param insertColumns A ResultColumnList with the names of the
+ * @param targetName The name of the table/VTI to insert into
+ * @param insertColumns A ResultColumnList with the names of the
* columns to insert into. May be null if the
* user did not specify the columns - in this
* case, the binding phase will have to figure
* it out.
- * @param queryExpression The query expression that will generate
- * the rows to insert into the given table
- * @param targetProperties The properties specified on the target table
- * @param orderByList The order by list for the source result set, null if no order by list
- * @param offset The value of a <result offset clause> if present
- * @param fetchFirst The value of a <fetch first clause> if present
- * @param hasJDBClimitClause True if the offset/fetchFirst clauses come from JDBC limit/offset escape syntax
+ * @param queryExpression The query expression that will generate
+ * the rows to insert into the given table
+ * @param targetProperties The properties specified on the target table
+ * @param orderByList The order by list for the source result set,
+ * null if no order by list
+ * @param offset The value of a <result offset clause> if
+ * present
+ * @param fetchFirst The value of a <fetch first clause> if present
+ * @param hasJDBClimitClause True if the offset/fetchFirst clauses come
+ * from JDBC limit/offset escape syntax
+ * @param cm The context manager
*/
-
- public void init(
- Object targetName,
- Object insertColumns,
- Object queryExpression,
- Object targetProperties,
- Object orderByList,
- Object offset,
- Object fetchFirst,
- Object hasJDBClimitClause)
+ InsertNode(
+ QueryTreeNode targetName,
+ ResultColumnList insertColumns,
+ ResultSetNode queryExpression,
+ Properties targetProperties,
+ OrderByList orderByList,
+ ValueNode offset,
+ ValueNode fetchFirst,
+ boolean hasJDBClimitClause,
+ ContextManager cm)
{
/* statementType gets set in super() before we've validated
* any properties, so we've kludged the code to get the
* right statementType for a bulk insert replace.
*/
- super.init(
- queryExpression,
- ReuseFactory.getInteger(getStatementType(
- (Properties) targetProperties))
- );
- setTarget((QueryTreeNode) targetName);
- targetColumnList = (ResultColumnList) insertColumns;
- this.targetProperties = (Properties) targetProperties;
- this.orderByList = (OrderByList) orderByList;
- this.offset = (ValueNode)offset;
- this.fetchFirst = (ValueNode)fetchFirst;
- this.hasJDBClimitClause = (hasJDBClimitClause == null) ? false : ((Boolean) hasJDBClimitClause).booleanValue();
+ super(queryExpression, getStatementType(targetProperties), cm);
+ setNodeType(C_NodeTypes.INSERT_NODE);
+ setTarget(targetName);
+ targetColumnList = insertColumns;
+ this.targetProperties = targetProperties;
+ this.orderByList = orderByList;
+ this.offset = offset;
+ this.fetchFirst = fetchFirst;
+ this.hasJDBClimitClause = hasJDBClimitClause;
/* Remember that the query expression is the source to an INSERT */
getResultSetNode().setInsertSource();
@@ -180,7 +166,7 @@ public final class InsertNode extends DM
}
}
- public String statementToString()
+ String statementToString()
{
return "INSERT";
}
@@ -192,7 +178,7 @@ public final class InsertNode extends DM
* @param depth The depth of this node in the tree
*/
- public void printSubNodes(int depth)
+ void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
{
@@ -248,10 +234,9 @@ public final class InsertNode extends DM
// We just need select privilege on the expressions
getCompilerContext().pushCurrentPrivType( Authorizer.SELECT_PRIV);
- FromList fromList = (FromList) getNodeFactory().getNode(
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
- getContextManager());
+ FromList fromList = new FromList(
+ getOptimizerFactory().doJoinOrderOptimization(),
+ getContextManager());
/* If any underlying ResultSetNode is a SelectNode, then we
* need to do a full bind(), including the expressions
@@ -464,11 +449,8 @@ public final class InsertNode extends DM
resultSet.getResultColumns()))
{
- resultSet =
- (ResultSetNode) getNodeFactory().getNode(
- C_NodeTypes.NORMALIZE_RESULT_SET_NODE, resultSet,
- resultColumnList, null, Boolean.FALSE,
- getContextManager());
+ resultSet = new NormalizeResultSetNode(
+ resultSet, resultColumnList, null, false, getContextManager());
}
if (targetTableDescriptor != null)
@@ -482,7 +464,7 @@ public final class InsertNode extends DM
/* Get and bind all constraints on the table */
checkConstraints = bindConstraints(dataDictionary,
- getNodeFactory(),
+ getOptimizerFactory(),
targetTableDescriptor,
null,
sourceRCL,
@@ -733,7 +715,7 @@ public final class InsertNode extends DM
*
* @exception StandardException Thrown on failure
*/
- public ConstantAction makeConstantAction() throws StandardException
+ public ConstantAction makeConstantAction() throws StandardException
{
/* Different constant actions for base tables and updatable VTIs */
@@ -811,7 +793,7 @@ public final class InsertNode extends DM
*
* @exception StandardException Thrown on failure
*/
- public boolean[] getIndexedCols() throws StandardException
+ boolean[] getIndexedCols() throws StandardException
{
/* Create a boolean[] to track the (0-based) columns which are indexed */
boolean[] indexedCols = new boolean[targetTableDescriptor.getNumberOfColumns()];
@@ -939,7 +921,7 @@ public final class InsertNode extends DM
ExecRowBuilder builder =
new ExecRowBuilder(cdl.size(), false);
for (int i = 0; i < cdl.size(); i++) {
- ColumnDescriptor cd = (ColumnDescriptor) cdl.get(i);
+ ColumnDescriptor cd = cdl.get(i);
builder.setColumn(i + 1, cd.getType());
}
mb.push(acb.addItem(builder));
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IntersectOrExceptNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IntersectOrExceptNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IntersectOrExceptNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IntersectOrExceptNode.java Fri Jun 21 07:47:47 2013
@@ -21,37 +21,26 @@
package org.apache.derby.impl.sql.compile;
+import java.sql.Types;
+import java.util.BitSet;
+import java.util.Properties;
+import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.reference.ClassName;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.services.classfile.VMOpcode;
import org.apache.derby.iapi.services.compiler.MethodBuilder;
import org.apache.derby.iapi.services.context.ContextManager;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.sql.compile.NodeFactory;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.Optimizable;
-import org.apache.derby.iapi.sql.compile.OptimizablePredicate;
import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
import org.apache.derby.iapi.sql.compile.Optimizer;
-import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.RowOrdering;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-
-import org.apache.derby.iapi.reference.SQLState;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
+import org.apache.derby.iapi.types.TypeId;
import org.apache.derby.iapi.util.JBitSet;
import org.apache.derby.iapi.util.ReuseFactory;
-import java.sql.Types;
-
-import java.util.BitSet;
-
/**
* A IntersectOrExceptNode represents an INTERSECT or EXCEPT DML statement.
*
@@ -89,25 +78,27 @@ public class IntersectOrExceptNode exten
private boolean[] intermediateOrderByNullsLow; // TRUE means NULL values should be ordered lower than non-NULL values
/**
- * Initializer for a SetOperatorNode.
+ * Constructor for a SetOperatorNode.
*
+ * @param opType The operator type: one of {@link #EXCEPT_OP} or
+ * {@link #INTERSECT_OP}.
* @param leftResult The ResultSetNode on the left side of this union
* @param rightResult The ResultSetNode on the right side of this union
- * @param all Whether or not this is an ALL.
+ * @param all {@code true} if this is an ALL set operation.
* @param tableProperties Properties list associated with the table
- *
+ * @param cm The context manager
* @exception StandardException Thrown on error
*/
-
- public void init( Object opType,
- Object leftResult,
- Object rightResult,
- Object all,
- Object tableProperties)
- throws StandardException
- {
- super.init( leftResult, rightResult, all, tableProperties);
- this.opType = ((Integer) opType).intValue();
+ IntersectOrExceptNode(int opType,
+ ResultSetNode leftResult,
+ ResultSetNode rightResult,
+ boolean all,
+ Properties tableProperties,
+ ContextManager cm) throws StandardException {
+
+ super(leftResult, rightResult, all, tableProperties, cm);
+ setNodeType(C_NodeTypes.INTERSECT_OR_EXCEPT_NODE);
+ this.opType = opType;
}
private int getOpType()
@@ -128,7 +119,8 @@ public class IntersectOrExceptNode exten
* @exception StandardException Thrown on error
*/
- public ResultSetNode preprocess(int numTables,
+ @Override
+ ResultSetNode preprocess(int numTables,
GroupByList gbl,
FromList fromList)
throws StandardException
@@ -202,20 +194,27 @@ public class IntersectOrExceptNode exten
throws StandardException
{
ContextManager cm = getContextManager();
- NodeFactory nf = getNodeFactory();
- OrderByList orderByList = (OrderByList) nf.getNode( C_NodeTypes.ORDER_BY_LIST, cm);
+ OrderByList orderByList = new OrderByList(null, cm);
+
for( int i = 0; i < intermediateOrderByColumns.length; i++)
{
- OrderByColumn orderByColumn = (OrderByColumn)
- nf.getNode( C_NodeTypes.ORDER_BY_COLUMN,
- nf.getNode(C_NodeTypes.INT_CONSTANT_NODE,
- ReuseFactory.getInteger( intermediateOrderByColumns[i] + 1),
- cm),
- cm);
- if( intermediateOrderByDirection[i] < 0)
+ OrderByColumn orderByColumn =
+ new OrderByColumn(
+ new NumericConstantNode(
+ TypeId.getBuiltInTypeId(Types.INTEGER),
+ ReuseFactory.getInteger(
+ intermediateOrderByColumns[i] + 1),
+ cm),
+ cm);
+
+ if( intermediateOrderByDirection[i] < 0) {
orderByColumn.setDescending();
- if( intermediateOrderByNullsLow[i])
+ }
+
+ if( intermediateOrderByNullsLow[i]) {
orderByColumn.setNullsOrderedLow();
+ }
+
orderByList.addOrderByColumn( orderByColumn);
}
orderByList.bindOrderByColumns( rsn);
@@ -225,6 +224,7 @@ public class IntersectOrExceptNode exten
/**
* @see org.apache.derby.iapi.sql.compile.Optimizable#estimateCost
*/
+ @Override
public CostEstimate estimateCost( OptimizablePredicateList predList,
ConglomerateDescriptor cd,
CostEstimate outerCost,
@@ -244,17 +244,23 @@ public class IntersectOrExceptNode exten
(PredicateList) null,
outerCost);
- CostEstimate costEstimate = getCostEstimate(optimizer);
+ CostEstimate costEst = getCostEstimate(optimizer);
CostEstimate leftCostEstimate = leftResultSet.getCostEstimate();
CostEstimate rightCostEstimate = rightResultSet.getCostEstimate();
- // The cost is the sum of the two child costs plus the cost of sorting the union.
- costEstimate.setCost( leftCostEstimate.getEstimatedCost() + rightCostEstimate.getEstimatedCost(),
- getRowCountEstimate( leftCostEstimate.rowCount(),
- rightCostEstimate.rowCount()),
- getSingleScanRowCountEstimate( leftCostEstimate.singleScanRowCount(),
- rightCostEstimate.singleScanRowCount()));
- return costEstimate;
+ // The cost is the sum of the two child costs plus the cost of
+ // sorting the union.
+ costEst.setCost(
+ leftCostEstimate.getEstimatedCost() +
+ rightCostEstimate.getEstimatedCost(),
+ getRowCountEstimate(
+ leftCostEstimate.rowCount(),
+ rightCostEstimate.rowCount()),
+ getSingleScanRowCountEstimate(
+ leftCostEstimate.singleScanRowCount(),
+ rightCostEstimate.singleScanRowCount()));
+
+ return costEst;
} // End of estimateCost
/**
@@ -262,6 +268,7 @@ public class IntersectOrExceptNode exten
*
* @exception StandardException Thrown on error
*/
+ @Override
public Optimizable modifyAccessPath(JBitSet outerTables) throws StandardException
{
Optimizable retOptimizable;
@@ -280,7 +287,8 @@ public class IntersectOrExceptNode exten
*
* @exception StandardException Thrown on error
*/
- public ResultSetNode modifyAccessPaths() throws StandardException
+ @Override
+ ResultSetNode modifyAccessPaths() throws StandardException
{
ResultSetNode retRSN;
retRSN = super.modifyAccessPaths();
@@ -317,8 +325,7 @@ public class IntersectOrExceptNode exten
if( orderByLists[0] != null) {
// Generate an order by node on top of the intersect/except
- treeTop = (ResultSetNode) getNodeFactory().getNode(
- C_NodeTypes.ORDER_BY_NODE,
+ treeTop = new OrderByNode(
treeTop,
orderByLists[0],
tableProperties,
@@ -330,13 +337,12 @@ public class IntersectOrExceptNode exten
treeTop.getResultColumns().copyListAndObjects();
newRcl.genVirtualColumnNodes(treeTop, treeTop.getResultColumns());
- treeTop = (ResultSetNode)getNodeFactory().getNode(
- C_NodeTypes.ROW_COUNT_NODE,
+ treeTop = new RowCountNode(
treeTop,
newRcl,
offset,
fetchFirst,
- Boolean.valueOf( hasJDBClimitClause ),
+ hasJDBClimitClause,
getContextManager());
}
return treeTop;
@@ -348,6 +354,7 @@ public class IntersectOrExceptNode exten
*
* @exception StandardException Thrown on error
*/
+ @Override
void generate( ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -407,7 +414,8 @@ public class IntersectOrExceptNode exten
* rows depends on whether this is an INTERSECT or EXCEPT (see
* getRowCountEstimate() in this class for more).
*/
- public CostEstimate getFinalCostEstimate()
+ @Override
+ CostEstimate getFinalCostEstimate()
throws StandardException
{
if (finalCostEstimate != null)