jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [4/4] jena git commit: JENA-1187: Correct scope calculation for OpUnion
Date Thu, 02 Jun 2016 10:27:23 GMT
JENA-1187: Correct scope calculation for OpUnion


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

Branch: refs/heads/master
Commit: 363287f23ce4c5e93df74a76bd826090001126e2
Parents: 4918d7f
Author: Andy Seaborne <andy@apache.org>
Authored: Thu Jun 2 10:04:00 2016 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Thu Jun 2 10:04:00 2016 +0100

----------------------------------------------------------------------
 .../jena/sparql/engine/main/JoinClassifier.java | 10 ++++-----
 .../jena/sparql/engine/main/VarFinder.java      | 22 ++++++++++++++++++--
 .../jena/sparql/algebra/TestClassify.java       |  7 ++++---
 3 files changed, 29 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/363287f2/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/JoinClassifier.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/JoinClassifier.java
b/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/JoinClassifier.java
index bdae14c..22c3f39 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/JoinClassifier.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/JoinClassifier.java
@@ -98,11 +98,11 @@ public class JoinClassifier
             System.err.println("Left/opt:      " + vLeftOpt) ;
         // if (print) System.err.println("Left/filter:   " + vLeftFilter) ;
 
-        VarFinder vfRight = VarFinder.process(rightOp) ;
-        Set<Var> vRightFixed = vfRight.getFixed() ;
-        Set<Var> vRightOpt = vfRight.getOpt() ;
-        Set<Var> vRightFilter = vfRight.getFilter() ;
-        Set<Var> vRightAssign = vfRight.getAssign() ;
+        VarFinder vfRight       = VarFinder.process(rightOp) ;
+        Set<Var> vRightFixed    = vfRight.getFixed() ;
+        Set<Var> vRightOpt      = vfRight.getOpt() ;
+        Set<Var> vRightFilter   = vfRight.getFilter() ;
+        Set<Var> vRightAssign   = vfRight.getAssign() ;
 
         if ( print )
             System.err.println("Right/fixed:   " + vRightFixed) ;

http://git-wip-us.apache.org/repos/asf/jena/blob/363287f2/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java
index 731532b..258f7ea 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java
@@ -28,6 +28,7 @@ import java.util.HashSet ;
 import java.util.List ;
 import java.util.Set ;
 
+import org.apache.jena.atlas.lib.SetUtils ;
 import org.apache.jena.sparql.algebra.Op ;
 import org.apache.jena.sparql.algebra.OpVisitor ;
 import org.apache.jena.sparql.algebra.op.* ;
@@ -213,8 +214,25 @@ public class VarFinder
 
         @Override
         public void visit(OpUnion opUnion) {
-            mergeVars(opUnion.getLeft());
-            mergeVars(opUnion.getRight());
+            VarUsageVisitor usage1 = VarUsageVisitor.apply(opUnion.getLeft());
+            VarUsageVisitor usage2 = VarUsageVisitor.apply(opUnion.getRight());
+
+            // Fixed both sides.
+            Set<Var> fixed = SetUtils.intersection(usage1.defines, usage2.defines)
;  
+            defines.addAll(fixed) ;
+            
+            // Fixed one side or the other, not both.
+            Set<Var> notFixed = SetUtils.symmetricDifference(usage1.defines, usage2.defines)
;
+            optDefines.addAll(notFixed) ;                              
+
+            optDefines.addAll(usage1.optDefines);
+            optDefines.addAll(usage2.optDefines);
+            
+            filterMentions.addAll(usage1.filterMentions);
+            filterMentions.addAll(usage2.filterMentions);
+            
+            assignMentions.addAll(usage1.assignMentions);
+            assignMentions.addAll(usage2.assignMentions);
         }
         
         @Override

http://git-wip-us.apache.org/repos/asf/jena/blob/363287f2/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestClassify.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestClassify.java b/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestClassify.java
index 741500d..17e7692 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestClassify.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestClassify.java
@@ -104,9 +104,10 @@ public class TestClassify extends BaseTest
     // Use of a filter variable from the LHS but optional in RHS
     @Test public void testClassify_Join_35() 
     { classifyJ("{ GRAPH ?g { ?x ?y ?z } { OPTIONAL{?a ?b ?z} FILTER (?z) } }", false) ;
}
-    
-    @Test public void testClassify_Join_40() 
-    { classifyJ("{ ?x ?y ?z { ?x ?y ?z } UNION { ?x1 ?y1 ?z1 }}", true) ; }
+
+    // The fix for JENA-1187 invalidates this test.
+//    @Test public void testClassify_Join_40()
+//    { classifyJ("{ ?x ?y ?z { ?x ?y ?z } UNION { ?x1 ?y1 ?z1 }}", true) ; }
 
     @Test public void testClassify_Join_41() 
     { classifyJ("{ ?x ?y ?z { ?x1 ?y1 ?z1 BIND(?z+2 AS ?A) } UNION { ?x1 ?y1 ?z1 }}", false)
; }


Mime
View raw message