Search in sources :

Example 16 with ExprList

use of org.apache.jena.sparql.expr.ExprList in project jena by apache.

the class TransformFilterConjunction method transform.

@Override
public Op transform(OpFilter opFilter, Op subOp) {
    ExprList exprList = opFilter.getExprs();
    exprList = ExprList.splitConjunction(exprList);
    // Do not use -- OpFilter.filter(exprList, subOp) -- it compresses (filter (..) (filter ))
    return OpFilter.filterDirect(exprList, subOp);
}
Also used : ExprList(org.apache.jena.sparql.expr.ExprList)

Example 17 with ExprList

use of org.apache.jena.sparql.expr.ExprList in project jena by apache.

the class OpFilter method tidy.

/** Compress multiple filters: (filter (filter (filter op)))) into one (filter op) */
public static OpFilter tidy(OpFilter base) {
    ExprList exprs = new ExprList();
    Op op = base;
    while (op instanceof OpFilter) {
        OpFilter f = (OpFilter) op;
        exprs.addAll(f.getExprs());
        op = f.getSubOp();
    }
    return new OpFilter(exprs, op);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) ExprList(org.apache.jena.sparql.expr.ExprList)

Example 18 with ExprList

use of org.apache.jena.sparql.expr.ExprList in project jena by apache.

the class OpRewriter method visit.

@Override
public void visit(OpProcedure opProc) {
    opProc.getSubOp().visit(this);
    Op op = pop();
    ExprList args = new ExprRewriter(values).rewrite(opProc.getArgs());
    Node procId = changeNode(opProc.getProcId());
    push(new OpProcedure(procId, args, op));
}
Also used : Op(org.apache.jena.sparql.algebra.Op) ExprList(org.apache.jena.sparql.expr.ExprList) Node(org.apache.jena.graph.Node)

Example 19 with ExprList

use of org.apache.jena.sparql.expr.ExprList in project jena by apache.

the class TransformFilterPlacement method wrapBGP.

/** Wrap the Basic Pattern with any applicable expressions from the ExprList
     * but do not break up the BasicPattern in any way.
     */
private Placement wrapBGP(ExprList exprsIn, BasicPattern pattern) {
    Set<Var> vs = new HashSet<>();
    VarUtils.addVars(vs, pattern);
    ExprList pushed = new ExprList();
    ExprList unpushed = new ExprList();
    for (Expr e : exprsIn) {
        Set<Var> eVars = e.getVarsMentioned();
        if (vs.containsAll(eVars))
            pushed.add(e);
        else
            unpushed.add(e);
    }
    // Can't push anything into a filter around this BGP
    if (pushed.size() == 0)
        return noChangePlacement;
    // Safe to place some conditions around the BGP
    Op opx = OpFilter.filterBy(pushed, new OpBGP(pattern));
    return result(opx, unpushed);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Expr(org.apache.jena.sparql.expr.Expr) ExprList(org.apache.jena.sparql.expr.ExprList) Var(org.apache.jena.sparql.core.Var)

Example 20 with ExprList

use of org.apache.jena.sparql.expr.ExprList in project jena by apache.

the class TransformFilterPlacementConservative method transform.

@Override
public Op transform(OpFilter opFilter, Op x) {
    // Destructive use of exprs - copy it.
    ExprList exprs = ExprList.copy(opFilter.getExprs());
    Set<Var> varsScope = new HashSet<>();
    Op op = transform(exprs, varsScope, x);
    if (op == x)
        // Didn't do anything.
        return super.transform(opFilter, x);
    // Remaining exprs
    op = buildFilter(exprs, op);
    return op;
}
Also used : Op(org.apache.jena.sparql.algebra.Op) ExprList(org.apache.jena.sparql.expr.ExprList) Var(org.apache.jena.sparql.core.Var) HashSet(java.util.HashSet)

Aggregations

ExprList (org.apache.jena.sparql.expr.ExprList)27 Op (org.apache.jena.sparql.algebra.Op)17 Expr (org.apache.jena.sparql.expr.Expr)15 Var (org.apache.jena.sparql.core.Var)11 Node (org.apache.jena.graph.Node)3 Triple (org.apache.jena.graph.Triple)3 HashSet (java.util.HashSet)2 OpFilter (org.apache.jena.sparql.algebra.op.OpFilter)2 BasicPattern (org.apache.jena.sparql.core.BasicPattern)2 Test (org.junit.Test)2 ExprRewriter (org.apache.jena.arq.querybuilder.rewriters.ExprRewriter)1 MockSecurityEvaluator (org.apache.jena.permissions.MockSecurityEvaluator)1 SecurityEvaluator (org.apache.jena.permissions.SecurityEvaluator)1 OpRewriter (org.apache.jena.permissions.query.rewriter.OpRewriter)1 SecuredFunction (org.apache.jena.permissions.query.rewriter.SecuredFunction)1 SortCondition (org.apache.jena.query.SortCondition)1 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)1 VarExprList (org.apache.jena.sparql.core.VarExprList)1 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)1 NodeValue (org.apache.jena.sparql.expr.NodeValue)1