use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.
the class TestQuadFilter method setup.
/** Example setup - in-memory dataset with two graphs, one triple in each */
private static Dataset setup() {
Dataset ds = TDBFactory.createDataset();
DatasetGraphTDB dsg = (DatasetGraphTDB) (ds.asDatasetGraph());
Quad q1 = SSE.parseQuad("(<http://example/g1> <http://example/s> <http://example/p> <http://example/o1>)");
Quad q2 = SSE.parseQuad("(<http://example/g2> <http://example/s> <http://example/p> <http://example/o2>)");
dsg.add(q1);
dsg.add(q2);
return ds;
}
use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.
the class TestQuadFilter method createFilter.
/** Create a filter to exclude the graph http://example/g2 */
private static Predicate<Tuple<NodeId>> createFilter(Dataset ds) {
DatasetGraphTDB dsg = (DatasetGraphTDB) (ds.asDatasetGraph());
final NodeTable nodeTable = dsg.getQuadTable().getNodeTupleTable().getNodeTable();
final NodeId target = nodeTable.getNodeIdForNode(NodeFactory.createURI(graphToHide));
return item -> !(item.len() == 4 && item.get(0).equals(target));
}
use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.
the class StoreConnection method make.
/**
* Return a StoreConnection for a particular connection. This is used to
* create transactions for the database at the location.
*/
public static synchronized StoreConnection make(Location location, StoreParams params) {
StoreConnection sConn = cache.get(location);
if (sConn != null)
return sConn;
DatasetGraphTDB dsg = DatasetBuilderStd.create(location, params);
sConn = _makeAndCache(dsg);
return sConn;
}
use of org.apache.jena.tdb.store.DatasetGraphTDB 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);
}
}
use of org.apache.jena.tdb.store.DatasetGraphTDB in project jena by apache.
the class TestTransRestart method setupPlain.
private void setupPlain() {
// Make without transactions.
DatasetGraphTDB dsg = createPlain(location);
dsg.add(quad1);
dsg.close();
StoreConnection.release(location);
return;
}
Aggregations