@Override public final void sync() { getDatasetGraphTDB().sync(); }
@Override public void commit() { graph.getDatasetGraphTDB().sync(); }
protected DatasetPrefixStorage getPrefixStorage() { return getDatasetGraphTDB().getPrefixes() ; }
private static void loadGraph$(GraphTDB graph, List<String> urls, boolean showProgress, boolean collectStats) { if ( graph.getGraphName() == null ) loadDefaultGraph$(graph.getDatasetGraphTDB(), urls, showProgress, collectStats) ; else loadNamedGraph$(graph.getDatasetGraphTDB(), graph.getGraphName(), urls, showProgress, collectStats) ; }
/** The NodeTupleTable for this graph - valid only inside the transaction or non-transactional. */ public NodeTupleTable getNodeTupleTable() { return getDatasetGraphTDB().chooseNodeTupleTable(getGraphName()) ; }
@Override protected ExtendedIterator<Triple> graphUnionFind(Node s, Node p, Node o) { Iterator<Quad> iterQuads = getDatasetGraphTDB().find(Quad.unionGraph, s, p, o) ; Iterator<Triple> iter = GLib.quads2triples(iterQuads) ; // Suppress duplicates after projecting to triples. // TDB guarantees that duplicates are adjacent. // See SolverLib. iter = Iter.distinctAdjacent(iter) ; return WrappedIterator.createNoRemove(iter) ; }
@Override public void remove(Node s, Node p, Node o) { if ( getEventManager().listening() ) { // Have to do it the hard way so that triple events happen. super.remove(s, p, o) ; return ; } getDatasetGraphTDB().deleteAny(getGraphName(), s, p, o) ; // We know no one is listening ... // getEventManager().notifyEvent(this, GraphEvents.remove(s, p, o) ) ; } }
private static void loadGraph$(GraphTDB graph, InputStream input, boolean showProgress, boolean collectStats) { DatasetGraphTDB dsgtdb = TDBInternal.getBaseDatasetGraphTDB(graph.getDatasetGraphTDB()); if ( graph.getGraphName() == null ) loadDefaultGraph$(dsgtdb, input, showProgress, collectStats) ; else loadNamedGraph$(dsgtdb, graph.getGraphName(), input, showProgress, collectStats) ; }
/** Execute a BGP (and filters) on a TDB graph, which may be in default storage or it may be a named graph */ private static QueryIterator executeBGP(GraphTDB graph, OpBGP opBGP, QueryIterator input, ExprList exprs, ExecutionContext execCxt) { DatasetGraphTDB dsgtdb = graph.getDatasetGraphTDB() ; // Is it the real default graph (normal route or explicitly named)? if ( ! isDefaultGraphStorage(graph.getGraphName())) { // Not default storage - it's a named graph in storage. return optimizeExecuteQuads(dsgtdb, input, graph.getGraphName(), opBGP.getPattern(), exprs, execCxt) ; } // Execute a BGP on the real default graph return optimizeExecuteTriples(dsgtdb, input, opBGP.getPattern(), exprs, execCxt) ; }
private PrefixMapping createPrefixMapping$() { DatasetPrefixStorage dsgPrefixes = getDatasetGraphTDB().getPrefixes() ; if ( isDefaultGraph() ) return dsgPrefixes.getPrefixMapping() ; if ( isUnionGraph() ) return dsgPrefixes.getPrefixMapping() ; return dsgPrefixes.getPrefixMapping(getGraphName().getURI()) ; }
@Override public QueryIterator execute(OpBGP opBGP, QueryIterator input) { Graph g = execCxt.getActiveGraph() ; if ( g instanceof GraphTDB ) { BasicPattern bgp = opBGP.getPattern() ; Explain.explain("Execute", bgp, execCxt.getContext()) ; // Triple-backed (but may be named as explicit default graph). //return SolverLib.execute((GraphTDB)g, bgp, input, filter, execCxt) ; GraphTDB gtdb = (GraphTDB)g ; Node gn = decideGraphNode(gtdb.getGraphName(), execCxt) ; return SolverLib.execute(gtdb.getDatasetGraphTDB(), gn, bgp, input, filter, execCxt) ; } Log.warn(this, "Non-GraphTDB passed to OpExecutorPlainTDB") ; return super.execute(opBGP, input) ; }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build( assemblerFile, VocabTDB.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); } }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build( assemblerFile, VocabTDB.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); } }
@Override protected final int graphBaseSize() { if ( isDefaultGraph() ) return (int)getNodeTupleTable().size() ; Node gn = getGraphName() ; boolean unionGraph = isUnionGraph(gn) ; gn = unionGraph ? Node.ANY : gn ; QuadTable quadTable = getDatasetGraphTDB().getQuadTable() ; Iterator<Tuple<NodeId>> iter = quadTable.getNodeTupleTable().findAsNodeIds(gn, null, null, null) ; if ( unionGraph ) { iter = Iter.map(iter, project4TupleTo3Tuple) ; iter = Iter.distinctAdjacent(iter) ; } return (int)Iter.count(iter) ; }
@Test public void createGraphEmbed() { String f = dirAssem+"/tdb-graph-embed.ttl" ; Object thing = null ; try { thing = AssemblerUtils.build( f, JA.Model) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); }
@Test public void createGraphEmbed() { String f = dirAssem+"/tdb-graph-embed.ttl" ; Object thing = null ; try { thing = AssemblerUtils.build( f, JA.Model) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphTDB) ; DatasetGraphTDB ds = ((GraphTDB)graph).getDatasetGraphTDB() ; if ( ds != null ) ds.close(); }
@Override public QueryIterator execute(OpQuadPattern opQuadPattern, QueryIterator input) { Node gn = opQuadPattern.getGraphNode() ; gn = decideGraphNode(gn, execCxt) ; if ( execCxt.getDataset() instanceof DatasetGraphTDB ) { DatasetGraphTDB ds = (DatasetGraphTDB)execCxt.getDataset() ; Explain.explain("Execute", opQuadPattern.getPattern(), execCxt.getContext()) ; BasicPattern bgp = opQuadPattern.getBasicPattern() ; return SolverLib.execute(ds, gn, bgp, input, filter, execCxt) ; } // Maybe a TDB named graph inside a non-TDB dataset. Graph g = execCxt.getActiveGraph() ; if ( g instanceof GraphTDB ) { // Triples graph from TDB (which is the default graph of the dataset), // used a named graph in a composite dataset. BasicPattern bgp = opQuadPattern.getBasicPattern() ; Explain.explain("Execute", bgp, execCxt.getContext()) ; // Don't pass in G -- gn may be different. return SolverLib.execute(((GraphTDB)g).getDatasetGraphTDB(), gn, bgp, input, filter, execCxt) ; } Log.warn(this, "Non-DatasetGraphTDB passed to OpExecutorPlainTDB") ; return super.execute(opQuadPattern, input) ; }