[NO ISSUE] Refactoring plan optimization method

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Refactoring plan optimization method.

Change-Id: I8275bca00b41969444824cffd12f542d802bf26f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3101
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/HeuristicOptimizer.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/HeuristicOptimizer.java
index a2a0ca1..2aacc0e 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/HeuristicOptimizer.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/HeuristicOptimizer.java
@@ -74,15 +74,12 @@
         if (plan == null) {
             return;
         }
-        if (AlgebricksConfig.ALGEBRICKS_LOGGER.isTraceEnabled()) {
-            AlgebricksConfig.ALGEBRICKS_LOGGER.trace("Starting logical optimizations.\n");
-        }
 
-        logPlanAt("Logical Plan", Level.TRACE);
-        runOptimizationSets(plan, logicalRewrites);
+        logPlanAt("Plan Before Optimization", Level.TRACE);
+        runLogicalOptimizationSets(plan, logicalRewrites);
         computeSchemaBottomUpForPlan(plan);
-        runPhysicalOptimizations(plan, physicalRewrites);
-        logPlanAt("Optimized Plan", Level.TRACE);
+        runPhysicalOptimizationSets(plan, physicalRewrites);
+        logPlanAt("Plan After Optimization", Level.TRACE);
     }
 
     private void logPlanAt(String name, Level lvl) throws AlgebricksException {
@@ -94,9 +91,19 @@
         }
     }
 
+    private void runLogicalOptimizationSets(ILogicalPlan plan,
+            List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> optimizationSet)
+            throws AlgebricksException {
+        if (AlgebricksConfig.ALGEBRICKS_LOGGER.isTraceEnabled()) {
+            AlgebricksConfig.ALGEBRICKS_LOGGER.trace("Starting logical optimizations.\n");
+        }
+        runOptimizationSets(plan, optimizationSet);
+    }
+
     private void runOptimizationSets(ILogicalPlan plan,
-            List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> optimSet) throws AlgebricksException {
-        for (Pair<AbstractRuleController, List<IAlgebraicRewriteRule>> ruleList : optimSet) {
+            List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> optimizationSet)
+            throws AlgebricksException {
+        for (Pair<AbstractRuleController, List<IAlgebraicRewriteRule>> ruleList : optimizationSet) {
             for (Mutable<ILogicalOperator> r : plan.getRoots()) {
                 ruleList.first.setContext(context);
                 ruleList.first.rewriteWithRuleCollection(r, ruleList.second);
@@ -123,13 +130,12 @@
         op.recomputeSchema();
     }
 
-    private void runPhysicalOptimizations(ILogicalPlan plan,
-            List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> physicalRewrites)
+    private void runPhysicalOptimizationSets(ILogicalPlan plan,
+            List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> optimizationSet)
             throws AlgebricksException {
         if (AlgebricksConfig.ALGEBRICKS_LOGGER.isTraceEnabled()) {
             AlgebricksConfig.ALGEBRICKS_LOGGER.trace("Starting physical optimizations.\n");
         }
-        runOptimizationSets(plan, physicalRewrites);
+        runOptimizationSets(plan, optimizationSet);
     }
-
 }