Search in sources :

Example 36 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class TestOptimizer method combine_assign_02.

@Test
public void combine_assign_02() {
    Op assign = OpAssign.create(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
    assign = OpAssign.create(assign, new VarExprList(Var.alloc("y"), new ExprVar("x")));
    String opExpectedString = StrUtils.strjoinNL("(assign ((?x 1) (?y ?x))", "  (table unit))");
    check(assign, new TransformExtendCombine(), opExpectedString);
}
Also used : ExprVar(org.apache.jena.sparql.expr.ExprVar) 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)

Example 37 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class TestOptimizer method combine_assign_01.

@Test
public void combine_assign_01() {
    Op assign = OpAssign.create(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
    assign = OpAssign.create(assign, new VarExprList(Var.alloc("y"), new NodeValueInteger(2)));
    String opExpectedString = StrUtils.strjoinNL("(assign ((?x 1) (?y 2))", "  (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)

Example 38 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class TestOptimizer method combine_extend_02.

@Test
public void combine_extend_02() {
    Op extend = OpExtend.create(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
    extend = OpExtend.create(extend, new VarExprList(Var.alloc("y"), new ExprVar("x")));
    String opExpectedString = StrUtils.strjoinNL("(extend ((?x 1) (?y ?x))", "  (table unit))");
    check(extend, new TransformExtendCombine(), opExpectedString);
}
Also used : ExprVar(org.apache.jena.sparql.expr.ExprVar) 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)

Example 39 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class BuilderExpr method buildNamedExpr.

public static VarExprList buildNamedExpr(Item item) {
    VarExprList varExprList = new VarExprList();
    buildNamedExpr(item, varExprList);
    return varExprList;
}
Also used : VarExprList(org.apache.jena.sparql.core.VarExprList)

Example 40 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class TransformExtendCombine method transform.

@Override
public Op transform(OpExtend opExtend, Op subOp) {
    if (subOp instanceof OpExtend) {
        // The case of (extend (?x e1) (extend (?x e2) ...op...))
        // is actually illegal in SPARQL.  ?x must be a fresh variable.
        OpExtend x = (OpExtend) subOp;
        VarExprList outerVarExprList = opExtend.getVarExprList();
        // Copy
        VarExprList innerVarExprList = new VarExprList(x.getVarExprList());
        Op r = OpExtend.extend(x.getSubOp(), innerVarExprList);
        // This contains an "if already (extend)" test.
        r = OpExtend.extend(r, outerVarExprList);
        return r;
    }
    return super.transform(opExtend, subOp);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) OpExtend(org.apache.jena.sparql.algebra.op.OpExtend) VarExprList(org.apache.jena.sparql.core.VarExprList)

Aggregations

VarExprList (org.apache.jena.sparql.core.VarExprList)49 Var (org.apache.jena.sparql.core.Var)21 Test (org.junit.Test)15 Op (org.apache.jena.sparql.algebra.Op)12 Expr (org.apache.jena.sparql.expr.Expr)8 Query (org.apache.jena.query.Query)7 NodeValueInteger (org.apache.jena.sparql.expr.nodevalue.NodeValueInteger)7 ContractTest (org.xenei.junit.contract.ContractTest)6 E_Random (org.apache.jena.sparql.expr.E_Random)4 QueryParseException (org.apache.jena.query.QueryParseException)3 ExprAggregator (org.apache.jena.sparql.expr.ExprAggregator)2 ExprVar (org.apache.jena.sparql.expr.ExprVar)2 StringReader (java.io.StringReader)1 Map (java.util.Map)1 ExprRewriter (org.apache.jena.arq.querybuilder.rewriters.ExprRewriter)1 Node (org.apache.jena.graph.Node)1 SortCondition (org.apache.jena.query.SortCondition)1 OpAssign (org.apache.jena.sparql.algebra.op.OpAssign)1 OpExtend (org.apache.jena.sparql.algebra.op.OpExtend)1 BindingHashMap (org.apache.jena.sparql.engine.binding.BindingHashMap)1