Search in sources :

Example 21 with Op

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

the class TestTransformFilterEquality method equality_expression_1.

// JENA -1202
@Test
public void equality_expression_1() {
    // Need to fold to a string or URI to trigger equality.
    Op op = SSE.parseOp("(filter (= ?o (+ 'a' 'b')) (bgp (?x <http://p2> ?o)))");
    // Fold constants.
    Op op1 = Transformer.transform(new TransformCopy(), new ExprTransformConstantFold(), op);
    // Then apply filter-equality.
    check(op1, t_equality, "(assign ((?o 'ab')) (bgp (?x <http://p2> 'ab')) )");
}
Also used : Op(org.apache.jena.sparql.algebra.Op) TransformCopy(org.apache.jena.sparql.algebra.TransformCopy) Test(org.junit.Test)

Example 22 with Op

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

the class TestPattern2Join method test.

private static void test(Op input, String... joinForm) {
    Op op2 = Transformer.transform(new TransformPattern2Join(), input);
    String x = StrUtils.strjoinNL(joinForm);
    Op opExpected = SSE.parseOp("(prefix ((: <http://example/>)) " + x + ")");
    assertEquals(opExpected, op2);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) TransformPattern2Join(org.apache.jena.sparql.algebra.optimize.TransformPattern2Join)

Example 23 with Op

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

the class TestTransformQuads method test.

private static void test(String patternString, boolean optimize, String... strExpected) {
    Query q = QueryFactory.create("SELECT * WHERE " + patternString);
    Op op = Algebra.compile(q);
    if (optimize)
        op = Algebra.optimize(op);
    op = Algebra.toQuadForm(op);
    Op op2 = SSE.parseOp(StrUtils.strjoinNL(strExpected));
    assertEquals(op2, op);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Example 24 with Op

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

the class TestVarFinder method varfind.

private static void varfind(String string, String[] varsFixed, String[] varsOpt, String[] varsFilter, String[] varsFilterOnly) {
    Op op = SSE.parseOp(string);
    VarFinder vf = VarFinder.process(op);
    if (varsFixed != null)
        check(varsFixed, vf.getFixed());
    if (varsOpt != null)
        check(varsOpt, vf.getOpt());
    if (varsFilter != null)
        check(varsFilter, vf.getFilter());
    if (varsFilterOnly != null)
        check(varsFilterOnly, vf.getFilterOnly());
}
Also used : Op(org.apache.jena.sparql.algebra.Op) VarFinder(org.apache.jena.sparql.engine.main.VarFinder)

Example 25 with Op

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

the class TestVarRename method checkRename.

private void checkRename(String queryString, String opExpectedString) {
    Op opExpected = SSE.parseOp(opExpectedString);
    queryString = "PREFIX : <http://example/>\n" + queryString;
    Query query = QueryFactory.create(queryString);
    Op op = Algebra.compile(query);
    Op opRenamed = TransformScopeRename.transform(op);
    assertEquals(opExpected, opRenamed);
}
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