use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TransformSliceProject method transform.
@Override
public Op transform(OpSlice opSlice, Op subOp) {
// (slice (project...)) ==> (project (slice ...))
if (subOp instanceof OpProject) {
OpProject p = (OpProject) subOp;
Op sub = p.getSubOp();
Op x = new OpSlice(sub, opSlice.getStart(), opSlice.getLength());
x = new OpProject(x, p.getVars());
return x;
}
return super.transform(opSlice, subOp);
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class QueryIterOpSQL method nextStage.
@Override
protected QueryIterator nextStage(Binding binding) {
OpSQL execSQL = this.opSQL;
if (binding != null && !isRoot(binding)) {
QueryCompiler qc = opSQL.getRequest().getStore().getQueryCompilerFactory().createQueryCompiler(request);
Op op2 = Substitute.substitute(opSQL.getOriginal(), binding);
Op op = qc.compile(op2);
if (op instanceof OpSQL)
execSQL = (OpSQL) op;
else
throw new SDBInternalError("Failed to recompile the OpSQL to an OpSQL");
}
return execSQL.exec(binding, getExecContext());
// QueryIterator qIter = execSQL.exec(binding, getExecContext()) ;
// List<Binding> x = Iter.toList(qIter) ;
// qIter = new QueryIterPlainWrapper(x.iterator(), getExecContext()) ;
// System.out.println("SQL Eval:") ;
// x.forEach(b -> System.out.println(" "+b) );
// System.out.println() ;
// return qIter ;
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class QueryValidator method outputAlgebra.
private void outputAlgebra(ServletOutputStream outStream, final Query query, boolean lineNumbers) throws IOException {
outStream.println("<p>Algebra structure:</p>");
// No optimization
final Op op = Algebra.compile(query);
output(outStream, query, op, lineNumbers);
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class sdbprint method compilePrint.
private void compilePrint(Store store, Query query) {
SDB.getContext().setIfUndef(SDB.annotateGeneratedSQL, true);
if (!printQuery && !printOp && !printSqlNode && !printSQL && !printPlan)
printSQL = true;
if (isVerbose()) {
//printQuery = true ;
printOp = true;
//printSqlNode = true ;
printSQL = true;
}
if (printQuery) {
divider();
query.serialize(System.out, Syntax.syntaxARQ);
}
QueryEngineSDB qe = new QueryEngineSDB(store, query);
Op op = qe.getOp();
if (printOp) {
divider();
PrintSDB.print(op);
// No newline.
}
if (printSqlNode) {
divider();
PrintSDB.printSqlNodes(op);
}
if (printSQL) {
divider();
PrintSDB.printSQL(op);
}
if (printPlan) {
divider();
System.out.print(qe.getPlan());
}
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TestSolverTDB method exec.
private static ResultSet exec(String pattern, Graph graph) {
Op op = SSE.parseOp(pattern, pmap);
List<Var> vars = new ArrayList<>();
vars.addAll(OpVars.visibleVars(op));
QueryIterator qIter = Algebra.exec(op, graph);
return ResultSetFactory.create(qIter, Var.varNames(vars));
}
Aggregations