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 2017/06/29 10:45:44 UTC
[08/11] jena git commit: JENA-1369: Cleaning up TDB Transaction setup.
JENA-1369: Cleaning up TDB Transaction setup.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/3764a2ae
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/3764a2ae
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/3764a2ae
Branch: refs/heads/master
Commit: 3764a2aedd86e9ca0edd4faac1f36850074dd51d
Parents: b92ba1a
Author: Andy Seaborne <an...@apache.org>
Authored: Wed Jun 28 09:28:57 2017 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Wed Jun 28 09:28:57 2017 +0100
----------------------------------------------------------------------
.../org/apache/jena/tdb/index/SetupIndex.java | 50 +--------
.../jena/tdb/setup/DatasetBuilderStd.java | 82 ++++++++++-----
.../apache/jena/tdb/store/StorageConfig.java | 14 ++-
.../tdb/store/nodetable/NodeTableNative.java | 23 +++--
.../java/org/apache/jena/tdb/sys/SetupTDB.java | 51 +---------
.../jena/tdb/transaction/DatasetBuilderTxn.java | 101 ++++++++++++-------
.../jena/tdb/transaction/JournalControl.java | 21 ++--
.../tdb/transaction/TransactionManager.java | 2 +-
8 files changed, 168 insertions(+), 176 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/3764a2ae/jena-tdb/src/main/java/org/apache/jena/tdb/index/SetupIndex.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/index/SetupIndex.java b/jena-tdb/src/main/java/org/apache/jena/tdb/index/SetupIndex.java
index ded91e3..dfcee8b 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/index/SetupIndex.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/index/SetupIndex.java
@@ -122,52 +122,8 @@ public class SetupIndex {
}
public static RecordFactory makeRecordFactory(int keyLen, int valueLen)
- {
- return new RecordFactory(keyLen, valueLen) ;
- }
- //
- // /** Make a NodeTable without cache and inline wrappers */
- // public static NodeTable makeNodeTableBase(Location location, String indexNode2Id, String indexId2Node)
- // {
- // if (location.isMem())
- // return NodeTableFactory.createMem() ;
- //
- // // -- make id to node mapping -- Names.indexId2Node
- // FileSet fsIdToNode = new FileSet(location, indexId2Node) ;
- //
- // ObjectFile stringFile = makeObjectFile(fsIdToNode) ;
- //
- // // -- make node to id mapping -- Names.indexNode2Id
- // // Make index of id to node (data table)
- //
- // // No caching at the index level - we use the internal caches of the node table.
- // Index nodeToId = makeIndex(location, indexNode2Id, LenNodeHash, SizeOfNodeId, -1 ,-1) ;
- //
- // // -- Make the node table using the components established above.
- // NodeTable nodeTable = new NodeTableNative(nodeToId, stringFile) ;
- // return nodeTable ;
- // }
- //
- // /** Make a NodeTable with cache and inline wrappers */
- // public static NodeTable makeNodeTable(Location location)
- // {
- // return makeNodeTable(location,
- // Names.indexNode2Id, SystemTDB.Node2NodeIdCacheSize,
- // Names.indexId2Node, SystemTDB.NodeId2NodeCacheSize,
- // SystemTDB.NodeMissCacheSize) ;
- // }
- //
- // /** Make a NodeTable with cache and inline wrappers */
- // public static NodeTable makeNodeTable(Location location,
- // String indexNode2Id, int nodeToIdCacheSize,
- // String indexId2Node, int idToNodeCacheSize,
- // int nodeMissCacheSize)
- // {
- // NodeTable nodeTable = makeNodeTableBase(location, indexNode2Id, indexId2Node) ;
- // nodeTable = NodeTableCache.create(nodeTable, nodeToIdCacheSize, idToNodeCacheSize, nodeMissCacheSize) ;
- // nodeTable = NodeTableInline.create(nodeTable) ;
- // return nodeTable ;
- // }
- //
+ {
+ return new RecordFactory(keyLen, valueLen) ;
+ }
}
http://git-wip-us.apache.org/repos/asf/jena/blob/3764a2ae/jena-tdb/src/main/java/org/apache/jena/tdb/setup/DatasetBuilderStd.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/setup/DatasetBuilderStd.java b/jena-tdb/src/main/java/org/apache/jena/tdb/setup/DatasetBuilderStd.java
index 1319e0e..d538c0a 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/setup/DatasetBuilderStd.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/setup/DatasetBuilderStd.java
@@ -34,6 +34,7 @@ import org.apache.jena.tdb.base.block.BlockMgr ;
import org.apache.jena.tdb.base.file.BufferChannel ;
import org.apache.jena.tdb.base.file.FileSet ;
import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.base.objectfile.ObjectFile;
import org.apache.jena.tdb.index.BuilderStdIndex ;
import org.apache.jena.tdb.index.IndexBuilder ;
import org.apache.jena.tdb.index.IndexParams ;
@@ -105,15 +106,18 @@ public class DatasetBuilderStd implements DatasetBuilder {
// Used by DatasetBuilderTxn
public DatasetBuilderStd(BlockMgrBuilder blockMgrBuilder, NodeTableBuilder nodeTableBuilder) {
- set(blockMgrBuilder, nodeTableBuilder) ;
+ setupRecord(blockMgrBuilder, nodeTableBuilder) ;
}
- protected void set(NodeTableBuilder nodeTableBuilder, TupleIndexBuilder tupleIndexBuilder) {
- this.nodeTableBuilder = nodeTableBuilder ;
- this.tupleIndexBuilder = tupleIndexBuilder ;
+ private void standardSetup() {
+ ObjectFileBuilder objectFileBuilder = new BuilderStdDB.ObjectFileBuilderStd() ;
+ BlockMgrBuilder blockMgrBuilder = new BuilderStdIndex.BlockMgrBuilderStd() ;
+ IndexBuilder indexBuilderNT = new BuilderStdIndex.IndexBuilderStd(blockMgrBuilder, blockMgrBuilder) ;
+ NodeTableBuilder nodeTableBuilder = new BuilderStdDB.NodeTableBuilderStd(indexBuilderNT, objectFileBuilder) ;
+ setupRecord(blockMgrBuilder, nodeTableBuilder) ;
}
-
- protected void set(BlockMgrBuilder blockMgrBuilder, NodeTableBuilder nodeTableBuilder) {
+
+ protected void setupRecord(BlockMgrBuilder blockMgrBuilder, NodeTableBuilder nodeTableBuilder) {
recorder = new Recorder() ;
BlockMgrBuilder blockMgrBuilderRec = new BlockMgrBuilderRecorder(blockMgrBuilder, recorder) ;
@@ -127,6 +131,11 @@ public class DatasetBuilderStd implements DatasetBuilder {
set(nodeTableBuilder, tupleIndexBuilder) ;
}
+ protected void set(NodeTableBuilder nodeTableBuilder, TupleIndexBuilder tupleIndexBuilder) {
+ this.nodeTableBuilder = nodeTableBuilder ;
+ this.tupleIndexBuilder = tupleIndexBuilder ;
+ }
+
private static void checkLocation(Location location) {
if ( location.isMem() )
@@ -144,14 +153,6 @@ public class DatasetBuilderStd implements DatasetBuilder {
error(log, "Directory not writeable: "+dirname) ;
}
- private void standardSetup() {
- ObjectFileBuilder objectFileBuilder = new BuilderStdDB.ObjectFileBuilderStd() ;
- BlockMgrBuilder blockMgrBuilder = new BuilderStdIndex.BlockMgrBuilderStd() ;
- IndexBuilder indexBuilderNT = new BuilderStdIndex.IndexBuilderStd(blockMgrBuilder, blockMgrBuilder) ;
- NodeTableBuilder nodeTableBuilder = new BuilderStdDB.NodeTableBuilderStd(indexBuilderNT, objectFileBuilder) ;
- set(blockMgrBuilder, nodeTableBuilder) ;
- }
-
@Override
public DatasetGraphTDB build(Location location, StoreParams params) {
// Ensure that there is global synchronization
@@ -182,8 +183,8 @@ public class DatasetBuilderStd implements DatasetBuilder {
ReorderTransformation transform = (_transform == null) ? chooseReorderTransformation(location) : _transform ;
- StorageConfig storageConfig = new StorageConfig(location, params, writeable,
- recorder.blockMgrs, recorder.bufferChannels, recorder.nodeTables) ;
+ StorageConfig storageConfig = new StorageConfig(location, params, writeable,
+ recorder.blockMgrs, recorder.objectFiles, recorder.bufferChannels, recorder.nodeTables) ;
recorder.finish() ;
@@ -377,13 +378,17 @@ public class DatasetBuilderStd implements DatasetBuilder {
void record(FileRef fileRef, BlockMgr blockMgr) ;
}
+ interface RecordObjectFile {
+ void record(FileRef fileRef, ObjectFile objFile);
+ }
+
interface RecordNodeTable {
void record(FileRef fileRef, NodeTable nodeTable) ;
}
static class NodeTableBuilderRecorder implements NodeTableBuilder {
- private NodeTableBuilder builder ;
- private RecordNodeTable recorder ;
+ private final NodeTableBuilder builder ;
+ private final RecordNodeTable recorder ;
NodeTableBuilderRecorder(NodeTableBuilder ntb, RecordNodeTable recorder) {
this.builder = ntb ;
@@ -401,9 +406,27 @@ public class DatasetBuilderStd implements DatasetBuilder {
}
+ static class ObjectFileBuilderRecorder implements ObjectFileBuilder {
+ private final ObjectFileBuilder builder ;
+ private final RecordObjectFile recorder ;
+
+ ObjectFileBuilderRecorder(ObjectFileBuilder objFileBuilder, RecordObjectFile recorder) {
+ this.builder = objFileBuilder ;
+ this.recorder = recorder ;
+ }
+
+ @Override
+ public ObjectFile buildObjectFile(FileSet fsObjectFile, String ext) {
+ ObjectFile objectFile = builder.buildObjectFile(fsObjectFile, ext);
+ FileRef ref = FileRef.create(fsObjectFile, ext) ;
+ recorder.record(ref, objectFile);
+ return objectFile;
+ }
+ }
+
static class BlockMgrBuilderRecorder implements BlockMgrBuilder {
- private BlockMgrBuilder builder ;
- private RecordBlockMgr recorder ;
+ private final BlockMgrBuilder builder ;
+ private final RecordBlockMgr recorder ;
BlockMgrBuilderRecorder(BlockMgrBuilder blkMgrBuilder, RecordBlockMgr recorder) {
this.builder = blkMgrBuilder ;
@@ -414,16 +437,19 @@ public class DatasetBuilderStd implements DatasetBuilder {
public BlockMgr buildBlockMgr(FileSet fileSet, String ext, IndexParams params) {
BlockMgr blkMgr = builder.buildBlockMgr(fileSet, ext, params) ;
FileRef ref = FileRef.create(fileSet, ext) ;
+ //System.err.println("Record (BlockMgr) = "+ref);
recorder.record(ref, blkMgr) ;
return blkMgr ;
}
}
- static class Recorder implements RecordBlockMgr, RecordNodeTable {
+ static class Recorder implements RecordBlockMgr, RecordObjectFile, RecordNodeTable {
Map<FileRef, BlockMgr> blockMgrs = null ;
+ Map<FileRef, ObjectFile> objectFiles = null ;
+ // Not used currently.
Map<FileRef, BufferChannel> bufferChannels = null ;
- Map<FileRef, NodeTable> nodeTables = null ;
+ Map<FileRef, NodeTable> nodeTables = null ;
boolean recording = false ;
Recorder() { }
@@ -433,15 +459,18 @@ public class DatasetBuilderStd implements DatasetBuilder {
throw new TDBException("Recorder already recording") ;
recording = true ;
blockMgrs = new HashMap<>() ;
+
+ objectFiles = new HashMap<>() ;
bufferChannels = new HashMap<>() ;
nodeTables = new HashMap<>() ;
}
void finish() {
if ( ! recording )
throw new TDBException("Recorder not recording") ;
+ // null out, not .clear.
blockMgrs = null ;
+ objectFiles = null ;
bufferChannels = null ;
- nodeTables = null ;
recording = false ;
}
@@ -453,6 +482,13 @@ public class DatasetBuilderStd implements DatasetBuilder {
}
@Override
+ public void record(FileRef fileRef, ObjectFile objFile) {
+ if ( recording )
+ // log.info("ObjectTable: "+fileRef) ;
+ objectFiles.put(fileRef, objFile);
+ }
+
+ @Override
public void record(FileRef fileRef, NodeTable nodeTable) {
if ( recording )
// log.info("NodeTable: "+fileRef) ;
http://git-wip-us.apache.org/repos/asf/jena/blob/3764a2ae/jena-tdb/src/main/java/org/apache/jena/tdb/store/StorageConfig.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/StorageConfig.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/StorageConfig.java
index 9c01f42..1da389b 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/StorageConfig.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/StorageConfig.java
@@ -23,29 +23,33 @@ import java.util.Map ;
import org.apache.jena.tdb.base.block.BlockMgr ;
import org.apache.jena.tdb.base.file.BufferChannel ;
import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.base.objectfile.ObjectFile;
import org.apache.jena.tdb.setup.StoreParams ;
-import org.apache.jena.tdb.store.nodetable.NodeTable ;
+import org.apache.jena.tdb.store.nodetable.NodeTable;
import org.apache.jena.tdb.sys.FileRef ;
public class StorageConfig
{
public final StoreParams params ;
public final Map<FileRef, BlockMgr> blockMgrs ;
- public final Map<FileRef, BufferChannel> bufferChannels ;
- public final Map<FileRef, NodeTable> nodeTables ;
+ public final Map<FileRef, ObjectFile> objectFiles;
+ public final Map<FileRef, BufferChannel> bufferChannels;
+ public final Map<FileRef, NodeTable> nodeTables;
public final Location location ;
public final boolean writeable ;
public StorageConfig(Location location, StoreParams params, boolean writeable,
Map<FileRef, BlockMgr> blockMgrs,
- Map<FileRef, BufferChannel> bufferChannels,
+ Map<FileRef, ObjectFile> objectFiles,
+ Map<FileRef, BufferChannel> bufferChannels,
Map<FileRef, NodeTable> nodeTables)
{
this.location = location ;
this.params = params ;
this.blockMgrs = blockMgrs ;
+ this.objectFiles = objectFiles ;
this.bufferChannels = bufferChannels ;
- this.nodeTables = nodeTables ;
+ this.nodeTables = nodeTables;
this.writeable = writeable ;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/3764a2ae/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetable/NodeTableNative.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetable/NodeTableNative.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetable/NodeTableNative.java
index 51ceee1..9974c5d 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetable/NodeTableNative.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/nodetable/NodeTableNative.java
@@ -228,23 +228,24 @@ public class NodeTableNative implements NodeTable
}
@Override
- public void sync()
- {
- if ( syncNeeded )
- {
- if ( nodeHashToId != null )
- nodeHashToId.sync() ;
+ public void sync() {
+ if ( syncNeeded ) {
if ( getObjects() != null )
- getObjects().sync() ;
- syncNeeded = false ;
+ getObjects().sync();
+ if ( nodeHashToId != null )
+ nodeHashToId.sync();
+ syncNeeded = false;
}
}
- public ObjectFile getObjects()
- {
+ public ObjectFile getObjects() {
return objects;
}
-
+
+ public Index getIndex() {
+ return nodeHashToId;
+ }
+
@Override
public String toString() { return objects.getLabel() ; }
http://git-wip-us.apache.org/repos/asf/jena/blob/3764a2ae/jena-tdb/src/main/java/org/apache/jena/tdb/sys/SetupTDB.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/sys/SetupTDB.java b/jena-tdb/src/main/java/org/apache/jena/tdb/sys/SetupTDB.java
index 29ff118..bbed8eb 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/sys/SetupTDB.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/sys/SetupTDB.java
@@ -104,55 +104,10 @@ public class SetupTDB
}
public static RecordFactory makeRecordFactory(int keyLen, int valueLen)
- {
- return SetupIndex.makeRecordFactory(keyLen, valueLen) ;
- }
- //
- // /** Make a NodeTable without cache and inline wrappers */
- // public static NodeTable makeNodeTableBase(Location location, String indexNode2Id, String indexId2Node)
- // {
- // if (location.isMem())
- // return NodeTableFactory.createMem() ;
- //
- // // -- make id to node mapping -- Names.indexId2Node
- // FileSet fsIdToNode = new FileSet(location, indexId2Node) ;
- //
- // ObjectFile stringFile = makeObjectFile(fsIdToNode) ;
- //
- // // -- make node to id mapping -- Names.indexNode2Id
- // // Make index of id to node (data table)
- //
- // // No caching at the index level - we use the internal caches of the node table.
- // Index nodeToId = makeIndex(location, indexNode2Id, LenNodeHash, SizeOfNodeId, -1 ,-1) ;
- //
- // // -- Make the node table using the components established above.
- // NodeTable nodeTable = new NodeTableNative(nodeToId, stringFile) ;
- // return nodeTable ;
- // }
- //
- // /** Make a NodeTable with cache and inline wrappers */
- // public static NodeTable makeNodeTable(Location location)
- // {
- // return makeNodeTable(location,
- // Names.indexNode2Id, SystemTDB.Node2NodeIdCacheSize,
- // Names.indexId2Node, SystemTDB.NodeId2NodeCacheSize,
- // SystemTDB.NodeMissCacheSize) ;
- // }
- //
- // /** Make a NodeTable with cache and inline wrappers */
- // public static NodeTable makeNodeTable(Location location,
- // String indexNode2Id, int nodeToIdCacheSize,
- // String indexId2Node, int idToNodeCacheSize,
- // int nodeMissCacheSize)
- // {
- // NodeTable nodeTable = makeNodeTableBase(location, indexNode2Id, indexId2Node) ;
- // nodeTable = NodeTableCache.create(nodeTable, nodeToIdCacheSize, idToNodeCacheSize, nodeMissCacheSize) ;
- // nodeTable = NodeTableInline.create(nodeTable) ;
- // return nodeTable ;
- // }
- //
+ {
+ return SetupIndex.makeRecordFactory(keyLen, valueLen) ;
+ }
- // XXX Move to FileFactory
public static ObjectFile makeObjectFile(FileSet fsIdToNode)
{
String filename = fsIdToNode.filename(Names.extNodeData) ;
http://git-wip-us.apache.org/repos/asf/jena/blob/3764a2ae/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetBuilderTxn.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetBuilderTxn.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetBuilderTxn.java
index 1a052f4..7a3adb5 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetBuilderTxn.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetBuilderTxn.java
@@ -25,53 +25,52 @@ import org.apache.jena.tdb.TDBException ;
import org.apache.jena.tdb.base.block.BlockMgr ;
import org.apache.jena.tdb.base.block.BlockMgrLogger ;
import org.apache.jena.tdb.base.block.BlockMgrReadonly ;
-import org.apache.jena.tdb.base.file.FileFactory ;
+import org.apache.jena.tdb.base.file.FileFactory;
import org.apache.jena.tdb.base.file.FileSet ;
import org.apache.jena.tdb.base.objectfile.ObjectFile ;
-import org.apache.jena.tdb.base.record.RecordFactory ;
-import org.apache.jena.tdb.index.Index ;
-import org.apache.jena.tdb.index.IndexMap ;
-import org.apache.jena.tdb.index.IndexParams ;
-import org.apache.jena.tdb.setup.BlockMgrBuilder ;
-import org.apache.jena.tdb.setup.DatasetBuilderStd ;
-import org.apache.jena.tdb.setup.NodeTableBuilder ;
-import org.apache.jena.tdb.setup.StoreParams ;
+import org.apache.jena.tdb.base.objectfile.ObjectFileReadonly;
+import org.apache.jena.tdb.base.record.RecordFactory;
+import org.apache.jena.tdb.index.*;
+import org.apache.jena.tdb.setup.*;
import org.apache.jena.tdb.store.DatasetGraphTDB ;
-import org.apache.jena.tdb.store.nodetable.NodeTable ;
-import org.apache.jena.tdb.store.nodetable.NodeTableInline ;
-import org.apache.jena.tdb.store.nodetable.NodeTableReadonly ;
+import org.apache.jena.tdb.store.nodetable.NodeTable;
+import org.apache.jena.tdb.store.nodetable.NodeTableInline;
+import org.apache.jena.tdb.store.nodetable.NodeTableReadonly;
import org.apache.jena.tdb.sys.FileRef ;
-import org.apache.jena.tdb.sys.Names ;
-import org.apache.jena.tdb.sys.SystemTDB ;
+import org.apache.jena.tdb.sys.Names;
+import org.apache.jena.tdb.sys.SystemTDB;
public class DatasetBuilderTxn
{
// Ideally, don't make a DatasetGraphTDB to pass to new DatasetGraphTxn as it rips it apart.
// Context for the build.
- private TransactionManager txnMgr ;
- private Map<FileRef, BlockMgr> blockMgrs ;
- private Map<FileRef, NodeTable> nodeTables ;
- private Transaction txn ;
- private DatasetGraphTDB dsg ;
-
- public DatasetBuilderTxn(TransactionManager txnMgr) { this.txnMgr = txnMgr ; }
-
- public DatasetGraphTxn build(Transaction transaction, ReadWrite mode, DatasetGraphTDB dsg) {
+ private final TransactionManager txnMgr ;
+ private final Map<FileRef, BlockMgr> blockMgrs ;
+ private final Map<FileRef, ObjectFile> objectFiles;
+ private final Map<FileRef, NodeTable> nodeTables;
+ private final DatasetGraphTDB dsg ;
+ private Transaction txn;
+
+ public DatasetBuilderTxn(TransactionManager txnMgr, DatasetGraphTDB dsg) {
+ this.txnMgr = txnMgr ;
this.blockMgrs = dsg.getConfig().blockMgrs ;
+ this.objectFiles = dsg.getConfig().objectFiles ;
this.nodeTables = dsg.getConfig().nodeTables ;
- this.txn = transaction ;
this.dsg = dsg ;
-
+ }
+
+ DatasetGraphTxn build(Transaction txn, ReadWrite mode) {
+ this.txn = txn;
DatasetGraphTDB dsgTDB ;
-
+
switch(mode)
{
- case READ : dsgTDB = buildReadonly() ; break ;
- case WRITE : dsgTDB = buildWritable() ; break ;
- default: dsgTDB = null ; // Silly Java.
+ case READ : dsgTDB = buildReadonly() ; break ;
+ case WRITE : dsgTDB = buildWritable() ; break ;
+ default: dsgTDB = null ;
}
-
+
DatasetGraphTxn dsgTxn = new DatasetGraphTxn(dsgTDB, txn) ;
// Copy context. Changes not propagated back to the base dataset.
dsgTxn.getContext().putAll(dsg.getContext()) ;
@@ -79,17 +78,16 @@ public class DatasetBuilderTxn
}
private DatasetGraphTDB buildReadonly() {
- BlockMgrBuilder blockMgrBuilder = new BlockMgrBuilderReadonly() ;
- NodeTableBuilder nodeTableBuilder = new NodeTableBuilderReadonly() ;
+ BlockMgrBuilder blockMgrBuilder = new BlockMgrBuilderReadonly();
+ NodeTableBuilder nodeTableBuilder = new NodeTableBuilderReadonly();
DatasetBuilderStd x = new DatasetBuilderStd(blockMgrBuilder, nodeTableBuilder) ;
DatasetGraphTDB dsg2 = x._build(dsg.getLocation(), dsg.getConfig().params, false, dsg.getReorderTransform()) ;
-
return dsg2 ;
}
private DatasetGraphTDB buildWritable() {
BlockMgrBuilder blockMgrBuilder = new BlockMgrBuilderTx() ;
- NodeTableBuilder nodeTableBuilder = new NodeTableBuilderTx() ;
+ NodeTableBuilder nodeTableBuilder = new NodeTableBuilderTx();
DatasetBuilderStd x = new DatasetBuilderStd(blockMgrBuilder, nodeTableBuilder) ;
DatasetGraphTDB dsg2 = x._build(dsg.getLocation(), dsg.getConfig().params, true, dsg.getReorderTransform()) ;
dsg2.getContext().putAll(dsg.getContext()) ;
@@ -135,7 +133,10 @@ public class DatasetBuilderTxn
else
objectFile = FileFactory.createObjectFileDisk(objFilename) ;
- NodeTableTrans ntt = new NodeTableTrans(txn, fsObjectFile.getBasename(), ntBase, idx, objectFile) ;
+ // Allow for a modified base NodeTable.
+ NodeTable ntBaseTrans = ntBase;
+
+ NodeTableTrans ntt = new NodeTableTrans(txn, fsObjectFile.getBasename(), ntBaseTrans, idx, objectFile) ;
txn.addComponent(ntt) ;
// Add inline wrapper.
@@ -159,6 +160,22 @@ public class DatasetBuilderTxn
}
}
+ // Object files currently, don't need journalling. Because they aer apend only, they
+ // are "self journalling" - can append to them which used read-only elsewhere if the
+ // index to access them is transactional.
+// class ObjectFileBuilderTx implements ObjectFileBuilder
+// {
+// @Override
+// public ObjectFile buildObjectFile(FileSet fileSet, String ext) {
+// FileRef ref = FileRef.create(fileSet, ext) ;
+// ObjectFile baseObjFile = objectFiles.get(ref);
+// if ( baseObjFile == null )
+// throw new TDBException("No ObjectFile for " + ref) ;
+// ObjectFileJournal objFile = new ObjectFileJournal(txn, ref, baseObjectFile);
+// return objFile;
+// }
+// }
+
// ---- Build passthrough versions for readonly access
class BlockMgrBuilderReadonly implements BlockMgrBuilder
@@ -184,4 +201,18 @@ public class DatasetBuilderTxn
return nt ;
}
}
+
+ class ObjectFileBuilderReadonly implements ObjectFileBuilder
+ {
+ @Override
+ public ObjectFile buildObjectFile(FileSet fileSet, String ext) {
+ FileRef ref = FileRef.create(fileSet, ext) ;
+ ObjectFile objFile = objectFiles.get(ref);
+ if ( objFile == null )
+ throw new TDBException("No ObjectFile for " + ref) ;
+ objFile = new ObjectFileReadonly(objFile) ;
+ return objFile;
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/jena/blob/3764a2ae/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java
index a2282c6..f384908 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java
@@ -29,22 +29,23 @@ import java.util.Iterator ;
import org.apache.jena.atlas.iterator.Iter ;
import org.apache.jena.atlas.lib.FileOps ;
+import org.apache.jena.atlas.logging.FmtLog;
import org.apache.jena.tdb.TDBException ;
import org.apache.jena.tdb.base.block.Block ;
import org.apache.jena.tdb.base.block.BlockMgr ;
import org.apache.jena.tdb.base.file.BufferChannel ;
import org.apache.jena.tdb.base.file.BufferChannelFile ;
-import org.apache.jena.tdb.base.file.FileFactory ;
+import org.apache.jena.tdb.base.file.FileFactory;
import org.apache.jena.tdb.base.file.Location ;
-import org.apache.jena.tdb.base.objectfile.ObjectFile ;
-import org.apache.jena.tdb.base.record.RecordFactory ;
-import org.apache.jena.tdb.index.IndexMap ;
+import org.apache.jena.tdb.base.objectfile.ObjectFile;
+import org.apache.jena.tdb.base.record.RecordFactory;
+import org.apache.jena.tdb.index.IndexMap;
import org.apache.jena.tdb.store.DatasetGraphTDB ;
import org.apache.jena.tdb.store.StorageConfig ;
-import org.apache.jena.tdb.store.nodetable.NodeTable ;
+import org.apache.jena.tdb.store.nodetable.NodeTable;
import org.apache.jena.tdb.sys.FileRef ;
import org.apache.jena.tdb.sys.Names ;
-import org.apache.jena.tdb.sys.SystemTDB ;
+import org.apache.jena.tdb.sys.SystemTDB;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
@@ -91,8 +92,12 @@ public class JournalControl
if ( journal == null || journal.isEmpty() )
return ;
+
for ( FileRef fileRef : dsg.getConfig().nodeTables.keySet() )
recoverNodeDat(dsg, fileRef) ;
+ // Not used currently.
+// for ( FileRef fileRef : dsg.getConfig().objectFiles.keySet() )
+// recoverObjectFile(dsg, fileRef) ;
recoverFromJournal(dsg.getConfig(), journal) ;
journal.close() ;
@@ -196,6 +201,10 @@ public class JournalControl
} finally { Iter.close(iter) ; }
}
+ private static void recoverObjectFile(DatasetGraphTDB dsg, FileRef fileRef) {
+ FmtLog.warn(log, "Not recovered: recoverObjectFile[%s]", fileRef);
+ }
+
/** Recover a node data file (".dat").
* Node data files are append-only so recovering, then not using the data is safe.
* Node data file is a precursor for full recovery that works from the master journal.
http://git-wip-us.apache.org/repos/asf/jena/blob/3764a2ae/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
index 433da45..c87b977 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
@@ -466,7 +466,7 @@ public class TransactionManager
}
}
- DatasetGraphTxn dsgTxn = new DatasetBuilderTxn(this).build(txn, mode, dsg) ;
+ DatasetGraphTxn dsgTxn = new DatasetBuilderTxn(this, dsg).build(txn, mode);
if ( mode == ReadWrite.READ ) {
// If a READ transaction, cache the storage view.
// This is cleared when a WRITE commits