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 2011/07/10 20:59:27 UTC

svn commit: r1144933 - in /incubator/jena/Experimental/TxTDB/trunk/src-dev/tx: DevTx.java ExTxTDB.java TestTransactions.java api/ api/ReadWrite.java api/StoreConnection.java

Author: andy
Date: Sun Jul 10 18:59:26 2011
New Revision: 1144933

URL: http://svn.apache.org/viewvc?rev=1144933&view=rev
Log: (empty)

Added:
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/ExTxTDB.java   (with props)
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestTransactions.java   (with props)
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/ReadWrite.java   (with props)
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/StoreConnection.java   (with props)
Modified:
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java

Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java?rev=1144933&r1=1144932&r2=1144933&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java Sun Jul 10 18:59:26 2011
@@ -21,10 +21,17 @@ public class DevTx
     //            Iterator<Tuple<NodeId>> find(Tuple<NodeId> tuple) ==> checkIterator: 
     //     =>RangeIndex eventually.
     //     **** Catch in NodeTupleTable.find
+    // reset ConcurrencyPolicy
+    
     // Larger grain "start write" -- one on each NodeTupleTableConcrete.addRow but need a parser or triple "add" 
     
     // ?? Read-only by concurrency policy.
     
+    // "Connection" to a daatset.
+    //   Enable txn mode and then must use transactions.
+    //   or require queries explicitly closed.
+    
+    
     
     // Evenetually:
     // Iterator<Tuple<NodeId>> find(Tuple<NodeId> tuple)

Added: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/ExTxTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/ExTxTDB.java?rev=1144933&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/ExTxTDB.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/ExTxTDB.java Sun Jul 10 18:59:26 2011
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tx;
+
+import tx.api.ReadWrite ;
+import tx.api.StoreConnection ;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.QueryExecution ;
+import com.hp.hpl.jena.query.QueryExecutionFactory ;
+import com.hp.hpl.jena.tdb.transaction.DatasetGraphTxnTDB ;
+import com.hp.hpl.jena.tdb.transaction.Transaction ;
+import com.hp.hpl.jena.update.GraphStore ;
+import com.hp.hpl.jena.update.GraphStoreFactory ;
+import com.hp.hpl.jena.update.UpdateExecutionFactory ;
+import com.hp.hpl.jena.update.UpdateFactory ;
+import com.hp.hpl.jena.update.UpdateProcessor ;
+import com.hp.hpl.jena.update.UpdateRequest ;
+
+public class ExTxTDB
+{
+    // Internal state of a DSG
+    enum DSG_STATE { DSG_READ, DSG_WRITE, DGS_BLOCKED } ;
+    
+    interface DatasetTx extends Dataset
+    {
+        public Transaction getTransaction() ; //{ return transaction ; }
+        public void commit() ; // { transaction.commit() ; }
+        public void abort() ; //{ transaction.abort() ; }
+    }
+    
+    public static void example1()
+    {
+        // TODO
+        // Add to UpdateExecutionFactory
+        //UpdateProcessor ==> UpdateExecution
+        // Silent abort
+        
+        StoreConnection sConn = StoreConnection.make("DB") ;
+        
+        DatasetGraphTxnTDB dsg = sConn.begin(ReadWrite.READ) ;
+        try {
+            // SPARQL
+            QueryExecution qExec = QueryExecutionFactory.create("ASK{}", /*dsg*/(Dataset)null) ;
+            qExec.close() ;
+        } finally { dsg.close() ; } // Close all QExecs
+        
+        dsg = sConn.begin(ReadWrite.WRITE) ;
+        try {
+            // Update
+            dsg.commit() ;
+        } finally { dsg.close() ; } // WARNING if no commit or abort.
+        
+        // Alt: .beginQuery / .beginUpdate (isa Graphstore)
+        
+        dsg = sConn.begin(ReadWrite.WRITE) ;
+        try {
+            // Update.
+            GraphStore gs = GraphStoreFactory.create(dsg) ;
+            UpdateRequest request = UpdateFactory.create("") ;
+            // Add this operation to bypass the need for GraphStore.
+            UpdateProcessor proc = UpdateExecutionFactory.create(request, dsg) ;
+            proc.execute() ;
+            dsg.commit() ;
+        } finally { dsg.close() ; } // WARNING if no commit or abort.
+    }
+}
+

Propchange: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/ExTxTDB.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestTransactions.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestTransactions.java?rev=1144933&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestTransactions.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestTransactions.java Sun Jul 10 18:59:26 2011
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tx;
+
+public class TestTransactions
+{
+
+}
+

Propchange: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TestTransactions.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/ReadWrite.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/ReadWrite.java?rev=1144933&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/ReadWrite.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/ReadWrite.java Sun Jul 10 18:59:26 2011
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tx.api;
+
+public enum ReadWrite
+{
+    READ,
+    WRITE
+}
+

Propchange: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/ReadWrite.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/StoreConnection.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/StoreConnection.java?rev=1144933&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/StoreConnection.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/StoreConnection.java Sun Jul 10 18:59:26 2011
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tx.api;
+
+import com.hp.hpl.jena.tdb.base.file.Location ;
+import com.hp.hpl.jena.tdb.setup.DatasetBuilderStd ;
+import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
+import com.hp.hpl.jena.tdb.transaction.DatasetGraphTxnTDB ;
+import com.hp.hpl.jena.tdb.transaction.TransactionManager ;
+
+public class StoreConnection
+{
+    private DatasetGraphTDB baseDSG ;
+
+    private StoreConnection(Location location)
+    {
+        baseDSG = DatasetBuilderStd.build(location.getDirectoryPath()) ;
+    }
+    
+    public DatasetGraphTxnTDB begin(ReadWrite mode)
+    {
+        switch (mode)
+        {
+            case READ :
+                // Make a new read dataset.
+                //new DatasetGraphTxnRead(baseDSG) ;
+                break ;
+            case WRITE :
+                // Check only active transaction.
+                // Make from the last commited transation or base.
+                DatasetGraphTxnTDB dsg2 = new TransactionManager().begin(baseDSG) ;
+        }
+        System.err.println("StoreConnection.begin: Not implemented fully") ;
+        return null ;
+    }
+    
+    
+    // ---- statics
+    
+    public static StoreConnection make(String location)
+    {
+        return make(new Location(location)) ; 
+    }
+
+    
+    public static StoreConnection make(Location location)
+    {
+        //TDBFactory.expel(location) ;
+        // Cache?
+        return new StoreConnection(location) ; 
+    }
+    
+    
+    
+}
+

Propchange: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/api/StoreConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain