Search in sources :

Example 81 with Op

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

the class sse_query method exec.

@Override
protected void exec() {
    Op op = modAlgebra.getOp();
    if (op == null) {
        System.err.println("No query expression to execute");
        throw new TerminationException(9);
    }
    Dataset dataset = modDataset.getDataset();
    // Check there is a dataset.
    if (dataset == null)
        dataset = DatasetFactory.createGeneral();
    modTime.startTimer();
    DatasetGraph dsg = dataset.asDatasetGraph();
    if (printOp || printPlan) {
        if (printOp) {
            divider();
            IndentedWriter out = new IndentedWriter(System.out, true);
            op.output(out);
            out.flush();
        }
        if (printPlan) {
            QueryIterator qIter = Algebra.exec(op, dsg);
            Plan plan = new PlanOp(op, null, qIter);
            divider();
            IndentedWriter out = new IndentedWriter(System.out, false);
            plan.output(out);
            out.flush();
        }
    //return ;
    }
    // Do not optimize.  Execute as-is.
    QueryExecUtils.execute(op, dsg, modResults.getResultsFormat());
    long time = modTime.endTimer();
    if (modTime.timingEnabled())
        System.out.println("Time: " + modTime.timeStr(time));
}
Also used : IndentedWriter(org.apache.jena.atlas.io.IndentedWriter) PlanOp(org.apache.jena.sparql.engine.PlanOp) Op(org.apache.jena.sparql.algebra.Op) TerminationException(jena.cmd.TerminationException) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) ModDataset(arq.cmdline.ModDataset) Dataset(org.apache.jena.query.Dataset) PlanOp(org.apache.jena.sparql.engine.PlanOp) Plan(org.apache.jena.sparql.engine.Plan) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 82 with Op

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

the class QueryValidatorHTML method outputAlgebra.

private static 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);
    outputQueryOp(outStream, query, op, lineNumbers);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 83 with Op

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

the class QueryValidatorHTML method outputAlgebraOpt.

private static void outputAlgebraOpt(ServletOutputStream outStream, final Query query, boolean lineNumbers) throws IOException {
    outStream.println("<p>Alebgra, with general triple optimizations:</p>");
    final Op op = Algebra.optimize(Algebra.compile(query));
    outputQueryOp(outStream, query, op, lineNumbers);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 84 with Op

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

the class QueryValidatorHTML method outputAlgebraQuads.

private static void outputAlgebraQuads(ServletOutputStream outStream, final Query query, boolean lineNumbers) throws IOException {
    outStream.println("<p>Quad structure:</p>");
    final Op op = Algebra.toQuadForm(Algebra.compile(query));
    outputQueryOp(outStream, query, op, lineNumbers);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 85 with Op

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

the class QueryValidatorJSON method algebraQuads.

private static void algebraQuads(JsonBuilder obj, Query query) {
    Op op = Algebra.compile(query);
    op = Algebra.toQuadForm(op);
    obj.key(jAlgebraQuads).value(string(query, op));
}
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