use of org.apache.jena.sparql.engine.iterator.QueryIterYieldN in project jena by apache.
the class PathLib method evalGroundedPath.
// Subject and object are nodes.
private static QueryIterator evalGroundedPath(Binding binding, Graph graph, Node subject, Path path, Node object, ExecutionContext execCxt) {
Iterator<Node> iter = PathEval.eval(graph, subject, path, execCxt.getContext());
// Now count the number of matches.
int count = 0;
for (; iter.hasNext(); ) {
Node n = iter.next();
if (n.sameValueAs(object))
count++;
}
return new QueryIterYieldN(count, binding, execCxt);
}
use of org.apache.jena.sparql.engine.iterator.QueryIterYieldN in project jena by apache.
the class PathLib method execUngroundedPathSameVar.
private static QueryIterator execUngroundedPathSameVar(Binding binding, Graph graph, Var var, Path path, ExecutionContext execCxt) {
// Try each end, ungrounded.
// Slightly more efficient would be to add a per-engine to do this.
Iterator<Node> iter = determineUngroundedStartingSet(graph, path, execCxt);
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, execCxt);
if (x > 0) {
QueryIterator qIter = new QueryIterYieldN(x, b2, execCxt);
qIterCat.add(qIter);
}
}
return qIterCat;
}
Aggregations