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));
}
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));
}
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 "";
}
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);
}
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);
}
Aggregations