From commits-return-20547-archive-asf-public=cust-asf.ponee.io@jena.apache.org Sat Nov 17 18:20:29 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 13DBA180658 for ; Sat, 17 Nov 2018 18:20:28 +0100 (CET) Received: (qmail 27080 invoked by uid 500); 17 Nov 2018 17:20:28 -0000 Mailing-List: contact commits-help@jena.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jena.apache.org Delivered-To: mailing list commits@jena.apache.org Received: (qmail 27071 invoked by uid 99); 17 Nov 2018 17:20:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Nov 2018 17:20:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D98E3E11E5; Sat, 17 Nov 2018 17:20:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: andy@apache.org To: commits@jena.apache.org Date: Sat, 17 Nov 2018 17:20:27 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/34] jena git commit: Cope with non-existent graphs in "GRAPH ?g" loop. 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 Authored: Thu Nov 1 18:46:56 2018 +0000 Committer: Andy Seaborne 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 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.