// first generate the Add(...)-operators for
// the evaluated triple patterns and add them
// under an UNION operator
final Union union = new Union();
final TriggerOneTime trigger = new TriggerOneTime();
while (it.hasNext()) {
final Triple t = it.next();
BasicOperator lastOperator = union;
for (int i = 0; i < 3; i++) {
if (tp.getPos(i).isVariable()) {
final AddBinding add = new AddBinding(
(Variable) tp.getPos(i), t
.getPos(i));
add
.addSucceedingOperator(new OperatorIDTuple(
lastOperator, 0));
// Not completely correct, but for
// the succeeding optimization steps
// enough!
add
.setUnionVariables((HashSet<Variable>) tp
.getVariables().clone());
add.setIntersectionVariables(add
.getUnionVariables());
lastOperator.addPrecedingOperator(add);
lastOperator = add;
}
}
trigger.addSucceedingOperator(new OperatorIDTuple(
lastOperator, 0));
}
if (trigger.getSucceedingOperators().size() > 0) {
trigger.setPrecedingOperators(tp
.getPrecedingOperators());
for (final BasicOperator po : tp
.getPrecedingOperators()) {
po.addSucceedingOperator(new OperatorIDTuple(
trigger, 0));