db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1492766 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/compile/Optimizer.java impl/sql/compile/OptimizerImpl.java impl/sql/compile/TableOperatorNode.java
Date Thu, 13 Jun 2013 17:06:02 GMT
Author: rhillegas
Date: Thu Jun 13 17:06:02 2013
New Revision: 1492766

URL: http://svn.apache.org/r1492766
Log:
DERBY-6259: Make optimizer fields private: tests passed cleanly on derby-6259-02-aa-increasePrivacy.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/impl/sql/compile/OptimizerImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.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=1492766&r1=1492765&r2=1492766&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 Thu Jun
13 17:06:02 2013
@@ -290,4 +290,32 @@ public interface Optimizer
      * @return the maximum number of bytes to be used per table.
      */
     public int getMaxMemoryPerTable();
+
+    /**
+     * Get the number of optimizables being considered by this Optimizer.
+     */
+    public  int getOptimizableCount();
+
+    /**
+     * Get the ith (0-based) Optimizable being considered by this Optimizer.
+     */
+    public  Optimizable getOptimizable( int idx );
+
+	/**
+	 * Process (i.e. add, load, or remove) current best join order as the
+	 * best one for some outer query or ancestor node, represented by another
+	 * Optimizer or an instance of FromTable, respectively. Then
+	 * iterate through our optimizableList and tell each Optimizable
+	 * to do the same.  See Optimizable.updateBestPlan() for more on why
+	 * this is necessary.
+	 *
+	 * @param action Indicates whether to add, load, or remove the plan
+	 * @param planKey Object to use as the map key when adding/looking up
+	 *  a plan.  If this is an instance of Optimizer then it corresponds
+	 *  to an outer query; otherwise it's some Optimizable above this
+	 *  Optimizer that could potentially reject plans chosen by this
+	 *  Optimizer.
+	 */
+	public void updateBestPlanMaps(short action, Object planKey)
+        throws StandardException;
 }

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=1492766&r1=1492765&r2=1492766&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 Thu
Jun 13 17:06:02 2013
@@ -64,30 +64,30 @@ import java.util.HashMap;
  * clauses between permutations yet.)
  */
 
