use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.
the class EvaluatorSimple method extend.
@Override
public Table extend(Table table, VarExprList exprs) {
QueryIterator qIter = table.iterator(getExecContext());
qIter = new QueryIterAssign(qIter, exprs, getExecContext(), true);
return new TableN(qIter);
}
use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.
the class EvaluatorSimple method propertyFunction.
@Override
public Table propertyFunction(Table table, Node procId, PropFuncArg subjArgs, PropFuncArg objArgs) {
Procedure proc = ProcEval.build(procId, subjArgs, objArgs, execCxt);
QueryIterator qIter = ProcEval.eval(table.iterator(execCxt), proc, execCxt);
return TableFactory.create(qIter);
}
use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.
the class AlgebraExec method main.
public static void main(String[] argv) {
String BASE = "http://example/";
BasicPattern bp = new BasicPattern();
Var var_x = Var.alloc("x");
Var var_z = Var.alloc("z");
// ---- Build expression
bp.add(new Triple(var_x, NodeFactory.createURI(BASE + "p"), var_z));
Op op = new OpBGP(bp);
//Expr expr = ExprUtils.parse("?z < 2 ") ;
Expr expr = new E_LessThan(new ExprVar(var_z), NodeValue.makeNodeInteger(2));
op = OpFilter.filter(expr, op);
// ---- Example setup
Model m = makeModel();
m.write(System.out, "TTL");
System.out.println("--------------");
System.out.print(op);
System.out.println("--------------");
// ---- Execute expression
QueryIterator qIter = Algebra.exec(op, m.getGraph());
// -------- Either read the query iterator directly ...
if (false) {
for (; qIter.hasNext(); ) {
Binding b = qIter.nextBinding();
Node n = b.get(var_x);
System.out.println(NodeFmtLib.displayStr(n));
System.out.println(b);
}
qIter.close();
} else {
// -------- Or make ResultSet from it (but not both - reading an
// iterator consumes the current solution)
List<String> varNames = new ArrayList<>();
varNames.add("x");
varNames.add("z");
ResultSet rs = new ResultSetStream(varNames, m, qIter);
ResultSetFormatter.out(rs);
qIter.close();
}
System.exit(0);
}
use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.
the class TableBase method toResultSet.
@Override
public ResultSet toResultSet() {
QueryIterator qIter = iterator(null);
ResultSet rs = new ResultSetStream(getVarNames(), null, qIter);
rs = ResultSetFactory.makeRewindable(rs);
qIter.close();
return rs;
}
use of org.apache.jena.sparql.engine.QueryIterator in project jena by apache.
the class TableWriter method output.
public static void output(Table table, IndentedWriter out, SerializationContext sCxt) {
// Prefix. But then qnames are wrong.
if (sCxt != null) {
}
out.print("(table");
out.incIndent();
QueryIterator qIter = table.iterator(null);
for (; qIter.hasNext(); ) {
out.println();
Binding binding = qIter.nextBinding();
output(binding, out, sCxt);
}
out.decIndent();
out.print(")");
}
Aggregations