Search in sources :

Example 1 with DatasetGraphTransaction

use of org.apache.jena.tdb.transaction.DatasetGraphTransaction in project jena by apache.

the class T_QuadsObjectIsNull method one.

public static void one() {
    Quad q1 = SSE.parseQuad("(<g1> <s1> <p1> '1')");
    Quad q2 = SSE.parseQuad("(<g2> <s2> <p2> '2')");
    Quad q3 = SSE.parseQuad("(<g3> <s3> <p3> '3')");
    DatasetGraphTransaction dsg = (DatasetGraphTransaction) TDBFactory.createDatasetGraph(location);
    System.out.println("Start");
    dump(dsg);
    write(dsg, q1);
    write(dsg, q2);
    //write(dsg, q3) ;
    System.out.println("Finish");
    dump(dsg);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) DatasetGraphTransaction(org.apache.jena.tdb.transaction.DatasetGraphTransaction)

Example 2 with DatasetGraphTransaction

use of org.apache.jena.tdb.transaction.DatasetGraphTransaction in project jena by apache.

the class TestTDBFactory method testTDBMakerTxn3.

@Test
public void testTDBMakerTxn3() {
    // Un-named memory locations
    TDBMaker.reset();
    DatasetGraph dg1 = TDBMaker.createDatasetGraphTransaction(Location.mem());
    DatasetGraph dg2 = TDBMaker.createDatasetGraphTransaction(Location.mem());
    DatasetGraph dgBase1 = ((DatasetGraphTransaction) dg1).getBaseDatasetGraph();
    DatasetGraph dgBase2 = ((DatasetGraphTransaction) dg2).getBaseDatasetGraph();
    assertNotSame(dgBase1, dgBase2);
}
Also used : DatasetGraphTransaction(org.apache.jena.tdb.transaction.DatasetGraphTransaction) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 3 with DatasetGraphTransaction

use of org.apache.jena.tdb.transaction.DatasetGraphTransaction 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 DatasetGraphTransaction);
    assertTrue(ds.supportsTransactions());
    ds.close();
}
Also used : Dataset(org.apache.jena.query.Dataset) DatasetGraphTransaction(org.apache.jena.tdb.transaction.DatasetGraphTransaction)

Example 4 with DatasetGraphTransaction

use of org.apache.jena.tdb.transaction.DatasetGraphTransaction in project jena by apache.

the class TDB method sync.

/** Sync a TDB-backed DatasetGraph. Do nothing if not TDB-backed. */
public static void sync(DatasetGraph dataset) {
    if (dataset == null)
        return;
    // Should be: SystemARQ.sync(dataset) ;
    if (dataset instanceof DatasetGraphTDB) {
        syncObject(dataset);
        return;
    }
    if (dataset instanceof DatasetGraphTransaction) {
        DatasetGraphTransaction dsgt = (DatasetGraphTransaction) dataset;
        // This only sync if the dataset has not been used transactionally.
        // Can't sync transactional datasets (it's meaningless)
        dsgt.syncIfNotTransactional();
        return;
    }
    // May be a general purpose dataset with TDB objects in it.
    sync(dataset.getDefaultGraph());
    Iterator<Node> iter = dataset.listGraphNodes();
    // Avoid iterator concurrency.
    iter = Iter.toList(iter).iterator();
    for (; iter.hasNext(); ) {
        Node n = iter.next();
        Graph g = dataset.getGraph(n);
        sync(g);
    }
}
Also used : InfGraph(org.apache.jena.reasoner.InfGraph) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph) Node(org.apache.jena.graph.Node) DatasetGraphTransaction(org.apache.jena.tdb.transaction.DatasetGraphTransaction) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB)

Example 5 with DatasetGraphTransaction

use of org.apache.jena.tdb.transaction.DatasetGraphTransaction in project jena by apache.

the class DataService method shutdown.

private void shutdown() {
    Fuseki.serverLog.info("Shutting down dataset");
    dataset.close();
    if (dataset instanceof DatasetGraphTransaction) {
        DatasetGraphTransaction dsgtxn = (DatasetGraphTransaction) dataset;
        StoreConnection.release(dsgtxn.getLocation());
    }
    dataset = null;
}
Also used : DatasetGraphTransaction(org.apache.jena.tdb.transaction.DatasetGraphTransaction)

Aggregations

DatasetGraphTransaction (org.apache.jena.tdb.transaction.DatasetGraphTransaction)9 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)4 BaseTest (org.apache.jena.atlas.junit.BaseTest)3 Test (org.junit.Test)3 ModDataset (arq.cmdline.ModDataset)1 CmdException (jena.cmd.CmdException)1 Graph (org.apache.jena.graph.Graph)1 Node (org.apache.jena.graph.Node)1 Dataset (org.apache.jena.query.Dataset)1 InfGraph (org.apache.jena.reasoner.InfGraph)1 JenaException (org.apache.jena.shared.JenaException)1 Quad (org.apache.jena.sparql.core.Quad)1 DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)1