Search in sources :

Example 21 with DatasetGraphTDB

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);
}
Also used : GraphTDB(org.apache.jena.tdb.store.GraphTDB) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB)

Example 22 with DatasetGraphTDB

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());
    }
}
Also used : NodeTupleTable(org.apache.jena.tdb.store.nodetupletable.NodeTupleTable) TDBException(org.apache.jena.tdb.TDBException) DatasetPrefixesTDB(org.apache.jena.tdb.store.DatasetPrefixesTDB) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) HashSet(java.util.HashSet)

Example 23 with DatasetGraphTDB

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;
}
Also used : DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB)

Example 24 with DatasetGraphTDB

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());
}
Also used : DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb.ConfigTest) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Aggregations

DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)24 Node (org.apache.jena.graph.Node)5 BaseTest (org.apache.jena.atlas.junit.BaseTest)4 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)4 Test (org.junit.Test)4 StoreConnection (org.apache.jena.tdb.StoreConnection)3 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 Quad (org.apache.jena.sparql.core.Quad)2 BlockMgrBuilder (org.apache.jena.tdb.setup.BlockMgrBuilder)2 DatasetBuilderStd (org.apache.jena.tdb.setup.DatasetBuilderStd)2 NodeTableBuilder (org.apache.jena.tdb.setup.NodeTableBuilder)2 NodeId (org.apache.jena.tdb.store.NodeId)2 DatasetGraphTxn (org.apache.jena.tdb.transaction.DatasetGraphTxn)2 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 HashSet (java.util.HashSet)1 Predicate (java.util.function.Predicate)1 AtlasException (org.apache.jena.atlas.AtlasException)1