Search in sources :

Example 1 with Op

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);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) OpProject(org.apache.jena.sparql.algebra.op.OpProject) OpSlice(org.apache.jena.sparql.algebra.op.OpSlice)

Example 2 with Op

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 ;
}
Also used : Op(org.apache.jena.sparql.algebra.Op) SDBInternalError(org.apache.jena.sdb.shared.SDBInternalError)

Example 3 with Op

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);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 4 with Op

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());
    }
}
Also used : Op(org.apache.jena.sparql.algebra.Op) QueryEngineSDB(org.apache.jena.sdb.engine.QueryEngineSDB)

Example 5 with Op

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));
}
Also used : Op(org.apache.jena.sparql.algebra.Op) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) Var(org.apache.jena.sparql.core.Var) ArrayList(java.util.ArrayList)

Aggregations

Op (org.apache.jena.sparql.algebra.Op)193 Var (org.apache.jena.sparql.core.Var)38 Test (org.junit.Test)31 Query (org.apache.jena.query.Query)23 VarExprList (org.apache.jena.sparql.core.VarExprList)19 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)19 Triple (org.apache.jena.graph.Triple)18 BasicPattern (org.apache.jena.sparql.core.BasicPattern)18 ExprList (org.apache.jena.sparql.expr.ExprList)18 OpAsQuery (org.apache.jena.sparql.algebra.OpAsQuery)16 Expr (org.apache.jena.sparql.expr.Expr)15 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)14 ArrayList (java.util.ArrayList)12 Node (org.apache.jena.graph.Node)12 Binding (org.apache.jena.sparql.engine.binding.Binding)8 OpProject (org.apache.jena.sparql.algebra.op.OpProject)7 ExprVar (org.apache.jena.sparql.expr.ExprVar)7 NodeValueInteger (org.apache.jena.sparql.expr.nodevalue.NodeValueInteger)7 TransformCopy (org.apache.jena.sparql.algebra.TransformCopy)5 ResourceImpl (org.apache.jena.rdf.model.impl.ResourceImpl)4