You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/11/08 15:00:45 UTC

[3/4] jena git commit: Cope with property paths in p+ paths.

Cope with property paths in p+ paths.

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

Branch: refs/heads/master
Commit: b9657963c66927530e931c822b3f98ee3de0f725
Parents: 39c7d5a
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Nov 8 14:16:27 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Nov 8 14:16:27 2016 +0000

----------------------------------------------------------------------
 .../org/apache/jena/sparql/path/PathLib.java    | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/b9657963/jena-arq/src/main/java/org/apache/jena/sparql/path/PathLib.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/path/PathLib.java b/jena-arq/src/main/java/org/apache/jena/sparql/path/PathLib.java
index a6e8e6d..9e3738b 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/path/PathLib.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/path/PathLib.java
@@ -48,6 +48,7 @@ import org.apache.jena.sparql.mgt.Explain ;
 import org.apache.jena.sparql.path.eval.PathEval ;
 import org.apache.jena.sparql.pfunction.PropertyFunctionFactory ;
 import org.apache.jena.sparql.pfunction.PropertyFunctionRegistry ;
+import org.apache.jena.sparql.util.Context;
 import org.apache.jena.sparql.util.graph.GraphUtils ;
 
 public class PathLib
@@ -220,17 +221,22 @@ public class PathLib
             Path subPath = ((P_Path1)path).getSubPath() ;
             if ( subPath instanceof P_Link ) {
                 // :predicate+
+                // If a property functions, 
                 P_Link link = (P_Link)subPath ;
-                Iterator<Triple> sIter = graph.find(null, link.getNode(), null) ;
-                return Iter.iter(sIter).distinctAdjacent().map(Triple::getSubject).distinct() ;
+                if ( ! isPropertyFunction(link.getNode(), execCxt.getContext()) ) {
+                    Iterator<Triple> sIter = graph.find(null, link.getNode(), null) ;
+                    return Iter.iter(sIter).distinctAdjacent().map(Triple::getSubject).distinct() ;
+                }
             } else {
                 if ( subPath instanceof P_Inverse ) {
                     P_Inverse pInv = (P_Inverse)subPath ;
                     if ( pInv.getSubPath() instanceof P_Link ) {
                         //  (^:predicate)+
                         P_Link link = (P_Link)(pInv.getSubPath()) ;
-                        Iterator<Triple> sIter = graph.find(null, link.getNode(), null) ;
-                        return Iter.iter(sIter).distinctAdjacent().map(Triple::getObject).distinct() ;
+                        if ( ! isPropertyFunction(link.getNode(), execCxt.getContext()) ) {
+                            Iterator<Triple> sIter = graph.find(null, link.getNode(), null) ;
+                            return Iter.iter(sIter).distinctAdjacent().map(Triple::getObject).distinct() ;
+                        }
                     }
                 }
             }
@@ -239,6 +245,12 @@ public class PathLib
         return GraphUtils.allNodes(graph) ;
     }
     
+    private static boolean isPropertyFunction(Node node, Context context) {
+        if ( ! node.isURI() )
+            return false ;
+        return PropertyFunctionRegistry.chooseRegistry(context).isRegistered(node.getURI());
+    }
+
     private static int existsPath(Graph graph, Node subject, Path path, final Node object, ExecutionContext execCxt) {
         if ( ! subject.isConcrete() || !object.isConcrete() )
             throw new ARQInternalErrorException("Non concrete node for existsPath evaluation") ;