Put in default StoreParams calls
Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/906be05b Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/906be05b Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/906be05b Branch: refs/heads/JENA-507 Commit: 906be05b1f491c96eadba008c494b8faa72cdf81 Parents: 74b75f3 Author: Andy Seaborne <a...@apache.org> Authored: Wed Nov 5 16:36:12 2014 +0000 Committer: Andy Seaborne <a...@apache.org> Committed: Wed Nov 5 16:36:12 2014 +0000 ---------------------------------------------------------------------- .../com/hp/hpl/jena/tdb/StoreConnection.java | 4 +- .../hpl/jena/tdb/setup/DatasetBuilderStd.java | 37 +++++++++++++----- .../com/hp/hpl/jena/tdb/setup/StoreParams.java | 41 +++++++++++++++++--- .../hp/hpl/jena/tdb/setup/StoreParamsConst.java | 27 +++++++++++++ .../store/bulkloader2/CmdNodeTableBuilder.java | 2 +- .../com/hp/hpl/jena/tdb/store/TestLoader.java | 2 +- 6 files changed, 94 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/906be05b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java index 91b333e..5935a9a 100644 --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java @@ -230,12 +230,12 @@ public class StoreConnection return sConn ; } - @Deprecated + /** Make a StoreConnection based on any StoreParams at eh location or the system defaults. */ public static StoreConnection make(Location location) { return make(location, null) ; } - /** + /** * Return the StoreConnection if one already exists for this location, else * return null */ http://git-wip-us.apache.org/repos/asf/jena/blob/906be05b/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 38173b5..3dd02e6 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 @@ -67,28 +67,47 @@ public class DatasetBuilderStd implements DatasetBuilder { private TupleIndexBuilder tupleIndexBuilder ; private Recorder recorder = null ; - @Deprecated + /** + * + * @param location + * @return DatasetGraphTDB + */ public static DatasetGraphTDB create(Location location) { return create(location, null) ; } - public static DatasetGraphTDB create(Location location, StoreParams $params) { - StoreParams params = paramsForLocation(location) ; + /** + * Create a {@linkplain DatasetGraphTDB} with a set of {@linkplain StoreParams}. + * The parameters for a store have 3 inputs: the parameters provided, + * any parameters + * + * + * + * @param location Where to create the database. + * @param params Store parameters to use (null means use default). + * @return DatasetGraphTDB + */ + public static DatasetGraphTDB create(Location location, StoreParams params) { + StoreParams $params = paramsForLocation(location) ; // ---- Experimental - if ( ! location.isMem() && $params != null ) { + if ( ! location.isMem() && params != null ) { if ( FileOps.existsAnyFiles(location.getDirectoryPath()) ) - params = StoreParamsBuilder.modify(params, $params) ; + $params = StoreParamsBuilder.modify($params, params) ; else - params = $params ; - $params = null ; + $params = params ; + params = null ; } // ---- - if ( $params != null ) + if ( params != null ) log.warn("StoreParams != null (experimental)") ; DatasetBuilderStd x = new DatasetBuilderStd() ; x.standardSetup() ; - return x.build(location, params) ; + DatasetGraphTDB dsg = x.build(location, $params) ; + // Write params. + //if ( params != StoreParams.getDftStoreParams() ) + + return dsg ; } public static DatasetGraphTDB create(StoreParams params) { http://git-wip-us.apache.org/repos/asf/jena/blob/906be05b/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 8790c9b..ee71b01 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 @@ -25,12 +25,25 @@ import org.apache.jena.atlas.lib.StrUtils ; import com.hp.hpl.jena.tdb.base.block.FileMode ; import com.hp.hpl.jena.tdb.index.IndexParams ; -/** System parameters for a TDB database instance. */ +/** System parameters for a TDB database instance. + * <p> + * Some parameters can be changed from run to run + * and some parameters can only be changed at the point the database is + * created. + * <p> + * Getting paramters settings wrong can destroy a databse. + * Alternating the block size is not encouraged and should only be + * done if necessary. It can silently destroy a database if set + * to a different value than thatused to create the database. The + * default value of 8Kbytes is good for almo + * + * + * + * @see StoreParamsBuilder for constructing StoreParams + * @see StoreParamsConst for default values. + */ public class StoreParams implements IndexParams, StoreParamsDynamic { - // SystemParams are built with a SystemParamsBuilder - - private static StoreParams dftStoreParams = StoreParamsBuilder.create().build() ; /* These are items you can change JVM to JVM */ @@ -89,9 +102,25 @@ public class StoreParams implements IndexParams, StoreParamsDynamic this.prefixNode2Id = prefixNode2Id ; this.prefixId2Node = prefixId2Node ; } - + + /** The system default settings. This is the normal set to use. + * It is the set of values used when no StoreParams is provided, + * which is the normal usage. + */ public static StoreParams getDftStoreParams() { - return dftStoreParams ; + return StoreParamsConst.dftStoreParams ; + } + + /** A {@code StoreParams} that provides a smaller + * in-JVM foot print. This is compatible with + * any database but it it is wise to use this consistently, + * that is, use when created and when opened later. + * It reduces cache sizes and runs the database in "direct" + * file mode so as not to use memory mapped files + * in addition to the JVM space. + */ + public static StoreParams getSmallStoreParams() { + return StoreParamsConst.smallStoreParams ; } @Override http://git-wip-us.apache.org/repos/asf/jena/blob/906be05b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsConst.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsConst.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsConst.java index 7f10450..70e6b6a 100644 --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsConst.java +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParamsConst.java @@ -23,6 +23,33 @@ import com.hp.hpl.jena.tdb.sys.Names ; import com.hp.hpl.jena.tdb.sys.SystemTDB ; public class StoreParamsConst { + + // SystemParams are built with a SystemParamsBuilder + + /** The system default parameters for on-disk databases. */ + static StoreParams dftStoreParams = StoreParamsBuilder.create().build() ; + + /** The system default parameters for in-memory databases. */ + static StoreParams dftMemStoreParams = StoreParamsBuilder.create() + .fileMode(FileMode.direct) + // Small block caches, mainly so it behaves like a direct on-disk database. + .blockReadCacheSize(10) + .blockWriteCacheSize(10) + .node2NodeIdCacheSize(10000) + .nodeId2NodeCacheSize(10000) + .nodeMissCacheSize(100) + .build() ; + + /** The "small store" parameters. */ + static StoreParams smallStoreParams = StoreParamsBuilder.create() + .fileMode(FileMode.direct) + .blockReadCacheSize(100) + .blockWriteCacheSize(100) + .node2NodeIdCacheSize(10000) + .nodeId2NodeCacheSize(10000) + .nodeMissCacheSize(100) + .build() ; + // Initial values are the system defaults. /** Database and query configuration */ http://git-wip-us.apache.org/repos/asf/jena/blob/906be05b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdNodeTableBuilder.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdNodeTableBuilder.java b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdNodeTableBuilder.java index 1782de6..f6eabc5 100644 --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdNodeTableBuilder.java +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdNodeTableBuilder.java @@ -142,7 +142,7 @@ public class CmdNodeTableBuilder extends CmdGeneral // Later - attach prefix table to parser. dsg.getPrefixes().close() ; - ProgressLogger monitor = new ProgressLogger(cmdLog, "Data", BulkLoader.DataTickPoint,BulkLoader.superTick) ; + ProgressLogger monitor = new ProgressLogger(cmdLog, "Data", BulkLoader.DataTickPoint, BulkLoader.superTick) ; OutputStream outputTriples = null ; OutputStream outputQuads = null ; http://git-wip-us.apache.org/repos/asf/jena/blob/906be05b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestLoader.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestLoader.java b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestLoader.java index 60ed84f..4284dde 100644 --- a/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestLoader.java +++ b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestLoader.java @@ -61,7 +61,7 @@ public class TestLoader extends BaseTest { } static DatasetGraphTDB fresh() { - return TDBMaker.createDatasetGraphTDB(Location.mem()) ; + return TDBMaker.createDatasetGraphTDB(Location.mem(), null) ; } @Test