use of org.apache.jena.tdb2.store.DatasetGraphTDB in project jena by apache.
the class OpExecutorTDB2 method execute.
@Override
protected QueryIterator execute(OpQuadPattern quadPattern, QueryIterator input) {
if (!isForTDB)
return super.execute(quadPattern, input);
// DatasetGraph dg = execCxt.getDataset();
// if ( ! ( dg instanceof DatasetGraphTDB ) )
// throw new InternalErrorException("Not a TDB backed dataset in quad pattern execution");
DatasetGraphTDB ds = (DatasetGraphTDB) execCxt.getDataset();
BasicPattern bgp = quadPattern.getBasicPattern();
Node gn = quadPattern.getGraphNode();
return optimizeExecuteQuads(ds, input, gn, bgp, null, execCxt);
}
use of org.apache.jena.tdb2.store.DatasetGraphTDB in project jena by apache.
the class TestQuadFilter method createFilter.
/**
* Create a filter to exclude the graph http://example/g2
*/
private static Predicate<Tuple<NodeId>> createFilter(Dataset dataset) {
return Txn.calculateRead(dataset, () -> {
DatasetGraphTDB dsg = TDBInternal.getDatasetGraphTDB(dataset);
final NodeTable nodeTable = dsg.getQuadTable().getNodeTupleTable().getNodeTable();
final NodeId target = nodeTable.getNodeIdForNode(NodeFactory.createURI(graphToHide));
// Check g slot. Exclude graphToHide
return item -> !(item.len() == 4 && item.get(0).equals(target));
});
}
use of org.apache.jena.tdb2.store.DatasetGraphTDB in project jena by apache.
the class AbstractTestStoreConnectionBasics method store_03.
@Test
public void store_03() {
StoreConnection sConn = StoreConnection.connectCreate(location);
DatasetGraphTDB dsg = sConn.getDatasetGraphTDB();
Txn.executeWrite(dsg, () -> {
dsg.add(q1);
});
Txn.executeWrite(dsg, () -> {
assertTrue(dsg.contains(q1));
});
try {
Txn.executeWrite(dsg, () -> {
dsg.add(q2);
throw new RuntimeException();
});
fail("Should not get to here!");
} catch (RuntimeException ex) {
}
Txn.executeRead(dsg, () -> {
assertTrue(dsg.contains(q1));
assertFalse(dsg.contains(q2));
});
}
use of org.apache.jena.tdb2.store.DatasetGraphTDB in project jena by apache.
the class AbstractTestStoreConnectionBasics method store_04.
@Test
public void store_04() {
StoreConnection sConn = StoreConnection.connectCreate(location);
DatasetGraphTDB dsg = sConn.getDatasetGraphTDB();
Txn.executeWrite(dsg, () -> {
dsg.add(q1);
});
Txn.executeWrite(dsg, () -> {
assertTrue(dsg.contains(q1));
});
dsg.begin(ReadWrite.WRITE);
dsg.add(q2);
dsg.abort();
dsg.end();
Txn.executeRead(dsg, () -> {
assertTrue(dsg.contains(q1));
assertFalse(dsg.contains(q2));
});
}
use of org.apache.jena.tdb2.store.DatasetGraphTDB 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