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/12/11 22:28:48 UTC
svn commit: r1213078 - in /incubator/jena/Jena2/TDB/trunk/src:
main/java/com/hp/hpl/jena/tdb/mgt/ main/java/com/hp/hpl/jena/tdb/nodetable/
main/java/com/hp/hpl/jena/tdb/setup/ main/java/com/hp/hpl/jena/tdb/store/
main/java/com/hp/hpl/jena/tdb/sys/ main...
Author: andy
Date: Sun Dec 11 21:28:47 2011
New Revision: 1213078
URL: http://svn.apache.org/viewvc?rev=1213078&view=rev
Log:
Expose setting of the node miss cache in NodeTableCache.
Modified:
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfoMBean.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/Builder.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/NodeTableBuilder.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tools/dumpnodetable.java
incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/nodetable/TestNodeTable.java
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java Sun Dec 11 21:28:47 2011
@@ -37,4 +37,7 @@ public class TDBSystemInfo implements TD
public int getNode2NodeIdCacheSize() { return SystemTDB.Node2NodeIdCacheSize ; }
@Override
public int getNodeId2NodeCacheSize() { return SystemTDB.NodeId2NodeCacheSize ; }
+
+ @Override
+ public int getNodeMissCacheSize() { return SystemTDB.NodeMissCacheSize ; }
}
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfoMBean.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfoMBean.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfoMBean.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfoMBean.java Sun Dec 11 21:28:47 2011
@@ -41,6 +41,12 @@ public interface TDBSystemInfoMBean
* Used for retriveing results.
*/
public int getNodeId2NodeCacheSize() ;
+
+ /** Size of NodeTable lookup miss cache
+ */
+ public int getNodeMissCacheSize() ;
+
+
/** Size of the delayed-write block cache (32 bit systems only) (per file) */
public int getBlockWriteCacheSize() ;
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableCache.java Sun Dec 11 21:28:47 2011
@@ -20,6 +20,7 @@ package com.hp.hpl.jena.tdb.nodetable;
import java.util.Iterator ;
+import org.openjena.atlas.iterator.Iter ;
import org.openjena.atlas.lib.Cache ;
import org.openjena.atlas.lib.CacheFactory ;
import org.openjena.atlas.lib.CacheSet ;
@@ -28,6 +29,7 @@ import org.openjena.atlas.logging.Log ;
import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.tdb.TDBException ;
import com.hp.hpl.jena.tdb.store.NodeId ;
/** Cache wrapper around a NodeTable.
@@ -43,25 +45,26 @@ public class NodeTableCache implements N
// A small cache of "known unknowns" to speed up searching for impossible things.
// Cache update needed on NodeTable changes because a node may become "known"
- private CacheSet<Node> notPresent ;
+ private CacheSet<Node> notPresent = null ;
private NodeTable baseTable ;
private Object lock = new Object() ;
- public static NodeTable create(NodeTable nodeTable, int nodeToIdCacheSize, int idToNodeCacheSize)
+ public static NodeTable create(NodeTable nodeTable, int nodeToIdCacheSize, int idToNodeCacheSize, int nodeMissesCacheSize)
{
if ( nodeToIdCacheSize <= 0 && idToNodeCacheSize <= 0 )
return nodeTable ;
- return new NodeTableCache(nodeTable, nodeToIdCacheSize, idToNodeCacheSize) ;
+ return new NodeTableCache(nodeTable, nodeToIdCacheSize, idToNodeCacheSize, nodeMissesCacheSize) ;
}
- private NodeTableCache(NodeTable baseTable, int nodeToIdCacheSize, int idToNodeCacheSize)
+ private NodeTableCache(NodeTable baseTable, int nodeToIdCacheSize, int idToNodeCacheSize, int nodeMissesCacheSize)
{
this.baseTable = baseTable ;
if ( nodeToIdCacheSize > 0)
node2id_Cache = CacheFactory.createCache(nodeToIdCacheSize) ;
if ( idToNodeCacheSize > 0)
id2node_Cache = CacheFactory.createCache(idToNodeCacheSize) ;
- notPresent = CacheFactory.createCacheSet(100) ;
+ if ( nodeMissesCacheSize > 0 )
+ notPresent = CacheFactory.createCacheSet(nodeMissesCacheSize) ;
}
/** Get the Node for this NodeId, or null if none */
@@ -140,9 +143,11 @@ public class NodeTableCache implements N
/** Check caches to see if we can map a Node to a NodeId. Returns null on no cache entry. */
private NodeId cacheLookup(Node node)
{
- // Remember things known (currently) not to exist
- if ( notPresent.contains(node) ) return null ;
- if ( node2id_Cache == null ) return null ;
+ // Remember things known (currently) not to exist
+ if ( notPresent != null && notPresent.contains(node) )
+ return null ;
+ if ( node2id_Cache == null )
+ return null ;
return node2id_Cache.get(node) ;
}
@@ -155,7 +160,8 @@ public class NodeTableCache implements N
// This must be specially handled later if the node is added.
if ( NodeId.isDoesNotExist(id) )
{
- notPresent.add(node) ;
+ if ( notPresent != null )
+ notPresent.add(node) ;
return ;
}
@@ -170,7 +176,7 @@ public class NodeTableCache implements N
if ( id2node_Cache != null )
id2node_Cache.put(id, node) ;
// Remove if previously marked "not present"
- if ( notPresent.contains(node) )
+ if ( notPresent != null && notPresent.contains(node) )
notPresent.remove(node) ;
}
// ----
@@ -215,9 +221,39 @@ public class NodeTableCache implements N
@Override
public Iterator<Pair<NodeId, Node>> all()
{
+ if ( false )
+ testForConsistency() ;
return baseTable.all() ;
}
+ private void testForConsistency()
+ {
+ Iterator<Node> iter1 = Iter.toList(node2id_Cache.keys()).iterator() ;
+
+ for ( ; iter1.hasNext() ; )
+ {
+ Node n = iter1.next() ;
+
+ NodeId nId = node2id_Cache.get(n) ;
+ if ( !id2node_Cache.containsKey(nId) )
+ throw new TDBException("Inconsistent: "+n+" => "+nId) ;
+ if ( notPresent.contains(n) )
+ throw new TDBException("Inconsistent: "+n+" in notPresent cache (1)") ;
+ }
+ Iterator<NodeId> iter2 = Iter.toList(id2node_Cache.keys()).iterator() ; ;
+ for ( ; iter2.hasNext() ; )
+ {
+ NodeId nId = iter2.next() ;
+ Node n = id2node_Cache.get(nId) ;
+ if ( !node2id_Cache.containsKey(n) )
+ throw new TDBException("Inconsistent: "+nId+" => "+n) ;
+ if ( notPresent.contains(n) )
+ throw new TDBException("Inconsistent: "+n+" in notPresent cache (2)") ;
+ }
+
+
+ }
+
@Override
public String toString() { return "Cache("+baseTable.toString()+")" ; }
}
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java Sun Dec 11 21:28:47 2011
@@ -61,13 +61,14 @@ public class NodeTableFactory
return create(indexBuilder, filesetNodeTable, filesetIdx,
SetupTDB.systemInfo.getNode2NodeIdCacheSize(),
- SetupTDB.systemInfo.getNodeId2NodeCacheSize()) ;
+ SetupTDB.systemInfo.getNodeId2NodeCacheSize(),
+ SetupTDB.systemInfo.getNodeMissCacheSize()) ;
}
/** Custom node table */
public static NodeTable create(IndexBuilder indexBuilder,
FileSet fsIdToNode, FileSet fsNodeToId,
- int nodeToIdCacheSize, int idToNodeCacheSize)
+ int nodeToIdCacheSize, int idToNodeCacheSize, int nodeMissCacheSize)
{
String filename = fsIdToNode.filename(Names.extNodeData) ;
@@ -77,7 +78,7 @@ public class NodeTableFactory
ObjectFile objects = FileFactory.createObjectFileMem(filename) ;
NodeTable nodeTable = new NodeTableNative(nodeToId, objects) ;
- nodeTable = NodeTableCache.create(nodeTable, 100, 100) ;
+ nodeTable = NodeTableCache.create(nodeTable, 100, 100, 100) ;
nodeTable = NodeTableInline.create(nodeTable) ;
return nodeTable ;
@@ -89,7 +90,7 @@ public class NodeTableFactory
// Node table.
ObjectFile objects = FileFactory.createObjectFileDisk(filename);
NodeTable nodeTable = new NodeTableNative(nodeToId, objects) ;
- nodeTable = NodeTableCache.create(nodeTable, nodeToIdCacheSize, idToNodeCacheSize) ;
+ nodeTable = NodeTableCache.create(nodeTable, nodeToIdCacheSize, idToNodeCacheSize, nodeMissCacheSize) ;
nodeTable = NodeTableInline.create(nodeTable) ;
return nodeTable ;
@@ -97,7 +98,7 @@ public class NodeTableFactory
public static NodeTable createMem(IndexBuilder indexBuilder)
{
- return create(indexBuilder, FileSet.mem(), FileSet.mem(), 100, 100) ;
+ return create(indexBuilder, FileSet.mem(), FileSet.mem(), 100, 100, 10) ;
}
public static NodeTable createSink(IndexBuilder indexBuilder, Location location)
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/Builder.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/Builder.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/Builder.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/Builder.java Sun Dec 11 21:28:47 2011
@@ -79,13 +79,13 @@ public class Builder
}
@Override
- public NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile, int sizeNode2NodeIdCache, int sizeNodeId2NodeCache)
+ public NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile, int sizeNode2NodeIdCache, int sizeNodeId2NodeCache, int sizeNodeMissCacheSize)
{
RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId) ;
Index idx = indexBuilder.buildIndex(fsIndex, recordFactory) ;
ObjectFile objectFile = objectFileBuilder.buildObjectFile(fsObjectFile, Names.extNodeData) ;
NodeTable nodeTable = new NodeTableNative(idx, objectFile) ;
- nodeTable = NodeTableCache.create(nodeTable, sizeNode2NodeIdCache, sizeNodeId2NodeCache) ;
+ nodeTable = NodeTableCache.create(nodeTable, sizeNode2NodeIdCache, sizeNodeId2NodeCache, sizeNodeMissCacheSize) ;
nodeTable = NodeTableInline.create(nodeTable) ;
return nodeTable ;
}
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java Sun Dec 11 21:28:47 2011
@@ -183,7 +183,7 @@ public class DatasetBuilderStd implement
NodeTable nodeTable = makeNodeTable(location,
params.indexNode2Id, params.indexId2Node,
- params.Node2NodeIdCacheSize, params.NodeId2NodeCacheSize) ;
+ params.Node2NodeIdCacheSize, params.NodeId2NodeCacheSize, params.NodeMissCacheSize) ;
TripleTable tripleTable = makeTripleTable(location, nodeTable, policy) ;
QuadTable quadTable = makeQuadTable(location, nodeTable, policy) ;
@@ -297,7 +297,7 @@ public class DatasetBuilderStd implement
String pnId2Node = metafile.getOrSetDefault("tdb.prefixes.nodetable.mapping.id2node", params.prefixId2Node) ;
// No cache - the prefix mapping is a cache
- NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, pnId2Node, -1, -1) ;
+ NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, pnId2Node, -1, -1, -1) ;
DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixIndexes, prefixNodes, policy) ;
@@ -355,7 +355,7 @@ public class DatasetBuilderStd implement
// ----
protected NodeTable makeNodeTable(Location location, String indexNode2Id, String indexId2Node,
- int sizeNode2NodeIdCache, int sizeNodeId2NodeCache)
+ int sizeNode2NodeIdCache, int sizeNodeId2NodeCache, int sizeNodeMissCache)
{
/* Physical
* ---- An object file
@@ -375,7 +375,7 @@ public class DatasetBuilderStd implement
metafile.checkOrSetMetadata("tdb.file.impl.version", "dat-v1") ;
metafile.checkOrSetMetadata("tdb.object.encoding", "sse") ;
- NodeTable nt = nodeTableBuilder.buildNodeTable(fsNodeToId, fsId2Node, sizeNode2NodeIdCache, sizeNodeId2NodeCache) ;
+ NodeTable nt = nodeTableBuilder.buildNodeTable(fsNodeToId, fsId2Node, sizeNode2NodeIdCache, sizeNodeId2NodeCache, sizeNodeMissCache) ;
fsNodeToId.getMetaFile().flush() ;
fsId2Node.getMetaFile().flush() ;
return nt ;
@@ -405,6 +405,7 @@ public class DatasetBuilderStd implement
final int writeCacheSize = SystemTDB.BlockWriteCacheSize ;
final int Node2NodeIdCacheSize = SystemTDB.Node2NodeIdCacheSize ;
final int NodeId2NodeCacheSize = SystemTDB.NodeId2NodeCacheSize ;
+ final int NodeMissCacheSize = SystemTDB.NodeMissCacheSize ;
final String indexNode2Id = Names.indexNode2Id ;
final String indexId2Node = Names.indexId2Node ;
@@ -443,9 +444,9 @@ public class DatasetBuilderStd implement
@Override
public NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile, int sizeNode2NodeIdCache,
- int sizeNodeId2NodeCache)
+ int sizeNodeId2NodeCache, int sizeNodeMissCacheSize)
{
- NodeTable nt = builder.buildNodeTable(fsIndex, fsObjectFile, sizeNode2NodeIdCache, sizeNodeId2NodeCache) ;
+ NodeTable nt = builder.buildNodeTable(fsIndex, fsObjectFile, sizeNode2NodeIdCache, sizeNodeId2NodeCache, sizeNodeMissCacheSize) ;
// It just knows, right?
FileRef ref = FileRef.create(fsObjectFile.filename(Names.extNodeData)) ;
recorder.record(ref, nt) ;
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/NodeTableBuilder.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/NodeTableBuilder.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/NodeTableBuilder.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/setup/NodeTableBuilder.java Sun Dec 11 21:28:47 2011
@@ -22,5 +22,6 @@ import com.hp.hpl.jena.tdb.base.file.Fil
import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
public interface NodeTableBuilder {
- NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile, int sizeNode2NodeIdCache, int sizeNodeId2NodeCache) ;
+ NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile,
+ int sizeNode2NodeIdCache, int sizeNodeId2NodeCache, int sizeNodeMissCache) ;
}
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java Sun Dec 11 21:28:47 2011
@@ -90,7 +90,7 @@ public class DatasetPrefixesTDB implemen
if ( location != null )
filesetNodeTable = new FileSet(location, Names.prefixId2Node) ;
- NodeTable nodes = NodeTableFactory.create(indexBuilder, filesetNodeTable, filesetNodeTableIdx, -1, -1) ;
+ NodeTable nodes = NodeTableFactory.create(indexBuilder, filesetNodeTable, filesetNodeTableIdx, -1, -1, -1) ;
nodeTupleTable = new NodeTupleTableConcrete(3, indexes, nodes, policy) ;
}
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/Names.java Sun Dec 11 21:28:47 2011
@@ -132,6 +132,7 @@ public class Names
public static final String pNode2NodeIdCacheSize = "tdb.cache.node2nodeid.size" ;
public static final String pNodeId2NodeCacheSize = "tdb.cache.nodeid2node.size" ;
+ public static final String pNodeMissesCacheSize = "tdb.cache.nodeMiss.size" ;
public static final String pBlockWriteCacheSize = "tdb.cache.blockwrite.size" ;
public static final String pBlockReadCacheSize = "tdb.cache.blockread.size" ;
public static final String pSyncTick = "tdb.synctick" ;
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java Sun Dec 11 21:28:47 2011
@@ -26,6 +26,7 @@ import static com.hp.hpl.jena.tdb.sys.Sy
import static com.hp.hpl.jena.tdb.sys.SystemTDB.LenNodeHash ;
import static com.hp.hpl.jena.tdb.sys.SystemTDB.Node2NodeIdCacheSize ;
import static com.hp.hpl.jena.tdb.sys.SystemTDB.NodeId2NodeCacheSize ;
+import static com.hp.hpl.jena.tdb.sys.SystemTDB.NodeMissCacheSize ;
import static com.hp.hpl.jena.tdb.sys.SystemTDB.SizeOfNodeId ;
import java.io.IOException ;
@@ -52,25 +53,12 @@ import com.hp.hpl.jena.tdb.base.file.Loc
import com.hp.hpl.jena.tdb.base.file.MetaFile ;
import com.hp.hpl.jena.tdb.base.objectfile.ObjectFile ;
import com.hp.hpl.jena.tdb.base.record.RecordFactory ;
-import com.hp.hpl.jena.tdb.index.Index ;
-import com.hp.hpl.jena.tdb.index.IndexBuilder ;
-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.index.* ;
import com.hp.hpl.jena.tdb.index.bplustree.BPlusTree ;
import com.hp.hpl.jena.tdb.index.bplustree.BPlusTreeParams ;
import com.hp.hpl.jena.tdb.mgt.TDBSystemInfoMBean ;
-import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
-import com.hp.hpl.jena.tdb.nodetable.NodeTableCache ;
-import com.hp.hpl.jena.tdb.nodetable.NodeTableFactory ;
-import com.hp.hpl.jena.tdb.nodetable.NodeTableInline ;
-import com.hp.hpl.jena.tdb.nodetable.NodeTableNative ;
-import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
-import com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB ;
-import com.hp.hpl.jena.tdb.store.NodeId ;
-import com.hp.hpl.jena.tdb.store.QuadTable ;
-import com.hp.hpl.jena.tdb.store.StoreConfig ;
-import com.hp.hpl.jena.tdb.store.TripleTable ;
+import com.hp.hpl.jena.tdb.nodetable.* ;
+import com.hp.hpl.jena.tdb.store.* ;
/** Makes things: datasets from locations, indexes */
@@ -111,6 +99,7 @@ public class SetupTDB
static {
globalConfig.setProperty(Names.pNode2NodeIdCacheSize, Integer.toString(Node2NodeIdCacheSize)) ;
globalConfig.setProperty(Names.pNodeId2NodeCacheSize, Integer.toString(NodeId2NodeCacheSize)) ;
+ globalConfig.setProperty(Names.pNodeMissesCacheSize, Integer.toString(NodeMissCacheSize)) ;
globalConfig.setProperty(Names.pBlockWriteCacheSize, Integer.toString(BlockWriteCacheSize)) ;
globalConfig.setProperty(Names.pBlockReadCacheSize, Integer.toString(BlockReadCacheSize)) ;
// globalConfig.setProperty(Names.pSyncTick, Integer.toString(SyncTick)) ;
@@ -124,6 +113,8 @@ public class SetupTDB
public int getNodeId2NodeCacheSize() { return getIntProperty(Names.pNodeId2NodeCacheSize); }
@Override
public int getNode2NodeIdCacheSize() { return getIntProperty(Names.pNode2NodeIdCacheSize); }
+ @Override
+ public int getNodeMissCacheSize() { return getIntProperty(Names.pNodeMissesCacheSize); }
@Override
public int getBlockWriteCacheSize() { return getIntProperty(Names.pBlockWriteCacheSize); }
@Override
@@ -253,11 +244,13 @@ public class SetupTDB
int n2idCacheSize = PropertyUtils.getPropertyAsInteger(config, Names.pNode2NodeIdCacheSize) ;
int id2nCacheSize = PropertyUtils.getPropertyAsInteger(config, Names.pNodeId2NodeCacheSize) ;
+ int nodeMissCacheSize = PropertyUtils.getPropertyAsInteger(config, Names.pNodeMissesCacheSize) ;
// Cache sizes should come from this.info.
NodeTable nodeTable = makeNodeTable(location,
indexNode2Id, n2idCacheSize,
- indexId2Node, id2nCacheSize) ;
+ indexId2Node, id2nCacheSize,
+ nodeMissCacheSize) ;
DatasetControl policy = createConcurrencyPolicy() ;
@@ -383,7 +376,7 @@ public class SetupTDB
String pnId2Node = metafile.getOrSetDefault("tdb.prefixes.nodetable.mapping.id2node", Names.prefixId2Node) ;
// No cache - the prefix mapping is a cache
- NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, -1, pnId2Node, -1) ;
+ NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, -1, pnId2Node, -1, -1) ;
DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixIndexes, prefixNodes, policy) ;
@@ -575,16 +568,18 @@ public class SetupTDB
{
return makeNodeTable(location,
Names.indexNode2Id, SystemTDB.Node2NodeIdCacheSize,
- Names.indexId2Node, SystemTDB.NodeId2NodeCacheSize) ;
+ 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)
+ String indexId2Node, int idToNodeCacheSize,
+ int nodeMissCacheSize)
{
NodeTable nodeTable = makeNodeTableBase(location, indexNode2Id, indexId2Node) ;
- nodeTable = NodeTableCache.create(nodeTable, nodeToIdCacheSize, idToNodeCacheSize) ;
+ nodeTable = NodeTableCache.create(nodeTable, nodeToIdCacheSize, idToNodeCacheSize, nodeMissCacheSize) ;
nodeTable = NodeTableInline.create(nodeTable) ;
return nodeTable ;
}
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java Sun Dec 11 21:28:47 2011
@@ -179,6 +179,10 @@ public class SystemTDB
*/
public static final int NodeId2NodeCacheSize = intValue("NodeId2NodeCacheSize", ( is64bitSystem ? 500*1000 : 50*1000 ) ) ;
+
+ /** Size of Node lookup miss cache. */
+ public static final int NodeMissCacheSize = 100 ;
+
/** Size of the delayed-write block cache (32 bit systems only) (per file) */
public static final int BlockWriteCacheSize = intValue("BlockWriteCacheSize", 2*1000) ;
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetBuilderTxn.java Sun Dec 11 21:28:47 2011
@@ -113,7 +113,7 @@ public class DatasetBuilderTxn
{
@Override
public NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile, int sizeNode2NodeIdCache,
- int sizeNodeId2NodeCache)
+ int sizeNodeId2NodeCache, int sizeNodeMissCacheSize)
{
FileRef ref = FileRef.create(fsObjectFile.filename(Names.extNodeData)) ;
NodeTable ntBase = nodeTables.get(ref) ;
@@ -175,8 +175,8 @@ public class DatasetBuilderTxn
{
@Override
- public NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile, int sizeNode2NodeIdCache,
- int sizeNodeId2NodeCache)
+ public NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile,
+ int sizeNode2NodeIdCache, int sizeNodeId2NodeCache, int sizeNodeMissCacheSize)
{
FileRef ref = FileRef.create(fsObjectFile.filename(Names.extNodeData)) ;
NodeTable nt = nodeTables.get(ref) ;
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java Sun Dec 11 21:28:47 2011
@@ -188,7 +188,7 @@ public class NodeTableTrans implements N
//debug("begin: base=%s offset=0x%X journalOffset=0x%X", base, offset, journalOffset) ;
this.nodeTableJournal = new NodeTableNative(nodeIndex, journalObjFile) ;
- this.nodeTableJournal = NodeTableCache.create(nodeTableJournal, CacheSize, CacheSize) ;
+ this.nodeTableJournal = NodeTableCache.create(nodeTableJournal, CacheSize, CacheSize, 100) ;
// This class knows about non-mappable inline values. mapToJournal(NodeId)/mapFromJournal.
this.nodeTableJournal = NodeTableInline.create(nodeTableJournal) ;
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tools/dumpnodetable.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tools/dumpnodetable.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tools/dumpnodetable.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tools/dumpnodetable.java Sun Dec 11 21:28:47 2011
@@ -72,22 +72,24 @@ public class dumpnodetable extends CmdGe
public static void dumpNodes(OutputStream w, String location)
{
- dump(w, location, Names.indexNode2Id, SystemTDB.Node2NodeIdCacheSize, Names.indexId2Node, SystemTDB.NodeId2NodeCacheSize) ;
+ dump(w, location, Names.indexNode2Id, SystemTDB.Node2NodeIdCacheSize, Names.indexId2Node, SystemTDB.NodeId2NodeCacheSize, SystemTDB.NodeMissCacheSize) ;
}
public static void dumpPrefixes(OutputStream w, String location)
{
- dump(w, location, Names.prefixNode2Id, 100, Names.prefixId2Node, 100) ;
+ dump(w, location, Names.prefixNode2Id, 100, Names.prefixId2Node, 100, 10) ;
}
public static void dump(OutputStream w, String location,
String indexNode2Id, int node2NodeIdCacheSize,
- String indexId2Node, int nodeId2NodeCacheSize)
+ String indexId2Node, int nodeId2NodeCacheSize,
+ int sizeNodeMissCacheSize)
{
NodeTable nodeTable = SetupTDB.makeNodeTable(new Location(location),
indexNode2Id, node2NodeIdCacheSize,
- indexId2Node, nodeId2NodeCacheSize) ;
+ indexId2Node, nodeId2NodeCacheSize,
+ sizeNodeMissCacheSize) ;
}
Modified: incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/nodetable/TestNodeTable.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/nodetable/TestNodeTable.java?rev=1213078&r1=1213077&r2=1213078&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/nodetable/TestNodeTable.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/test/java/com/hp/hpl/jena/tdb/nodetable/TestNodeTable.java Sun Dec 11 21:28:47 2011
@@ -28,6 +28,6 @@ public class TestNodeTable extends TestN
@Override
protected NodeTable createEmptyNodeTable()
{
- return SetupTDB.makeNodeTable(Location.mem(), Names.indexNode2Id, 10, Names.indexId2Node, 10) ;
+ return SetupTDB.makeNodeTable(Location.mem(), Names.indexNode2Id, 10, Names.indexId2Node, 10, 10) ;
}
}