jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1202359 - in /incubator/jena/Jena2/TDB/trunk/src: main/java/com/hp/hpl/jena/tdb/ main/java/com/hp/hpl/jena/tdb/migrate/ main/java/com/hp/hpl/jena/tdb/store/ test/java/com/hp/hpl/jena/tdb/graph/ test/java/com/hp/hpl/jena/tdb/junit/ test/jav...
Date Tue, 15 Nov 2011 18:30:02 GMT
Author: andy
Date: Tue Nov 15 18:30:01 2011
New Revision: 1202359

URL: http://svn.apache.org/viewvc?rev=1202359&view=rev
Log:
Add a transactional DatasetGraph.

Added:
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTransaction.java
      - copied, changed from r1201763, incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTX.java
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/migrate/DatasetGraphTrackActive.java
      - copied, changed from r1201763, incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTrackActive.java
Modified:
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTxn.java
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java
    incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestBulkUpdateTDB.java
    incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java
    incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/junit/GraphLocation.java
    incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/solver/TestSolverTDB.java

Copied: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTransaction.java
(from r1201763, incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTX.java)
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTransaction.java?p2=incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTransaction.java&p1=incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTX.java&r1=1201763&r2=1202359&rev=1202359&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTX.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTransaction.java
Tue Nov 15 18:30:01 2011
@@ -16,45 +16,37 @@
  * limitations under the License.
  */
 
-package tx.api;
+package com.hp.hpl.jena.tdb;
 
 import com.hp.hpl.jena.query.ReadWrite ;
-import com.hp.hpl.jena.shared.JenaException ;
+import com.hp.hpl.jena.sparql.JenaTransactionException ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
-import com.hp.hpl.jena.tdb.DatasetGraphTxn ;
-import com.hp.hpl.jena.tdb.StoreConnection ;
 import com.hp.hpl.jena.tdb.base.file.Location ;
+import com.hp.hpl.jena.tdb.migrate.DatasetGraphTrackActive ;
 import com.hp.hpl.jena.tdb.transaction.TDBTransactionException ;
 
 /** Transactional DatasetGraph that allows one active transaction.
  * For multiple read transactions, create multiple DatasetGraphTX objects.
  */
 
