jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [3/4] jena git commit: Help for debugging filter placement.
Date Fri, 06 Feb 2015 12:51:10 GMT
Help for debugging filter placement.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/fd14ac19
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/fd14ac19
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/fd14ac19

Branch: refs/heads/master
Commit: fd14ac19722b99f762fcb493d6f3d322a9f4a151
Parents: 2b3569f
Author: Andy Seaborne <andy@apache.org>
Authored: Fri Feb 6 12:05:03 2015 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Fri Feb 6 12:05:03 2015 +0000

----------------------------------------------------------------------
 .../optimize/TransformFilterPlacement.java      | 92 +++++++++++++-------
 1 file changed, 61 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/fd14ac19/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformFilterPlacement.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformFilterPlacement.java
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformFilterPlacement.java
index c0f1ca1..023b03c 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformFilterPlacement.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformFilterPlacement.java
@@ -18,10 +18,14 @@ z * Licensed to the Apache Software Foundation (ASF) under one
 
 package com.hp.hpl.jena.sparql.algebra.optimize ;
 
-import java.util.* ;
+import java.util.Collection ;
+import java.util.Iterator ;
+import java.util.List ;
+import java.util.Set ;
 
 import org.apache.jena.atlas.lib.CollectionUtils ;
 import org.apache.jena.atlas.lib.DS ;
+import org.apache.jena.atlas.lib.Lib ;
 
 import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.graph.Triple ;
@@ -45,12 +49,28 @@ import com.hp.hpl.jena.sparql.util.VarUtils ;
  */
 
 public class TransformFilterPlacement extends TransformCopy {
-    static class Placement {
-        final Op op ;
-        final ExprList unplaced ; 
-        Placement(Op op, ExprList remaining) { this.op = op ; this.unplaced = remaining ;
}
+    public static class Placement {
+        final public Op op ;
+        final public ExprList unplaced ; 
+        public Placement(Op op, ExprList remaining) { 
+            this.op = op ; 
+            this.unplaced = remaining ; 
+        }
+        @Override
+        public String toString() { return ""+op+" : "+unplaced ; }
+        
+        @Override
+        public int hashCode() {
+            return 31*Lib.hashCodeObject(op,1) + Lib.hashCodeObject(unplaced) ;
+        }
         @Override
-        public String toString() { return ""+op+" : "+unplaced ; } 
+        public boolean equals(Object obj) {
+            if ( this == obj ) return true ;
+            if ( obj == null ) return false ;
+            if ( getClass() != obj.getClass() ) return false ;
+            Placement other = (Placement)obj ;
+            return Lib.equal(op, other.op) && Lib.equal(unplaced, other.unplaced)
;
+        }
     }
     
     // Empty, immutable ExprList
@@ -98,6 +118,16 @@ public class TransformFilterPlacement extends TransformCopy {
     public TransformFilterPlacement(boolean includeBGPs)
     { this.includeBGPs = includeBGPs ; }
 
+    /** Operation exposes the filter placement mechanism 
+     *  so that investigation of filter placement issues
+     *  can be done from outside this class.
+     *  <i>Do not use in application code : subject to removal or change at any time.</i>
+     */
+    public static Placement filterPlacement$(ExprList exprs, Op op) {
+        TransformFilterPlacement t = new TransformFilterPlacement() ;
+        return t.transform(exprs, op) ;
+    }
+    
     @Override
     public Op transform(OpFilter opFilter, Op x) {
         ExprList exprs = opFilter.getExprs() ;
@@ -507,7 +537,7 @@ public class TransformFilterPlacement extends TransformCopy {
             if ( pRight != null && ! pRight.unplaced.isEmpty() )
                 return noChangePlacement ;
 
-            // Musrt be guarded by the above.
+            // Must be guarded by the above.
             left = transformOpAlways(exprs, left) ;
             right = transformOpAlways(exprs, right) ;
             
@@ -574,30 +604,6 @@ public class TransformFilterPlacement extends TransformCopy {
         return processExtendAssign(exprs, input) ;
     }
     
-    /* Complete processing for an Op1. 
-     * Having split expressions into pushed and unpushed at this point,
-     * try to push "pushed" down further into the subOp.
-     */  
-    private Placement processSubOp1(ExprList pushed, ExprList unpushed, Op1 input) {
-        Op opSub = input.getSubOp() ;
-        Placement subPlacement = transform(pushed, opSub) ;
-        if ( subPlacement == null ) {
-            // (Same as if a placement of the exprlist and op passed in is given).
-            // Didn't make any changes below, so add a filter for the 'pushed' and
-            // return a placement for the unpushed. 
-            Op op1 = input.getSubOp() ;
-            if ( pushed != null &&! pushed.isEmpty() )
-                op1 = OpFilter.filter(pushed, op1) ;
-            Op op2 = input.copy(op1) ;
-            return result(op2, unpushed) ;
-        }
-        // We did make changes below.  Add filter for these (which includes the 
-        // "pushed" at this level, now in the p.op or left in p.unplaced.
-        Op op_a = OpFilter.filter(subPlacement.unplaced, subPlacement.op) ;
-        op_a =  input.copy(op_a) ;
-        return result(op_a, unpushed) ;
-    }
-    
     private Placement processExtendAssign(ExprList exprs, OpExtendAssign input) {
         // We assume that each (extend) and (assign) is usually in simple form -
         // always one assignment. We cope with the general form (multiple
@@ -669,6 +675,30 @@ public class TransformFilterPlacement extends TransformCopy {
     
     // This is the cause of JENA-874.
    
+    /* Complete processing for an Op1. 
+     * Having split expressions into pushed and unpushed at this point,
+     * try to push "pushed" down further into the subOp.
+     */  
+    private Placement processSubOp1(ExprList pushed, ExprList unpushed, Op1 input) {
+        Op opSub = input.getSubOp() ;
+        Placement subPlacement = transform(pushed, opSub) ;
+        if ( subPlacement == null ) {
+            // (Same as if a placement of the exprlist and op passed in is given).
+            // Didn't make any changes below, so add a filter for the 'pushed' and
+            // return a placement for the unpushed. 
+            Op op1 = input.getSubOp() ;
+            if ( pushed != null &&! pushed.isEmpty() )
+                op1 = OpFilter.filter(pushed, op1) ;
+            Op op2 = input.copy(op1) ;
+            return result(op2, unpushed) ;
+        }
+        // We did make changes below.  Add filter for these (which includes the 
+        // "pushed" at this level, now in the p.op or left in p.unplaced.
+        Op op_a = OpFilter.filter(subPlacement.unplaced, subPlacement.op) ;
+        op_a =  input.copy(op_a) ;
+        return result(op_a, unpushed) ;
+    }
+
     private Placement placeDistinctReduced(ExprList exprs, OpDistinctReduced input) {
         Op subOp = input.getSubOp() ;
         Placement p = transform(exprs, subOp) ;


Mime
View raw message