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);
}
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);
}
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));
}
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);
}
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;
}
Aggregations