use of org.apache.jena.sparql.expr.E_LogicalOr in project jena by apache.
the class TransformFilterDisjunction method explodeDisjunction.
/** Explode a expr into a list of disjunctions */
private static List<Expr> explodeDisjunction(List<Expr> exprList, Expr expr) {
if (!(expr instanceof E_LogicalOr)) {
exprList.add(expr);
return exprList;
}
E_LogicalOr exprOr = (E_LogicalOr) expr;
Expr e1 = exprOr.getArg1();
Expr e2 = exprOr.getArg2();
explodeDisjunction(exprList, e1);
explodeDisjunction(exprList, e2);
return exprList;
}
use of org.apache.jena.sparql.expr.E_LogicalOr in project jena by apache.
the class TransformFilterDisjunction method expandDisjunction.
// Todo:
// 1 - convert TransformEqualityFilter to use ExprLib for testing.
// 2 - Scan for safe equality filters in disjunction.
public static Op expandDisjunction(Expr expr, Op subOp) {
// if ( !( expr instanceof E_LogicalOr ) )
// return null ;
List<Expr> exprList = explodeDisjunction(new ArrayList<Expr>(), expr);
// All disjunctions - some can be done efficiently via assignments, some can not.
// Really should only do if every disjunction can turned into a assign-grounded pattern
// otherwise the full is done anyway.
List<Expr> exprList2 = null;
Op op = null;
for (Expr e : exprList) {
Op op2 = TransformFilterEquality.processFilter(e, subOp);
if (op2 == null) {
// Not done.
if (exprList2 == null)
exprList2 = new ArrayList<>();
exprList2.add(e);
//continue ;
// Can't do one so don't do any as the original pattern is still executed.
}
op = OpDisjunction.create(op, op2);
}
if (exprList2 != null && !exprList2.isEmpty()) {
// These are left as disjunctions.
Expr eOther = null;
for (Expr e : exprList2) {
if (eOther == null)
eOther = e;
else
eOther = new E_LogicalOr(eOther, e);
}
Op opOther = OpFilter.filter(eOther, subOp);
op = OpDisjunction.create(op, opOther);
}
return op;
}
Aggregations