jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/2] jena git commit: JENA-881 : Don't leak filter expressions into the unplaced list.
Date Sat, 07 Feb 2015 12:37:56 GMT
Repository: jena
Updated Branches:
  refs/heads/master 387bc73e5 -> 491d0f964


JENA-881 : Don't leak filter expressions into the unplaced list.

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

Branch: refs/heads/master
Commit: 4f5fd491949127be1d4584df8444d1c4ac8772b5
Parents: 387bc73
Author: Andy Seaborne <andy@apache.org>
Authored: Sat Feb 7 12:37:02 2015 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Sat Feb 7 12:37:02 2015 +0000

----------------------------------------------------------------------
 .../optimize/TransformFilterPlacement.java      | 34 +++++++++++++-------
 1 file changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/4f5fd491/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 023b03c..435d787 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
@@ -210,7 +210,6 @@ public class TransformFilterPlacement extends TransformCopy {
             placement = placeAssign(exprs, (OpAssign)input) ;
         // Modifiers
 //        else if ( input instanceof OpGroup ) {
-//            // TODO
 //            placement = noChangePlacement ;
 //        }
 //        else if ( input instanceof OpSlice ) {
@@ -233,16 +232,29 @@ public class TransformFilterPlacement extends TransformCopy {
     }
     
     private Placement placeFilter(ExprList exprs, OpFilter input) {
-        if ( exprs.size() == 0 )
-            // Unpack the filter,
-            return transform(input.getExprs(), input.getSubOp()) ;
-        
-        // Thrown the filter expressions into the general list to be placed.
-        // Add to keep the application order (original filter then additional exprs)
-        // Not important, but nice.
-        ExprList exprs2 = ExprList.copy(input.getExprs()) ;
-        exprs2.addAll(exprs);
-        return transform(exprs2, input.getSubOp()) ;
+        // If input.getSubOp is itself a filter, it has already been
+        // processed because the Transform is applied bottom-up.
+
+        // We must not let the filter's expressions go back as "unplaced"
+        // as they are scoped to the input and if "unplaced" are available
+        // out of that scope.
+
+        Op op = input.getSubOp() ;
+        ExprList exprsInner = input.getExprs() ;
+        ExprList exprsOuter = exprs ;
+
+        // Outer
+        Placement p = transform(exprsOuter, input.getSubOp()) ;
+        if ( p != null ) {
+            op = p.op ;
+            exprsOuter = p.unplaced ;
+        }
+        // Put inner round the modified Op.
+        // If op is also a filter, a single filter is created with
+        // exprsInner now after placed filters.
+        // ("after" means later in the exprList of the filter).
+        Op f = OpFilter.filter(exprsInner, op) ;
+        return new Placement(f, exprsOuter) ;
     }
 
     private Placement placeOrWrapBGP(ExprList exprs, OpBGP x) {


Mime
View raw message