Search in sources :

Example 51 with Op

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

the class TestVarRename method rename.

private void rename(String inputStr, String expectedStr, boolean reversable, Set<Var> constant) {
    Op opOrig = SSE.parseOp(inputStr);
    Op opExpected = SSE.parseOp(expectedStr);
    Op opActual = Rename.renameVars(opOrig, constant);
    if (DEV && !opExpected.equals(opActual)) {
        System.err.println("**** Test: " + name.getMethodName());
        System.err.println("::Expected::");
        System.err.print(opExpected);
        System.err.println("::Got::");
        System.err.print(opActual);
    }
    assertEquals(opExpected, opActual);
    if (reversable) {
        // Undo.
        Op opRebuilt = Rename.reverseVarRename(opActual, false);
        assertEquals(opOrig, opRebuilt);
    }
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 52 with Op

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

the class TestTransformPromoteTableEmpty method test.

public static void test(String input, Transform transform, String... output) {
    Op opInput = SSE.parseOp(input);
    test(opInput, transform, output);
}
Also used : Op(org.apache.jena.sparql.algebra.Op)

Example 53 with Op

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

the class TestTransformPromoteTableEmpty method test.

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

Example 54 with Op

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

the class TestVarRename method filter_not_exists_scoping_03.

// JENA-1275
@Test
public void filter_not_exists_scoping_03() {
    //@formatter:off
    Op orig = SSE.parseOp(StrUtils.strjoinNL("(project (?triangles ?openTriplets)", "  (project (?openTriplets)", "    (extend ((?openTriplets ?.0))", "      (group () ((?.0 (count ?x)))", "        (filter (notexists", "                   (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?z ?c ?x)))", "          (quadpattern", "            (quad <urn:x-arq:DefaultGraphNode> ?x ?a ?y)", "            (quad <urn:x-arq:DefaultGraphNode> ?y ?b ?z)", "          ))))))"));
    Op expected = SSE.parseOp(StrUtils.strjoinNL("(project (?triangles ?openTriplets)", "  (project (?openTriplets)", "    (extend ((?openTriplets ?/.0))", "      (group () ((?/.0 (count ?/x)))", "        (filter (notexists", "                   (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?/z ?/c ?/x)))", "          (quadpattern", "            (quad <urn:x-arq:DefaultGraphNode> ?/x ?/a ?/y)", "            (quad <urn:x-arq:DefaultGraphNode> ?/y ?/b ?/z)", "          ))))))"));
    //@formatter:on
    Op transformed = TransformScopeRename.transform(orig);
    Assert.assertEquals(transformed, expected);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 55 with Op

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

the class AbstractTestTransform method checkAlgebra.

public static void checkAlgebra(String algString, Transform additionalOptimizer, String opExpectedString) {
    Op algebra = SSE.parseOp(algString);
    // Safe copy
    Op algebra1 = SSE.parseOp(algString);
    Op optimized = Algebra.optimize(algebra);
    if (additionalOptimizer != null)
        optimized = Transformer.transform(additionalOptimizer, optimized);
    Op opExpected = SSE.parseOp(opExpectedString != null ? opExpectedString : algString);
    assertEquals(opExpected, optimized);
    assertEquals("Modification of input during optimization", algebra1, algebra);
}
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