Search in sources :

Example 21 with StoreParams

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;
}
Also used : StoreParams(org.apache.jena.tdb2.params.StoreParams) ReorderTransformation(org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation) StoragePrefixes(org.apache.jena.dboe.storage.StoragePrefixes) ComponentIdMgr(org.apache.jena.tdb2.sys.ComponentIdMgr)

Example 22 with StoreParams

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;
}
Also used : NodeTable(org.apache.jena.tdb2.store.nodetable.NodeTable)

Example 23 with StoreParams

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;
}
Also used : StoreParams(org.apache.jena.tdb2.params.StoreParams)

Example 24 with StoreParams

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;
}
Also used : TDBException(org.apache.jena.tdb2.TDBException) DatasetGraphSwitchable(org.apache.jena.tdb2.store.DatasetGraphSwitchable) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Location(org.apache.jena.dboe.base.file.Location) DatasetGraphTDB(org.apache.jena.tdb2.store.DatasetGraphTDB)

Example 25 with StoreParams

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;
}
Also used : ProcessFileLock(org.apache.jena.dboe.base.file.ProcessFileLock) DatasetGraphTDB(org.apache.jena.tdb2.store.DatasetGraphTDB)

Aggregations

StoreParams (org.apache.jena.tdb2.params.StoreParams)33 Test (org.junit.Test)26 ConfigTest (org.apache.jena.tdb2.ConfigTest)15 JsonObject (org.apache.jena.atlas.json.JsonObject)5 Location (org.apache.jena.dboe.base.file.Location)5 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)3 NodeTable (org.apache.jena.tdb2.store.nodetable.NodeTable)3 ProcessFileLock (org.apache.jena.dboe.base.file.ProcessFileLock)2 TDBException (org.apache.jena.tdb2.TDBException)2 DatasetGraphTDB (org.apache.jena.tdb2.store.DatasetGraphTDB)2 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)1 Index (org.apache.jena.dboe.index.Index)1 RangeIndex (org.apache.jena.dboe.index.RangeIndex)1 StoragePrefixes (org.apache.jena.dboe.storage.StoragePrefixes)1 ReorderTransformation (org.apache.jena.sparql.engine.optimizer.reorder.ReorderTransformation)1 DatasetGraphSwitchable (org.apache.jena.tdb2.store.DatasetGraphSwitchable)1 NodeTableTRDF (org.apache.jena.tdb2.store.nodetable.NodeTableTRDF)1 ComponentIdMgr (org.apache.jena.tdb2.sys.ComponentIdMgr)1