use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.
the class ExecutionDispatch method visit.
@Override
public void visit(OpOrder opOrder) {
QueryIterator input = pop();
QueryIterator qIter = opExecutor.execute(opOrder, input);
push(qIter);
}
use of org.apache.jena.sparql.engine.QueryIterator 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;
}
use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.
the class PathEngine method graphFindWorker.
private Iterator<Triple> graphFindWorker(Graph graph, Node s, PropertyFunctionFactory f, Node p, Node o, Context context) {
// Expensive?
PropertyFunction pf = f.create(p.getURI());
PropFuncArg sv = arg(s, "S");
PropFuncArg ov = arg(o, "O");
QueryIterator r = QueryIterRoot.create(new ExecutionContext(context, graph, null, null));
QueryIterator qIter = pf.exec(r, sv, p, ov, new ExecutionContext(ARQ.getContext(), graph, null, null));
if (!qIter.hasNext())
return Iter.nullIterator();
List<Triple> array = new ArrayList<>();
for (; qIter.hasNext(); ) {
Binding b = qIter.next();
Node st = value(sv, b);
Node ot = value(ov, b);
array.add(Triple.create(st, p, ot));
}
// Materialise so the inner QueryIterators are used up.
return array.iterator();
}
use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.
the class PathLib method execUngroundedPath.
// Brute force evaluation of a TriplePath where neither subject nor object are bound
private static QueryIterator execUngroundedPath(Binding binding, Graph graph, Var sVar, Path path, Var oVar, ExecutionContext execCxt) {
// Starting points.
Iterator<Node> iter = determineUngroundedStartingSet(graph, path, execCxt);
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, execCxt.getContext());
QueryIterator qIter = evalGroundedOneEnd(b2, pathIter, oVar, execCxt);
qIterCat.add(qIter);
}
return qIterCat;
}
use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.
the class Eval method evalDS.
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<>((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);
}
Aggregations