use of org.apache.jena.sparql.algebra.Table in project jena by apache.
the class Eval method evalGraph.
static Table evalGraph(OpGraph opGraph, Evaluator evaluator) {
ExecutionContext execCxt = evaluator.getExecContext();
if (!Var.isVar(opGraph.getNode())) {
DatasetGraph dsg = execCxt.getDataset();
Node graphNode = opGraph.getNode();
if (!dsg.containsGraph(graphNode))
return new TableEmpty();
Graph graph = execCxt.getDataset().getGraph(opGraph.getNode());
if (// But contains was true?!!
graph == null)
throw new InternalErrorException("Graph was present, now it's not");
ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph);
Evaluator e2 = EvaluatorFactory.create(execCxt2);
return eval(e2, opGraph.getSubOp());
}
// Graph node is a variable.
Var gVar = Var.alloc(opGraph.getNode());
Table current = null;
for (Iterator<Node> iter = execCxt.getDataset().listGraphNodes(); iter.hasNext(); ) {
Node gn = iter.next();
Graph graph = execCxt.getDataset().getGraph(gn);
ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph);
Evaluator e2 = EvaluatorFactory.create(execCxt2);
Table tableVarURI = TableFactory.create(gVar, gn);
// Evaluate the pattern, join with this graph node possibility.
// XXX If Var.ANON then no-opt.
Table patternTable = eval(e2, opGraph.getSubOp());
Table stepResult = evaluator.join(patternTable, tableVarURI);
if (current == null)
current = stepResult;
else
current = evaluator.union(current, stepResult);
}
if (current == null)
// Nothing to loop over
return new TableEmpty();
return current;
}
use of org.apache.jena.sparql.algebra.Table in project jena by apache.
the class Eval method eval.
public static Table eval(Evaluator evaluator, Op op) {
EvaluatorDispatch ev = new EvaluatorDispatch(evaluator);
op.visit(ev);
Table table = ev.getResult();
return table;
}
use of org.apache.jena.sparql.algebra.Table in project jena by apache.
the class EvaluatorDispatch method visit.
@Override
public void visit(OpFilter opFilter) {
Table table = eval(opFilter.getSubOp());
table = evaluator.filter(opFilter.getExprs(), table);
push(table);
}
use of org.apache.jena.sparql.algebra.Table in project jena by apache.
the class EvaluatorDispatch method visit.
@Override
public void visit(OpTopN opTop) {
Table table = eval(opTop.getSubOp());
//table = evaluator.topN(table, opTop.getLimti(), opTop.getConditions()) ;
table = evaluator.order(table, opTop.getConditions());
table = evaluator.slice(table, 0, opTop.getLimit());
push(table);
}
use of org.apache.jena.sparql.algebra.Table in project jena by apache.
the class EvaluatorDispatch method visit.
@Override
public void visit(OpOrder opOrder) {
Table table = eval(opOrder.getSubOp());
table = evaluator.order(table, opOrder.getConditions());
push(table);
}
Aggregations