jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [01/34] jena git commit: Cope with non-existent graphs in "GRAPH ?g" loop.
Date Sat, 17 Nov 2018 17:20:27 GMT
Repository: jena
Updated Branches:
  refs/heads/master 8aca3ae29 -> 9aae2ee1f


Cope with non-existent graphs in "GRAPH ?g" loop.

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

Branch: refs/heads/master
Commit: 2303bfad5750f9bafad6510218b1db657c5acd11
Parents: b87a34f
Author: Andy Seaborne <andy@apache.org>
Authored: Thu Nov 1 18:46:56 2018 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Tue Nov 13 15:35:19 2018 +0000

----------------------------------------------------------------------
 .../engine/main/iterator/QueryIterGraph.java    | 30 +++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/2303bfad/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/iterator/QueryIterGraph.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/iterator/QueryIterGraph.java
b/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/iterator/QueryIterGraph.java
index 3fec4f5..a07110e 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/iterator/QueryIterGraph.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/iterator/QueryIterGraph.java
@@ -83,7 +83,7 @@ public class QueryIterGraph extends QueryIterRepeatApply
     protected static Iterator<Node> makeSources(DatasetGraph data, Binding b, Node
graphVar) {
         Node n2 = resolve(b, graphVar) ;
         if ( n2 != null && n2.isLiteral() ) 
-            // Blank node or literal possible after resolving
+            // Literal possible after resolving
             return Iter.nullIterator() ;
         
         // n2 is a URI or null.
@@ -136,21 +136,23 @@ public class QueryIterGraph extends QueryIterRepeatApply
             return iter.nextBinding();
         }
 
-        // This code predates ARQ using Java 1.5.
-
-        // This is very like QueryIteratorRepeatApply except its not
-        // repeating over bindings, but over graph nodes.
-        // There is a tradeoff of generalising QueryIteratorRepeatApply to Objects
-        // and hence no type safety. Or duplicating code (generics?)
-        
+        // Proceed to the next iterator.
         protected QueryIterator nextIterator() {
-            if ( ! graphNames.hasNext() )
-                return null ;
-            Node gn = graphNames.next() ;
-
+            while( graphNames.hasNext() ) {
+                Node gn = graphNames.next() ;
+                QueryIterator iter = buildIterator(gn);
+                if ( iter != null )
+                    return iter;
+            }
+            return null;
+        }
+        
+        // Build iterator or return null for if there can't be any results.
+        private QueryIterator buildIterator(Node gn) {
             QueryIterator qIter = buildIterator(parentBinding, gn, opSubstituted, getExecContext())
;
             if ( qIter == null )
-                // Know to be nothing (e.g. graph does not exist). 
+                // Known to be nothing (e.g. graph does not exist). 
+                // try again.
                 return null ;
             
             if ( Var.isVar(opGraph.getNode()) ) {
@@ -163,7 +165,7 @@ public class QueryIterGraph extends QueryIterRepeatApply
             return qIter ;
         }
         
-        // Create the iterator - or return null if there can't be any results.
+        // Create the iterator for a cycle of one node - or return null if there can't be
any results.
         protected static QueryIterator buildIterator(Binding binding, Node graphNode, Op
opExec, ExecutionContext outerCxt) {
             if ( !graphNode.isURI() && !graphNode.isBlank() )
                 // e.g. variable bound to a literal or blank node.


Mime
View raw message