Search in sources :

Example 56 with Op

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

the class AbstractTestTransform method test.

public void test(Op op1, Transform transform, String... output) {
    Op op2 = Transformer.transform(transform, op1);
    if (output == null) {
        // No transformation.
        Assert.assertEquals(op1, op2);
        return;
    }
    Op op3 = SSE.parseOp(StrUtils.strjoinNL(output));
    Assert.assertEquals(op3, op2);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 57 with Op

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

the class AbstractTestTransform method testOptimize.

public void testOptimize(String input, String... output) {
    Query q = QueryFactory.create(input);
    Op op = Algebra.compile(q);
    check(op, StrUtils.strjoinNL(output));
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Example 58 with Op

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

the class AbstractTestTransform method check.

public static void check(String queryString, String opExpectedString) {
    queryString = "PREFIX : <http://example/>\n" + queryString;
    Query query = QueryFactory.create(queryString);
    Op opQuery = Algebra.compile(query);
    // Safe copy
    Op op1 = Algebra.compile(query);
    check(opQuery, opExpectedString);
    assertEquals("Modification of input during optimization", op1, opQuery);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Example 59 with Op

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

the class AbstractTestTransform method check.

public static void check(Op opToOptimize, Transform additionalOptimizer, String opExpectedString) {
    Op opOptimize = Algebra.optimize(opToOptimize);
    opOptimize = Transformer.transform(additionalOptimizer, opOptimize);
    Op opExpected = SSE.parseOp(opExpectedString);
    assertEquals(opExpected, opOptimize);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 60 with Op

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

the class TestOptimizer method combine_assign_03.

@Test
public void combine_assign_03() {
    Op assign = OpAssign.create(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
    assign = OpAssign.create(assign, new VarExprList(Var.alloc("x"), new NodeValueInteger(2)));
    String opExpectedString = StrUtils.strjoinNL("(assign ((?x 2))", "  (assign ((?x 1))", "    (table unit)))");
    check(assign, new TransformExtendCombine(), opExpectedString);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) NodeValueInteger(org.apache.jena.sparql.expr.nodevalue.NodeValueInteger) VarExprList(org.apache.jena.sparql.core.VarExprList) Test(org.junit.Test)

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