use of org.eclipse.rdf4j.query.algebra.Union in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public TupleExpr visit(ASTTupleUnion node, Object data) throws VisitorException {
TupleExpr leftArg = (TupleExpr) node.getLeftArg().jjtAccept(this, null);
TupleExpr rightArg = (TupleExpr) node.getRightArg().jjtAccept(this, null);
TupleExpr result = new Union(leftArg, rightArg);
if (node.isDistinct()) {
result = new Distinct(result);
}
return result;
}
use of org.eclipse.rdf4j.query.algebra.Union in project rdf4j by eclipse.
the class TupleExprBuilder method visit.
@Override
public Object visit(ASTPathAlternative pathAltNode, Object data) throws VisitorException {
int altCount = pathAltNode.jjtGetNumChildren();
if (altCount > 1) {
GraphPattern parentGP = graphPattern;
Union union = new Union();
Union currentUnion = union;
for (int i = 0; i < altCount - 1; i++) {
graphPattern = new GraphPattern(parentGP);
pathAltNode.jjtGetChild(i).jjtAccept(this, data);
TupleExpr arg = graphPattern.buildTupleExpr();
currentUnion.setLeftArg(arg);
if (i == altCount - 2) {
// second-to-last item
graphPattern = new GraphPattern(parentGP);
pathAltNode.jjtGetChild(i + 1).jjtAccept(this, data);
arg = graphPattern.buildTupleExpr();
currentUnion.setRightArg(arg);
} else {
Union newUnion = new Union();
currentUnion.setRightArg(newUnion);
currentUnion = newUnion;
}
}
parentGP.addRequiredTE(union);
graphPattern = parentGP;
} else {
pathAltNode.jjtGetChild(0).jjtAccept(this, data);
}
return null;
}
Aggregations