public boolean containsGraph(Node graphNode) { return dsg.containsGraph(graphNode) ; }
@Override public boolean httpHead(Node graphName) { return dataset.containsGraph(graphName) ; }
public boolean containsNamedModel(String uri) { Node n = Node.createURI(uri) ; return dsg.containsGraph(n) ; }
@Override public boolean containsGraph(Node graphNode) { return get().containsGraph(graphNode) ; }
@Override public boolean containsGraph(Node graphNode) { return get().containsGraph(graphNode) ; }
public boolean containsNamedModel(String uri) { checkGraphName(uri) ; // Don't look in the cache - just ask the DSG which either caches graphs // or asks the storage as needed. The significant case is whether an // empty graph is contained in a dataset. If it's pure quad storage, // the answer is usually better as "no"; if it's an in-memory // dataset the answer is "yes". return dsg.containsGraph(Node.createURI(uri)) ; }
@Override public boolean containsNamedModel(String uri) { // Does not touch the cache. checkGraphName(uri) ; Node n = NodeFactory.createURI(uri) ; return dsg.containsGraph(n) ; }
public static boolean containsGraph(DatasetGraph dsg, Node gn) { // [[DynDS]] if ( Quad.isDefaultGraph(gn)) return true ; if ( Quad.isUnionGraph(gn)) return true ; return dsg.containsGraph(gn) ; }
static Table evalDS(OpDatasetNames opDSN, Evaluator evaluator) { Node graphNode = opDSN.getGraphNode() ; if ( graphNode.isURI() ) { if ( evaluator.getExecContext().getDataset().containsGraph(graphNode) ) { return new TableUnit() ; } else // WRONG { return new TableEmpty() ; } } if ( ! Var.isVar(graphNode) ) throw new ARQInternalErrorException("OpDatasetNames: Not a URI or variable: "+graphNode) ; DatasetGraph dsg = evaluator.getExecContext().getDataset() ; Iterator<Node> iter = dsg.listGraphNodes() ; List<Binding> list = new ArrayList<Binding>((int)dsg.size()) ; for ( ; iter.hasNext(); ) { Node gn = iter.next(); Binding b = BindingFactory.binding(Var.alloc(graphNode), gn) ; list.add(b) ; } QueryIterator qIter = new QueryIterPlainWrapper(list.iterator(), evaluator.getExecContext()) ; return TableFactory.create(qIter) ; }
static Table evalDS(OpDatasetNames opDSN, Evaluator evaluator) { Node graphNode = opDSN.getGraphNode() ; if ( graphNode.isURI() ) { if ( evaluator.getExecContext().getDataset().containsGraph(graphNode) ) { return new TableUnit() ; } else // WRONG { return new TableEmpty() ; } } if ( ! Var.isVar(graphNode) ) throw new ARQInternalErrorException("OpDatasetNames: Not a URI or variable: "+graphNode) ; DatasetGraph dsg = evaluator.getExecContext().getDataset() ; Iterator<Node> iter = dsg.listGraphNodes() ; List<Binding> list = new ArrayList<Binding>((int)dsg.size()) ; for ( ; iter.hasNext(); ) { Node gn = iter.next(); Binding b = BindingFactory.binding(Var.alloc(graphNode), gn) ; list.add(b) ; } QueryIterator qIter = new QueryIterPlainWrapper(list.iterator(), evaluator.getExecContext()) ; return TableFactory.create(qIter) ; }
@Override protected QueryIterator nextStage(Binding binding) { DatasetGraph ds = super.getExecContext().getDataset() ; Node n = Substitute.substitute(node, binding) ; String uri = n.getURI(); if ( ds.containsGraph(n) ) return IterLib.result(binding, getExecContext()) ; // DO NOT LOOK AT THIS CODE Model m = FileManager.get().loadModel(uri) ; Graph g = m.getGraph() ; ds.addGraph(n, g) ; return IterLib.result(binding, getExecContext()) ; }
protected static QueryIterator buildIterator(Binding binding, Node graphNode, OpGraph opGraph, ExecutionContext outerCxt) { if ( !graphNode.isURI() && !graphNode.isBlank() ) // e.g. variable bound to a literal or blank node. throw new ARQInternalErrorException("QueryIterGraphInner.buildIterator: Not a URI or balnk node: "+graphNode) ; // Think about avoiding substitution. // If the subpattern does not involve the vars from the binding, avoid the substitute. Op op = QC.substitute(opGraph.getSubOp(), binding) ; // We can't just use DatasetGraph.getGraph because it may "auto-create" graphs. // Use the containsGraph function. boolean syntheticGraph = ( Quad.isDefaultGraph(graphNode) || Quad.isUnionGraph(graphNode) ) ; if ( ! syntheticGraph && ! outerCxt.getDataset().containsGraph(graphNode) ) return null ; Graph g = outerCxt.getDataset().getGraph(graphNode) ; // And the contains was true??!!!!!! if ( g == null ) return null ; //throw new ARQInternalErrorException(".containsGraph was true but .getGraph is null") ; ExecutionContext cxt2 = new ExecutionContext(outerCxt, g) ; QueryIterator subInput = QueryIterSingleton.create(binding, cxt2) ; return QC.execute(op, subInput, cxt2) ; }