Interface for tunable store parameters. Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ef40d6b7 Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ef40d6b7 Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ef40d6b7
Branch: refs/heads/eliminate-assignments Commit: ef40d6b7d4f648062f25fc994fc3cd98451681de Parents: 7f3b9c6 Author: Andy Seaborne <a...@apache.org> Authored: Tue Nov 4 15:43:09 2014 +0000 Committer: Andy Seaborne <a...@apache.org> Committed: Tue Nov 4 15:43:09 2014 +0000 ---------------------------------------------------------------------- .../com/hp/hpl/jena/tdb/index/IndexParams.java | 9 ++++ .../com/hp/hpl/jena/tdb/setup/StoreParams.java | 5 +- .../hpl/jena/tdb/setup/StoreParamsBuilder.java | 18 ++++++++ .../hpl/jena/tdb/setup/StoreParamsDynamic.java | 48 ++++++++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/ef40d6b7/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/index/IndexParams.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/index/IndexParams.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/index/IndexParams.java index 0e82caf..cdfbe9f 100644 --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/index/IndexParams.java +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/index/IndexParams.java @@ -22,8 +22,17 @@ import com.hp.hpl.jena.tdb.base.block.BlockParams ; import com.hp.hpl.jena.tdb.base.block.FileMode ; public interface IndexParams extends BlockParams { + /** File Mode */ @Override public FileMode getFileMode() ; + + /** Block size - this is only configurable when the on-disk are created. + * After that, the same value as at creation must be used each time. + */ @Override public int getBlockSize() ; + + /** Block read cache size (mmap'ed files do not have a block cache)*/ @Override public int getBlockReadCacheSize() ; + + /** Block write cache size (mmap'ed files do not have a block cache)*/ @Override public int getBlockWriteCacheSize() ; } http://git-wip-us.apache.org/repos/asf/jena/blob/ef40d6b7/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 7c1829b..7d06f82 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 @@ -26,7 +26,7 @@ import com.hp.hpl.jena.tdb.base.block.FileMode ; import com.hp.hpl.jena.tdb.index.IndexParams ; /** System parameters for a TDB database instance. */ -public class StoreParams implements IndexParams +public class StoreParams implements IndexParams, StoreParamsDynamic { // SystemParams are built with a SystemParamsBuilder @@ -114,14 +114,17 @@ public class StoreParams implements IndexParams return blockWriteCacheSize ; } + @Override public int getNode2NodeIdCacheSize() { return Node2NodeIdCacheSize ; } + @Override public int getNodeId2NodeCacheSize() { return NodeId2NodeCacheSize ; } + @Override public int getNodeMissCacheSize() { return NodeMissCacheSize ; } http://git-wip-us.apache.org/repos/asf/jena/blob/ef40d6b7/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 ca039c7..806fd13 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 @@ -85,6 +85,24 @@ public class StoreParamsBuilder { private String prefixId2Node = Names.prefixId2Node ; public static StoreParamsBuilder create() { return new StoreParamsBuilder() ; } + + /** Using a base set of {@linkplain StoreParams}, and update with dynamic parameters. + * + * @param baseParams + * @param additionalParams + * @return StoreParams + */ + + public static StoreParams modify(StoreParams baseParams, StoreParamsDynamic additionalParams) { + return new StoreParamsBuilder(baseParams) + .fileMode(additionalParams.getFileMode()) + .blockReadCacheSize(additionalParams.getBlockReadCacheSize()) + .blockWriteCacheSize(additionalParams.getBlockWriteCacheSize()) + .node2NodeIdCacheSize(additionalParams.getNode2NodeIdCacheSize()) + .nodeId2NodeCacheSize(additionalParams.getNodeId2NodeCacheSize()) + .nodeMissCacheSize(additionalParams.getNodeMissCacheSize()) + .build(); + } public StoreParamsBuilder() {} public StoreParamsBuilder(StoreParams other) { http://git-wip-us.apache.org/repos/asf/jena/blob/ef40d6b7/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 new file mode 100644 index 0000000..1063bf2 --- /dev/null +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsDynamic.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hp.hpl.jena.tdb.setup; + +import com.hp.hpl.jena.tdb.base.block.FileMode ; + +/** Store parameters that can be adjusted after a store has been created, + * and given different values when the JVM attaches to a store area. + * (They are still fixed for any given database once created in a JVM.) + */ + +public interface StoreParamsDynamic { + + /** Store-wide file access mode */ + public FileMode getFileMode() ; + + /** Block read cache (note: mapped files do not have a block cache) */ + public int getBlockReadCacheSize() ; + + /** Block write cache (note: mapped files do not have a block cache) */ + public int getBlockWriteCacheSize() ; + + /** Node cache for Node->NodeId. */ + public int getNode2NodeIdCacheSize() ; + + /** Node cache for NodeId->Node. Important for SPARQL results. */ + public int getNodeId2NodeCacheSize() ; + + /** Node cache for recording known misses */ + public int getNodeMissCacheSize() ; +} +