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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations