StoreParams enabled in DatasetBuilderStd Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/74b75f38 Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/74b75f38 Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/74b75f38
Branch: refs/heads/JENA-507 Commit: 74b75f380f82f5e0078246711a8a41401413af8a Parents: aae3f23 Author: Andy Seaborne <a...@apache.org> Authored: Wed Nov 5 14:38:39 2014 +0000 Committer: Andy Seaborne <a...@apache.org> Committed: Wed Nov 5 15:06:44 2014 +0000 ---------------------------------------------------------------------- .../java/com/hp/hpl/jena/tdb/setup/Build.java | 4 +-- .../hpl/jena/tdb/setup/DatasetBuilderStd.java | 16 +++++++++-- .../com/hp/hpl/jena/tdb/setup/StoreParams.java | 2 +- .../hpl/jena/tdb/setup/StoreParamsBuilder.java | 30 +++++++++++++------- .../hpl/jena/tdb/setup/StoreParamsDynamic.java | 3 ++ .../hp/hpl/jena/tdb/setup/TestStoreParams.java | 18 ++++++++---- 6 files changed, 51 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/74b75f38/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/Build.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/Build.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/Build.java index 4bd2157..ddb98d2 100644 --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/Build.java +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/Build.java @@ -48,7 +48,7 @@ public class Build // XXX replace with: // return DatasetBuilderStd.stdBuilder().makeTupleIndex(location, indexName, primary, indexOrder) ; // All this to BuilderDB. - StoreParamsBuilder spb = new StoreParamsBuilder() ; + StoreParamsBuilder spb = StoreParamsBuilder.create() ; spb.blockReadCacheSize(readCacheSize) ; spb.blockWriteCacheSize(writeCacheSize) ; RecordFactory recordFactory = new RecordFactory(dftKeyLength, dftValueLength) ; @@ -77,7 +77,7 @@ public class Build String indexNode2Id, int node2NodeIdCacheSize, String indexId2Node, int nodeId2NodeCacheSize, int sizeNodeMissCacheSize) { - StoreParamsBuilder spb = new StoreParamsBuilder() ; + StoreParamsBuilder spb = StoreParamsBuilder.create() ; spb.indexNode2Id(indexNode2Id).node2NodeIdCacheSize(node2NodeIdCacheSize) ; spb.indexId2Node(indexId2Node).nodeId2NodeCacheSize(nodeId2NodeCacheSize) ; DatasetBuilderStd dbBuild = DatasetBuilderStd.stdBuilder() ; http://git-wip-us.apache.org/repos/asf/jena/blob/74b75f38/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java index ae903ca..38173b5 100644 --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java @@ -73,9 +73,19 @@ public class DatasetBuilderStd implements DatasetBuilder { } public static DatasetGraphTDB create(Location location, StoreParams $params) { - if ( $params != null ) - log.warn("StoreParams != null (ignored)") ; StoreParams params = paramsForLocation(location) ; + // ---- Experimental + if ( ! location.isMem() && $params != null ) { + if ( FileOps.existsAnyFiles(location.getDirectoryPath()) ) + params = StoreParamsBuilder.modify(params, $params) ; + else + params = $params ; + $params = null ; + } + + // ---- + if ( $params != null ) + log.warn("StoreParams != null (experimental)") ; DatasetBuilderStd x = new DatasetBuilderStd() ; x.standardSetup() ; return x.build(location, params) ; @@ -331,7 +341,7 @@ public class DatasetBuilderStd implements DatasetBuilder { } protected NodeTable makeNodeTableNoCache(Location location, String indexNode2Id, String indexId2Node, StoreParams params) { - StoreParamsBuilder spb = new StoreParamsBuilder(params) ; + StoreParamsBuilder spb = StoreParamsBuilder.create(params) ; spb.node2NodeIdCacheSize(-1) ; spb.nodeId2NodeCacheSize(-1) ; spb.nodeMissCacheSize(-1) ; http://git-wip-us.apache.org/repos/asf/jena/blob/74b75f38/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java index 7d06f82..8790c9b 100644 --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java @@ -30,7 +30,7 @@ public class StoreParams implements IndexParams, StoreParamsDynamic { // SystemParams are built with a SystemParamsBuilder - private static StoreParams dftStoreParams = new StoreParamsBuilder().build() ; + private static StoreParams dftStoreParams = StoreParamsBuilder.create().build() ; /* These are items you can change JVM to JVM */ http://git-wip-us.apache.org/repos/asf/jena/blob/74b75f38/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java index 0fa5d42..e0ceda7 100644 --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsBuilder.java @@ -63,7 +63,13 @@ public class StoreParamsBuilder { private String prefixId2Node = StoreParamsConst.prefixId2Node ; - public static StoreParamsBuilder create() { return new StoreParamsBuilder() ; } + public static StoreParamsBuilder create() { + return new StoreParamsBuilder() ; + } + + public static StoreParamsBuilder create(StoreParams params) { + return new StoreParamsBuilder(params) ; + } /** Using a base set of {@linkplain StoreParams}, and update with dynamic parameters. * @@ -75,6 +81,7 @@ public class StoreParamsBuilder { public static StoreParams modify(StoreParams baseParams, StoreParamsDynamic additionalParams) { return new StoreParamsBuilder(baseParams) .fileMode(additionalParams.getFileMode()) + .blockSize(additionalParams.getBlockSize()) .blockReadCacheSize(additionalParams.getBlockReadCacheSize()) .blockWriteCacheSize(additionalParams.getBlockWriteCacheSize()) .node2NodeIdCacheSize(additionalParams.getNode2NodeIdCacheSize()) @@ -83,8 +90,8 @@ public class StoreParamsBuilder { .build(); } - public StoreParamsBuilder() {} - public StoreParamsBuilder(StoreParams other) { + private StoreParamsBuilder() {} + private StoreParamsBuilder(StoreParams other) { this.fileMode = other.getFileMode() ; this.blockSize = other.getBlockSize() ; this.blockReadCacheSize = other.getBlockReadCacheSize() ; @@ -95,16 +102,19 @@ public class StoreParamsBuilder { this.indexNode2Id = other.getIndexNode2Id() ; this.indexId2Node = other.getIndexId2Node() ; - this.primaryIndexTriples = other.getPrimaryIndexPrefix() ; - this.tripleIndexes = other.getQuadIndexes() ; - this.primaryIndexQuads = other.getPrimaryIndexPrefix() ; - this.quadIndexes = other.getPrefixIndexes() ; - this.primaryIndexPrefix = other.getIndexPrefix() ; + + this.primaryIndexTriples = other.getPrimaryIndexTriples() ; + this.tripleIndexes = other.getTripleIndexes() ; + + this.primaryIndexQuads = other.getPrimaryIndexQuads() ; + this.quadIndexes = other.getQuadIndexes() ; + + this.primaryIndexPrefix = other.getPrimaryIndexPrefix() ; this.prefixIndexes = other.getPrefixIndexes() ; this.indexPrefix = other.getIndexPrefix() ; - this.prefixNode2Id = other.getIndexNode2Id() ; - this.prefixId2Node = other.getIndexId2Node() ; + this.prefixNode2Id = other.getPrefixNode2Id() ; + this.prefixId2Node = other.getPrefixId2Node() ; } public StoreParams build() { http://git-wip-us.apache.org/repos/asf/jena/blob/74b75f38/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsDynamic.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsDynamic.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsDynamic.java index 1063bf2..ca6290a 100644 --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsDynamic.java +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsDynamic.java @@ -30,6 +30,9 @@ public interface StoreParamsDynamic { /** Store-wide file access mode */ public FileMode getFileMode() ; + /** Block size - must agree with the original creation of the database */ + public int getBlockSize() ; + /** Block read cache (note: mapped files do not have a block cache) */ public int getBlockReadCacheSize() ; http://git-wip-us.apache.org/repos/asf/jena/blob/74b75f38/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/setup/TestStoreParams.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/setup/TestStoreParams.java b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/setup/TestStoreParams.java index 6612be9..1762518 100644 --- a/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/setup/TestStoreParams.java +++ b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/setup/TestStoreParams.java @@ -36,11 +36,17 @@ public class TestStoreParams extends BaseTest { } @Test public void store_params_02() { - StoreParams sp = StoreParamsBuilder.create().build() ; + StoreParams input = StoreParams.getDftStoreParams() ; + StoreParams sp = StoreParamsBuilder.create(input).build() ; assertEqualsStoreParams(StoreParams.getDftStoreParams(), sp) ; } @Test public void store_params_03() { + StoreParams sp = StoreParamsBuilder.create().build() ; + assertEqualsStoreParams(StoreParams.getDftStoreParams(), sp) ; + } + + @Test public void store_params_04() { StoreParams params = StoreParamsBuilder.create().build() ; StoreParams params2 = roundTrip(params) ; assertEqualsStoreParams(params,params2) ; @@ -48,7 +54,7 @@ public class TestStoreParams extends BaseTest { // ---- - @Test public void store_params_04() { + @Test public void store_params_10() { StoreParams params = StoreParamsBuilder.create().fileMode(FileMode.direct).blockSize(1024).build() ; StoreParams params2 = roundTrip(params) ; assertEqualsStoreParams(params,params2) ; @@ -56,7 +62,7 @@ public class TestStoreParams extends BaseTest { assertEquals(params.getBlockSize(), params2.getBlockSize()) ; } - @Test public void store_params_05() { + @Test public void store_params_11() { String xs = "{ \"tdb.block_size\": 2048 }" ; JsonObject x = JSON.parse(xs) ; StoreParams paramsExpected = StoreParamsBuilder.create().blockSize(2048).build() ; @@ -64,7 +70,7 @@ public class TestStoreParams extends BaseTest { assertEqualsStoreParams(paramsExpected,paramsActual) ; } - @Test public void store_params_06() { + @Test public void store_params_12() { String xs = "{ \"tdb.file_mode\": \"direct\" , \"tdb.block_size\": 2048 }" ; JsonObject x = JSON.parse(xs) ; StoreParams paramsExpected = StoreParamsBuilder.create().blockSize(2048).fileMode(FileMode.direct).build() ; @@ -72,7 +78,7 @@ public class TestStoreParams extends BaseTest { assertEqualsStoreParams(paramsExpected,paramsActual) ; } - @Test public void store_params_07() { + @Test public void store_params_13() { String xs = "{ \"tdb.triple_indexes\" : [ \"POS\" , \"PSO\"] } " ; JsonObject x = JSON.parse(xs) ; StoreParams params = StoreParamsCodec.decode(x) ; @@ -81,7 +87,7 @@ public class TestStoreParams extends BaseTest { } @Test(expected=TDBException.class) - public void store_params_08() { + public void store_params_14() { String xs = "{ \"tdb.triples_indexes\" : [ \"POS\" , \"PSO\"] } " ; // Misspelt. JsonObject x = JSON.parse(xs) ; StoreParams params = StoreParamsCodec.decode(x) ;