Author: daijy
Date: Mon Aug 30 07:44:20 2010
New Revision: 990715

URL: http://svn.apache.org/viewvc?rev=990715&view=rev
Log:
PIG-1574: Optimization rule PushUpFilter causes filter to be pushed up out joins

Modified:
    hadoop/pig/trunk/CHANGES.txt
    hadoop/pig/trunk/src/org/apache/pig/newplan/logical/rules/PushUpFilter.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=990715&r1=990714&r2=990715&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon Aug 30 07:44:20 2010
@@ -26,6 +26,8 @@ PIG-1249: Safe-guards against misconfigu
 
 IMPROVEMENTS
 
+PIG-1574: Optimization rule PushUpFilter causes filter to be pushed up out 
joins (xuefuz via daijy)
+
 PIG-1515: Migrate logical optimization rule: PushDownForeachFlatten (xuefuz 
via daijy)
 
 PIG-1321: Logical Optimizer: Merge cascading foreach (xuefuz via daijy)

Modified: 
hadoop/pig/trunk/src/org/apache/pig/newplan/logical/rules/PushUpFilter.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/newplan/logical/rules/PushUpFilter.java?rev=990715&r1=990714&r2=990715&view=diff
==============================================================================
--- hadoop/pig/trunk/src/org/apache/pig/newplan/logical/rules/PushUpFilter.java 
(original)
+++ hadoop/pig/trunk/src/org/apache/pig/newplan/logical/rules/PushUpFilter.java 
Mon Aug 30 07:44:20 2010
@@ -125,26 +125,19 @@ public class PushUpFilter extends Rule {
                     }
                 }
                 
-                // find the farthest predecessor that has all the fields
-                LogicalRelationalOperator input = join;
-                List<Operator> preds = currentPlan.getPredecessors(input);
-                while(!(input instanceof LOForEach) && preds != null) {        
        
-                    boolean found = false;
-                    for(int j=0; j<preds.size(); j++) {
-                        if (hasAll((LogicalRelationalOperator)preds.get(j), 
uids)) {
-                            input = (LogicalRelationalOperator)preds.get(j);   
-                            subPlan.add(input);
-                            found = true;
-                            break;
-                        }
-                    }
-                    if (!found) {
+                // Find the predecessor of join that contains all required 
uids.
+                Operator input = null;
+                List<Operator> preds = currentPlan.getPredecessors(join);
+                for(int j=0; j<preds.size(); j++) {
+                    if( hasAll((LogicalRelationalOperator)preds.get(j), uids) 
) {
+                        input = preds.get(j);   
+                        subPlan.add(input);
                         break;
                     }
-                    preds = currentPlan.getPredecessors(input);
                 }
                             
-                if (input != join) {                           
+                if( input != null ) {
+                    // Found one of the join's predeccessors of the join which 
has all the uids.
                     Operator pred = currentPlan.getPredecessors(filter).get(0);
                     Operator succed = currentPlan.getSuccessors(filter).get(0);
                     subPlan.add(succed);
@@ -156,17 +149,17 @@ public class PushUpFilter extends Rule {
                     succed = currentPlan.getSuccessors(input).get(0);
                     Pair<Integer, Integer> p3 = currentPlan.disconnect(input, 
succed);
                     currentPlan.connect(input, p3.first, filter, 0);
-                    currentPlan.connect(filter, 0, succed, p3.second);         
                               
-                    
+                    currentPlan.connect(filter, 0, succed, p3.second);
                     return;
-                }  
-                
-                List<Operator> l = currentPlan.getSuccessors(filter);
-                if (l != null) {
-                    next = l.get(0);
-                } else {
-                    next = null;
-                }                         
+                }  else {
+                    // Didn't find the opeartor, so looking at the next one 
after the filter.
+                    List<Operator> l = currentPlan.getSuccessors(filter );
+                    if( l != null ) {
+                        next = l.get( 0 );
+                    } else {
+                        next = null;
+                    }
+                }
             }
         }
         


Reply via email to