jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1477607 - in /jena/trunk/jena-tdb/src: main/java/com/hp/hpl/jena/tdb/solver/ main/java/com/hp/hpl/jena/tdb/store/ test/java/com/hp/hpl/jena/tdb/assembler/ test/java/com/hp/hpl/jena/tdb/graph/basics/ test/java/com/hp/hpl/jena/tdb/store/
Date Tue, 30 Apr 2013 13:00:27 GMT
Author: andy
Date: Tue Apr 30 13:00:26 2013
New Revision: 1477607

URL: http://svn.apache.org/r1477607
Log:
Simplify GraphTDB and its implementations.

Modified:
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphNamedTDB.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDB.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDBBase.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTriplesTDB.java
    jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/assembler/TestTDBAssembler.java
    jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/FactoryGraphTDB.java
    jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/GraphTDBFactoryTesting.java
    jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/solver/SolverLib.java Tue Apr 30
13:00:26 2013
@@ -70,7 +70,8 @@ public class SolverLib
                                         QueryIterator input, Filter<Tuple<NodeId>>
filter,
                                         ExecutionContext execCxt)
     {
-        return execute(graph.getNodeTupleTable(), null, pattern, input, filter, execCxt)
;
+        NodeTupleTable ntt = graph.getNodeTupleTable() ;
+        return execute(ntt, null, pattern, input, filter, execCxt) ;
     }
     
     /** Non-reordering execution of a quad pattern, given a iterator of bindings as input.

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java Tue Apr
30 13:00:26 2013
@@ -90,10 +90,6 @@ public class DatasetGraphTDB extends Dat
     public QuadTable getQuadTable()         { return quadTable ; }
     public TripleTable getTripleTable()     { return tripleTable ; }
     
-//    private Lock lock = new MRSWLite() ;
-//    @Override 
-//    public Lock getLock()                   { return lock ; }
-    
     @Override
     protected Iterator<Quad> findInDftGraph(Node s, Node p, Node o)
     {
@@ -208,7 +204,9 @@ public class DatasetGraphTDB extends Dat
     @Override
     protected Graph _createDefaultGraph()
     {
-        return new GraphTriplesTDB(this, tripleTable, prefixes) ; 
+        return new GraphTriplesTDB(this) ;
+        // This also works - but it's close to a release so leave as is. 
+        //return new GraphNamedTDB(this,  null) ; 
     }
 
     @Override

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphNamedTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphNamedTDB.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphNamedTDB.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphNamedTDB.java Tue Apr
30 13:00:26 2013
@@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory ;
 
 import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.shared.PrefixMapping ;
-import com.hp.hpl.jena.sparql.core.Quad ;
 import com.hp.hpl.jena.sparql.util.Utils ;
 import com.hp.hpl.jena.tdb.TDBException ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTupleTable ;
@@ -40,12 +39,11 @@ import com.hp.hpl.jena.tdb.sys.TDBIntern
 public class GraphNamedTDB extends GraphTDBBase
 {
     // Collapse this into GraphTDBBase and have one class, no interface.
-    
-    /*
-        Quad.unionGraph
-        Quad.defaultGraphIRI
-        Quad.defaultGraphNodeGenerated
-    */
+    // This copes with
+    //    null for graphName (= default graph).
+    //    Quad.unionGraph
+    //    Quad.defaultGraphIRI
+    //    Quad.defaultGraphNodeGenerated
     private static Logger log = LoggerFactory.getLogger(GraphNamedTDB.class) ;
     
     private NodeId graphNodeId = null ;
@@ -54,23 +52,23 @@ public class GraphNamedTDB extends Graph
     {
         super(dataset, graphName) ;
 
-        if ( graphName == null )
-            throw new TDBException("GraphNamedTDB: Null graph name") ; 
-        if ( ! graphName.isURI() )
+        if ( graphName != null && ! graphName.isURI() )
             throw new TDBException("GraphNamedTDB: Graph name not a URI - " + graphName.toString())
; 
     }
 
     @Override
     protected PrefixMapping createPrefixMapping()
     {
-        return dataset.getPrefixes().getPrefixMapping(graphNode.getURI()) ;
+        if ( isDefaultGraph() )
+            return dataset.getPrefixes().getPrefixMapping() ;
+        else
+            return dataset.getPrefixes().getPrefixMapping(graphNode.getURI()) ;
     }
 
