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-1317: Handle when the engine is in reverse mode.
Date Mon, 10 Apr 2017 15:11:50 GMT
Repository: jena
Updated Branches:
  refs/heads/master 78df9f98e -> 588f43f58


JENA-1317: Handle when the engine is in reverse mode.

When the object is grounded, and not the subject, 
the engine is created recervesd with a fixed subject.

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

Branch: refs/heads/master
Commit: f0ab13d9ad12038183730172e845bea4dd3046ac
Parents: 78df9f9
Author: Andy Seaborne <andy@apache.org>
Authored: Mon Apr 10 16:07:56 2017 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Mon Apr 10 16:07:56 2017 +0100

----------------------------------------------------------------------
 .../jena/sparql/path/eval/PathEngineSPARQL.java | 18 ++++++++++++++----
 .../org/apache/jena/sparql/path/TestPath.java   | 20 ++++++++++++++++++++
 2 files changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/f0ab13d9/jena-arq/src/main/java/org/apache/jena/sparql/path/eval/PathEngineSPARQL.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/path/eval/PathEngineSPARQL.java
b/jena-arq/src/main/java/org/apache/jena/sparql/path/eval/PathEngineSPARQL.java
index d2be392..96bc19a 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/path/eval/PathEngineSPARQL.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/path/eval/PathEngineSPARQL.java
@@ -68,12 +68,22 @@ public class PathEngineSPARQL extends PathEngine
 
     @Override
     protected void doNegatedPropertySet(P_NegPropSet pathNotOneOf, Node node, Collection<Node>
output) {
-        if ( pathNotOneOf.getFwdNodes().size() > 0 ) {
-            Iterator<Node> nodes1 = stepExcludeForwards(node, pathNotOneOf.getFwdNodes())
;
+        List<Node> fwdSteps = pathNotOneOf.getFwdNodes();
+        List<Node> bwkSteps = pathNotOneOf.getBwdNodes();
+        
+        // Flip lists processed - flips calls of stepExcludeForwards/stepExcludeBackwards
+        if ( ! forwardMode ) {
+            List<Node> tmp = fwdSteps;
+            fwdSteps = bwkSteps;
+            bwkSteps = tmp;
+        }
+
+        if ( fwdSteps.size() > 0 ) {
+            Iterator<Node> nodes1 = stepExcludeForwards(node, fwdSteps) ;
             fill(nodes1, output) ;
         }
-        if ( pathNotOneOf.getBwdNodes().size() > 0 ) {
-            Iterator<Node> nodes2 = stepExcludeBackwards(node, pathNotOneOf.getBwdNodes())
;
+        if ( bwkSteps.size() > 0 ) {
+            Iterator<Node> nodes2 = stepExcludeBackwards(node, bwkSteps) ;
             fill(nodes2, output) ;
         }
     }

http://git-wip-us.apache.org/repos/asf/jena/blob/f0ab13d9/jena-arq/src/test/java/org/apache/jena/sparql/path/TestPath.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/path/TestPath.java b/jena-arq/src/test/java/org/apache/jena/sparql/path/TestPath.java
index 49a7138..1b09ef5 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/path/TestPath.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/path/TestPath.java
@@ -309,6 +309,26 @@ public class TestPath extends BaseTest
         assertEquals(2, x.size()) ;
     }
 
+    @Test public void path_50() 
+    { 
+        List<Binding> x = eval(graph1, "?x", "(notoneof :DoesNotExist)", "<n4>"
) ;
+        assertEquals(1, x.size()) ;
+    }
+
+    @Test public void path_51() 
+    { 
+        List<Binding> x = eval(graph1, "?x", "(notoneof :DoesNotExist)", "?z" ) ;
+        assertEquals(3, x.size()) ;
+    }
+
+    @Test public void path_52() 
+    { 
+        List<Binding> x = eval(graph1, "<n1>", "(notoneof :DoesNotExist)", "?z"
) ;
+        assertEquals(1, x.size()) ;
+    }
+
+
+    
     // TODO Shortest path is not implemented yet.  These also need to be verified that they
are correct.
 //    @Ignore @Test public void path_40()   { test(graph1, n1,   "shortest(:p*)",       n1)
; }
 //    @Ignore @Test public void path_41()   { test(graph1, n1,   "shortest(:p+)",       n2)
; }


Mime
View raw message