Search in sources :

Example 31 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 32 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 33 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)

Example 34 with Op

use of org.apache.jena.sparql.algebra.Op in project jena by apache.

the class ApplyTransformVisitor method visit.

@Override
public void visit(OpLeftJoin op) {
    Op left = null;
    Op right = null;
    // Must do right-left because the pushes onto the stack were left-right.
    if (op.getRight() != null)
        right = pop(opStack);
    if (op.getLeft() != null)
        left = pop(opStack);
    ExprList exprs = op.getExprs();
    ExprList exprs2 = collect(exprs);
    OpLeftJoin x = op;
    if (exprs != exprs2)
        x = OpLeftJoin.createLeftJoin(left, right, exprs2);
    Op opX = x.apply(opTransform, left, right);
    push(opStack, opX);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) VarExprList(org.apache.jena.sparql.core.VarExprList)

Example 35 with Op

use of org.apache.jena.sparql.algebra.Op in project jena by apache.

the class ApplyTransformVisitor method visitN.

@Override
public void visitN(OpN op) {
    List<Op> x = new ArrayList<>(op.size());
    for (Iterator<Op> iter = op.iterator(); iter.hasNext(); ) {
        Op sub = iter.next();
        Op r = pop(opStack);
        // Skip nulls.
        if (r != null)
            // Add in reverse.
            x.add(0, r);
    }
    Op opX = op.apply(opTransform, x);
    push(opStack, opX);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Aggregations

Op (org.apache.jena.sparql.algebra.Op)166 Var (org.apache.jena.sparql.core.Var)29 VarExprList (org.apache.jena.sparql.core.VarExprList)18 Query (org.apache.jena.query.Query)17 ExprList (org.apache.jena.sparql.expr.ExprList)17 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)15 Test (org.junit.Test)14 Triple (org.apache.jena.graph.Triple)13 Expr (org.apache.jena.sparql.expr.Expr)13 BasicPattern (org.apache.jena.sparql.core.BasicPattern)11 ArrayList (java.util.ArrayList)9 Node (org.apache.jena.graph.Node)8 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)7 NodeValueInteger (org.apache.jena.sparql.expr.nodevalue.NodeValueInteger)7 Binding (org.apache.jena.sparql.engine.binding.Binding)5 ExprVar (org.apache.jena.sparql.expr.ExprVar)5 BaseTest (org.apache.jena.atlas.junit.BaseTest)3 Pair (org.apache.jena.atlas.lib.Pair)3 Table (org.apache.jena.sparql.algebra.Table)3 TransformCopy (org.apache.jena.sparql.algebra.TransformCopy)3