Search in sources :

Example 26 with StoreParams

use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.

the class DatabaseConnection method build.

private static DatabaseConnection build(Location location, StoreParams params) {
    if (location.isMemUnique()) {
        throw new TDBException("Can't buildForCache a memory-unique location");
    }
    ProcessFileLock lock = null;
    if (SystemTDB.DiskLocationMultiJvmUsagePrevention && !location.isMem()) {
        // Take the lock for the swithable.
        // StoreConnection will take a lock for the storage.
        lock = lockForLocation(location);
        // Take the lock.  This is atomic and non-reentrant.
        lock.lockEx();
    }
    // c.f. StoreConnection.make
    DatasetGraph dsg = DatabaseOps.create(location, params);
    return new DatabaseConnection(dsg, location, lock);
}
Also used : TDBException(org.apache.jena.tdb2.TDBException) ProcessFileLock(org.apache.jena.dboe.base.file.ProcessFileLock) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 27 with StoreParams

use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.

the class SpotTDB2 method checkStorageArea.

/**
 * Check all files exist for a TDB2 database, or the area is empty (and so a new
 * database can be created in the location). Throw {@link TDBException} is a file
 * is missing.
 */
private static void checkStorageArea(Location location) {
    if (location.isMem())
        return;
    if (isEmpty(location))
        return;
    // Journal, fixed name.
    validate(location, Names.journalFileBase, Names.extJournal);
    // Places for StoreParams: location or default
    StoreParams params = getStoreParams(location);
    // Check for indexes
    containsIndex(params.getPrimaryIndexTriples(), params.getTripleIndexes());
    validateBPT(location, params.getTripleIndexes());
    containsIndex(params.getPrimaryIndexQuads(), params.getTripleIndexes());
    validateBPT(location, params.getQuadIndexes());
    // prefixes. GPU
    containsIndex(params.getPrimaryIndexPrefix(), params.getPrefixIndexes());
    // GPU is not in files "GPU"
    // Filename of GPU.
    validateBPT(location, params.getPrefixIndexes());
    // ---- Node tables.
    /*
         * nodes.bpt
         * nodes.dat
         * nodes-data.bdf
         * nodes-data.obj
         */
    validateBPT(location, params.getNodeTableBaseName());
    validateDAT(location, params.getNodeTableBaseName() + "-data");
    /*
         * prefixes...
         */
    // XXX validateBPT(location, params.getPrefixTableBaseName());
    validateBPT(location, params.getPrefixTableBaseName());
    validateDAT(location, params.getPrefixTableBaseName() + "-data");
}
Also used : StoreParams(org.apache.jena.tdb2.params.StoreParams)

Example 28 with StoreParams

use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.

the class ProcIngestDataX method getDatasetGraph.

private static DatasetGraph getDatasetGraph(String location) {
    Location loc = Location.create(location);
    // Ensure reset
    DatasetGraph dsg0 = DatabaseMgr.connectDatasetGraph(location);
    TDBInternal.expel(dsg0);
    StoreParams storeParams = StoreParams.getDftStoreParams();
    if (true) {
        storeParams = StoreParams.builder(storeParams).node2NodeIdCacheSize(10_000_000).build();
    }
    DatasetGraph dsg = DatabaseConnection.connectCreate(loc, storeParams).getDatasetGraph();
    StoreParams storeParamsActual = TDBInternal.getDatasetGraphTDB(dsg).getStoreParams();
    // FmtLog.info(LOG, "NodeId to Node cache size: %,d", storeParamsActual.getNodeId2NodeCacheSize());
    return dsg;
}
Also used : StoreParams(org.apache.jena.tdb2.params.StoreParams) Location(org.apache.jena.dboe.base.file.Location) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 29 with StoreParams

use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.

the class TestStoreParams method store_params_03.

@Test
public void store_params_03() {
    StoreParams sp = StoreParams.builder().build();
    assertEqualsStoreParams(StoreParams.getDftStoreParams(), sp);
}
Also used : StoreParams(org.apache.jena.tdb2.params.StoreParams) Test(org.junit.Test)

Example 30 with StoreParams

use of org.apache.jena.tdb2.params.StoreParams in project jena by apache.

the class TestStoreParams method store_params_12.

@Test
public void store_params_12() {
    String xs = "{ \"tdb.file_mode\": \"direct\" , \"tdb.block_size\": 2048 }";
    JsonObject x = JSON.parse(xs);
    StoreParams paramsExpected = StoreParams.builder().blockSize(2048).fileMode(FileMode.direct).build();
    StoreParams paramsActual = StoreParamsCodec.decode(x);
    assertEqualsStoreParams(paramsExpected, paramsActual);
}
Also used : StoreParams(org.apache.jena.tdb2.params.StoreParams) JsonObject(org.apache.jena.atlas.json.JsonObject) Test(org.junit.Test)

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