-
     @Override
     protected Iterator<Tuple<NodeId>> countThis()
     {
-        if ( isDefaultGraph(graphNode) ) 
+        if ( isDefaultGraph() ) 
             return dataset.getTripleTable().getNodeTupleTable().findAll() ;
         
         NodeId gn = isUnionGraph(graphNode) ? null : getGraphNodeId() ; 
@@ -110,6 +108,10 @@ public class GraphNamedTDB extends Graph
         return graphNodeId ;
     }
 
+    private boolean isDefaultGraph() {
+        return isDefaultGraph(graphNode) ;
+    }
+    
     @Override
     protected final Logger getLog() { return log ; }
     
@@ -117,11 +119,15 @@ public class GraphNamedTDB extends Graph
     public NodeTupleTable getNodeTupleTable()
     {
         // Concrete default graph.
-        if ( graphNode == null || Quad.isDefaultGraph(graphNode) )
+        if ( isDefaultGraph() )
             return dataset.getTripleTable().getNodeTupleTable() ;
         return dataset.getQuadTable().getNodeTupleTable() ;
     }
 
     @Override
-    public String toString() { return Utils.className(this)+":<"+this.graphNode+">"
; }
+    public String toString() { 
+        String x = ":defaultGraph" ;
+        if ( graphNode != null )
+            x = ":<"+this.graphNode+">" ;
+        return Utils.className(this)+x ; }
 }

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDB.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDB.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDB.java Tue Apr 30 13:00:26
2013
@@ -23,17 +23,13 @@ import org.apache.jena.atlas.lib.Sync ;
 
 import com.hp.hpl.jena.graph.Graph ;
 import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.shared.Lock ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTupleTable ;
-import com.hp.hpl.jena.tdb.sys.Session ;
 
