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/05/25 21:31:05 UTC

svn commit: r1127645 - in /incubator/jena/Experimental/TxTDB/trunk/src-dev/tx: ./ base/ journal/ transaction/

Author: andy
Date: Wed May 25 19:31:04 2011
New Revision: 1127645

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

Added:
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionException.java   (with props)
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionManagerOld.java   (with props)
Modified:
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/BlockMgrJournal.java
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/base/BlockRef.java
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/Journal.java
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/JournalEntry.java
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/TestJournal.java
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionAbort.java

Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/BlockMgrJournal.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/BlockMgrJournal.java?rev=1127645&r1=1127644&r2=1127645&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/BlockMgrJournal.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/BlockMgrJournal.java Wed May 25 19:31:04 2011
@@ -14,8 +14,9 @@ import java.util.Map ;
 import java.util.Set ;
 
 import org.openjena.atlas.logging.Log ;
-
+import tx.base.FileRef ;
 import tx.journal.Journal ;
+import tx.journal.JournalEntry ;
 import tx.transaction.Transaction ;
 
 import com.hp.hpl.jena.tdb.base.block.Block ;
@@ -27,6 +28,7 @@ public class BlockMgrJournal implements 
     private BlockMgr blockMgr ; // read-only except during journal checkpoint.
     private Journal journal ;
     private Transaction transaction ;
+    private FileRef fileRef ;
     
     final private Set<Integer> readBlocks = new HashSet<Integer>() ;
     final private Set<Integer> iteratorBlocks = new HashSet<Integer>() ;
@@ -34,9 +36,9 @@ public class BlockMgrJournal implements 
     final private Map<Integer, Block> freedBlocks = new HashMap<Integer, Block>() ;
     private boolean closed = false ;
     
-    public BlockMgrJournal(Transaction txn, BlockMgr underlyingBlockMgr, Journal journal)
+    public BlockMgrJournal(Transaction txn, FileRef fileRef, BlockMgr underlyingBlockMgr, Journal journal)
     {
-        reset(txn, underlyingBlockMgr, journal) ;
+        reset(txn, fileRef, underlyingBlockMgr, journal) ;
     }
 
     public Iterator<Block> updatedBlocks()  { return writeBlocks.values().iterator() ; }
@@ -45,11 +47,12 @@ public class BlockMgrJournal implements 
     /** Set, or reset, this BlockMgr.
      *  Enables it to be reused when already part of a datastructure. 
      */
-    public void reset(Transaction txn, BlockMgr underlyingBlockMgr, Journal journal)
+    public void reset(Transaction txn, FileRef fileRef, BlockMgr underlyingBlockMgr, Journal journal)
     {
+        this.transaction = txn ;
+        this.fileRef = fileRef ;
         this.blockMgr = underlyingBlockMgr ;
         this.journal = journal ;
-        this.transaction = txn ;
     }
     
     @Override
@@ -201,13 +204,25 @@ public class BlockMgrJournal implements 
         checkIfClosed() ;
     }
 
+    // we only use the underlying blockMgr in read-mode - we don't write back blocks.  
     @Override
-    // Yes - read.
     public void beginUpdate()           { checkIfClosed() ; blockMgr.beginRead() ; }
 
     @Override
-    public void endUpdate()             { checkIfClosed() ; blockMgr.endRead() ; }
+    public void endUpdate()
+    {
+        checkIfClosed() ;
+        blockMgr.endRead() ;
+        for ( Block blk : writeBlocks.values() )
+            writeJournalEntry(blk) ;
+    }
 
+    private void writeJournalEntry(Block blk)
+    {
+        JournalEntry entry = new JournalEntry(fileRef, blk) ;
+        journal.writeJournal(entry) ;
+    }
+    
     @Override
     public void beginRead()             { checkIfClosed() ; blockMgr.beginRead() ; }
 

Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java?rev=1127645&r1=1127644&r2=1127645&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java Wed May 25 19:31:04 2011
@@ -10,6 +10,7 @@ import static com.hp.hpl.jena.tdb.base.r
 import static com.hp.hpl.jena.tdb.index.IndexTestLib.testInsert ;
 import static org.openjena.atlas.test.Gen.strings ;
 
