Repository: jena
Updated Branches:
  refs/heads/master 16fd26026 -> c433f1a5d


Factor out convert(Binding, NodeTable) -> BindingNodeId

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

Branch: refs/heads/master
Commit: c433f1a5de8086b64ac9a2b0b650ff771a1b737b
Parents: 16fd260
Author: Andy Seaborne <[email protected]>
Authored: Mon Sep 29 13:10:07 2014 +0100
Committer: Andy Seaborne <[email protected]>
Committed: Mon Sep 29 13:10:07 2014 +0100

----------------------------------------------------------------------
 .../com/hp/hpl/jena/tdb/solver/SolverLib.java   | 55 +++++++++++---------
 1 file changed, 30 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/c433f1a5/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java 
b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java
index 78bb5fe..cdd9c64 100644
--- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java
+++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java
@@ -241,35 +241,40 @@ public class SolverLib
         return new Transform<Binding, BindingNodeId>()
         {
             @Override
-            public BindingNodeId convert(Binding binding)
-            {
-                if ( binding instanceof BindingTDB )
-                    return ((BindingTDB)binding).getBindingId() ;
-                
-                BindingNodeId b = new BindingNodeId(binding) ;
-                // and copy over, getting NodeIds.
-                Iterator<Var> vars = binding.vars() ;
-    
-                for ( ; vars.hasNext() ; )
-                {
-                    Var v = vars.next() ;
-                    Node n = binding.get(v) ;  
-                    if ( n == null )
-                        // Variable mentioned in the binding but not actually 
defined.
-                        // Can occur with BindingProject
-                        continue ;
-                    
-                    // Rely on the node table cache for efficency - we will 
likely be
-                    // repeatedly looking up the same node in different 
bindings.
-                    NodeId id = nodeTable.getNodeIdForNode(n) ;
-                    // Even put in "does not exist" for a node now known not 
to be in the DB.
-                    b.put(v, id) ;
-                }
-                return b ;
+            public BindingNodeId convert(Binding binding) {
+                return SolverLib.convert(binding, nodeTable) ;
             }
         } ;
     }
     
+    /** Binding ==> BindingNodeId, given a NodeTable */
+    public static BindingNodeId convert(Binding binding, NodeTable nodeTable) 
+    {
+        if ( binding instanceof BindingTDB )
+            return ((BindingTDB)binding).getBindingId() ;
+
+        BindingNodeId b = new BindingNodeId(binding) ;
+        // and copy over, getting NodeIds.
+        Iterator<Var> vars = binding.vars() ;
+
+        for ( ; vars.hasNext() ; )
+        {
+            Var v = vars.next() ;
+            Node n = binding.get(v) ;  
+            if ( n == null )
+                // Variable mentioned in the binding but not actually defined.
+                // Can occur with BindingProject
+                continue ;
+
+            // Rely on the node table cache for efficency - we will likely be
+            // repeatedly looking up the same node in different bindings.
+            NodeId id = nodeTable.getNodeIdForNode(n) ;
+            // Even put in "does not exist" for a node now known not to be in 
the DB.
+            b.put(v, id) ;
+        }
+        return b ;
+    }
+    
     /** Find whether a specific graph name is in the quads table. */
     public static QueryIterator testForGraphName(DatasetGraphTDB ds, Node 
graphNode, QueryIterator input,
                                                  Filter<Tuple<NodeId>> filter, 
ExecutionContext execCxt) {

Reply via email to