use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.
the class TDB2StorageBuilder method build.
// public static DatasetGraphTxn build(Location location, StoreParams appParams) {
// StoreParams locParams = StoreParamsCodec.read(location);
// StoreParams dftParams = StoreParams.getDftStoreParams();
// boolean newArea = isNewDatabaseArea(location);
// if ( newArea ) {
// }
// // This can write the chosen parameters if necessary (new database, appParams != null, locParams == null)
// StoreParams params = StoreParamsFactory.decideStoreParams(location, newArea, appParams, locParams, dftParams);
// return create(location, params).build$();
// }
public static DatasetGraphTDB build(Location location, StoreParams appParams) {
StoreParams locParams = StoreParamsCodec.read(location);
StoreParams dftParams = StoreParams.getDftStoreParams();
boolean newArea = isNewDatabaseArea(location);
if (newArea) {
}
// This can write the chosen parameters if necessary (new database, appParams != null, locParams == null)
StoreParams params = StoreParamsFactory.decideStoreParams(location, newArea, appParams, locParams, dftParams);
// Builder pattern for adding components.
TransactionCoordinator txnCoord = buildTransactionCoordinator(location);
TransactionalSystem txnSystem = new TransactionalBase(txnCoord);
TDB2StorageBuilder builder = new TDB2StorageBuilder(txnSystem, location, params, new ComponentIdMgr(UUID.randomUUID()));
StorageTDB storage = builder.buildStorage();
StoragePrefixes prefixes = builder.buildPrefixes();
// Finalize.
builder.components.forEach(txnCoord::add);
builder.listeners.forEach(txnCoord::addListener);
// Freezes the TransactionCoordinator components
txnCoord.start();
ReorderTransformation reorderTranform = chooseReorderTransformation(location);
DatasetGraphTDB dsg = new DatasetGraphTDB(location, params, reorderTranform, storage, prefixes, txnSystem);
// Enable query processing.
QC.setFactory(dsg.getContext(), OpExecutorTDB2.OpExecFactoryTDB);
return dsg;
}
use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.
the class TDB2StorageBuilder method buildStorage.
// private Location getLocation() { return location; }
// private StoreParams getParams() { return params; }
// private TransactionCoordinator getTxnCoord() { return txnCoord; }
// private Collection<TransactionalComponent> getComponents() { return components; }
private StorageTDB buildStorage() {
NodeTable nodeTable = buildNodeTable(params.getNodeTableBaseName(), true);
TripleTable tripleTable = buildTripleTable(nodeTable);
QuadTable quadTable = buildQuadTable(nodeTable);
StorageTDB dsg = new StorageTDB(txnSystem, tripleTable, quadTable);
return dsg;
}
use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.
the class TDB2StorageBuilder method storeParams.
private static StoreParams storeParams(Location location, StoreParams appParams) {
StoreParams locParams = StoreParamsCodec.read(location);
StoreParams dftParams = StoreParams.getDftStoreParams();
// This can write the chosen parameters if necessary (new database, appParams != null, locParams == null)
boolean newArea = isNewDatabaseArea(location);
if (newArea) {
}
StoreParams params = StoreParamsFactory.decideStoreParams(location, newArea, appParams, locParams, dftParams);
return params;
}
use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.
the class DatabaseOps method createSwitchable.
private static DatasetGraphSwitchable createSwitchable(Location location, StoreParams params) {
if (location.isMem()) {
DatasetGraph dsg = StoreConnection.connectCreate(location).getDatasetGraph();
return new DatasetGraphSwitchable(null, location, dsg);
}
// Exists?
if (!location.exists())
throw new TDBException("No such location: " + location);
Path path = IO_DB.asPath(location);
// Scan for DBs
Path db = findLocation(path, dbPrefix);
if (db == null) {
db = path.resolve(dbPrefix + SEP + startCount);
IOX.createDirectory(db);
}
Location loc2 = IO_DB.asLocation(db);
DatasetGraphTDB dsg = StoreConnection.connectCreate(loc2, params).getDatasetGraphTDB();
DatasetGraphSwitchable appDSG = new DatasetGraphSwitchable(path, location, dsg);
return appDSG;
}
use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.
the class StoreConnection method make.
/**
* Return a {@code StoreConnection} for a particular location,
* creating it if it does not exist in storage.
*/
private static synchronized StoreConnection make(Location location, StoreParams params) {
StoreConnection sConn = cache.get(location);
if (sConn == null) {
ProcessFileLock lock = null;
// This is a tdb.lock file in the storage database, not the switchable.
if (SystemTDB.DiskLocationMultiJvmUsagePrevention && !location.isMem()) {
lock = lockForLocation(location);
// Take the lock. This is atomic and non-reentrant.
lock.lockEx();
}
// Recovery happens when TransactionCoordinator.start is called
// during the building of the DatasetGraphTDB
DatasetGraphTDB dsg = TDB2StorageBuilder.build(location, params);
sConn = new StoreConnection(dsg, lock);
if (!location.isMemUnique())
cache.put(location, sConn);
}
return sConn;
}
Aggregations