public static GraphViewSwitchable createDefaultGraph(DatasetGraphSwitchable dsg) { return new GraphViewSwitchable(dsg, Quad.defaultGraphNodeGenerated); }
@Override public Graph getGraph(Node gn) { Node key = ( gn != null ) ? gn : Quad.defaultGraphNodeGenerated; return ngCache.getOrFill(key, ()->GraphViewSwitchable.createNamedGraph(this, key)); } }
@Override protected int graphBaseSize() { if ( isDefaultGraph() ) return getDSG().getDefaultGraphTDB().size(); return getDSG().getGraphTDB(getGraphName()).size(); }
/** Return the {@code Graph} from the underlying DatasetGraph * Do not hold onto this reference across switches. */ public Graph getBaseGraph() { if ( getGraphName() == null ) return getDSG().getDefaultGraph(); else return getDSG().getGraph(getGraphName()); }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build(assemblerFile, VocabTDB2.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphViewSwitchable) ; DatasetGraphSwitchable dsg = ((GraphViewSwitchable)graph).getDataset(); if ( dsg != null ) dsg.close() ; } }
/** Return the {@link DatasetGraphSwitchable} we are viewing. */ @Override public DatasetGraphSwitchable getDataset() { return getx(); }
@Override protected PrefixMapping createPrefixMapping() { Node gn = super.getGraphName(); if ( gn == Quad.defaultGraphNodeGenerated ) gn = null; if ( Quad.isUnionGraph(gn) ) { // Read-only wrapper would be better than a copy. PrefixMapping pmap = new PrefixMappingImpl(); pmap.setNsPrefixes(prefixMapping(null)); return pmap; } return prefixMapping(gn); }
@Override public QueryIterator execute(BasicPattern pattern, QueryIterator input, ExecutionContext execCxt) { // --- In case this isn't for TDB2 Graph g = execCxt.getActiveGraph() ; if ( g instanceof GraphViewSwitchable ) { GraphViewSwitchable gvs = (GraphViewSwitchable)g; g = gvs.getBaseGraph(); } if ( ! ( g instanceof GraphTDB ) ) // Not us - bounce up the StageGenerator chain return above.execute(pattern, input, execCxt) ; GraphTDB graph = (GraphTDB)g ; Predicate<Tuple<NodeId>> filter = QC2.getFilter(execCxt.getContext()) ; return SolverLib.execute(graph, pattern, input, filter, execCxt) ; } }
private static void testGraph(String assemblerFile, boolean named) { Object thing = null ; try { thing = AssemblerUtils.build(assemblerFile, VocabTDB2.tGraphTDB) ; } catch (AssemblerException e) { e.getCause().printStackTrace(System.err) ; throw e ; } assertTrue(thing instanceof Model) ; Graph graph = ((Model)thing).getGraph() ; assertTrue(graph instanceof GraphViewSwitchable) ; DatasetGraphSwitchable dsg = ((GraphViewSwitchable)graph).getDataset(); if ( dsg != null ) dsg.close() ; } }
private DatasetGraphTDB getDSG() { return ((DatasetGraphTDB)(getx().get())); }
@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 GraphViewSwitchable) ; DatasetGraphSwitchable ds = ((GraphViewSwitchable)graph).getDataset() ; if ( ds != null ) ds.close() ; }
public static GraphView createNamedGraph(DatasetGraphSwitchable dsg, Node graphIRI) { return new GraphViewSwitchable(dsg, graphIRI); }
@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 GraphViewSwitchable) ; DatasetGraphSwitchable ds = ((GraphViewSwitchable)graph).getDataset() ; if ( ds != null ) ds.close() ; }
public static GraphViewSwitchable createUnionGraph(DatasetGraphSwitchable dsg) { return new GraphViewSwitchable(dsg, Quad.unionGraph); }