use of org.apache.jena.sparql.engine.iterator.QueryIterConcat in project jena by apache.
the class ListBase method allLists.
protected QueryIterator allLists(Binding binding, Collection<Node> x, Var listVar, Node predicate, PropFuncArg argObject, ExecutionContext execCxt) {
// BFI: Find all lists; work hard.
QueryIterConcat qIter = new QueryIterConcat(execCxt);
for (Node n : x) {
Binding b = BindingFactory.binding(binding, listVar, n);
QueryIterator q = execOneList(b, n, predicate, argObject, execCxt);
qIter.add(q);
}
return qIter;
}
use of org.apache.jena.sparql.engine.iterator.QueryIterConcat in project jena by apache.
the class QueryIterUnion method nextStage.
@Override
protected QueryIterator nextStage(Binding binding) {
QueryIterConcat unionQIter = new QueryIterConcat(getExecContext());
for (Op subOp : subOps) {
subOp = QC.substitute(subOp, binding);
QueryIterator parent = QueryIterSingleton.create(binding, getExecContext());
QueryIterator qIter = QC.execute(subOp, parent, getExecContext());
unionQIter.add(qIter);
}
return unionQIter;
}
use of org.apache.jena.sparql.engine.iterator.QueryIterConcat 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.iterator.QueryIterConcat 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.iterator.QueryIterConcat in project jena by apache.
the class Eval method evalQuadPattern.
static Table evalQuadPattern(OpQuadPattern opQuad, Evaluator evaluator) {
if (opQuad.isEmpty())
return TableFactory.createUnit();
ExecutionContext cxt = evaluator.getExecContext();
DatasetGraph ds = cxt.getDataset();
BasicPattern pattern = opQuad.getBasicPattern();
if (!opQuad.getGraphNode().isVariable()) {
if (!opQuad.getGraphNode().isURI()) {
throw new ARQInternalErrorException("Not a URI or variable: " + opQuad.getGraphNode());
}
Graph g = null;
if (opQuad.isDefaultGraph())
g = ds.getDefaultGraph();
else
g = ds.getGraph(opQuad.getGraphNode());
if (g == null)
return new TableEmpty();
ExecutionContext cxt2 = new ExecutionContext(cxt, g);
QueryIterator qIter = executeBGP(pattern, QueryIterRoot.create(cxt2), cxt2);
return TableFactory.create(qIter);
} else {
// Variable.
Var gVar = Var.alloc(opQuad.getGraphNode());
// Or just just devolve to OpGraph and get OpUnion chain of OpJoin
QueryIterConcat concat = new QueryIterConcat(cxt);
for (Iterator<Node> graphNodes = cxt.getDataset().listGraphNodes(); graphNodes.hasNext(); ) {
Node gn = graphNodes.next();
//Op tableVarURI = TableFactory.create(gn.getName(), Node.createURI(uri)) ;
Graph g = cxt.getDataset().getGraph(gn);
Binding b = BindingFactory.binding(BindingRoot.create(), gVar, gn);
ExecutionContext cxt2 = new ExecutionContext(cxt, g);
// Eval the pattern, eval the variable, join.
// Pattern may be non-linear in the variable - do a pure execution.
Table t1 = TableFactory.create(gVar, gn);
QueryIterator qIter = executeBGP(pattern, QueryIterRoot.create(cxt2), cxt2);
Table t2 = TableFactory.create(qIter);
Table t3 = evaluator.join(t1, t2);
concat.add(t3.iterator(cxt2));
}
return TableFactory.create(concat);
}
}
Aggregations