use of org.eclipse.rdf4j.query.algebra.And in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public ValueExpr visit(ASTAnd node, Object data) throws VisitorException {
Iterator<ASTBooleanExpr> iter = node.getOperandList().iterator();
ValueExpr result = (ValueExpr) iter.next().jjtAccept(this, null);
while (iter.hasNext()) {
ValueExpr operand = (ValueExpr) iter.next().jjtAccept(this, null);
result = new And(result, operand);
}
return result;
}
use of org.eclipse.rdf4j.query.algebra.And in project rdf4j by eclipse.
the class BasicGroup method filtersAsAnd.
private ValueExpr filtersAsAnd() {
ValueExpr aExpr = null;
for (ValueExpr aValEx : mFilters) {
if (aExpr == null) {
aExpr = aValEx;
} else {
And aAnd = new And();
aAnd.setLeftArg(aValEx);
aAnd.setRightArg(aExpr);
aExpr = aAnd;
}
}
return aExpr;
}
use of org.eclipse.rdf4j.query.algebra.And in project rdf4j by eclipse.
the class AbstractQueryBuilder method groupAsJoin.
private TupleExpr groupAsJoin(List<Group> theList) {
BinaryTupleOperator aJoin = new Join();
Filter aFilter = null;
for (Group aGroup : theList) {
TupleExpr aExpr = aGroup.expr();
if (aExpr == null) {
continue;
}
if (aExpr instanceof Filter && (((Filter) aExpr).getArg() == null || ((Filter) aExpr).getArg() instanceof EmptySet)) {
if (aFilter == null) {
aFilter = (Filter) aExpr;
} else {
// if we already have a filter w/ an empty arg, let's And the
// conditions together.
aFilter.setCondition(new And(aFilter.getCondition(), ((Filter) aExpr).getCondition()));
}
continue;
}
if (aFilter != null) {
aFilter.setArg(aExpr);
aExpr = aFilter;
aFilter = null;
}
if (aGroup.isOptional()) {
LeftJoin lj = new LeftJoin();
TupleExpr aLeft = joinOrExpr(aJoin);
if (aLeft != null) {
lj.setLeftArg(aLeft);
lj.setRightArg(aExpr);
aJoin = lj;
continue;
}
}
if (aJoin.getLeftArg() == null) {
aJoin.setLeftArg(aExpr);
} else if (aJoin.getRightArg() == null) {
aJoin.setRightArg(aExpr);
} else {
Join aNewJoin = new Join();
aNewJoin.setLeftArg(aJoin);
aNewJoin.setRightArg(aExpr);
aJoin = aNewJoin;
}
}
TupleExpr aExpr = joinOrExpr(aJoin);
if (aFilter != null) {
aFilter.setArg(aExpr);
aExpr = aFilter;
}
return aExpr;
}
Aggregations