Search in sources :

Example 16 with DatasetGraphTDB

use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.

the class AbstractTestTransSeq method trans_readBlock_10.

@Test
public void trans_readBlock_10() {
    // READ(start)-WRITE(start)-WRITE(finish)-WRITE(start)-READ(finish)-WRITE(finish)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    DatasetGraphTxn dsgW1 = sConn.begin(ReadWrite.WRITE);
    dsgW1.add(q1);
    dsgW1.commit();
    dsgW1.end();
    DatasetGraphTxn dsgW2 = sConn.begin(ReadWrite.WRITE);
    dsgW2.add(q2);
    dsgR1.end();
    dsgW2.commit();
    dsgW2.end();
    sConn.forceRecoverFromJournal();
    DatasetGraphTDB dsg = sConn.getBaseDataset();
    assertTrue(dsg.contains(q1));
    assertTrue(dsg.contains(q2));
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 17 with DatasetGraphTDB

use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.

the class AbstractTestTransSeq method trans_readBlock_11.

@Test
public void trans_readBlock_11() {
    // JENA-91
    // READ(start)-WRITE-WRITE-WRITE-READ(finish)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    DatasetGraphTxn dsgW1 = sConn.begin(ReadWrite.WRITE);
    dsgW1.add(q1);
    dsgW1.commit();
    dsgW1.end();
    DatasetGraphTxn dsgW2 = sConn.begin(ReadWrite.WRITE);
    dsgW2.add(q2);
    dsgW2.commit();
    dsgW2.end();
    DatasetGraphTxn dsgW3 = sConn.begin(ReadWrite.WRITE);
    dsgW3.add(q3);
    dsgW3.commit();
    dsgW3.end();
    dsgR1.end();
    sConn.flush();
    DatasetGraphTDB dsg = sConn.getBaseDataset();
    assertTrue(dsg.contains(q1));
    assertTrue(dsg.contains(q2));
    assertTrue(dsg.contains(q3));
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 18 with DatasetGraphTDB

use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.

the class MgtFunctions method prefixes.

/** Return prefixes for the datasets, SPARQL syntax. */
public static String prefixes(HttpServletRequest request) {
    String dsName = dataset(request);
    DatasetRef desc = getFromRegistry(dsName);
    if (desc == null)
        return "<not found>";
    DatasetGraph dsg = desc.dataset;
    if (dsg instanceof DatasetGraphTDB) {
        PrefixMapping pmap = ((DatasetGraphTDB) dsg).getPrefixes().getPrefixMapping();
        Prologue prologue = new Prologue(pmap);
        IndentedLineBuffer buff = new IndentedLineBuffer();
        PrologueSerializer.output(buff, prologue);
        buff.append("\n");
        return buff.asString();
    }
    return "";
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Prologue(org.apache.jena.sparql.core.Prologue) DatasetRef(org.apache.jena.fuseki.server.DatasetRef) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 19 with DatasetGraphTDB

use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.

the class ProcNodeTableBuilder method exec.

public static void exec(Location location, String dataFileTriples, String dataFileQuads, List<String> datafiles, boolean collectStats) {
    // This formats the location correctly.
    // But we're not really interested in it all.
    DatasetGraphTDB dsg = DatasetBuilderStd.create(location);
    // so close indexes and the prefix table.
    dsg.getTripleTable().getNodeTupleTable().getTupleTable().close();
    dsg.getQuadTable().getNodeTupleTable().getTupleTable().close();
    ProgressMonitor monitor = ProgressMonitor.create(cmdLog, "Data", BulkLoader.DataTickPoint, BulkLoader.superTick);
    OutputStream outputTriples = null;
    OutputStream outputQuads = null;
    try {
        outputTriples = new FileOutputStream(dataFileTriples);
        outputQuads = new FileOutputStream(dataFileQuads);
    } catch (FileNotFoundException e) {
        throw new AtlasException(e);
    }
    NodeTableBuilder sink = new NodeTableBuilder(dsg, monitor, outputTriples, outputQuads, collectStats);
    monitor.start();
    sink.startBulk();
    for (String filename : datafiles) {
        if (datafiles.size() > 0)
            cmdLog.info("Load: " + filename + " -- " + DateTimeUtils.nowAsString());
        RDFDataMgr.parse(sink, filename);
    }
    sink.finishBulk();
    IO.close(outputTriples);
    IO.close(outputQuads);
    // See Stats class.
    if (!location.isMem() && sink.getCollector() != null)
        Stats.write(dsg.getLocation().getPath(Names.optStats), sink.getCollector().results());
    // ---- Monitor
    long time = monitor.finish();
    long total = monitor.getTicks();
    float elapsedSecs = time / 1000F;
    float rate = (elapsedSecs != 0) ? total / elapsedSecs : 0;
    String str = String.format("Total: %,d tuples : %,.2f seconds : %,.2f tuples/sec [%s]", total, elapsedSecs, rate, DateTimeUtils.nowAsString());
    cmdLog.info(str);
}
Also used : ProgressMonitor(org.apache.jena.atlas.lib.ProgressMonitor) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) AtlasException(org.apache.jena.atlas.AtlasException) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB)

Example 20 with DatasetGraphTDB

use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.

the class OpExecutorTDB1 method execute.

@Override
protected QueryIterator execute(OpDatasetNames dsNames, QueryIterator input) {
    DatasetGraphTDB ds = (DatasetGraphTDB) execCxt.getDataset();
    Predicate<Tuple<NodeId>> filter = QC2.getFilter(execCxt.getContext());
    Node gn = dsNames.getGraphNode();
    if (Var.isVar(gn))
        return SolverLib.graphNames(ds, dsNames.getGraphNode(), input, filter, execCxt);
    else
        return SolverLib.testForGraphName(ds, dsNames.getGraphNode(), input, filter, execCxt);
}
Also used : Node(org.apache.jena.graph.Node) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB)

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