-public class OptimizerImpl implements Optimizer 
+class OptimizerImpl implements Optimizer 
 {
-	protected LanguageConnectionContext lcc;
+	private LanguageConnectionContext lcc;
 
-	DataDictionary			 dDictionary;
+	private DataDictionary			 dDictionary;
 	/* The number of tables in the query as a whole.  (Size of bit maps.) */
-	int						 numTablesInQuery;
+	private int						 numTablesInQuery;
 	/* The number of optimizables in the list to optimize */
-	int						 numOptimizables;
+	private int						 numOptimizables;
 
 	/* Bit map of tables that have already been assigned to slots.
 	 * Useful for pushing join clauses as slots are assigned.
      * Enforcement of ordering dependencies is done through
      * assignedTableMap.
      */
-	protected JBitSet		 assignedTableMap;
-	protected OptimizableList optimizableList;
-	OptimizablePredicateList predicateList;
-	JBitSet					 nonCorrelatedTableMap;
-
-	protected int[]			 proposedJoinOrder;
-	protected int[]					 bestJoinOrder;
-	protected int			 joinPosition;
-	boolean					 desiredJoinOrderFound;
+	private JBitSet		 assignedTableMap;
+	private OptimizableList optimizableList;
+	private OptimizablePredicateList predicateList;
+	private JBitSet					 nonCorrelatedTableMap;
+
+	private int[]			 proposedJoinOrder;
+	private int[]					 bestJoinOrder;
+	private int			 joinPosition;
+	private boolean					 desiredJoinOrderFound;
 
 	/* This implements a state machine to jump start to a appearingly good join
 	 * order, when the number of tables is high, and the optimization could take
@@ -107,24 +107,24 @@ public class OptimizerImpl implements Op
 	private boolean			 ruleBasedOptimization;
 
 	private CostEstimateImpl outermostCostEstimate;
-	protected CostEstimateImpl currentCost;
-	protected CostEstimateImpl currentSortAvoidanceCost;
-	protected CostEstimateImpl bestCost;
-
-	protected long			 timeOptimizationStarted;
-	protected long			 currentTime;
-	protected boolean		 timeExceeded;
+	private CostEstimateImpl currentCost;
+	private CostEstimateImpl currentSortAvoidanceCost;
+	private CostEstimateImpl bestCost;
+
+	private long			 timeOptimizationStarted;
+	private long			 currentTime;
+	private boolean		 timeExceeded;
 	private boolean			 noTimeout;
 	private boolean 		 useStatistics;
 	private int				 tableLockThreshold;
 
 	private JoinStrategy[]	joinStrategies;
 
-	protected RequiredRowOrdering	requiredRowOrdering;
+	private RequiredRowOrdering	requiredRowOrdering;
 
 	private boolean			 foundABestPlan;
 
-	protected CostEstimate sortCost;
+	private CostEstimate sortCost;
 
 	private RowOrdering currentRowOrdering = new RowOrderingImpl();
 	private RowOrdering bestRowOrdering = new RowOrderingImpl();
@@ -132,7 +132,7 @@ public class OptimizerImpl implements Op
 	private boolean	conglomerate_OneRowResultSet;
 
 	// max memory use per table
-	protected int maxMemoryPerTable;
+	private int maxMemoryPerTable;
 
 	// Whether or not we need to reload the best plan for an Optimizable
     // when we "pull" [1] it.  If the latest complete join order was the
@@ -170,11 +170,11 @@ public class OptimizerImpl implements Op
 
 	// Value used to figure out when/if we've timed out for this
 	// Optimizable.
-	protected double timeLimit;
+	private double timeLimit;
 
 	// Cost estimate for the final "best join order" that we chose--i.e.
 	// the one that's actually going to be generated.
-	CostEstimate finalCostEstimate;
+	private CostEstimate finalCostEstimate;
 
 	/* Status variables used for "jumping" to previous best join
 	 * order when possible.  In particular, this helps when this
@@ -194,7 +194,7 @@ public class OptimizerImpl implements Op
 	private boolean usingPredsPushedFromAbove;
 	private boolean bestJoinOrderUsedPredsFromAbove;
 
-	protected  OptimizerImpl(OptimizableList optimizableList, 
+	OptimizerImpl(OptimizableList optimizableList, 
 				  OptimizablePredicateList predicateList,
 				  DataDictionary dDictionary,
 				  boolean ruleBasedOptimization,
@@ -2640,7 +2640,7 @@ public class OptimizerImpl implements Op
 	 *  OptimizerImpl that could potentially reject plans chosen by this
 	 *  OptimizerImpl.
 	 */
-	protected void updateBestPlanMaps(short action,
+	public void updateBestPlanMaps(short action,
 		Object planKey) throws StandardException
 	{
 		// First we process this OptimizerImpl's best join order.  If there's
@@ -2724,10 +2724,13 @@ public class OptimizerImpl implements Op
 	 * clears out any scoped predicates that might be sitting in
 	 * OptimizerImpl's list from the last round of optimizing.
 	 *
+	 * This method should be in the Optimizer interface, but it relies
+     * on an argument type (PredicateList) which lives in an impl package.
+	 *
 	 * @param pList List of predicates to add to this OptimizerImpl's
 	 *  own list for pushing.
 	 */
-	protected void addScopedPredicatesToList(PredicateList pList)
+	void addScopedPredicatesToList(PredicateList pList)
 		throws StandardException
 	{
 		if ((pList == null) || (pList == predicateList))
@@ -2774,4 +2777,7 @@ public class OptimizerImpl implements Op
     /** Get the trace machinery */
     public  OptTrace    tracer()    { return lcc.getOptimizerTracer(); }
 
+    public  int getOptimizableCount() { return optimizableList.size(); }
+
+    public  Optimizable getOptimizable( int idx ) { return optimizableList.getOptimizable(
idx ); }
 }

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=1492766&r1=1492765&r2=1492766&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
Thu Jun 13 17:06:02 2013
@@ -126,8 +126,7 @@ abstract class TableOperatorNode extends
 				 */
 				leftOptimizer.modifyAccessPaths();
 				leftResultSet = (ResultSetNode)
-					((OptimizerImpl)leftOptimizer)
-						.optimizableList.getOptimizable(0);
+					leftOptimizer.getOptimizable(0);
 			}
 			else
 			{
@@ -153,8 +152,7 @@ abstract class TableOperatorNode extends
 				 */
 				rightOptimizer.modifyAccessPaths();
 				rightResultSet = (ResultSetNode)
-					((OptimizerImpl)rightOptimizer)
-						.optimizableList.getOptimizable(0);
+					rightOptimizer.getOptimizable(0);
 			}
 			else
 			{
@@ -747,8 +745,7 @@ abstract class TableOperatorNode extends
 				 */
 				leftOptimizer.modifyAccessPaths();
 				leftResultSet = (ResultSetNode)
-					((OptimizerImpl)leftOptimizer)
-						.optimizableList.getOptimizable(0);
+					leftOptimizer.getOptimizable(0);
 			}
 			else
 			{
@@ -778,8 +775,7 @@ abstract class TableOperatorNode extends
 				 */
 				rightOptimizer.modifyAccessPaths();
 				rightResultSet = (ResultSetNode)
-					((OptimizerImpl)rightOptimizer)
-						.optimizableList.getOptimizable(0);
+					rightOptimizer.getOptimizable(0);
 			}
 			else
 			{



Mime
View raw message