Search in sources :

Example 61 with Op

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

the class AbstractTestTransform method check.

private static void check(Op opToOptimize, String opExpectedString) {
    Op opOptimize = Algebra.optimize(opToOptimize);
    Op opExpected = SSE.parseOp(opExpectedString);
    if (false) {
        // Hook for more detail during development. 
        boolean b = Objects.equals(opExpected, opOptimize);
        if (!b) {
            System.err.println("** Input:");
            System.err.print(opToOptimize);
            System.err.println("** Expected:");
            System.err.print(opExpected);
            System.err.println("** Actual:");
            System.err.print(opOptimize);
            System.err.println("-------------------");
        }
    }
    assertEquals(opExpected, opOptimize);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 62 with Op

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

the class TestOptimizer method combine_assign_04.

@Test
public void combine_assign_04() {
    String opString = StrUtils.strjoinNL("(assign ((?x 2))", "  (assign ((?y 3))", "    (distinct", "      (assign ((?a 'A') (?b 'B'))", "        (assign ((?c 'C'))", "          (table unit)", "        )))))");
    String opExpectedString = StrUtils.strjoinNL("(assign ((?y 3) (?x 2))", "  (distinct", "    (assign ((?c 'C') (?a 'A') (?b 'B'))", "      (table unit))))");
    Op op = SSE.parseOp(opString);
    check(op, new TransformExtendCombine(), opExpectedString);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Test(org.junit.Test)

Example 63 with Op

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

the class TestAlgebraTranslate method test.

protected void test(String qs, String... y) {
    qs = "SELECT * {\n" + qs + "\n}";
    Query query = QueryFactory.create(qs, Syntax.syntaxARQ);
    String opStr = StrUtils.strjoinNL(y);
    Op opExpected = SSE.parseOp(opStr);
    Op opActual = this.getGenerator().compile(query);
    assertEquals(opExpected, opActual);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Example 64 with Op

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

the class TestOpAsQuery method test_equivalentQuery.

// There 3 classes of transformations: there are 3 main test operations.
//   test_roundTripQuery: The same query is recovered from OpAsQuery
//   test_roundTripAlegbra: Different queries with the same alegra forms
//   test_equivalentQuery: Different equivalent queries - same answers, different algebra.
//   test_algebraToQuery: algebra to query (e.g. optimization shapes)
// 
// test_roundTripQuery is test_equivalentQuery with same input and expected.
// + quad variants.
public static void test_equivalentQuery(String input, String expected) {
    Query orig = QueryFactory.create(input, Syntax.syntaxSPARQL_11);
    Op toReconstruct = Algebra.compile(orig);
    Query got = OpAsQuery.asQuery(toReconstruct);
    Query result = QueryFactory.create(expected, Syntax.syntaxSPARQL_11);
    assertEquals(result, got);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Example 65 with Op

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

the class TestPattern2Join method test4.

private static void test4(String pattern, String... joinForm) {
    Query q = QueryFactory.create("PREFIX : <http://example/> SELECT * " + pattern);
    Op op = Algebra.compile(q.getQueryPattern());
    op = Algebra.toQuadForm(op);
    test(op, joinForm);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

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