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 2014/09/05 15:37:46 UTC
svn commit: r1622698 - in
/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb:
mgt/TDBSystemInfo.java nodetable/NodeTableFactory.java
nodetable/NodeTableWrapper.java setup/DatasetBuilderStd.java
setup/SystemParams.java sys/SetupTDB.java
Author: andy
Date: Fri Sep 5 13:37:46 2014
New Revision: 1622698
URL: http://svn.apache.org/r1622698
Log:
Encapsulate fields of SystemParams
Modified:
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParams.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java?rev=1622698&r1=1622697&r2=1622698&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/mgt/TDBSystemInfo.java Fri Sep 5 13:37:46 2014
@@ -28,15 +28,15 @@ public class TDBSystemInfo implements TD
@Override
public int getSegmentSize() { return SystemTDB.SegmentSize; }
@Override
- public int getNodeId2NodeCacheSize() { return params.NodeId2NodeCacheSize ; }
+ public int getNodeId2NodeCacheSize() { return params.getNodeId2NodeCacheSize() ; }
@Override
- public int getNode2NodeIdCacheSize() { return params.Node2NodeIdCacheSize ; }
+ public int getNode2NodeIdCacheSize() { return params.getNode2NodeIdCacheSize() ; }
@Override
- public int getNodeMissCacheSize() { return params.NodeMissCacheSize ; }
+ public int getNodeMissCacheSize() { return params.getNodeMissCacheSize() ; }
@Override
- public int getBlockSize() { return params.blockSize ; }
+ public int getBlockSize() { return params.getBlockSize() ; }
@Override
- public int getBlockReadCacheSize() { return params.readCacheSize ; }
+ public int getBlockReadCacheSize() { return params.getReadCacheSize() ; }
@Override
- public int getBlockWriteCacheSize() { return params.writeCacheSize ; }
+ public int getBlockWriteCacheSize() { return params.getWriteCacheSize() ; }
}
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java?rev=1622698&r1=1622697&r2=1622698&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableFactory.java Fri Sep 5 13:37:46 2014
@@ -47,9 +47,9 @@ public class NodeTableFactory
SystemParams params = SystemParams.getStdSystemParams() ;
return create(indexBuilder, filesetNodeTable, filesetIdx,
- params.Node2NodeIdCacheSize ,
- params.NodeId2NodeCacheSize ,
- params.NodeMissCacheSize ) ;
+ params.getNode2NodeIdCacheSize() ,
+ params.getNodeId2NodeCacheSize() ,
+ params.getNodeMissCacheSize() ) ;
}
/** Custom node table */
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java?rev=1622698&r1=1622697&r2=1622698&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodeTableWrapper.java Fri Sep 5 13:37:46 2014
@@ -61,7 +61,6 @@ public class NodeTableWrapper implements
return nodeTable.allocOffset() ;
}
-
@Override
public Iterator<Pair<NodeId, Node>> all()
{
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java?rev=1622698&r1=1622697&r2=1622698&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java Fri Sep 5 13:37:46 2014
@@ -62,7 +62,7 @@ public class DatasetBuilderStd implement
public static DatasetGraphTDB build(Location location)
{
DatasetBuilderStd x = new DatasetBuilderStd() ;
- x.setStd() ;
+ x.setup() ;
return x.build(location, null) ;
}
@@ -74,12 +74,13 @@ public class DatasetBuilderStd implement
public static DatasetBuilderStd stdBuilder()
{
DatasetBuilderStd x = new DatasetBuilderStd() ;
- x.setStd() ;
+ x.setup() ;
return x ;
}
- protected DatasetBuilderStd() {}
+ protected DatasetBuilderStd() { }
+ // Used by DatasetBuilderTxn
public DatasetBuilderStd(BlockMgrBuilder blockMgrBuilder,
NodeTableBuilder nodeTableBuilder)
{
@@ -109,7 +110,7 @@ public class DatasetBuilderStd implement
set(nodeTableBuilder, tupleIndexBuilder) ;
}
- protected void setStd()
+ protected void setup()
{
ObjectFileBuilder objectFileBuilder = new Builder.ObjectFileBuilderStd() ;
BlockMgrBuilder blockMgrBuilder = new Builder.BlockMgrBuilderStd() ;
@@ -132,6 +133,8 @@ public class DatasetBuilderStd implement
}
}
+ // Main engine for building.
+ // Called by DatasetBuilderTxn
public DatasetGraphTDB _build(Location location, SystemParams _params, boolean readonly, ReorderTransformation _transform)
{
params = _params ;
@@ -139,8 +142,8 @@ public class DatasetBuilderStd implement
DatasetControl policy = createConcurrencyPolicy() ;
NodeTable nodeTable = makeNodeTable(location,
- params.indexNode2Id, params.indexId2Node,
- params.Node2NodeIdCacheSize, params.NodeId2NodeCacheSize, params.NodeMissCacheSize) ;
+ params.getIndexNode2Id(), params.getIndexId2Node(),
+ params.getNode2NodeIdCacheSize(), params.getNodeId2NodeCacheSize(), params.getNodeMissCacheSize()) ;
TripleTable tripleTable = makeTripleTable(location, nodeTable, policy) ;
QuadTable quadTable = makeQuadTable(location, nodeTable, policy) ;
@@ -168,8 +171,8 @@ public class DatasetBuilderStd implement
// ======== Dataset level
protected TripleTable makeTripleTable(Location location, NodeTable nodeTable, DatasetControl policy)
{
- String primary = params.primaryIndexTriples ;
- String[] indexes = params.tripleIndexes ;
+ String primary = params.getPrimaryIndexTriples() ;
+ String[] indexes = params.getTripleIndexes() ;
// Allow experimentation of other index layouts.
// if ( indexes.length != 3 )
@@ -186,8 +189,8 @@ public class DatasetBuilderStd implement
protected QuadTable makeQuadTable(Location location, NodeTable nodeTable, DatasetControl policy)
{
- String primary = params.primaryIndexQuads ;
- String[] indexes = params.quadIndexes ;
+ String primary = params.getPrimaryIndexQuads() ;
+ String[] indexes = params.getQuadIndexes() ;
// Allow experimentation of other index layouts.
// if ( indexes.length != 6 )
@@ -204,15 +207,15 @@ public class DatasetBuilderStd implement
protected DatasetPrefixesTDB makePrefixTable(Location location, DatasetControl policy)
{
- String primary = params.primaryIndexPrefix ;
- String[] indexes = params.prefixIndexes ;
+ String primary = params.getPrimaryIndexPrefix() ;
+ String[] indexes = params.getPrefixIndexes() ;
- TupleIndex prefixIndexes[] = makeTupleIndexes(location, primary, indexes, new String[]{params.indexPrefix}) ;
+ TupleIndex prefixIndexes[] = makeTupleIndexes(location, primary, indexes, new String[]{params.getIndexPrefix()}) ;
if ( prefixIndexes.length != 1 )
error(log, "Wrong number of triple table tuples indexes: "+prefixIndexes.length) ;
- String pnNode2Id = params.prefixNode2Id ;
- String pnId2Node = params.prefixId2Node ;
+ String pnNode2Id = params.getPrefixNode2Id() ;
+ String pnId2Node = params.getPrefixId2Node() ;
// No cache - the prefix mapping is a cache
NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, pnId2Node, -1, -1, -1) ;
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParams.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParams.java?rev=1622698&r1=1622697&r2=1622698&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParams.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/SystemParams.java Fri Sep 5 13:37:46 2014
@@ -18,33 +18,36 @@
package com.hp.hpl.jena.tdb.setup;
-import com.hp.hpl.jena.sparql.util.StringUtils ;
+import org.apache.jena.atlas.lib.StrUtils ;
+
+import com.hp.hpl.jena.tdb.base.block.FileMode ;
import com.hp.hpl.jena.tdb.sys.Names ;
import com.hp.hpl.jena.tdb.sys.SystemTDB ;
/** System parameters for a TDB database instance. */
public class SystemParams
{
- public int blockSize = SystemTDB.BlockSize ;
- public int memBlockSize = SystemTDB.BlockSizeTestMem ;
- public int readCacheSize = SystemTDB.BlockReadCacheSize ;
- public int writeCacheSize = SystemTDB.BlockWriteCacheSize ;
- public int Node2NodeIdCacheSize = SystemTDB.Node2NodeIdCacheSize ;
- public int NodeId2NodeCacheSize = SystemTDB.NodeId2NodeCacheSize ;
- public int NodeMissCacheSize = SystemTDB.NodeMissCacheSize ;
-
- public String indexNode2Id = Names.indexNode2Id ;
- public String indexId2Node = Names.indexId2Node ;
- public String primaryIndexTriples = Names.primaryIndexTriples ;
- public String[] tripleIndexes = Names.tripleIndexes ;
- public String primaryIndexQuads = Names.primaryIndexQuads ;
- public String[] quadIndexes = Names.quadIndexes ;
- public String primaryIndexPrefix = Names.primaryIndexPrefix ;
- public String[] prefixIndexes = Names.prefixIndexes ;
- public String indexPrefix = Names.indexPrefix ;
+ private FileMode fileMode = SystemTDB.fileMode() ;
+ private int blockSize = SystemTDB.BlockSize ;
+ private int memBlockSize = SystemTDB.BlockSizeTestMem ;
+ private int readCacheSize = SystemTDB.BlockReadCacheSize ;
+ private int writeCacheSize = SystemTDB.BlockWriteCacheSize ;
+ private int Node2NodeIdCacheSize = SystemTDB.Node2NodeIdCacheSize ;
+ private int NodeId2NodeCacheSize = SystemTDB.NodeId2NodeCacheSize ;
+ private int NodeMissCacheSize = SystemTDB.NodeMissCacheSize ;
+
+ private String indexNode2Id = Names.indexNode2Id ;
+ private String indexId2Node = Names.indexId2Node ;
+ private String primaryIndexTriples = Names.primaryIndexTriples ;
+ private String[] tripleIndexes = Names.tripleIndexes ;
+ private String primaryIndexQuads = Names.primaryIndexQuads ;
+ private String[] quadIndexes = Names.quadIndexes ;
+ private String primaryIndexPrefix = Names.primaryIndexPrefix ;
+ private String[] prefixIndexes = Names.prefixIndexes ;
+ private String indexPrefix = Names.indexPrefix ;
- public String prefixNode2Id = Names.prefixNode2Id ;
- public String prefixId2Node = Names.prefixId2Node ;
+ private String prefixNode2Id = Names.prefixNode2Id ;
+ private String prefixId2Node = Names.prefixId2Node ;
public SystemParams() {}
@@ -54,6 +57,195 @@ public class SystemParams
@Override
public String toString() {
- return StringUtils.str(tripleIndexes)+" "+StringUtils.str(quadIndexes) ;
+ StringBuilder buff = new StringBuilder() ;
+ fmt(buff, "fileMode", fileMode.toString()) ;
+ fmt(buff, "blockSize", getBlockSize()) ;
+ fmt(buff, "memBlockSize", getMemBlockSize()) ;
+ fmt(buff, "readCacheSize", getReadCacheSize()) ;
+ fmt(buff, "writeCacheSize", getWriteCacheSize()) ;
+ fmt(buff, "Node2NodeIdCacheSize", getNode2NodeIdCacheSize()) ;
+ fmt(buff, "NodeId2NodeCacheSize", getNodeId2NodeCacheSize()) ;
+ fmt(buff, "NodeMissCacheSize", getNodeMissCacheSize()) ;
+
+ fmt(buff, "indexNode2Id", getIndexNode2Id()) ;
+ fmt(buff, "indexId2Node", getIndexId2Node()) ;
+ fmt(buff, "primaryIndexTriples", getPrimaryIndexTriples()) ;
+ fmt(buff, "tripleIndexes", getTripleIndexes()) ;
+ fmt(buff, "primaryIndexQuads", getPrimaryIndexQuads()) ;
+ fmt(buff, "quadIndexes", getQuadIndexes()) ;
+ fmt(buff, "primaryIndexPrefix", getPrimaryIndexPrefix()) ;
+ fmt(buff, "prefixIndexes", getPrefixIndexes()) ;
+ fmt(buff, "indexPrefix", getIndexPrefix()) ;
+
+ fmt(buff, "prefixNode2Id", getPrefixNode2Id()) ;
+ fmt(buff, "prefixId2Node", getPrefixId2Node()) ;
+
+ return buff.toString() ;
+ }
+
+ private void fmt(StringBuilder buff, String name, String[] strings) {
+ buff.append(String.format("%-20s [%s]\n", name, StrUtils.strjoin(", ", strings))) ;
+ }
+
+ private void fmt(StringBuilder buff, String name, String value) {
+ buff.append(String.format("%-20s %s\n", name, value)) ;
+ }
+
+ private void fmt(StringBuilder buff, String name, int value) {
+ buff.append(String.format("%-20s %s\n", name, value)) ;
+ }
+
+ public FileMode getFileMode() {
+ return fileMode ;
+ }
+
+ public void setFileMode(FileMode fileMode) {
+ this.fileMode = fileMode ;
+ }
+
+ public int getBlockSize() {
+ return blockSize ;
+ }
+
+ public void setBlockSize(int blockSize) {
+ this.blockSize = blockSize;
+ }
+
+ public int getMemBlockSize() {
+ return memBlockSize;
+ }
+
+ public void setMemBlockSize(int memBlockSize) {
+ this.memBlockSize = memBlockSize;
+ }
+
+ public int getReadCacheSize() {
+ return readCacheSize;
+ }
+
+ public void setReadCacheSize(int readCacheSize) {
+ this.readCacheSize = readCacheSize;
+ }
+
+ public int getWriteCacheSize() {
+ return writeCacheSize;
+ }
+
+ public void setWriteCacheSize(int writeCacheSize) {
+ this.writeCacheSize = writeCacheSize;
+ }
+
+ public int getNode2NodeIdCacheSize() {
+ return Node2NodeIdCacheSize;
+ }
+
+ public void setNode2NodeIdCacheSize(int node2NodeIdCacheSize) {
+ Node2NodeIdCacheSize = node2NodeIdCacheSize;
+ }
+
+ public int getNodeId2NodeCacheSize() {
+ return NodeId2NodeCacheSize;
+ }
+
+ public void setNodeId2NodeCacheSize(int nodeId2NodeCacheSize) {
+ NodeId2NodeCacheSize = nodeId2NodeCacheSize;
+ }
+
+ public int getNodeMissCacheSize() {
+ return NodeMissCacheSize;
+ }
+
+ public void setNodeMissCacheSize(int nodeMissCacheSize) {
+ NodeMissCacheSize = nodeMissCacheSize;
+ }
+
+ public String getIndexNode2Id() {
+ return indexNode2Id;
}
+
+ public void setIndexNode2Id(String indexNode2Id) {
+ this.indexNode2Id = indexNode2Id;
+ }
+
+ public String getIndexId2Node() {
+ return indexId2Node;
+ }
+
+ public void setIndexId2Node(String indexId2Node) {
+ this.indexId2Node = indexId2Node;
+ }
+
+ public String getPrimaryIndexTriples() {
+ return primaryIndexTriples;
+ }
+
+ public void setPrimaryIndexTriples(String primaryIndexTriples) {
+ this.primaryIndexTriples = primaryIndexTriples;
+ }
+
+ public String[] getTripleIndexes() {
+ return tripleIndexes;
+ }
+
+ public void setTripleIndexes(String[] tripleIndexes) {
+ this.tripleIndexes = tripleIndexes;
+ }
+
+ public String getPrimaryIndexQuads() {
+ return primaryIndexQuads;
+ }
+
+ public void setPrimaryIndexQuads(String primaryIndexQuads) {
+ this.primaryIndexQuads = primaryIndexQuads;
+ }
+
+ public String[] getQuadIndexes() {
+ return quadIndexes;
+ }
+
+ public void setQuadIndexes(String[] quadIndexes) {
+ this.quadIndexes = quadIndexes;
+ }
+
+ public String getPrimaryIndexPrefix() {
+ return primaryIndexPrefix;
+ }
+
+ public void setPrimaryIndexPrefix(String primaryIndexPrefix) {
+ this.primaryIndexPrefix = primaryIndexPrefix;
+ }
+
+ public String[] getPrefixIndexes() {
+ return prefixIndexes;
+ }
+
+ public void setPrefixIndexes(String[] prefixIndexes) {
+ this.prefixIndexes = prefixIndexes;
+ }
+
+ public String getIndexPrefix() {
+ return indexPrefix;
+ }
+
+ public void setIndexPrefix(String indexPrefix) {
+ this.indexPrefix = indexPrefix;
+ }
+
+ public String getPrefixNode2Id() {
+ return prefixNode2Id;
+ }
+
+ public void setPrefixNode2Id(String prefixNode2Id) {
+ this.prefixNode2Id = prefixNode2Id;
+ }
+
+ public String getPrefixId2Node() {
+ return prefixId2Node;
+ }
+
+ public void setPrefixId2Node(String prefixId2Node) {
+ this.prefixId2Node = prefixId2Node;
+ }
+
+
}
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java?rev=1622698&r1=1622697&r2=1622698&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SetupTDB.java Fri Sep 5 13:37:46 2014
@@ -114,17 +114,17 @@ public class SetupTDB
public static DatasetPrefixesTDB makePrefixes(Location location, DatasetControl policy)
{
// The index using for Graph+Prefix => URI
- String indexPrefixes = params.indexPrefix ;
- String primary = params.primaryIndexPrefix ;
- String indexes[] = params.prefixIndexes ;
+ String indexPrefixes = params.getIndexPrefix() ;
+ String primary = params.getPrimaryIndexPrefix() ;
+ String indexes[] = params.getPrefixIndexes() ;
TupleIndex prefixIndexes[] = makeTupleIndexes(location, primary, indexes, new String[]{indexPrefixes}) ;
if ( prefixIndexes.length != indexes.length )
error(log, "Wrong number of triple table tuples indexes: "+prefixIndexes.length) ;
// The nodetable.
- String pnNode2Id = params.prefixNode2Id ;
- String pnId2Node = params.prefixId2Node ;
+ String pnNode2Id = params.getPrefixNode2Id() ;
+ String pnId2Node = params.getPrefixId2Node() ;
// No cache - the prefix mapping is a cache
NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, -1, pnId2Node, -1, -1) ;
@@ -153,8 +153,8 @@ public class SetupTDB
int keyLength)
{
FileSet fs = new FileSet(location, indexName) ;
- int readCacheSize = params.readCacheSize ;
- int writeCacheSize = params.writeCacheSize ;
+ int readCacheSize = params.getReadCacheSize() ;
+ int writeCacheSize = params.getWriteCacheSize() ;
// Value part is null (zero length)
RangeIndex rIndex = makeRangeIndex(location, indexName, keyLength, 0, readCacheSize, writeCacheSize) ;
@@ -183,7 +183,7 @@ public class SetupTDB
int dftKeyLength, int dftValueLength)
{
RecordFactory recordFactory = makeRecordFactory(dftKeyLength, dftValueLength) ;
- int blkSize = params.blockSize ;
+ int blkSize = params.getBlockSize() ;
// IndexBuilder.getBPlusTree().newRangeIndex(fs, recordFactory) ;
// Does not set order.