Search in sources :

Example 11 with Location

use of org.apache.jena.tdb.base.file.Location in project jena by apache.

the class dumpnodetable method exec.

@Override
protected void exec() {
    List<String> tripleIndexes = Arrays.asList(Names.tripleIndexes);
    List<String> quadIndexes = Arrays.asList(Names.quadIndexes);
    Location loc = modLocation.getLocation();
    StoreConnection sConn = StoreConnection.make(loc);
    DatasetGraphTDB dsg = sConn.getBaseDataset();
    NodeTable nodeTable = dsg.getQuadTable().getNodeTupleTable().getNodeTable();
    dump(System.out, nodeTable);
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable) Location(org.apache.jena.tdb.base.file.Location) ModLocation(tdb.cmdline.ModLocation) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB)

Example 12 with Location

use of org.apache.jena.tdb.base.file.Location in project jena by apache.

the class CmdRewriteIndex method main.

public static void main(String... argv) {
    // Usage: srcLocation dstLocation indexName
    if (argv.length != 3) {
        System.err.println("Usage: " + Lib.classShortName(CmdRewriteIndex.class) + " SrcLocation DstLocation IndexName");
        System.exit(1);
    }
    Location srcLoc = Location.create(argv[0]);
    Location dstLoc = Location.create(argv[1]);
    String indexName = argv[2];
    if (!FileOps.exists(argv[1])) {
        System.err.println("Destination directory does not exist");
        System.exit(1);
    }
    if (FileOps.exists(dstLoc.getPath(indexName, Names.bptExtTree))) {
        System.err.println("Destination contains an index of that name");
        System.exit(1);
    }
    ProcRewriteIndex.exec(srcLoc, dstLoc, indexName);
}
Also used : Location(org.apache.jena.tdb.base.file.Location)

Example 13 with Location

use of org.apache.jena.tdb.base.file.Location in project jena by apache.

the class DatasetAssemblerTDB method make.

static Dataset make(Resource root) {
    if (!exactlyOneProperty(root, pLocation))
        throw new AssemblerException(root, "No location given");
    String dir = getStringValue(root, pLocation);
    Location loc = Location.create(dir);
    DatasetGraph dsg = TDBFactory.createDatasetGraph(loc);
    if (root.hasProperty(pUnionDefaultGraph)) {
        Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode();
        NodeValue nv = NodeValue.makeNode(b);
        if (nv.isBoolean())
            dsg.getContext().set(TDB.symUnionDefaultGraph, nv.getBoolean());
        else
            Log.warn(DatasetAssemblerTDB.class, "Failed to recognize value for union graph setting (ignored): " + b);
    }
    /*
        <r> rdf:type tdb:DatasetTDB ;
            tdb:location "dir" ;
            //ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue "10000" ] ;
            tdb:unionGraph true ; # or "true"
        */
    AssemblerUtils.setContext(root, dsg.getContext());
    return DatasetFactory.wrap(dsg);
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) AssemblerException(org.apache.jena.assembler.exceptions.AssemblerException) Node(org.apache.jena.graph.Node) VocabTDB.pLocation(org.apache.jena.tdb.assembler.VocabTDB.pLocation) Location(org.apache.jena.tdb.base.file.Location) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 14 with Location

use of org.apache.jena.tdb.base.file.Location in project jena by apache.

the class TestLocationLockStoreConnection method location_lock_store_connection_02.

@Test(expected = TDBException.class)
public void location_lock_store_connection_02() throws IOException {
    Assume.assumeTrue(negativePidsTreatedAsAlive);
    Location dir = Location.create(tempDir.getRoot().getAbsolutePath());
    LocationLock lock = dir.getLock();
    Assert.assertTrue(lock.canLock());
    Assert.assertFalse(lock.isLocked());
    Assert.assertFalse(lock.isOwned());
    Assert.assertTrue(lock.canObtain());
    // Write a fake PID to the lock file
    try (BufferedWriter writer = new BufferedWriter(new FileWriter(dir.getPath("tdb.lock")))) {
        // Fake PID that would never be valid
        writer.write(Integer.toString(-1234));
    }
    Assert.assertTrue(lock.isLocked());
    Assert.assertFalse(lock.isOwned());
    // Attempting to create a connection on this location should error
    StoreConnection.make(dir);
}
Also used : FileWriter(java.io.FileWriter) LocationLock(org.apache.jena.tdb.base.file.LocationLock) Location(org.apache.jena.tdb.base.file.Location) BufferedWriter(java.io.BufferedWriter) Test(org.junit.Test)

Example 15 with Location

use of org.apache.jena.tdb.base.file.Location in project jena by apache.

the class AbstractStoreConnections method store_6.

@Test
public void store_6() {
    // Transaction - release - reattach
    // This tests that the dataset is sync'ed when going into transactional mode.
    StoreConnection sConn = getStoreConnection();
    Location loc = sConn.getLocation();
    DatasetGraphTxn dsgTxn = sConn.begin(ReadWrite.WRITE);
    dsgTxn.add(q1);
    assertTrue(dsgTxn.contains(q1));
    dsgTxn.commit();
    dsgTxn.end();
    sConn.forceRecoverFromJournal();
    assertTrue(sConn.getBaseDataset().contains(q1));
    StoreConnection.release(loc);
    sConn = StoreConnection.make(loc);
    DatasetGraph dsg2 = sConn.getBaseDataset();
    assertTrue(dsg2.contains(q1));
    DatasetGraphTxn dsgTxn2 = sConn.begin(ReadWrite.READ);
    assertTrue(dsgTxn2.contains(q1));
    dsgTxn2.end();
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) Location(org.apache.jena.tdb.base.file.Location) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb.ConfigTest) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Aggregations

Location (org.apache.jena.tdb.base.file.Location)29 Test (org.junit.Test)16 BaseTest (org.apache.jena.atlas.junit.BaseTest)9 LocationLock (org.apache.jena.tdb.base.file.LocationLock)8 ConfigTest (org.apache.jena.tdb.ConfigTest)6 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)4 StoreConnection (org.apache.jena.tdb.StoreConnection)4 TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)4 Record (org.apache.jena.tdb.base.record.Record)3 StoreParams (org.apache.jena.tdb.setup.StoreParams)3 AssemblerException (org.apache.jena.assembler.exceptions.AssemblerException)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 Dataset (org.apache.jena.query.Dataset)2 VocabTDB.pLocation (org.apache.jena.tdb.assembler.VocabTDB.pLocation)2 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)2 RangeIndex (org.apache.jena.tdb.index.RangeIndex)2 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)2 ColumnMap (org.apache.jena.tdb.lib.ColumnMap)2