Cleaned up rewrite rule collection which fixes problems with the corrected distinct by. Added new rule collection for access method rewrites.

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_inline_vars@778 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
index 1662b7e..17b0b1d 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
@@ -131,9 +131,6 @@
         condPushDownAndJoinInference.add(new IntroduceGroupByForSubplanRule());
         condPushDownAndJoinInference.add(new SubplanOutOfGroupRule());
         condPushDownAndJoinInference.add(new InsertOuterJoinRule());
-        condPushDownAndJoinInference.add(new AsterixInlineVariablesRule());
-        condPushDownAndJoinInference.add(new AsterixProperInlineVariablesRule());
-        condPushDownAndJoinInference.add(new RemoveUnusedAssignAndAggregateRule());
         condPushDownAndJoinInference.add(new FactorRedundantGroupAndDecorVarsRule());
         condPushDownAndJoinInference.add(new PushAggregateIntoGroupbyRule());
         condPushDownAndJoinInference.add(new EliminateSubplanRule());
@@ -174,12 +171,20 @@
         consolidation.add(new IntroduceGroupByCombinerRule());
         consolidation.add(new IntroduceAggregateCombinerRule());
         consolidation.add(new CountVarToCountOneRule());
-        consolidation.add(new IntroduceSelectAccessMethodRule());
-        consolidation.add(new IntroduceJoinAccessMethodRule());
         consolidation.add(new RemoveUnusedAssignAndAggregateRule());
         consolidation.add(new IntroduceSecondaryIndexInsertDeleteRule());
         return consolidation;
     }
+    
+    public final static List<IAlgebraicRewriteRule> buildAccessMethodRuleCollection() {
+        List<IAlgebraicRewriteRule> accessMethod = new LinkedList<IAlgebraicRewriteRule>();        
+        accessMethod.add(new IntroduceSelectAccessMethodRule());
+        //accessMethod.add(new AsterixProperInlineVariablesRule());
+        //accessMethod.add(new PushSelectIntoJoinRule());
+        //accessMethod.add(new RemoveUnusedAssignAndAggregateRule());        
+        accessMethod.add(new IntroduceJoinAccessMethodRule());
+        return accessMethod;
+    }
 
     public final static List<IAlgebraicRewriteRule> buildOpPushDownRuleCollection() {
         List<IAlgebraicRewriteRule> opPushDown = new LinkedList<IAlgebraicRewriteRule>();
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/AsterixProperInlineVariablesRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/AsterixProperInlineVariablesRule.java
index 5503b8b..3eeb731 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/AsterixProperInlineVariablesRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/AsterixProperInlineVariablesRule.java
@@ -59,6 +59,8 @@
     static {
         doNotInlineFuncs.add(AsterixBuiltinFunctions.CLOSED_RECORD_CONSTRUCTOR);
         doNotInlineFuncs.add(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR);
+        //doNotInlineFuncs.add(AsterixBuiltinFunctions.FIELD_ACCESS_BY_INDEX);
+        //doNotInlineFuncs.add(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME);
     }
     
     @Override
@@ -136,15 +138,14 @@
             case INDEX_INSERT_DELETE:
             case PROJECT:
             // We can currently only order/group by a variable reference expression.
-            case ORDER:
-            case INNERJOIN:
-            case LEFTOUTERJOIN: {
-                break;
-            }
-            // Remove non-live vars here.
             case GROUP:
             case DISTINCT:
-            case AGGREGATE: {
+            case AGGREGATE:
+            case ORDER:
+            case INNERJOIN:
+            case LEFTOUTERJOIN:
+            // TODO: Enabling this will require fixes in the access method rewrite rules.
+            case UNNEST_MAP: {
                 break;
             }
             default: {
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
index 57b2ff0..1875ccb 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
@@ -101,6 +101,8 @@
         defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs,
                 RuleCollections.buildConsolidationRuleCollection()));
         defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs,
+                RuleCollections.buildAccessMethodRuleCollection()));
+        defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs,
                 RuleCollections.buildOpPushDownRuleCollection()));
         return defaultLogicalRewrites;
     }
diff --git a/asterix-app/src/test/resources/logging.properties b/asterix-app/src/test/resources/logging.properties
index deb88307..f56d7fd 100644
--- a/asterix-app/src/test/resources/logging.properties
+++ b/asterix-app/src/test/resources/logging.properties
@@ -29,9 +29,9 @@
 # Note that the ConsoleHandler also has a separate level
 # setting to limit messages printed to the console.
 
-.level= WARNING
+# .level= WARNING
 # .level= INFO
-# .level= FINE
+.level= FINE
 # .level = FINEST
 
 ############################################################
diff --git a/asterix-app/src/test/resources/runtimets/ignore.txt b/asterix-app/src/test/resources/runtimets/ignore.txt
index 2b011ec..5dbfca9 100644
--- a/asterix-app/src/test/resources/runtimets/ignore.txt
+++ b/asterix-app/src/test/resources/runtimets/ignore.txt
@@ -33,3 +33,4 @@
 flwor
 string/startwith03.aql
 aggregate/droptype.aql
+bla.aql