@Override protected QueryIterator nextStage(Binding binding) { QueryIterator qIter = PathLib.execTriplePath(binding, triplePath, getExecContext()) ; return qIter ; }
/** Install a path as a property function in the global property function registry */ public static void install(String uri, Path path) { install(uri, path, PropertyFunctionRegistry.get()) ; }
protected Op compilePathBlock(PathBlock pathBlock) { // Empty path block : the parser does not generate this case. if ( pathBlock.size() == 0 ) return OpTable.unit() ; // Always turns the most basic paths to triples. return PathLib.pathToTriples(pathBlock) ; }
return ungroundedPathSameVar(binding, graph, Var.alloc(s), path, execCxt) ; else return ungroundedPath(binding, graph, Var.alloc(s), path, Var.alloc(o), execCxt) ; return groundedPath(binding, graph, s, path, o, execCxt) ; endNode = o ; return _execTriplePath(binding, iter, endNode, execCxt) ;
return ungroundedPath(binding, graph, Var.alloc(s), path, Var.alloc(o), execCxt) ; return groundedPath(binding, graph, s, path, o, execCxt) ; endNode = o ; return _execTriplePath(binding, iter, endNode, execCxt) ;
private static QueryIterator ungroundedPath(Binding binding, Graph graph, Var sVar, Path path, Var oVar, ExecutionContext execCxt) { Iterator<Node> iter = GraphUtils.allNodes(graph) ; QueryIterConcat qIterCat = new QueryIterConcat(execCxt) ; for ( ; iter.hasNext() ; ) { Node n = iter.next() ; Binding b2 = BindingFactory.binding(binding, sVar, n) ; Iterator<Node> pathIter = PathEval.eval(graph, n, path) ; QueryIterator qIter = _execTriplePath(b2, pathIter, oVar, execCxt) ; qIterCat.add(qIter) ; } return qIterCat ; }
/** Convert any paths of exactly one predicate to a triple pattern */ public static Op pathToTriples(PathBlock pattern) { BasicPattern bp = null ; Op op = null ; for ( TriplePath tp : pattern ) { if ( tp.isTriple() ) { if ( bp == null ) bp = new BasicPattern() ; bp.add(tp.asTriple()) ; continue ; } // Path form. op = flush(bp, op) ; bp = null ; OpPath opPath2 = new OpPath(tp) ; op = OpSequence.create(op, opPath2) ; continue ; } // End. Finish off any outstanding BGP. op = flush(bp, op) ; return op ; }
private static QueryIterator ungroundedPathSameVar(Binding binding, Graph graph, Var var, Path path, ExecutionContext execCxt) { // Try each end, grounded // Slightly more efficient would be to add a per-engine to do this. Iterator<Node> iter = GraphUtils.allNodes(graph) ; QueryIterConcat qIterCat = new QueryIterConcat(execCxt) ; for ( ; iter.hasNext() ; ) { Node n = iter.next() ; Binding b2 = BindingFactory.binding(binding, var, n) ; int x = existsPath(graph, n, path, n) ; if ( x > 0 ) { QueryIterator qIter = new QueryIterYieldN(x, b2, execCxt) ; qIterCat.add(qIter) ; } } return qIterCat ; }
private static QueryIterator ungroundedPath(Binding binding, Graph graph, Var sVar, Path path, Var oVar, ExecutionContext execCxt) { Iterator<Node> iter = GraphUtils.allNodes(graph) ; QueryIterConcat qIterCat = new QueryIterConcat(execCxt) ; for ( ; iter.hasNext() ; ) { Node n = iter.next() ; Binding b2 = BindingFactory.binding(binding, sVar, n) ; Iterator<Node> pathIter = PathEval.eval(graph, n, path) ; QueryIterator qIter = _execTriplePath(b2, pathIter, oVar, execCxt) ; qIterCat.add(qIter) ; } return qIterCat ; } }
/** Convert any paths of exactly one predicate to a triple pattern */ public static Op pathToTriples(PathBlock pattern) { BasicPattern bp = null ; Op op = null ; for ( TriplePath tp : pattern ) { if ( tp.isTriple() ) { if ( bp == null ) bp = new BasicPattern() ; bp.add(tp.asTriple()) ; continue ; } // Path form. op = flush(bp, op) ; bp = null ; OpPath opPath2 = new OpPath(tp) ; op = OpSequence.create(op, opPath2) ; continue ; } // End. Finish off any outstanding BGP. op = flush(bp, op) ; return op ; }
@Override public Op transform(OpPath opPath) { // Flatten down to triples where possible. PathBlock pattern = pathCompiler.reduce(opPath.getTriplePath()) ; // Any generated paths of exactly one to triple; convert to Op. return PathLib.pathToTriples(pattern) ; } }
@Override protected QueryIterator nextStage(Binding binding) { QueryIterator qIter = PathLib.execTriplePath(binding, triplePath, getExecContext()) ; return qIter ; }
/** Install a path as a property function in the global property function registry */ public static void install(String uri, Path path) { install(uri, path, PropertyFunctionRegistry.get()) ; }
protected Op compilePathBlock(PathBlock pathBlock) { // Empty path block : the parser does not generate this case. if ( pathBlock.size() == 0 ) return OpTable.unit() ; // Always turns the most basic paths to triples. return PathLib.pathToTriples(pathBlock) ; }
public static QueryIterator execTriplePath(Binding binding, TriplePath triplePath, ExecutionContext execCxt) { if ( triplePath.isTriple() ) { // Fake it. This happens only for API constructed situations. Path path = new P_Link(triplePath.getPredicate()) ; triplePath = new TriplePath(triplePath.getSubject(), path, triplePath.getObject()) ; } return execTriplePath(binding, triplePath.getSubject(), triplePath.getPath(), triplePath.getObject(), execCxt) ; }
@Override public Op transform(OpPath opPath) { // Flatten down to triples where possible. PathBlock pattern = pathCompiler.reduce(opPath.getTriplePath()) ; // Any generated paths of exactly one to triple; convert to Op. return PathLib.pathToTriples(pattern) ; } }
public static QueryIterator execTriplePath(Binding binding, TriplePath triplePath, ExecutionContext execCxt) { if ( triplePath.isTriple() ) { // Fake it. This happens only for API constructed situations. Path path = new P_Link(triplePath.getPredicate()) ; triplePath = new TriplePath(triplePath.getSubject(), path, triplePath.getObject()) ; } return execTriplePath(binding, triplePath.getSubject(), triplePath.getPath(), triplePath.getObject(), execCxt) ; }