jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/6] jena git commit: JENA-1355: Fix to VarFinder for OpPropFunc
Date Sun, 04 Jun 2017 08:02:15 GMT
Repository: jena
Updated Branches:
  refs/heads/master cc8810d9b -> e79199a7a


JENA-1355: Fix to VarFinder for OpPropFunc


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

Branch: refs/heads/master
Commit: 688006bf0318c206fc16eba2a8a97239e17060ce
Parents: 3b3ba37
Author: Andy Seaborne <andy@apache.org>
Authored: Thu Jun 1 21:41:36 2017 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Thu Jun 1 21:47:10 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/jena/sparql/engine/main/VarFinder.java  | 9 +++++++--
 .../src/main/java/org/apache/jena/sparql/util/VarUtils.java | 8 +++++++-
 .../java/org/apache/jena/sparql/algebra/TestVarFinder.java  | 5 +++++
 3 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/688006bf/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 b781ba2..8db255e 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
@@ -355,8 +355,13 @@ public class VarFinder
 
         @Override
         public void visit(OpPropFunc opPropFunc) {
-            VarUtils.addVarNodes(defines, opPropFunc.getSubjectArgs().getArgList()) ;
-            VarUtils.addVarNodes(defines, opPropFunc.getObjectArgs().getArgList()) ;
+            VarUtils.addVars(defines, opPropFunc.getSubjectArgs()) ;
+            VarUtils.addVars(defines, opPropFunc.getObjectArgs()) ;
+            
+            mergeVars(opPropFunc.getSubOp());
+            
+            // If definite (from the property function), remove from optDefines. 
+            optDefines.removeAll(this.defines);
         }
 
         // Ops that add nothing to variable scoping.

http://git-wip-us.apache.org/repos/asf/jena/blob/688006bf/jena-arq/src/main/java/org/apache/jena/sparql/util/VarUtils.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/VarUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/VarUtils.java
index 166293d..3247ba7 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/util/VarUtils.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/VarUtils.java
@@ -25,6 +25,7 @@ import java.util.Set;
 import org.apache.jena.graph.Node;
 import org.apache.jena.graph.Triple;
 import org.apache.jena.sparql.core.* ;
+import org.apache.jena.sparql.pfunction.PropFuncArg;
 
 public class VarUtils {
     public static Set<Var> getVars(Triple triple) {
@@ -87,5 +88,10 @@ public class VarUtils {
         }
     }
 
-
+    public static void addVars(Collection<Var> acc, PropFuncArg arg) {
+        if ( arg.isNode() )
+            addVar(acc, arg.getArg());
+        else
+            addVarNodes(acc, arg.getArgList());
+    }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/688006bf/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestVarFinder.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestVarFinder.java b/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestVarFinder.java
index b3eb539..c476180 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestVarFinder.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/algebra/TestVarFinder.java
@@ -54,6 +54,11 @@ public class TestVarFinder extends BaseTest
     @Test public void varfind_04_4() { varfindFilterOnly("(leftjoin (bgp (?x <q> <v>))
(filter (?Z) (bgp (?s <p> <o>))))", "Z") ; }
     @Test public void varfind_04_5() { varfindFilterOnly("(leftjoin (bgp (?x <q> <v>))
(bgp (?s <p> <o>)) ?Z)", "Z") ; }
 
+    @Test public void varfind_05_1() { varfindFixed("(propfunc :pf ?x (?y ?z) (table unit))",
"x", "y", "z"); }
+    @Test public void varfind_05_2() { varfindFixed("(propfunc :pf ?x (?y ?z) (bgp (?x ?p
?o)))", "x", "y", "z", "p", "o"); }
+    @Test public void varfind_05_3() { varfindFixed("(propfunc :pf ?x (?y ?z) (leftjoin (table
unit) (bgp (?x ?p ?o)) ))", "x", "y", "z"); }
+    @Test public void varfind_05_4() { varfindOpt(  "(propfunc :pf ?x (?y ?z) (leftjoin (table
unit) (bgp (?x ?p ?o)) ))", "p", "o"); }
+    
     private static void varfindFixed(String string, String... vars) {
         varfind(string, vars, null, null, null) ;
     }


Mime
View raw message