Search in sources :

Example 86 with Op

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

the class QueryValidatorJSON method algebraOptQuads.

private static void algebraOptQuads(JsonBuilder obj, Query query) {
    Op op = Algebra.compile(query);
    op = Algebra.toQuadForm(op);
    op = Algebra.optimize(op);
    obj.key(jAlgebraOptQuads).value(string(query, op));
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 87 with Op

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

the class QueryValidatorJSON method algebra.

private static void algebra(JsonBuilder obj, Query query) {
    Op op = Algebra.compile(query);
    obj.key(jAlgebra).value(string(query, op));
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 88 with Op

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

the class QueryEngineBase method createPlan.

protected Plan createPlan() {
    // Decide the algebra to actually execute.
    Op op = queryOp;
    if (!startBinding.isEmpty()) {
        op = Substitute.substitute(op, startBinding);
        context.put(ARQConstants.sysCurrentAlgebra, op);
    // Don't reset the startBinding because it also is
    // needed in the output.
    }
    op = modifyOp(op);
    QueryIterator queryIterator = null;
    if (dataset != null)
        // Null means setting up but not executing a query.
        queryIterator = evaluate(op, dataset, startBinding, context);
    else
        // Bypass management interface
        queryIterator = evaluateNoMgt(op, dataset, startBinding, context);
    // This could be an automagic iterator to catch close.
    return new PlanOp(getOp(), this, queryIterator);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 89 with Op

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

the class OpExecutor method execute.

protected QueryIterator execute(OpMinus opMinus, QueryIterator input) {
    Op lhsOp = opMinus.getLeft();
    Op rhsOp = opMinus.getRight();
    QueryIterator left = exec(lhsOp, input);
    QueryIterator right = exec(rhsOp, root());
    Set<Var> commonVars = OpVars.visibleVars(lhsOp);
    commonVars.retainAll(OpVars.visibleVars(rhsOp));
    return QueryIterMinus.create(left, right, commonVars, execCxt);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) Var(org.apache.jena.sparql.core.Var)

Example 90 with Op

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

the class PathLib method pathToTriples.

/** Convert any paths of exactly one predicate to a triple pattern */
public static Op pathToTriples(PathBlock pattern) {
    BasicPattern bp = null;
    Op op = null;
    for (TriplePath tp : pattern) {
        if (tp.isTriple()) {
            if (bp == null)
                bp = new BasicPattern();
            bp.add(tp.asTriple());
            continue;
        }
        // Path form.
        op = flush(bp, op);
        bp = null;
        OpPath opPath2 = new OpPath(tp);
        op = OpSequence.create(op, opPath2);
        continue;
    }
    // End. Finish off any outstanding BGP.
    op = flush(bp, op);
    return op;
}
Also used : Op(org.apache.jena.sparql.algebra.Op) OpPath(org.apache.jena.sparql.algebra.op.OpPath) BasicPattern(org.apache.jena.sparql.core.BasicPattern) TriplePath(org.apache.jena.sparql.core.TriplePath)

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