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/11/15 18:13:28 UTC

svn commit: r1202308 - in /incubator/jena/Scratch/AFS/Jena-Dev/trunk: ./ src/dev/ src/tx/api/ src/tx/base/

Author: andy
Date: Tue Nov 15 17:13:28 2011
New Revision: 1202308

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

Removed:
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTX.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphTrackActive.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetTransactional.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/Transactional.java
Modified:
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/Q.rq
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphWithLock.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/LockTx.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/base/LockManager.java

Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/Q.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/Q.rq?rev=1202308&r1=1202307&r2=1202308&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/Q.rq (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/Q.rq Tue Nov 15 17:13:28 2011
@@ -1,4 +1,5 @@
-PREFIX :	<http://www.example.org/>
+PREFIX  :     <http://example/ns#>
 
-SELECT *
-{  ?x   ^(:a/:b)   ?y  }
+SELECT  (count(?x) AS ?c)
+WHERE
+  { ?x :p1|:p2 "x1" }

Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java?rev=1202308&r1=1202307&r2=1202308&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java Tue Nov 15 17:13:28 2011
@@ -25,28 +25,14 @@ import org.junit.Test ;
 import org.openjena.atlas.lib.FileOps ;
 import org.openjena.atlas.lib.Lib ;
 import org.openjena.atlas.logging.Log ;
-import tx.api.DatasetGraphTX ;
-import tx.api.DatasetTransactional ;
 import arq.update ;
 
-import com.hp.hpl.jena.query.Dataset ;
-import com.hp.hpl.jena.query.Query ;
-import com.hp.hpl.jena.query.QueryCancelledException ;
-import com.hp.hpl.jena.query.QueryException ;
-import com.hp.hpl.jena.query.QueryExecution ;
-import com.hp.hpl.jena.query.QueryExecutionFactory ;
-import com.hp.hpl.jena.query.QueryFactory ;
-import com.hp.hpl.jena.query.QuerySolution ;
-import com.hp.hpl.jena.query.ReadWrite ;
-import com.hp.hpl.jena.query.ResultSet ;
+import com.hp.hpl.jena.query.* ;
 import com.hp.hpl.jena.sparql.api.wait ;
 import com.hp.hpl.jena.sparql.function.FunctionRegistry ;
 import com.hp.hpl.jena.sparql.lang.SyntaxVarScope ;
 import com.hp.hpl.jena.sparql.sse.SSE ;
-import com.hp.hpl.jena.tdb.DatasetGraphTxn ;
-import com.hp.hpl.jena.tdb.StoreConnection ;
-import com.hp.hpl.jena.tdb.TDBFactory ;
-import com.hp.hpl.jena.tdb.TDBLoader ;
+import com.hp.hpl.jena.tdb.* ;
 import com.hp.hpl.jena.tdb.base.file.Location ;
 import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
 import com.hp.hpl.jena.util.FileManager ;
@@ -57,7 +43,10 @@ public class Run extends RunBase
     
     public static void main(String[] argv) throws Exception
     {
-        Dataset ds = new DatasetTransactional(new DatasetGraphTX(Location.mem())) ;
+        // And TDBFactory.create
+        Dataset ds = DatasetFactory.create(new DatasetGraphTransaction(Location.mem())) ;
+        
+        
         ds.begin(ReadWrite.WRITE) ;
         FileManager.get().readModel(ds.getDefaultModel(), "D.nt") ;
         ds.commit() ;
@@ -69,9 +58,7 @@ public class Run extends RunBase
         
         exit(0) ;
         
-        
-        
-        DatasetGraphTX dsg = new DatasetGraphTX(Location.mem()) ;
+        DatasetGraphTransaction dsg = new DatasetGraphTransaction(Location.mem()) ;
         dsg.begin(ReadWrite.WRITE) ;
         dsg.add(SSE.parseQuad("(<g> <s> <p> <o>)")) ;
         dsg.commit() ;

Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java?rev=1202308&r1=1202307&r2=1202308&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java Tue Nov 15 17:13:28 2011
@@ -18,14 +18,20 @@
 
 package dev;
 
+import java.io.File ;
+import java.util.Iterator ;
 import java.util.List ;
-import java.util.Properties ;
+
+import org.openjena.atlas.lib.ColumnMap ;
 
 import tdb.cmdline.CmdTDB ;
 import arq.cmd.CmdException ;
 
 import com.hp.hpl.jena.tdb.TDB ;
+import com.hp.hpl.jena.tdb.base.record.Record ;
+import com.hp.hpl.jena.tdb.index.RangeIndex ;
 import com.hp.hpl.jena.tdb.index.TupleIndex ;
+import com.hp.hpl.jena.tdb.index.TupleIndexRecord ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTupleTable ;
 import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
 import com.hp.hpl.jena.tdb.store.NodeId ;
@@ -43,8 +49,12 @@ public class tdbindex extends CmdTDB
 {
     static public void main(String... argv)
     { 
+        // DEV
+        argv = new String[] {"--loc=DB", "POS", "PSO"} ;
+        
         TDB.setOptimizerWarningFlag(false) ;
         new tdbindex(argv).mainRun() ;
+        System.out.println("DONE") ;
     }
 
     protected tdbindex(String[] argv)
@@ -88,12 +98,35 @@ public class tdbindex extends CmdTDB
         destIndex = destIndex.toUpperCase() ;
         
         DatasetGraphTDB dsg = super.getDatasetGraph() ;
+        
         copyIndex(dsg, srcIndex, destIndex) ;
+        dumpIndex(dsg, srcIndex) ;
+        dumpIndex(dsg, destIndex) ;
     }
 
+    // tdbloader2 code.
+    private static void dumpIndex(DatasetGraphTDB dsg, String srcIndex)
+    {
+        System.out.println("Index: "+srcIndex) ;
+        String fn = dsg.getLocation().getPath(srcIndex+"."+Names.bptExtRecords) ; //Names.bptExtTree
+        if ( ! new File(fn).exists() )
+        {
+            throw new CmdException("No such index: "+srcIndex) ;
+        }
+        
+        int indexRecordLen = srcIndex.length()*NodeId.SIZE ;
+        RangeIndex rIndex = SetupTDB.makeRangeIndex(dsg.getLocation(), srcIndex, indexRecordLen, 0, 100*1000, 100*1000) ;
+        Iterator<Record> rIter = rIndex.iterator() ;
+        for ( ; rIter.hasNext() ; )
+        {
+            Record r = rIter.next() ;
+            System.out.println(r) ;
+        }
+    }
+    
     private static void copyIndex(DatasetGraphTDB dsg, String srcIndex, String destIndex)
     {
-        LoadMonitor loadMonitor = BulkLoader.createLoadMonitor(dsg, "TDB", false) ;
+        LoadMonitor loadMonitor = BulkLoader.createLoadMonitor(dsg, "TDB", true) ;
         
         BuilderSecondaryIndexes builder = new BuilderSecondaryIndexesSequential(loadMonitor) ;
         
@@ -117,17 +150,23 @@ public class tdbindex extends CmdTDB
         if ( srcIdx == null )
             throw new CmdException("No such index: "+srcIndex) ;
         if ( dstIdx != null )
-            throw new CmdException("Index already exists: "+destIndex) ;
+            throw new CmdException("Index already exists and is in-use: "+destIndex) ;
         
         //if ( true) throw new RuntimeException("BANG") ;
         
+        ColumnMap colMap = new ColumnMap(srcIndex, destIndex) ;
+        System.out.println(colMap.getLabel()) ;
+        
         int indexRecordLen = srcIndex.length()*NodeId.SIZE ;
+        RangeIndex rIndex = SetupTDB.makeRangeIndex(dsg.getLocation(), destIndex, indexRecordLen, 0, 100*1000, 100*1000) ;
+        dstIdx = new TupleIndexRecord(destIndex.length(), colMap, rIndex.getRecordFactory(), rIndex) ;
         
-        Properties config = new Properties() ;
-        dstIdx = SetupTDB.makeTupleIndex(dsg.getLocation(), config, srcIndex, destIndex, destIndex, indexRecordLen) ;
+        // NOT PRIMARY INDEX
         
+        loadMonitor.startLoad() ;
         // What about a builder that knows how to copy from one index to another while exploiting semi-locality?   
         builder.createSecondaryIndexes(srcIdx, new TupleIndex[] {dstIdx}) ;
+        loadMonitor.finishLoad() ;
     }
 
     private static TupleIndex find(TupleIndex[] indexes, String srcIndex)

Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphWithLock.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphWithLock.java?rev=1202308&r1=1202307&r2=1202308&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphWithLock.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/DatasetGraphWithLock.java Tue Nov 15 17:13:28 2011
@@ -21,7 +21,12 @@ package tx.api;
 import com.hp.hpl.jena.query.ReadWrite ;
 import com.hp.hpl.jena.shared.JenaException ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
+import com.hp.hpl.jena.tdb.migrate.DatasetGraphTrackActive ;
 
+/** A DatasetGraph that uses the dataset lock to give wek transactional behaviour.
+ *  Only supports multiple-reader OR single-writer, and no transction abort.
+ *  Transactions are not durable. 
+ */
 public class DatasetGraphWithLock extends DatasetGraphTrackActive 
 {
     static class JenaLockException extends JenaException

Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/LockTx.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/LockTx.java?rev=1202308&r1=1202307&r2=1202308&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/LockTx.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/api/LockTx.java Tue Nov 15 17:13:28 2011
@@ -18,21 +18,22 @@
 
 package tx.api;
 
+import com.hp.hpl.jena.query.ReadWrite ;
 import com.hp.hpl.jena.shared.Lock ;
+import com.hp.hpl.jena.tdb.DatasetGraphTransaction ;
 import com.hp.hpl.jena.tdb.transaction.TDBTransactionException ;
 
 import static tx.api.LockTx.LockTxState.* ;
 
 /** Lock that provides transactions
  *  Not reentrant.
- *   */
+ */
 
 public class LockTx implements Lock
 {
-    // Lock state.
-    // Either entrant 
+    private DatasetGraphTransaction dsg ;
     
-    //public LockTx(Store)
+    public LockTx(DatasetGraphTransaction dsg) { this.dsg = dsg ; }
     
     static enum LockTxState { TxNONE, TxREAD, TxWRITE }
     
@@ -47,14 +48,12 @@ public class LockTx implements Lock
         if ( readLockRequested )
         {
             state = TxREAD ;
-            // begin read
-            // switch dataset to tx-read one
+            dsg.begin(ReadWrite.READ) ;
         }
         else
         {
             state = TxWRITE ;
-            // begin write
-            // switch dataset to tx-write one
+            dsg.begin(ReadWrite.WRITE) ;
         }
     }
 
@@ -64,12 +63,8 @@ public class LockTx implements Lock
         switch (state)
         {
             case TxNONE :   throw new TDBTransactionException("Illegal state: "+state) ;
-            case TxREAD :   
-                // close
-                break ;
-            case TxWRITE :
-                // commit
-                break ;
+            case TxREAD :   dsg.close() ;  break ;
+            case TxWRITE :  dsg.commit() ; break ;
         }
         state = TxNONE ;
     }

Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/base/LockManager.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/base/LockManager.java?rev=1202308&r1=1202307&r2=1202308&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/base/LockManager.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/tx/base/LockManager.java Tue Nov 15 17:13:28 2011
@@ -20,6 +20,6 @@ package tx.base;
 
 // Lock?
 public class LockManager
-{ ;
+{
     
 }