db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1509671 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/compile/ impl/sql/compile/
Date Fri, 02 Aug 2013 12:46:54 GMT
Author: rhillegas
Date: Fri Aug  2 12:46:53 2013
New Revision: 1509671

URL: http://svn.apache.org/r1509671
Log:
DERBY-6211: Don't instantiate new optimizers just to create empty CostEstimate objects; commit
derby-6211-10-aa-makingCostEstimateObject.diff.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Optimizer.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizerFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLOptTrace.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Optimizer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Optimizer.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Optimizer.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Optimizer.java Fri Aug
 2 12:46:53 2013
@@ -188,9 +188,6 @@ public interface Optimizer
 	 */
 	public void modifyAccessPaths() throws StandardException;
 
-	/** Get a new CostEstimate object */
-	public CostEstimate newCostEstimate();
-
 	/** Get the trace machinery */
 	public OptTrace tracer();
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizerFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizerFactory.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizerFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizerFactory.java
Fri Aug  2 12:46:53 2013
@@ -72,8 +72,7 @@ public interface OptimizerFactory {
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public CostEstimate getCostEstimate()
-		throws StandardException;
+	public CostEstimate getCostEstimate();
 
 	/**
 	 * Return whether or not the optimizer associated with

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java Fri
Aug  2 12:46:53 2013
@@ -109,7 +109,7 @@ public final class CurrentOfNode extends
 		*/
 		if (singleScanCostEstimate == null)
 		{
-			singleScanCostEstimate = optimizer.newCostEstimate();
+			singleScanCostEstimate = getOptimizerFactory().getCostEstimate();
 		}
 
 		singleScanCostEstimate.setCost(0.0d, 1.0d, 1.0d);
@@ -389,20 +389,10 @@ public final class CurrentOfNode extends
     ResultSetNode optimize(DataDictionary dataDictionary,
 					     PredicateList predicateList,
 						 double outerRows) 
-						throws StandardException {
-		/* Get an optimizer so we can get a cost */
-        Optimizer opt =
-            getOptimizer(new FromList(
-                             getOptimizerFactory().doJoinOrderOptimization(),
-                             this,
-                             getContextManager()),
-                         predicateList,
-                         dataDictionary,
-                         (RequiredRowOrdering) null,
-                         null );
-
+						throws StandardException
+    {
 		/* Assume there is no cost associated with fetching the current row */
-        bestCostEstimate = opt.newCostEstimate();
+        bestCostEstimate = getOptimizerFactory().getCostEstimate();
 		bestCostEstimate.setCost(0.0d, outerRows, outerRows);
 
 		return this;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java Fri
Aug  2 12:46:53 2013
@@ -212,19 +212,10 @@ class DistinctNode extends SingleChildRe
         childResult = childResult.optimize(dataDictionary,
                                            predicates,
                                            outerRows);
-        Optimizer opt = getOptimizer(
-                        new FromList(
-                            getOptimizerFactory().doJoinOrderOptimization(),
-							this,
-							getContextManager()),
-						predicates,
-						dataDictionary,
-						(RequiredRowOrdering) null,
-                        null );
 
 		// RESOLVE: NEED TO FACTOR IN COST OF SORTING AND FIGURE OUT HOW
 		// MANY ROWS HAVE BEEN ELIMINATED.
-        costEstimate = opt.newCostEstimate();
+        costEstimate = getOptimizerFactory().getCostEstimate();
 
 		costEstimate.setCost(childResult.getCostEstimate().getEstimatedCost(),
 							 childResult.getCostEstimate().rowCount(),

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java Fri Aug
 2 12:46:53 2013
@@ -1029,7 +1029,7 @@ abstract class FromTable extends ResultS
 	{
 		if (costEstimate == null)
 		{
-			costEstimate = optimizer.newCostEstimate();
+			costEstimate = getOptimizerFactory().getCostEstimate();
 		}
 		return costEstimate;
 	}
@@ -1045,7 +1045,7 @@ abstract class FromTable extends ResultS
 	{
 		if (scratchCostEstimate == null)
 		{
-			scratchCostEstimate = optimizer.newCostEstimate();
+			scratchCostEstimate = getOptimizerFactory().getCostEstimate();
 		}
 
 		return scratchCostEstimate;

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=1509671&r1=1509670&r2=1509671&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
Aug  2 12:46:53 2013
@@ -936,17 +936,10 @@ class GroupByNode extends SingleChildRes
         childResult = childResult.optimize(dataDictionary,
                                            predicates,
                                            outerRows);
-        Optimizer opt = getOptimizer(
-            new FromList(getOptimizerFactory().doJoinOrderOptimization(),
-                         getContextManager()),
-            predicates,
-            dataDictionary,
-            (RequiredRowOrdering) null,
-            null );
 
 		// RESOLVE: NEED TO FACTOR IN COST OF SORTING AND FIGURE OUT HOW
 		// MANY ROWS HAVE BEEN ELIMINATED.
-        costEstimate = opt.newCostEstimate();
+        costEstimate = getOptimizerFactory().getCostEstimate();
 
 		costEstimate.setCost(childResult.getCostEstimate().getEstimatedCost(),
 							childResult.getCostEstimate().rowCount(),

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java
Fri Aug  2 12:46:53 2013
@@ -178,7 +178,6 @@ public class OptimizerFactoryImpl
 	 * @exception StandardException		Thrown on error
 	 */
 	public CostEstimate getCostEstimate()
-		throws StandardException
 	{
 		return new CostEstimateImpl();
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java Fri
Aug  2 12:46:53 2013
@@ -2516,8 +2516,7 @@ class OptimizerImpl implements Optimizer
 		}
 	}
 
-	/** @see Optimizer#newCostEstimate */
-	public CostEstimate newCostEstimate()
+	private CostEstimate newCostEstimate()
 	{
 		return new CostEstimateImpl();
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java
Fri Aug  2 12:46:53 2013
@@ -1209,19 +1209,9 @@ class ProjectRestrictNode extends Single
 											restrictionList,
 											outerRows);
 
-        Optimizer opt = getOptimizer(
-            new FromList(
-                getOptimizerFactory().doJoinOrderOptimization(),
-                this,
-                getContextManager()),
-            predicates,
-            dataDictionary,
-            (RequiredRowOrdering) null,
-            null );
-
 		// RESOLVE: SHOULD FACTOR IN THE NON-OPTIMIZABLE PREDICATES THAT
 		// WERE NOT PUSHED DOWN
-        costEstimate = opt.newCostEstimate();
+        costEstimate = getOptimizerFactory().getCostEstimate();
 
 		costEstimate.setCost(childResult.getCostEstimate().getEstimatedCost(),
 							childResult.getCostEstimate().rowCount(),

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
Fri Aug  2 12:46:53 2013
@@ -178,7 +178,7 @@ class RowResultSetNode extends FromTable
 		*/
 		if (costEstimate == null)
 		{
-			costEstimate = optimizer.newCostEstimate();
+			costEstimate = getOptimizerFactory().getCostEstimate();
 		}
 
 		costEstimate.setCost(0.0d, 1.0d, 1.0d);
@@ -623,15 +623,7 @@ class RowResultSetNode extends FromTable
 		** CostEstimate object, so we can represent the cost of this node.
 		** This seems like overkill, but it's just an object allocation...
 		*/
-        Optimizer opt = getOptimizer(
-                new FromList(getOptimizerFactory().doJoinOrderOptimization(),
-                             getContextManager()),
-                predicateList,
-                dataDictionary,
-                (RequiredRowOrdering) null,
-                null );
-
-        costEstimate = opt.newCostEstimate();
+        costEstimate = getOptimizerFactory().getCostEstimate();
 
 		// RESOLVE: THE COST SHOULD TAKE SUBQUERIES INTO ACCOUNT
 		costEstimate.setCost(0.0d, outerRows, outerRows);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java
Fri Aug  2 12:46:53 2013
@@ -402,15 +402,7 @@ abstract class SingleChildResultSetNode 
 										predicates,
 										outerRows);
 
-        Optimizer opt = getOptimizer(
-                new FromList(getOptimizerFactory().doJoinOrderOptimization(),
-                             getContextManager()),
-                predicates,
-                dataDictionary,
-                (RequiredRowOrdering) null,
-                null );
-
-        costEstimate = opt.newCostEstimate();
+        costEstimate = getOptimizerFactory().getCostEstimate();
 		costEstimate.setCost(childResult.getCostEstimate().getEstimatedCost(),
 							childResult.getCostEstimate().rowCount(),
 							childResult.getCostEstimate().singleScanRowCount());

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
Fri Aug  2 12:46:53 2013
@@ -687,17 +687,7 @@ abstract class TableOperatorNode extends
 								  double outerRows)
 				throws StandardException
 	{
-		/* Get an optimizer, so we can get a cost structure */
-        Optimizer opt = getOptimizer(
-                new FromList(getOptimizerFactory().doJoinOrderOptimization(),
-                             this,
-                             getContextManager()),
-                predicateList,
-                dataDictionary,
-                (RequiredRowOrdering) null,
-                null );
-
-        costEstimate = opt.newCostEstimate();
+        costEstimate = getOptimizerFactory().getCostEstimate();
 
 		/* RESOLVE: This is just a stub for now */
 		leftResultSet = leftResultSet.optimize(

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLOptTrace.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLOptTrace.java?rev=1509671&r1=1509670&r2=1509671&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLOptTrace.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLOptTrace.java Fri
Aug  2 12:46:53 2013
@@ -519,7 +519,9 @@ class   XMLOptTrace implements  OptTrace
             }
             else if ( isFromTable( optimizable ) )
             {
-                return ((FromTable) ((ProjectRestrictNode) optimizable).getChildResult()).getTableName();
+                TableName   retval = ((FromTable) ((ProjectRestrictNode) optimizable).getChildResult()).getTableName();
+
+                if ( retval !=  null ) { return retval; }
             }
         }
         catch (StandardException e)



Mime
View raw message