use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.
the class OpExecutorTDB1 method execute.
@Override
protected QueryIterator execute(OpFilter opFilter, QueryIterator input) {
if (!isForTDB)
return super.execute(opFilter, input);
// (filter (bgp ...))
if (OpBGP.isBGP(opFilter.getSubOp())) {
// Still may be a TDB graph in a non-TDB dataset (e.g. a named model)
GraphTDB graph = (GraphTDB) execCxt.getActiveGraph();
OpBGP opBGP = (OpBGP) opFilter.getSubOp();
return executeBGP(graph, opBGP, input, opFilter.getExprs(), execCxt);
}
// (filter (quadpattern ...))
if (opFilter.getSubOp() instanceof OpQuadPattern) {
OpQuadPattern quadPattern = (OpQuadPattern) opFilter.getSubOp();
DatasetGraphTDB ds = (DatasetGraphTDB) execCxt.getDataset();
return optimizeExecuteQuads(ds, input, quadPattern.getGraphNode(), quadPattern.getBasicPattern(), opFilter.getExprs(), execCxt);
}
// (filter (anything else))
return super.execute(opFilter, input);
}
use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.
the class DumpOps method dump.
public static void dump(Dataset ds) {
DatasetGraphTDB dsg = (DatasetGraphTDB) (ds.asDatasetGraph());
NodeTupleTable nodeTupleTableTriples = dsg.getTripleTable().getNodeTupleTable();
NodeTupleTable nodeTupleTableQuads = dsg.getQuadTable().getNodeTupleTable();
if (nodeTupleTableTriples.getNodeTable() != nodeTupleTableQuads.getNodeTable())
throw new TDBException("Different node tables for triples and quads");
NodeTable nodeTable = nodeTupleTableTriples.getNodeTable();
// V special.
Set<NodeTable> dumpedNodeTables = new HashSet<>();
if (true) {
System.out.print("## Node Table\n");
dumpNodeTable(nodeTupleTableTriples.getNodeTable(), dumpedNodeTables);
dumpNodeTable(nodeTupleTableQuads.getNodeTable(), dumpedNodeTables);
}
if (false) {
System.out.print("## Triple Table\n");
dumpNodeTupleTable(nodeTupleTableTriples.getTupleTable());
System.out.print("## Quad Table\n");
dumpNodeTupleTable(nodeTupleTableQuads.getTupleTable());
}
// Indexes.
if (true) {
dumpTupleIndexes(nodeTupleTableTriples.getTupleTable().getIndexes());
dumpTupleIndexes(nodeTupleTableQuads.getTupleTable().getIndexes());
}
// Prefixes
if (true) {
System.out.print("## Prefix Table\n");
DatasetPrefixesTDB prefixes = dsg.getPrefixes();
NodeTupleTable pntt = prefixes.getNodeTupleTable();
if (!dumpedNodeTables.contains(pntt.getNodeTable())) {
dumpNodeTable(pntt.getNodeTable(), dumpedNodeTables);
dumpedNodeTables.add(pntt.getNodeTable());
}
dumpTupleIndexes(prefixes.getNodeTupleTable().getTupleTable().getIndexes());
}
}
use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.
the class TransactionManager method begin$.
// If DatasetGraphTransaction has a sync lock on sConn, this
// does not need to be sync'ed. But it's possible to use some
// of the low level object directly so we'll play safe.
private synchronized DatasetGraphTxn begin$(ReadWrite mode, String label) {
if (// Guard
mode == ReadWrite.WRITE && activeWriters.get() > 0)
throw new TDBTransactionException("Existing active write transaction");
if (DEBUG)
switch(mode) {
case READ:
System.out.print("r");
break;
case WRITE:
System.out.print("w");
break;
}
DatasetGraphTDB dsg = determineBaseDataset();
Transaction txn = createTransaction(dsg, mode, label);
log("begin$", txn);
DatasetGraphTxn dsgTxn = createDSGTxn(dsg, txn, mode);
txn.setActiveDataset(dsgTxn);
// Empty for READ ; only WRITE transactions have components that need notifiying.
List<TransactionLifecycle> components = dsgTxn.getTransaction().lifecycleComponents();
if (mode == ReadWrite.READ) {
// ---- Consistency check. View caching does not reset components.
if (components.size() != 0)
log.warn("read transaction, non-empty lifecycleComponents list");
}
for (TransactionLifecycle component : components) component.begin(dsgTxn.getTransaction());
noteStartTxn(txn);
return dsgTxn;
}
use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.
the class TestTransRestart method testPlain.
@Test
public void testPlain() {
assertEquals(3, countRDFNodes());
DatasetGraphTDB dsg = createPlain(location);
assertTrue(dsg.contains(quad1));
dsg.add(quad2);
assertTrue(dsg.contains(quad2));
dsg.close();
StoreConnection.release(location);
assertEquals(4, countRDFNodes());
}
Aggregations