use of org.apache.jena.tdb2.store.DatasetGraphSwitchable in project jena by apache.
the class TDBInternal method expel.
/**
* Stop managing a DatasetGraph. Use with great care.
*/
public static synchronized void expel(DatasetGraph dsg, boolean force) {
Location locContainer = null;
Location locStorage = null;
if (dsg instanceof DatasetGraphSwitchable) {
locContainer = ((DatasetGraphSwitchable) dsg).getLocation();
dsg = ((DatasetGraphSwitchable) dsg).getWrapped();
}
if (dsg instanceof DatasetGraphTDB)
locStorage = ((DatasetGraphTDB) dsg).getLocation();
DatabaseConnection.internalExpel(locContainer, force);
StoreConnection.internalExpel(locStorage, force);
}
use of org.apache.jena.tdb2.store.DatasetGraphSwitchable in project jena by apache.
the class TDBInternal method expel.
/**
* Stop managing a DatasetGraph. Use with great care.
*/
public static synchronized void expel(DatasetGraph dsg) {
Location locContainer = null;
Location locStorage = null;
if (dsg instanceof DatasetGraphSwitchable) {
locContainer = ((DatasetGraphSwitchable) dsg).getLocation();
dsg = ((DatasetGraphSwitchable) dsg).getWrapped();
}
if (dsg instanceof DatasetGraphTDB)
locStorage = ((DatasetGraphTDB) dsg).getLocation();
if (locContainer != null)
DatabaseConnection.internalExpel(locContainer, false);
StoreConnection.internalExpel(locStorage, false);
}
use of org.apache.jena.tdb2.store.DatasetGraphSwitchable in project jena by apache.
the class TestTDBAssembler method createGraphEmbed.
@Test
public void createGraphEmbed() {
String f = dirAssem + "/tdb-graph-embed.ttl";
Object thing = null;
try {
thing = AssemblerUtils.build(f, JA.Model);
} catch (AssemblerException e) {
e.getCause().printStackTrace(System.err);
throw e;
}
assertTrue(thing instanceof Model);
Graph graph = ((Model) thing).getGraph();
assertTrue(graph instanceof GraphViewSwitchable);
DatasetGraphSwitchable ds = ((GraphViewSwitchable) graph).getDataset();
if (ds != null)
ds.close();
}
use of org.apache.jena.tdb2.store.DatasetGraphSwitchable in project jena by apache.
the class TestTDBAssembler method createTest.
private void createTest(String filename, Resource type) {
Object thing = AssemblerUtils.build(filename, type);
assertTrue(thing instanceof Dataset);
Dataset ds = (Dataset) thing;
assertTrue(ds.asDatasetGraph() instanceof DatasetGraphSwitchable);
assertTrue(ds.supportsTransactions());
ds.close();
}
use of org.apache.jena.tdb2.store.DatasetGraphSwitchable in project jena by apache.
the class TestDatabaseOps method compact_dsg_1.
@Test
public void compact_dsg_1() {
DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(dir);
DatasetGraphSwitchable dsgs = (DatasetGraphSwitchable) dsg;
DatasetGraph dsg1 = dsgs.get();
Location loc1 = ((DatasetGraphTDB) dsg1).getLocation();
Txn.executeWrite(dsg, () -> {
dsg.add(quad2);
dsg.add(quad1);
});
DatabaseMgr.compact(dsg, false);
assertFalse(StoreConnection.isSetup(loc1));
DatasetGraph dsg2 = dsgs.get();
Location loc2 = ((DatasetGraphTDB) dsg2).getLocation();
assertNotEquals(dsg1, dsg2);
assertNotEquals(loc1, loc2);
Txn.executeRead(dsg, () -> {
assertTrue(dsg.contains(quad2));
assertTrue(dsg.contains(quad1));
});
// dsg1 was closed and expelled. We must carefully reopen its storage only.
DatasetGraph dsgOld = StoreConnection.connectCreate(loc1).getDatasetGraph();
Txn.executeWrite(dsgOld, () -> dsgOld.delete(quad2));
Txn.executeRead(dsg, () -> assertTrue(dsg.contains(quad2)));
Txn.executeRead(dsg2, () -> assertTrue(dsg2.contains(quad2)));
}
Aggregations