Add TDB2Factory.assembleDataset. Remove out of date comments. Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/32608d25 Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/32608d25 Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/32608d25
Branch: refs/heads/master Commit: 32608d250fa60788b53db71b79d904fb63dbdd88 Parents: d30b3c0 Author: Andy Seaborne <a...@apache.org> Authored: Fri Apr 13 13:59:35 2018 +0100 Committer: Andy Seaborne <a...@apache.org> Committed: Fri Apr 13 13:59:35 2018 +0100 ---------------------------------------------------------------------- .../java/org/apache/jena/tdb2/DatabaseMgr.java | 4 -- .../java/org/apache/jena/tdb2/TDB2Factory.java | 49 +++++--------------- .../jena/tdb2/sys/DatabaseConnection.java | 3 ++ 3 files changed, 15 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/32608d25/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java ---------------------------------------------------------------------- diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java index e8e0091..52ca661 100644 --- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java +++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java @@ -37,8 +37,6 @@ public class DatabaseMgr { // All creation of DatasetGraph for TDB2 goes through this method. private static DatasetGraph DB_ConnectCreate(Location location) { return DatabaseConnection.connectCreate(location).getDatasetGraph(); -// // One level. -// return StoreConnection.connectCreate(location).getDatasetGraph() ; } /** Create or connect to a TDB2-backed dataset */ @@ -79,7 +77,6 @@ public class DatabaseMgr { return DatabaseOps.backup(dsg); } - /** Create an in-memory TDB2-backed dataset (for testing) */ public static DatasetGraph createDatasetGraph() { return connectDatasetGraph(Location.mem()) ; @@ -110,5 +107,4 @@ public class DatabaseMgr { throw new TDBException("Not a TDB database (argument is neither a switchable nor direct TDB DatasetGraph)"); return dsg; } - } http://git-wip-us.apache.org/repos/asf/jena/blob/32608d25/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java ---------------------------------------------------------------------- diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java index 62952d0..02b6138 100644 --- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java +++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java @@ -22,12 +22,17 @@ import org.apache.jena.dboe.base.file.Location; import org.apache.jena.query.Dataset ; import org.apache.jena.query.DatasetFactory ; import org.apache.jena.sparql.core.DatasetGraph ; +import org.apache.jena.sparql.core.assembler.AssemblerUtils ; +import org.apache.jena.system.JenaSystem; +import org.apache.jena.tdb2.assembler.VocabTDB2 ; /** * Public factory for connecting to and creating datasets backed by TDB2 storage. */ public class TDB2Factory { + static { JenaSystem.init(); } + private TDB2Factory() {} /** @deprecated Use {@link DatabaseMgr#connectDatasetGraph(Location)} */ @@ -74,23 +79,13 @@ public class TDB2Factory */ public static Dataset createDataset() { return connectDataset(Location.mem()) ; } -// /** -// * Read the file and assembler a dataset -// */ -// public static Dataset assembleDataset(String assemblerFile) { -// return (Dataset)AssemblerUtils.build(assemblerFile, VocabTDB.tDatasetTDB) ; -// } -// -// /** Release from the JVM. All caching is lost. */ -// public static void release(Dataset dataset) { -// _release(location(dataset)) ; -// } -// -// /** Release from the JVM. All caching is lost. */ -// public static void release(DatasetGraph dataset) { -// _release(location(dataset)) ; -// } - + /** + * Read the file and assemble a dataset + */ + public static Dataset assembleDataset(String assemblerFile) { + return (Dataset)AssemblerUtils.build(assemblerFile, VocabTDB2.tDatasetTDB) ; + } + /** Test whether a dataset is backed by TDB or not. */ public static boolean isBackedByTDB(Dataset dataset) { DatasetGraph dsg = dataset.asDatasetGraph() ; @@ -102,24 +97,4 @@ public class TDB2Factory DatasetGraph dsg = dataset.asDatasetGraph() ; return DatabaseMgr.location(dsg) ; } - -// /** Set the {@link StoreParams} for specific Location. -// * This call must only be called before a dataset from Location -// * is created. This operation should be used with care; bad choices -// * of {@link StoreParams} can reduce performance. -// * -// * <a href="http://jena.apache.org/documentation/tdb/store-paramters.html" -// * >See documentation</a>. -// * -// * @param location The persistent storage location -// * @param params StoreParams to use -// * @throws IllegalStateException If the dataset has already been setup. -// */ -// public static void setup(Location location, StoreParams params) { -// StoreConnection sConn = StoreConnection.getExisting(location) ; -// if ( sConn != null ) -// throw new IllegalStateException("Location is already active") ; -// StoreConnection.make(location, params) ; -// } - } http://git-wip-us.apache.org/repos/asf/jena/blob/32608d25/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java ---------------------------------------------------------------------- diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java index 69d1499..4e94a9b 100644 --- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java +++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java @@ -32,6 +32,7 @@ import org.apache.jena.dboe.base.file.Location; import org.apache.jena.dboe.base.file.ProcessFileLock; import org.apache.jena.dboe.sys.Names; import org.apache.jena.sparql.core.DatasetGraph ; +import org.apache.jena.system.JenaSystem; import org.apache.jena.tdb2.TDBException; import org.apache.jena.tdb2.setup.StoreParams; import org.apache.jena.tdb2.store.DatasetGraphSwitchable; @@ -39,6 +40,8 @@ import org.apache.jena.tdb2.store.DatasetGraphSwitchable; // StoreConnection, DatabaseConnection < Connection<X> public class DatabaseConnection { + static { JenaSystem.init(); } + // ConnectionTracker<X> private static Map<Location, DatabaseConnection> cache = new ConcurrentHashMap<>() ;