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/12/31 10:38:07 UTC

jena git commit: Fast track finding 'DoesNotExist' ids

Repository: jena
Updated Branches:
  refs/heads/master ff92139c7 -> 47d216f52


Fast track finding 'DoesNotExist' ids


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

Branch: refs/heads/master
Commit: 47d216f52d2838be53f2903b17741f7959ad3e15
Parents: ff92139
Author: Andy Seaborne <an...@apache.org>
Authored: Wed Dec 28 00:28:55 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Wed Dec 28 00:28:55 2016 +0000

----------------------------------------------------------------------
 .../java/org/apache/jena/tdb/solver/StageMatchTuple.java | 11 +++++++----
 .../tdb/store/nodetupletable/NodeTupleTableConcrete.java |  6 ++++--
 2 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/47d216f5/jena-tdb/src/main/java/org/apache/jena/tdb/solver/StageMatchTuple.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/solver/StageMatchTuple.java b/jena-tdb/src/main/java/org/apache/jena/tdb/solver/StageMatchTuple.java
index 3af05e2..6735373 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/solver/StageMatchTuple.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/solver/StageMatchTuple.java
@@ -27,7 +27,6 @@ import java.util.function.Function;
 import java.util.function.Predicate;
 
 import org.apache.jena.atlas.iterator.Iter ;
-import org.apache.jena.atlas.iterator.NullIterator ;
 import org.apache.jena.atlas.iterator.RepeatApplyIterator ;
 import org.apache.jena.atlas.lib.tuple.Tuple ;
 import org.apache.jena.atlas.lib.tuple.TupleFactory ;
@@ -63,8 +62,9 @@ public class StageMatchTuple extends RepeatApplyIterator<BindingNodeId>
     /** Prepare a pattern (tuple of nodes), and an existing binding of NodeId, into NodeIds and Variables. 
      *  A variable in the pattern is replaced by its binding or null in the Nodeids.
      *  A variable that is not bound by the binding is placed in the var array.
+     *  Return false if preparation detechs the pattern can not match. 
      */
-    public static void prepare(NodeTable nodeTable, Tuple<Node> patternTuple, BindingNodeId input, NodeId ids[], Var[] var)
+    public static boolean prepare(NodeTable nodeTable, Tuple<Node> patternTuple, BindingNodeId input, NodeId ids[], Var[] var)
     {
         // Process the Node to NodeId conversion ourselves because
         // we wish to abort if an unknown node is seen.
@@ -75,11 +75,12 @@ public class StageMatchTuple extends RepeatApplyIterator<BindingNodeId>
             // Variables unsubstituted are null NodeIds
             NodeId nId = idFor(nodeTable, input, n) ;
             if ( NodeId.isDoesNotExist(nId) )
-                new NullIterator<BindingNodeId>() ;
+                return false ;
             ids[i] = nId ;
             if ( nId == null )
                 var[i] = asVar(n) ;
         }
+        return true ;
     }
     
     @Override
@@ -90,7 +91,9 @@ public class StageMatchTuple extends RepeatApplyIterator<BindingNodeId>
         // Variables for this tuple after subsitution
         final Var[] var = new Var[patternTuple.len()] ;
 
-        prepare(nodeTupleTable.getNodeTable(), patternTuple, input, ids, var) ;
+        boolean b = prepare(nodeTupleTable.getNodeTable(), patternTuple, input, ids, var) ;
+        if ( !b ) 
+            return Iter.nullIterator() ;
         
         Iterator<Tuple<NodeId>> iterMatches = nodeTupleTable.find(asTuple(ids)) ;  
         

http://git-wip-us.apache.org/repos/asf/jena/blob/47d216f5/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetupletable/NodeTupleTableConcrete.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetupletable/NodeTupleTableConcrete.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetupletable/NodeTupleTableConcrete.java
index 08c4407..c90547d 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetupletable/NodeTupleTableConcrete.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetupletable/NodeTupleTableConcrete.java
@@ -102,7 +102,8 @@ public class NodeTupleTableConcrete implements NodeTupleTable
             for (int i = 0; i < nodes.length; i++)
             {
                 NodeId id = idForNode(nodes[i]) ;
-                if (NodeId.isDoesNotExist(id)) return false ;
+                if (NodeId.isDoesNotExist(id)) 
+                    return false ;
                 n[i] = id ;
             }
 
@@ -141,7 +142,8 @@ public class NodeTupleTableConcrete implements NodeTupleTable
             for (int i = 0; i < nodes.length; i++)
             {
                 NodeId id = idForNode(nodes[i]) ;
-                if (NodeId.isDoesNotExist(id)) return Iter.nullIterator() ;
+                if (NodeId.isDoesNotExist(id)) 
+                    return Iter.nullIterator() ;
                 n[i] = id ;
             }
             return find(n) ; // **public call