/** The NodeTupleTable for this graph */ public NodeTupleTable getNodeTupleTable() { return getDSG().chooseNodeTupleTable(getGraphName()) ; }
@Override protected ExtendedIterator<Triple> graphUnionFind(Node s, Node p, Node o) { Node g = Quad.unionGraph ; Iterator<Quad> iterQuads = getDSG().find(g, 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) ; }
/** 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) { // 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. DatasetGraphTDB ds = graph.getDSG() ; return optimizeExecuteQuads(ds, input, graph.getGraphName(), opBGP.getPattern(), exprs, execCxt) ; } // Execute a BGP on the real default graph return optimizeExecuteTriples(graph, input, opBGP.getPattern(), exprs, execCxt) ; }
@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.getDSG(), gn, bgp, input, filter, execCxt) ; } Log.warn(this, "Non-GraphTDB passed to OpExecutorPlainTDB") ; return super.execute(opBGP, input) ; }
ReorderTransformation transform = graph.getDSG().getReorderTransform() ; if ( transform != null )
@Override protected final int graphBaseSize() { if ( isDefaultGraph() ) return (int)getNodeTupleTable().size() ; Node gn = getGraphName() ; boolean unionGraph = isUnionGraph(gn) ; gn = unionGraph ? Node.ANY : gn ; Iterator<Tuple<NodeId>> iter = getDSG().getQuadTable().getNodeTupleTable().findAsNodeIds(gn, null, null, null) ; if ( unionGraph ) { iter = Iter.map(iter, project4TupleTo3Tuple) ; iter = Iter.distinctAdjacent(iter) ; } return (int)Iter.count(iter) ; }
@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).getDSG(), gn, bgp, input, filter, execCxt) ; } Log.warn(this, "Non-DatasetGraphTDB passed to OpExecutorPlainTDB") ; return super.execute(opQuadPattern, input) ; }