-public interface GraphTDB extends Graph, Closeable, Sync, Session
+public interface GraphTDB extends Graph, Closeable, Sync
 {
+    /** The NodeTupleTable for this graph */ 
     public NodeTupleTable getNodeTupleTable() ;
     
-    /** Get a lock that is shared for all graphs from the same dataset (it is the dataset
lock) */
-    public Lock getLock() ;
-    
     /**
      * Return the graph node for this graph if it's in a quad table, else return
      * null for a triple table based (e.g. the default graph of a dataset)

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDBBase.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDBBase.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDBBase.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTDBBase.java Tue Apr
30 13:00:26 2013
@@ -34,7 +34,6 @@ import com.hp.hpl.jena.graph.Transaction
 import com.hp.hpl.jena.graph.Triple ;
 import com.hp.hpl.jena.graph.TripleMatch ;
 import com.hp.hpl.jena.graph.impl.GraphBase ;
-import com.hp.hpl.jena.shared.Lock ;
 import com.hp.hpl.jena.sparql.core.Quad ;
 import com.hp.hpl.jena.tdb.TDB ;
 import com.hp.hpl.jena.tdb.TDBException ;
@@ -66,10 +65,7 @@ public abstract class GraphTDBBase exten
     
     @Override
     public final DatasetGraphTDB getDataset()                   { return dataset ; }
-    
-    @Override
-    public Lock getLock()                                       { return dataset.getLock()
; }
-    
+
     // Intercept performAdd/preformDelete and bracket in start/finish markers   
     
     @Override
@@ -174,14 +170,10 @@ public abstract class GraphTDBBase exten
     /** Iterator over something that, when counted, is the graph size. */
     protected abstract Iterator<?> countThis() ;
 
-    @Override
     public void startRead()             { dataset.startRead() ; }
-    @Override
     public void finishRead()            { dataset.finishRead() ; }
 
-    @Override
     public final void startUpdate()     { dataset.startUpdate() ; }
-    @Override
     public final void finishUpdate()    { dataset.finishUpdate() ; }
 
     @Override

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTriplesTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTriplesTDB.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTriplesTDB.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/GraphTriplesTDB.java Tue Apr
30 13:00:26 2013
@@ -25,7 +25,6 @@ import org.slf4j.Logger ;
 import org.slf4j.LoggerFactory ;
 
 import com.hp.hpl.jena.shared.PrefixMapping ;
-import com.hp.hpl.jena.sparql.core.DatasetPrefixStorage ;
 import com.hp.hpl.jena.sparql.util.Utils ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTupleTable ;
 
@@ -33,17 +32,13 @@ import com.hp.hpl.jena.tdb.nodetable.Nod
 public class GraphTriplesTDB extends GraphTDBBase
 {
     // Collapse this into GraphTDBBase and have one class, no interface.
+    // GraphNamedTDB should work.
     
     private static Logger log = LoggerFactory.getLogger(GraphTriplesTDB.class) ;
     
-    private final DatasetPrefixStorage prefixes ;
-    
-    public GraphTriplesTDB(DatasetGraphTDB dataset,
-                           TripleTable tripleTable,
-                           DatasetPrefixStorage prefixes)
+    public GraphTriplesTDB(DatasetGraphTDB dataset)
     {
         super(dataset, null) ;
-        this.prefixes = prefixes ;
     }
 
     @Override
@@ -64,7 +59,7 @@ public class GraphTriplesTDB extends Gra
     @Override
     protected PrefixMapping createPrefixMapping()
     {
-        return prefixes.getPrefixMapping() ;
+        return dataset.getPrefixes().getPrefixMapping() ;
     }
 
     @Override

Modified: jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/assembler/TestTDBAssembler.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/assembler/TestTDBAssembler.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/assembler/TestTDBAssembler.java
(original)
+++ jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/assembler/TestTDBAssembler.java
Tue Apr 30 13:00:26 2013
@@ -100,12 +100,9 @@ public class TestTDBAssembler extends Ba
         
         assertTrue(thing instanceof Model) ;
         Graph graph = ((Model)thing).getGraph() ;
-        
         assertTrue(graph instanceof GraphTDB) ; 
-        assertTrue(graph instanceof GraphTriplesTDB) ;
-        assertFalse(graph instanceof GraphNamedTDB) ;
 
-        DatasetGraphTDB ds = ((GraphTDBBase)graph).getDataset() ;
+        DatasetGraphTDB ds = ((GraphTDB)graph).getDataset() ;
         if ( ds != null )
             ds.close();
     }
@@ -135,23 +132,12 @@ public class TestTDBAssembler extends Ba
             throw e ;
         }
 
-
         assertTrue(thing instanceof Model) ;
         Graph graph = ((Model)thing).getGraph() ;
         
         assertTrue(graph instanceof GraphTDB) ; 
-        if ( named )
-        {
-            assertFalse( graph instanceof GraphTriplesTDB) ;
-            assertTrue(graph instanceof GraphNamedTDB) ;
-        }
-        else
-        {
-            assertTrue( graph instanceof GraphTriplesTDB) ;
-            assertFalse(graph instanceof GraphNamedTDB) ;
-        }
         
-        DatasetGraphTDB ds = ((GraphTDBBase)graph).getDataset() ;
+        DatasetGraphTDB ds = ((GraphTDB)graph).getDataset() ;
         if ( ds != null )
             ds.close();
     }

Modified: jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/FactoryGraphTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/FactoryGraphTDB.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/FactoryGraphTDB.java
(original)
+++ jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/FactoryGraphTDB.java
Tue Apr 30 13:00:26 2013
@@ -43,11 +43,7 @@ import com.hp.hpl.jena.tdb.index.TupleIn
 import com.hp.hpl.jena.tdb.index.TupleIndexRecord ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTableFactory ;
-import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
-import com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB ;
-import com.hp.hpl.jena.tdb.store.GraphTriplesTDB ;
-import com.hp.hpl.jena.tdb.store.QuadTable ;
-import com.hp.hpl.jena.tdb.store.TripleTable ;
+import com.hp.hpl.jena.tdb.store.* ;
 import com.hp.hpl.jena.tdb.sys.DatasetControl ;
 import com.hp.hpl.jena.tdb.sys.DatasetControlMRSW ;
 import com.hp.hpl.jena.tdb.sys.Names ;