-public class DatasetGraphTX extends DatasetGraphTrackActive 
+public class DatasetGraphTransaction extends DatasetGraphTrackActive 
 {
     // This is analogous to a "connection" in JDBC.
     
     /* Initially, the app can use this DatasetGraph non-transactionally.
-     * But as soon as it starts a trasnaction, the dataset can only be used
+     * But as soon as it starts a transaction, the dataset can only be used
      * inside transactions. 
      */
 
     // TODO Concurrency
+    // TODO tests
     
     private DatasetGraphTxn dsgTxn = null ;
     private boolean haveUsedInTransaction = false ;
     private final Location location ;
     private final StoreConnection sConn ;
-    
-    static class JenaTransactionException extends JenaException
-    {
-        public JenaTransactionException()                                  { super(); }
-        public JenaTransactionException(String message)                    { super(message);
}
-        public JenaTransactionException(Throwable cause)                   { super(cause)
; }
-        public JenaTransactionException(String message, Throwable cause)   { super(message,
cause) ; }
-    }
-    
-    public DatasetGraphTX(Location location)
+
+    public DatasetGraphTransaction(Location location)
     {
         this.location = location ;
         sConn = StoreConnection.make(location) ;

Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTxn.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTxn.java?rev=1202359&r1=1202358&r2=1202359&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTxn.java
(original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/DatasetGraphTxn.java
Tue Nov 15 18:30:01 2011
@@ -21,6 +21,9 @@ package com.hp.hpl.jena.tdb;
 import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
 import com.hp.hpl.jena.tdb.transaction.Transaction ;
 
+/** A DatasetGraph that is a singe transaction.
+ * It does not support transactions, it is a transaction (single use).
+ */
 public class DatasetGraphTxn extends DatasetGraphTDB
 {
     private final Transaction transaction ;

Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java?rev=1202359&r1=1202358&r2=1202359&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBFactory.java Tue Nov
15 18:30:01 2011
@@ -21,9 +21,9 @@ package com.hp.hpl.jena.tdb;
 import com.hp.hpl.jena.graph.Graph ;
 import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.DatasetFactory ;
 import com.hp.hpl.jena.rdf.model.Model ;
 import com.hp.hpl.jena.rdf.model.ModelFactory ;
-import com.hp.hpl.jena.sparql.core.DatasetImpl ;
 import com.hp.hpl.jena.sparql.core.assembler.AssemblerUtils ;
 import com.hp.hpl.jena.sparql.engine.optimizer.reorder.ReorderLib ;
 import com.hp.hpl.jena.sparql.engine.optimizer.reorder.ReorderTransformation ;
@@ -58,28 +58,43 @@ public class TDBFactory
         return (Dataset)AssemblerUtils.build(assemblerFile, VocabTDB.tDatasetTDB) ;
     }
     
-    /** Create a model, at the given location */
+    /** Create a model, at the given location.
+     *  It is better to create a dataset and get the default model from that.
+     */
+    @Deprecated
     public static Model createModel(Location loc)
     {
         return ModelFactory.createModelForGraph(createGraph(loc)) ;
     }
 
-    /** Create a model, at the given location */
+    /** Create a model, at the given location 
+     *  It is better to create a dataset and get the default model from that.
+     */
+    @Deprecated
+
     public static Model createModel(String dir)
     {
         return ModelFactory.createModelForGraph(createGraph(dir)) ;
     }
 
-    /** Create a TDB model backed by an in-memory block manager. For testing. */  
+    /** Create a TDB model backed by an in-memory block manager. For testing. */
+    @Deprecated
+
     public static Model createModel()
     { return ModelFactory.createModelForGraph(createGraph()) ; }
 
     
-    /** Create a TDB model for named model */  
+    /** Create a TDB model for named model
+     * It is better to create a dataset and get the named model from that.
+     */
+    @Deprecated
     public static Model createNamedModel(String name, String location)
     { return createDataset(location).getNamedModel(name) ; }
     
-    /** Create a TDB model for named model */  
+    /** Create a TDB model for named model.
+     * It is better to create a dataset and get the named model from that.
+     */  
+    @Deprecated
     public static Model createNamedModel(String name, Location location)
     { return createDataset(location).getNamedModel(name) ; }
 
@@ -102,12 +117,18 @@ public class TDBFactory
 
     /** Create a dataset around a DatasetGraphTDB */ 
     public static Dataset createDataset(DatasetGraphTDB datasetGraph)
-    { return new DatasetImpl(datasetGraph) ; }
+    { return DatasetFactory.create(datasetGraph) ; }
     
-    /** Create a graph, at the given location */
+    /** Create a graph, at the given location 
+     * @deprecated Create a DatasetGraph and use the default graph.
+     */
+    @Deprecated
     public static Graph createGraph(Location loc)       { return TDBMaker._createGraph(loc)
; }
 
-    /** Create a graph, at the given location */
+    /** Create a graph, at the given location 
+     * @deprecated Create a DatasetGraph and use the default graph.
+     */
+    @Deprecated
     public static Graph createGraph(String dir)
     {
         Location loc = new Location(dir) ;
@@ -115,13 +136,20 @@ public class TDBFactory
     }
     
     /** Create a TDB graph backed by an in-memory block manager. For testing. */  
+    @Deprecated
     public static Graph createGraph()   { return TDBMaker._createGraph() ; }
 
-    /** Create a TDB graph for named graph */  
+    /** Create a TDB graph for named graph
+     * @deprecated Create a DatasetGraph and get the name graph from that.
+     */  
+    @Deprecated
     public static Graph createNamedGraph(String name, String location)
     { return createDatasetGraph(location).getGraph(Node.createURI(name)) ; }
     
-    /** Create a TDB graph for named graph */  
+    /** Create a TDB graph for named graph
+     * @deprecated Create a DatasetGraph and get the name graph from that.
+     */  
+    @Deprecated
     public static Graph createNamedGraph(String name, Location location)
     { return createDatasetGraph(location).getGraph(Node.createURI(name)) ; }
 

Copied: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/migrate/DatasetGraphTrackActive.java
(from r1201763, incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTrackActive.java)
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/migrate/DatasetGraphTrackActive.java?p2=incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/migrate/DatasetGraphTrackActive.java&p1=incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTrackActive.java&r1=1201763&r2=1202359&rev=1202359&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTrackActive.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/migrate/DatasetGraphTrackActive.java
Tue Nov 15 18:30:01 2011
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package tx.api;
+package com.hp.hpl.jena.tdb.migrate;
 
 import java.util.Iterator ;
 
@@ -26,12 +26,13 @@ import com.hp.hpl.jena.query.ReadWrite ;
 import com.hp.hpl.jena.shared.Lock ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
 import com.hp.hpl.jena.sparql.core.Quad ;
+import com.hp.hpl.jena.sparql.core.Transactional ;
 import com.hp.hpl.jena.sparql.util.Context ;
 
 public abstract class DatasetGraphTrackActive implements DatasetGraph, Transactional
 {
     // Layer - make this extend DatasetGraphWrapper - i.e. a switching wrapper.
-    // Canuse switcher for switching betwen locations?
+    // Can use switcher for switching between locations?
     
     protected abstract DatasetGraph get() ;
     private boolean inTransaction = false ; 

Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java?rev=1202359&r1=1202358&r2=1202359&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java
(original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java
Tue Nov 15 18:30:01 2011
@@ -283,7 +283,7 @@ public class DatasetGraphTDB extends Dat
     public void finishRequest()     { this.sync() ; } 
 
     @Override
-    public Dataset toDataset()      { return new DatasetImpl(this) ; }
+    public Dataset toDataset()      { return DatasetImpl.wrap(this) ; }
 
     // ---- DataSourceGraph
     

Modified: incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestBulkUpdateTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestBulkUpdateTDB.java?rev=1202359&r1=1202358&r2=1202359&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestBulkUpdateTDB.java
(original)
+++ incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestBulkUpdateTDB.java
Tue Nov 15 18:30:01 2011
@@ -45,7 +45,7 @@ public class TestBulkUpdateTDB extends B
     
     private static Graph create()
     {
-        Graph g = TDBFactory.createGraph() ;
+        Graph g = TDBFactory.createDatasetGraph().getDefaultGraph() ;
         return g ;
     }
     

Modified: incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java?rev=1202359&r1=1202358&r2=1202359&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java
(original)
+++ incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/graph/TestPrefixMappingTDB.java
Tue Nov 15 18:30:01 2011
@@ -116,7 +116,7 @@ public class TestPrefixMappingTDB extend
         FileOps.clearDirectory(DB) ;
         {
             // Create new DB (assuming it's empty now)
-            Graph graph = TDBFactory.createGraph(DB);
+            Graph graph = TDBFactory.createDatasetGraph(DB).getDefaultGraph() ;
             PrefixMapping pm = graph.getPrefixMapping();
             pm.setNsPrefix("test", "http://test");
             graph.close();
@@ -124,7 +124,7 @@ public class TestPrefixMappingTDB extend
 
         {
             // Reconnect to the same DB
-            Graph graph = TDBFactory.createGraph(DB);
+            Graph graph = TDBFactory.createDatasetGraph(DB).getDefaultGraph() ;
             PrefixMapping pm = graph.getPrefixMapping();
             Map<String, String> map = pm.getNsPrefixMap();
             assertEquals(1, map.size()) ;

Modified: incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/junit/GraphLocation.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/junit/GraphLocation.java?rev=1202359&r1=1202358&r2=1202359&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/junit/GraphLocation.java
(original)
+++ incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/junit/GraphLocation.java
Tue Nov 15 18:30:01 2011
@@ -29,9 +29,9 @@ import com.hp.hpl.jena.graph.Graph ;
 import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.graph.Triple ;
 import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.DatasetFactory ;
 import com.hp.hpl.jena.rdf.model.Model ;
 import com.hp.hpl.jena.rdf.model.ModelFactory ;
-import com.hp.hpl.jena.sparql.core.DatasetImpl ;
 import com.hp.hpl.jena.tdb.TDBFactory ;
 import com.hp.hpl.jena.tdb.base.file.Location ;
 import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
@@ -58,7 +58,7 @@ public class GraphLocation
     public Dataset getDataset()
     { 
         if ( dsg == null ) return null ;
-        return new DatasetImpl(dsg) ;
+        return DatasetFactory.create(dsg) ;
     }
 
     public Dataset createDataset() 
@@ -66,14 +66,14 @@ public class GraphLocation
         if ( dsg != null )
             throw new TDBTestException("dataset already in use") ;
         dsg = TDBFactory.createDatasetGraph(loc) ;
-        return new DatasetImpl(dsg) ;
+        return DatasetFactory.create(dsg) ;
     }
     
     public Graph createGraph()
     {
         if ( graph != null )
             throw new TDBTestException("Graph already in use") ;
-        graph = TDBFactory.createGraph(loc) ;
+        graph = TDBFactory.createDatasetGraph(loc).getDefaultGraph() ;
         model = ModelFactory.createModelForGraph(graph) ;
         return graph ;
     }

Modified: incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/solver/TestSolverTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/solver/TestSolverTDB.java?rev=1202359&r1=1202358&r2=1202359&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/solver/TestSolverTDB.java
(original)
+++ incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/solver/TestSolverTDB.java
Tue Nov 15 18:30:01 2011
@@ -59,7 +59,7 @@ public class TestSolverTDB extends BaseT
 
     @BeforeClass static public void beforeClass()
     { 
-        graph = TDBFactory.createGraph() ;
+        graph = TDBFactory.createDatasetGraph().getDefaultGraph() ;
         Model m = ModelFactory.createModelForGraph(graph) ;
         FileManager.get().readModel(m, graphData) ;
 



Mime
View raw message