@Override public Graph getDefaultGraph() { return GraphView.createDefaultGraph(this) ; }
@Override public Graph getGraph(Node graphNode) { return GraphView.createNamedGraph(this, graphNode) ; }
graphData = new LineGraphSeries<DataPoint>(); graphDataRemote = new LineGraphSeries<DataPoint>(); GraphView graph = new GraphView(this); graph.addSeries(graphData); graph.addSeries(graphDataRemote); graph.getViewport().setMaxY(graphMaxY); graph.getViewport().setMaxX(graphMaxX); ...
@Test public void graphDSG_basic_1() { Graph g = makeDefaultGraph(baseDSG) ; assertTrue(g instanceof GraphView) ; GraphView gv = (GraphView)g ; assertEquals(baseDSG, gv.getDataset()) ; assertEquals(null, gv.getGraphName()) ; }
public static GraphView createDefaultGraph(DatasetGraph dsg) { return new GraphView(dsg, Quad.defaultGraphNodeGenerated) ; }
protected ExtendedIterator<Triple> graphUnionFind(Node s, Node p, Node o) { Node g = graphNode(gn) ; // Implementations may wish to do better so this is separated out. // For example, Iter.distinctAdjacent is a lot cheaper than Iter.distinct // but assumes things come back in a particular order Iterator<Quad> iterQuads = getDataset().find(g, s, p, o) ; Iterator<Triple> iter = GLib.quads2triples(iterQuads) ; // Suppress duplicates after projecting to triples. iter = Iter.distinct(iter) ; return WrappedIterator.createNoRemove(iter) ; }
@Override public JenaGraph getUnionGraph() { final GraphView gv = GraphView.createUnionGraph(datasetGraph); return new JenaGraphImpl(gv, salt); }
private static Object calcKey(Graph graph) { if ( graph instanceof GraphView ) // Use the database as the key so that transactions are started once-per-storage. // This the case of a graph from some storage being placed in a general dataset. return ((GraphView)graph).getDataset(); if ( graph instanceof InfGraph ) // InfGraph TransactionHandler passes the graph transaction to the base graph. // This calcKey allows the base graph to be included in the dataset as well as the InfGraph. return calcKey(((InfGraph)graph).getRawGraph()); // These should be handled by their respective graph transaction handler // or the graph is overriding that behaviour for some reason. // if ( graph instanceof GraphWrapper ) // return calcKey(((GraphWrapper)graph).get()); // if ( graph instanceof WrappedGraph ) // return calcKey(((WrappedGraph)graph).getWrapped()); return graph; }
@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 ; } dataset.deleteAny(getGraphName(), s, p, o) ; // We know no one is listening ... // getEventManager().notifyEvent(this, GraphEvents.remove(s, p, o) ) ; } }
@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); }
@Test public void graphDSG_basic_2() { Node gn1 = SSE.parseNode("<g1>") ; Graph g = makeNamedGraph(baseDSG, gn1) ; assertTrue(g instanceof GraphView) ; GraphView gv = (GraphView)g ; assertEquals(baseDSG, gv.getDataset()) ; assertEquals(gn1, gv.getGraphName()) ; }
public static GraphView createUnionGraph(DatasetGraph dsg) { return new GraphView(dsg, Quad.unionGraph) ; }
@Test public void graphDSG_view_union_3() { Graph g = GraphView.createUnionGraph(baseDSG) ; assertEquals(2, g.size()) ; }
public static DatasetGraph create(Graph graph) { // Find the deepest graph, the one that may be attached to a DatasetGraph. Graph graph2 = unwrap(graph); if ( graph2 instanceof GraphView ) { // This becomes a simple class that passes all transaction operations the // underlying dataset and masks the fact here are other graphs in the storage. return new DatasetGraphOne(graph, ((GraphView)graph2).getDataset()); } // Didn't find a GraphView so no backing DatasetGraph; work on the graph as given. return new DatasetGraphOne(graph); }
@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) ) ; } }
@Override public Graph getDefaultGraph() { return GraphView.createDefaultGraph(this); }
@Override public Graph getGraph(Node graphNode) { return GraphView.createNamedGraph(this, graphNode) ; } // ----
public static GraphView createNamedGraph(DatasetGraph dsg, Node graphIRI) { return new GraphView(dsg, graphIRI) ; }
@Test public void graphDSG_view_union_2() { Graph g = GraphView.createUnionGraph(baseDSG) ; assertTrue(g instanceof GraphView) ; long x = Iter.count(g.find(null,null,null)) ; assertEquals(2, x) ; }
protected static QueryExecution make(Query query, Model model) { Dataset dataset = DatasetFactory.wrap(model); Graph g = unwrap(model.getGraph()); if ( g instanceof GraphView ) { GraphView gv = (GraphView)g; // Copy context of the storage dataset to the wrapper dataset. dataset.getContext().putAll(gv.getDataset().getContext()); } return make(query, dataset); }