@@ -71,14 +67,14 @@ class FactoryGraphTDB
     public final static RecordFactory nodeRecordFactory = new RecordFactory(LenNodeHash,
SizeOfNodeId) ;
     
     /** Create a TDB graph using a specifc index builder - mainly for testing */
-    public static GraphTriplesTDB createGraph(IndexBuilder indexBuilder, Location location)
+    public static GraphTDB createGraph(IndexBuilder indexBuilder, Location location)
     {
         DatasetGraphTDB ds = _createDatasetGraph(indexBuilder, location, tripleIndexes, quadIndexes)
;
-        return (GraphTriplesTDB)ds.getDefaultGraph() ;
+        return (GraphTDB)ds.getDefaultGraph() ;
     }  
 
     /** Create a TDB graph in-memory - for testing */
-    public static GraphTriplesTDB createGraphMem(IndexBuilder indexBuilder)
+    public static GraphTDB createGraphMem(IndexBuilder indexBuilder)
     {
         return createGraph(indexBuilder, Location.mem()) ;
     }

Modified: jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/GraphTDBFactoryTesting.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/GraphTDBFactoryTesting.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/GraphTDBFactoryTesting.java
(original)
+++ jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/graph/basics/GraphTDBFactoryTesting.java
Tue Apr 30 13:00:26 2013
@@ -21,7 +21,7 @@ package com.hp.hpl.jena.tdb.graph.basics
 import com.hp.hpl.jena.tdb.base.file.Location ;
 import com.hp.hpl.jena.tdb.index.IndexBuilder ;
 import com.hp.hpl.jena.tdb.index.factories.IndexFactoryBPlusTree ;
-import com.hp.hpl.jena.tdb.store.GraphTriplesTDB ;
+import com.hp.hpl.jena.tdb.store.GraphTDB ;
 import com.hp.hpl.jena.tdb.sys.SystemTDB ;
 
 /** Place to put various "making" explicitly for testing */
@@ -31,7 +31,7 @@ class GraphTDBFactoryTesting
     // This class and FactoryGraphTDB are old ways of making graphs and datasets 
     
     /** Create a graph backed with storage at a location using B+Tree indexes (testing) */
-    public static GraphTriplesTDB createBPlusTree(Location location)
+    public static GraphTDB createBPlusTree(Location location)
     { 
         IndexFactoryBPlusTree idxFactory = new IndexFactoryBPlusTree(SystemTDB.BlockSizeTest)
;
         IndexBuilder builder = new IndexBuilder(idxFactory,idxFactory) ; 
@@ -39,7 +39,7 @@ class GraphTDBFactoryTesting
     }
 
     /** Create a graph backed with storage and B+Tree indexes in-memory (testing) */
-    public static GraphTriplesTDB createBPlusTreeMem()
+    public static GraphTDB createBPlusTreeMem()
     { 
         IndexFactoryBPlusTree idxFactory = new IndexFactoryBPlusTree(SystemTDB.BlockSizeTestMem)
;
         IndexBuilder builder = new IndexBuilder(idxFactory,idxFactory) ; 

Modified: jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java?rev=1477607&r1=1477606&r2=1477607&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java
(original)
+++ jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java
Tue Apr 30 13:00:26 2013
@@ -78,8 +78,8 @@ public class TestDatasetTDBPersist exten
     @Test public void dataset1()
     {
         Dataset ds = graphLocation.getDataset() ;
-        assertTrue( ds.getDefaultModel().getGraph() instanceof GraphTriplesTDB ) ;
-        assertTrue( ds.getNamedModel("http://example/").getGraph() instanceof GraphNamedTDB
) ;
+        assertTrue( ds.getDefaultModel().getGraph() instanceof GraphTDB ) ;
+        assertTrue( ds.getNamedModel("http://example/").getGraph() instanceof GraphTDB )
;
     }
     
     @Test public void dataset2()



Mime
View raw message