+import java.nio.ByteBuffer ;
 import java.util.Iterator ;
 
 import org.junit.Test ;
@@ -19,6 +20,9 @@ import org.openjena.atlas.logging.Log ;
 import org.openjena.atlas.test.Gen ;
 import org.slf4j.Logger ;
 import org.slf4j.LoggerFactory ;
+import tx.base.BlockRef ;
+import tx.journal.Journal ;
+import tx.journal.JournalEntry ;
 import tx.transaction.TransactionManager ;
 
 import com.hp.hpl.jena.query.DatasetFactory ;
@@ -30,6 +34,7 @@ import com.hp.hpl.jena.query.Syntax ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
 import com.hp.hpl.jena.sparql.sse.SSE ;
 import com.hp.hpl.jena.sparql.util.QueryExecUtils ;
+import com.hp.hpl.jena.tdb.base.block.Block ;
 import com.hp.hpl.jena.tdb.base.block.BlockMgr ;
 import com.hp.hpl.jena.tdb.base.block.BlockMgrFactory ;
 import com.hp.hpl.jena.tdb.base.block.BlockMgrLogger ;
@@ -81,7 +86,27 @@ public class TxMain
         transactional() ; exit(0) ;
     }
     
+    public static void replay()
+    {
+        Journal journal = new Journal(null) ;
+        
+        for ( JournalEntry e : journal )
+        {
+            BlockRef ref = e.getBlockRef() ;
+            ByteBuffer bb = e.getByteBuffer() ;
+            Block block = new Block(ref.getBlockId(), bb) ;
+            // File BlockMgr ;
+            BlockMgr blockMgr = fromBlockRef(null) ;
+            blockMgr.write(block) ;
+        }
+    }
     
