use of org.apache.jena.sparql.core.Var in project jena by apache.
the class TransformFilterEquality method processSpecialCase1.
private static List<Op> processSpecialCase1(List<Op> ops, List<Pair<Var, NodeValue>> equalities) {
List<Op> ops2 = new ArrayList<>();
Collection<Var> vars = varsMentionedInEqualityFilters(equalities);
for (Op op : ops) {
Op op2 = op;
if (safeToTransform(vars, op)) {
for (Pair<Var, NodeValue> p : equalities) op2 = processFilterWorker(op, p.getLeft(), p.getRight());
}
ops2.add(op2);
}
return ops2;
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class TransformFilterEquality method preprocessFilterEquality.
// --- find and extract
private static Pair<List<Pair<Var, NodeValue>>, ExprList> preprocessFilterEquality(ExprList exprs) {
List<Pair<Var, NodeValue>> exprsFilterEquality = new ArrayList<>();
ExprList exprsOther = new ExprList();
for (Expr e : exprs.getList()) {
Pair<Var, NodeValue> p = preprocess(e);
if (p != null)
exprsFilterEquality.add(p);
else
exprsOther.add(e);
}
if (exprsFilterEquality.size() == 0)
return null;
return Pair.create(exprsFilterEquality, exprsOther);
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class TransformRemoveAssignment method processAssignments.
private VarExprList processAssignments(OpExtendAssign opAssign) {
VarExprList orig = opAssign.getVarExprList();
if (!orig.contains(this.var))
return null;
if (!orig.getExpr(this.var).equals(this.expr))
return null;
VarExprList modified = new VarExprList();
for (Var v : orig.getVars()) {
if (!v.equals(this.var)) {
modified.add(v, orig.getExpr(v));
}
}
if (modified.size() > 0 && modified.size() == orig.size())
return null;
return modified;
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class VariableUsageVisitor method visit.
@Override
public void visit(OpBGP opBGP) {
Collection<Var> vars = new ArrayList<>();
for (Triple t : opBGP.getPattern().getList()) {
Vars.addVarsFromTriple(vars, t);
}
action(vars);
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class VariableUsageVisitor method visit.
@Override
public void visit(OpExtend opExtend) {
Collection<Var> vars = new ArrayList<>();
for (Var var : opExtend.getVarExprList().getVars()) {
vars.add(var);
ExprVars.varsMentioned(vars, opExtend.getVarExprList().getExpr(var));
}
action(vars);
}
Aggregations