+    
+    private static BlockMgr fromBlockRef(Object object)
+    {
+        return null ;
+    }
+
     public static void test()
     {
         BlockMgrFactory.AddTracker = false ;

Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/base/BlockRef.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/base/BlockRef.java?rev=1127645&r1=1127644&r2=1127645&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/base/BlockRef.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/base/BlockRef.java Wed May 25 19:31:04 2011
@@ -13,7 +13,7 @@ public class BlockRef
     private final int blockId ;
     
     static public BlockRef create(FileRef file, int blockId)    { return new BlockRef(file, blockId) ; }
-    static public BlockRef create(String file, int blockId)     { return new BlockRef(file, blockId) ; }
+    //static public BlockRef create(String file, Integer blockId)     { return new BlockRef(file, blockId) ; }
 
     private BlockRef(String file, int blockId)
     {

Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/Journal.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/Journal.java?rev=1127645&r1=1127644&r2=1127645&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/Journal.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/Journal.java Wed May 25 19:31:04 2011
@@ -21,7 +21,8 @@ import com.hp.hpl.jena.tdb.base.file.Buf
  *  The write performance is more important than read; reads only happen
  *  if the journal grows to the point where it needs to free up cache. 
  */
-public class Journal
+public final
+class Journal implements Iterable<JournalEntry>
 {
     // Version 1 : issue might be excessive copying
     // [TxTDB:TODO] Caching
@@ -172,6 +173,8 @@ public class Journal
         return new IteratorEntries() ;
     }
     
+    @Override
+    public Iterator<JournalEntry> iterator() { return entries() ; }
 }
 
 /*

Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/JournalEntry.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/JournalEntry.java?rev=1127645&r1=1127644&r2=1127645&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/JournalEntry.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/JournalEntry.java Wed May 25 19:31:04 2011
@@ -8,9 +8,12 @@ package tx.journal;
 
 import java.nio.ByteBuffer ;
 
+import com.hp.hpl.jena.tdb.base.block.Block ;
+
 import org.openjena.atlas.logging.Log ;
 
 import tx.base.BlockRef ;
+import tx.base.FileRef ;
 
 public class JournalEntry
 {
@@ -24,6 +27,11 @@ public class JournalEntry
     private final BlockRef fileReference ; 
     private final ByteBuffer byteBuffer ;
     
+    public JournalEntry(FileRef fileRef, Block block)
+    {
+        this(Type.Block.id, BlockRef.create(fileRef, block.getId()), block.getByteBuffer()) ;
+    }
+    
     public JournalEntry(int type, BlockRef blockRef, ByteBuffer bytes)
     {
         if ( type == 0 )

Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/TestJournal.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/TestJournal.java?rev=1127645&r1=1127644&r2=1127645&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/TestJournal.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/journal/TestJournal.java Wed May 25 19:31:04 2011
@@ -31,12 +31,16 @@ public class TestJournal extends BaseTes
     static ByteBuffer bb1 = ByteBuffer.allocate(4) ;
     static ByteBuffer bb2 = ByteBuffer.allocate(4) ;
     static ByteBuffer bb3 = ByteBuffer.allocate(4) ;
+
+    static FileRef fileref1 = FileRef.create("xyz") ;
+    static FileRef fileref2 = FileRef.create("abc") ;
+
     
-    static BlockRef blockref1 = BlockRef.create("xyz", 10) ;
-    static BlockRef blockref2 = BlockRef.create("xyz", 10) ;
+    static BlockRef blockref1 = BlockRef.create(fileref1, 10) ;
+    static BlockRef blockref2 = BlockRef.create(fileref1, 10) ;
 
-    static BlockRef blockref3 = BlockRef.create("xyz", 20) ;
-    static BlockRef blockref4 = BlockRef.create("abc", 10) ;
+    static BlockRef blockref3 = BlockRef.create(fileref1, 20) ;
+    static BlockRef blockref4 = BlockRef.create(fileref2, 10) ;
     
     // [TxTDB:TODO] Use these 
     static JournalEntry je1 = new JournalEntry(10, blockref1, bb1) ;

Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionAbort.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionAbort.java?rev=1127645&r1=1127644&r2=1127645&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionAbort.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionAbort.java Wed May 25 19:31:04 2011
@@ -4,11 +4,9 @@
  * [See end of file]
  */
 
-package tx.transaction;
+package tx.transaction ;
 
-import com.hp.hpl.jena.tdb.TDBException ;
-
-public class TransactionAbort extends TDBException
+public class TransactionAbort extends TransactionException
 {
     public TransactionAbort()                          { super() ; }
     public TransactionAbort(String msg)                { super(msg) ; }

Added: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionException.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionException.java?rev=1127645&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionException.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionException.java Wed May 25 19:31:04 2011
@@ -0,0 +1,44 @@
+/*
+ * (c) Copyright 2011 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package tx.transaction;
+
+import com.hp.hpl.jena.tdb.TDBException ;
+
+public class TransactionException extends TDBException
+{
+    public TransactionException()                          { super() ; }
+    public TransactionException(String msg)                { super(msg) ; }
+    public TransactionException(Throwable th)              { super(th) ; }
+    public TransactionException(String msg, Throwable th)  { super(msg, th) ; }
+}
+
+/*
+ * (c) Copyright 2011 Epimorphics Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
\ No newline at end of file

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

Added: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionManagerOld.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionManagerOld.java?rev=1127645&view=auto
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionManagerOld.java (added)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/transaction/TransactionManagerOld.java Wed May 25 19:31:04 2011
@@ -0,0 +1,419 @@
+/*
+ * (c) Copyright 2011 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package tx.transaction;
+
+//import java.nio.ByteBuffer ;
+//import java.util.ArrayList ;
+//import java.util.HashMap ;
+//import java.util.Iterator ;
+//import java.util.List ;
+//import java.util.Map ;
+//import java.util.Properties ;
+//
+//import org.openjena.atlas.lib.Pair ;
+//import setup.BlockMgrBuilder ;
+//import setup.DatasetBuilder ;
+//import setup.DatasetBuilderStd ;
+//import setup.DatasetBuilderStd.BlockMgrBuilderStd ;
+//import setup.IndexBuilder ;
+//import setup.NodeTableBuilder ;
+//import setup.ObjectFileBuilder ;
+//import setup.RangeIndexBuilder ;
+//import setup.TupleIndexBuilder ;
+//import tx.DatasetGraphTxView ;
+//
+//import com.hp.hpl.jena.graph.Node ;
+//import com.hp.hpl.jena.sparql.core.DatasetGraph ;
+//import com.hp.hpl.jena.sparql.core.DatasetPrefixStorage ;
+//import com.hp.hpl.jena.sparql.engine.optimizer.reorder.ReorderTransformation ;
+//import com.hp.hpl.jena.tdb.base.block.Block ;
+//import com.hp.hpl.jena.tdb.base.block.BlockMgr ;
+//import com.hp.hpl.jena.tdb.base.block.BlockMgrLogger ;
+//import com.hp.hpl.jena.tdb.base.block.BlockMgrWrapper ;
+//import com.hp.hpl.jena.tdb.base.file.FileSet ;
+//import com.hp.hpl.jena.tdb.base.file.Location ;
+//import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
+//import com.hp.hpl.jena.tdb.nodetable.NodeTableWrapper ;
+//import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
+//import com.hp.hpl.jena.tdb.store.NodeId ;
+//import com.hp.hpl.jena.tdb.store.QuadTable ;
+//import com.hp.hpl.jena.tdb.store.TripleTable ;
+//import com.hp.hpl.jena.tdb.sys.ConcurrencyPolicy ;
+
+public class TransactionManagerOld
+{
+//    // Setup.
+//    // Fragile.
+//    private final DatasetBuilderTxnBase baseDatasetBuilder ;
+//    private final BlockMgrBuilderRemember baseBlockMgrBuilder ;
+//    NodeTable nodeTable ;
+//    static long transactionId = 10 ;
+//    
+//    public TransactionManager()
+//    {
+//        baseDatasetBuilder = new DatasetBuilderTxnBase() ;
+//        baseDatasetBuilder.setStd() ;
+//        baseBlockMgrBuilder = baseDatasetBuilder.blockMgrBuilder1 ;
+//    }
+//    
+//    public DatasetGraphTDB build(Location location)
+//    {
+//        DatasetGraphTDB dsg = baseDatasetBuilder.build(location, null) ;
+//        nodeTable = dsg.getTripleTable().getNodeTupleTable().getNodeTable() ;
+//        return dsg ;
+//    }
+//    
+//    public DatasetGraphTxView begin(DatasetGraph dsg)
+//    {
+//        // If already a transaction ... 
+//        // Subs transactions are a new view - commit is only comit to parent transaction.  
+//        if ( dsg instanceof DatasetGraphTxView )
+//        {
+//            System.err.println("Already in transactional DatasetGraph") ;
+//            // Either:
+//            //   error -> implies nested
+//            //   create new transaction 
+//        }
+//        DatasetBuilder x = new DatasetBuilderTxn(baseBlockMgrBuilder, nodeTable) ;
+//        DatasetGraph dsg2 = x.build(Location.mem(), null) ;
+//        
+//        Transaction txn = new Transaction(transactionId++, this) ;
+//        return new DatasetGraphTxView(txn, dsg2) ;
+//    }
+//    
+//    public void commit(Transaction transaction)
+//    {
+//        System.err.println("Commit") ;
+//    }
+//
+//    public void abort(Transaction transaction)
+//    {    
+//        System.err.println("Abort") ;
+//        // Release allocated blocks back to the
+//        //   Reset allocation id.
+//        // Forget any free blocks as being free. 
+//    }
+//    
+//    static class DatasetBuilderTxnBase extends DatasetBuilderStd
+//    {
+//        BlockMgrBuilderRemember blockMgrBuilder1         = new BlockMgrBuilderRemember() ;
+//        
+//        DatasetBuilderTxnBase() {}
+//        
+//        @Override
+//        protected void setStd()
+//        {
+//            ObjectFileBuilder objectFileBuilder     = new ObjectFileBuilderStd() ;
+//            //BlockMgrBuilder blockMgrBuilderStd         = new BlockMgrBuilderStd(SystemTDB.BlockSize) ;
+//            
+//            BlockMgrBuilder blockMgrBuilder = blockMgrBuilder1 ;
+//            
+//            IndexBuilder indexBuilder               = new IndexBuilderStd(blockMgrBuilder, blockMgrBuilder) ;
+//            RangeIndexBuilder rangeIndexBuilder     = new RangeIndexBuilderStd(blockMgrBuilder, blockMgrBuilder) ;
+//            
+//            NodeTableBuilder nodeTableBuilder       = new NodeTableBuilderStd(indexBuilder, objectFileBuilder) ;
+//            TupleIndexBuilder tupleIndexBuilder     = new TupleIndexBuilderStd(rangeIndexBuilder) ;
+//            
+//            set(nodeTableBuilder, tupleIndexBuilder, 
+//                indexBuilder, rangeIndexBuilder, 
+//                blockMgrBuilder, objectFileBuilder) ;
+//        }
+//
+//    }
+//    
+//    static class DatasetBuilderTxn extends DatasetBuilderStd
+//    {
+//        private BlockMgrBuilderRemember blockMgrBuilderRemember ;
+//        private NodeTableBuilder nodeTableBuilder ; 
+//
+//        DatasetBuilderTxn(BlockMgrBuilderRemember blockMgrBuilderRemember, NodeTable nodeTable)
+//        {
+//            super() ;
+//            this.blockMgrBuilderRemember = blockMgrBuilderRemember ;
+//            
+//            
+//            ObjectFileBuilder objectFileBuilder     = new ObjectFileBuilderStd() ;
+//            
+//            BlockMgrBuilder blockMgrBuilder2         = new BlockMgrBuilderTxn(blockMgrBuilderRemember) ;
+//            
+//            IndexBuilder indexBuilder               = new IndexBuilderStd(blockMgrBuilder2, blockMgrBuilder2) ;
+//            RangeIndexBuilder rangeIndexBuilder     = new RangeIndexBuilderStd(blockMgrBuilder2, blockMgrBuilder2) ;
+//            
+//            NodeTableBuilder nodeTableBuilder       = new NodeTableBuilderTxn(nodeTable) ;
+//            this.nodeTableBuilder = nodeTableBuilder ;
+//            
+//            TupleIndexBuilder tupleIndexBuilder     = new TupleIndexBuilderStd(rangeIndexBuilder) ;
+//            
+//            set(nodeTableBuilder, tupleIndexBuilder, 
+//                indexBuilder, rangeIndexBuilder, 
+//                blockMgrBuilder2, objectFileBuilder) ;
+//        }
+//        
+//        @Override
+//        public DatasetGraphTDB build(Location location, Properties config)
+//        {
+//            NodeTable nodeTable = nodeTableBuilder.buildNodeTable(null, null, 0, 0) ;
+//            
+//            ConcurrencyPolicy policy = createConcurrencyPolicy() ;
+//            TripleTable tripleTable = makeTripleTable(location, nodeTable, policy) ; 
+//            QuadTable quadTable = makeQuadTable(location, nodeTable, policy) ;
+//            DatasetPrefixStorage prefixes = makePrefixTable(location, policy) ;
+//            ReorderTransformation transform  = chooseReorderTransformation(location) ;
+//            DatasetGraphTDB dsg = new DatasetGraphTDB(tripleTable, quadTable, prefixes, transform, location, config) ;
+//            return dsg ;
+//        }
+//    }
+//    
+//    static class BlockMgrBuilderTxn implements BlockMgrBuilder
+//    {
+//
+//        private BlockMgrBuilderRemember baseBlockMgr ;
+//
+//        public BlockMgrBuilderTxn(BlockMgrBuilderRemember blockMgr)
+//        {
+//            this.baseBlockMgr = blockMgr ;
+//        }
+//
+//        @Override
+//        public BlockMgr buildBlockMgr(FileSet fileSet, String ext, int blockSize)
+//        {
+//            BlockMgr base = baseBlockMgr.created(fileSet, ext) ;
+//            String label = fileSet.getBasename()+"."+ext ;
+//            BlockMgr blkMgr = new BlockMgrTxn(base) ;
+//            
+//            if ( false )
+//            {
+//                label = label.replace('.', '-') ;
+//                return new BlockMgrLogger(label, blkMgr, true) ;
+//            }
+//            return blkMgr ;
+//        }
+//    }
+//    
+//    static class BlockMgrTxn extends BlockMgrWrapper
+//    {
+//        Map<Integer, Block> blocks = new HashMap<Integer, Block>() ;
+//        
+//        public BlockMgrTxn(BlockMgr blockMgr)
+//        {
+//            super(blockMgr) ;
+//        }
+//        
+//        // Create new blocks here in-memory
+//        
+//        @Override
+//        public Block allocate(int blockSize)
+//        {
+//            Block blk = blockMgr.allocate(blockSize) ;
+//            // Hmm - if backed by a mmap, may mess with file.
+//            // But does it matter?
+//            // How do we recover?
+//            
+//            blocks.put(blk.getId(), blk) ;
+//            return blk ;
+//        }
+//
+//        @Override
+//        public Block getRead(int id)
+//        {
+//            // [TxTDB:PATCH-UP]
+//            // HACK
+//            Block b = getWrite(id) ;
+//            b.setModified(false) ;
+//            return b ;
+//        }
+//        
+//        @Override
+//        public Block promote(Block block)
+//        {
+//            return block ;
+//        }
+//
+//        @Override
+//        public Block getWrite(int id)
+//        {
+//            // [TxTDB:PATCH-UP]
+//            // Copies out of the underlying layer always.
+//            {
+//            Block block = blocks.get(id) ;
+//            if ( block != null )
+//                return block ;
+//            }
+//            
+//            // Until we track read and write gets, need to copy for safety
+//            // INEFFICIENT
+//            
+//            Block block = super.getRead(id) ;
+//            ByteBuffer bb = block.getByteBuffer() ;
+//            // This copies contents and resizes ByteBuffer - seems to break for memory use.
+//            //bb = ByteBufferLib.duplicate(bb) ;
+//            
+//            ByteBuffer bb2 = ByteBuffer.allocate(bb.capacity()) ;
+//            int x = bb.position() ;
+//            bb.position(0) ;
+//            bb2.put(bb) ;
+//            bb.position(x) ;
+//            
+//            bb2.position(0) ;
+//            bb2.limit(bb2.capacity()) ;
+//            Block block2 = new Block(id, bb2) ;
+//            blocks.put(id, block2) ;
+//            return block2 ;
+//        }
+//
+//        @Override
+//        public void write(Block block)
+//        {
+//            Block bb = blocks.get(block.getId()) ;
+//            if ( bb != block )
+//                System.err.println("Odd!") ;
+//            blocks.put(block.getId(), block) ;
+//        }
+//
+//        @Override
+//        public void free(Block block)
+//        {
+//            blocks.remove(block.getId()) ;
+//        }
+//    }
+//    
+//    static class BlockMgrBuilderRemember implements BlockMgrBuilder
+//    {
+//
+//        private Map<String, BlockMgr> created = new  HashMap<String, BlockMgr>() ;
+//        BlockMgrBuilderStd bmb ;
+//        
+//        public BlockMgrBuilderRemember()
+//        {
+//            bmb = new BlockMgrBuilderStd() ;
+//        }
+//
+//        @Override
+//        public BlockMgr buildBlockMgr(FileSet fileSet, String ext, int blockSize)
+//        {
+//            String key = fileSet.getBasename()+"."+ext ;
+//            BlockMgr blkMgr = bmb.buildBlockMgr(fileSet, ext, blockSize) ;
+//            created.put(key, blkMgr) ;
+//            return blkMgr ;
+//        }
+//        
+//        public BlockMgr created(FileSet fileSet, String ext)
+//        {
+//            String key = fileSet.getBasename()+"."+ext ;
+//            return created.get(key) ;
+//        }
+//        
+//    }
+//    
+//    static class NodeTableBuilderTxn implements NodeTableBuilder
+//    {
+//        
+//        
+//        private NodeTable other ;
+//
+//
+//        NodeTableBuilderTxn(NodeTable other)
+//        {
+//            this.other = other ;
+//        }
+//        
+//        
+//        @Override
+//        public NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile, int sizeNode2NodeIdCache,
+//                                        int sizeNodeId2NodeCache)
+//        {
+//            return new NodeTableTxn(other) ;
+//        }
+//    }
+//    
+//    static class NodeTableTxn extends NodeTableWrapper
+//    {
+//        
+//        Map<NodeId, Node> nodeIdToNode = new HashMap<NodeId, Node>() ;
+//        Map<Node, NodeId> nodeToNodeId = new HashMap<Node, NodeId>() ;
+//        // Well side practical space.
+//        long alloc = 0x888888888L ;
+//
+//        public NodeTableTxn(NodeTable other)
+//        {
+//            super(other) ;
+//        }
+//
+//        @Override
+//        public NodeId getAllocateNodeId(Node node)
+//        {
+//            NodeId nodeId = getNodeIdForNode(node) ;
+//            if ( nodeId != NodeId.NodeDoesNotExist )
+//                return nodeId ;
+//            // Need to create.
+//            // HACK
+//            nodeId = new NodeId(alloc) ;  
+//            alloc++ ;
+//            nodeIdToNode.put(nodeId, node) ;
+//            nodeToNodeId.put(node, nodeId) ;
+//            return nodeId ;
+//        }
+//
+//        @Override
+//        public NodeId getNodeIdForNode(Node node)
+//        {
+//            NodeId nodeId = nodeToNodeId.get(node) ;
+//            if ( nodeId != null )
+//                return nodeId ;
+//            return super.getNodeIdForNode(node) ;
+//        }
+//
+//        @Override
+//        public Node getNodeForNodeId(NodeId id)
+//        {
+//            Node n = nodeIdToNode.get(id) ;
+//            if ( n != null )
+//                return n ;
+//            return super.getNodeForNodeId(id) ;
+//        }
+//
+//        @Override
+//        public Iterator<Pair<NodeId, Node>> all()
+//        {
+//            List<Pair<NodeId, Node>> here = new ArrayList<Pair<NodeId, Node>>() ;
+//            for ( Map.Entry<NodeId, Node> e : nodeIdToNode.entrySet() )
+//            {
+//                here.add(new Pair<NodeId, Node>(e.getKey(), e.getValue())) ;
+//            }
+//            //Iter<T>.concat(here.iterator(), super.all()) ;
+//            return here.iterator() ;
+//        }
+//        
+//    }
+}
+
+/*
+ * (c) Copyright 2011 Epimorphics Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
\ No newline at end of file

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