break;
}
}
// Set the candidate to a inner relation and remove from the relation set.
JoinNode lastJoinNode = new JoinNode(plan.newPID(), chosen.getJoinType());
lastJoinNode.setLeftChild(lastOne); // Set the first candidate to a left relation of the first join
lastJoinNode.setRightChild(chosen.getRelation());
Schema merged = SchemaUtil.merge(lastJoinNode.getLeftChild().getOutSchema(),
lastJoinNode.getRightChild().getOutSchema());
lastJoinNode.setInSchema(merged);
lastJoinNode.setOutSchema(merged);
if (chosen.hasJoinQual()) {
lastJoinNode.setJoinQual(EvalTreeUtil.transformCNF2Singleton(chosen.getJoinQual()));
for (EvalNode joinCondition : chosen.getJoinQual()) {
qualSet.remove(joinCondition);
}
}
lastJoinNode.setCost(getCost(chosen));
alreadyJoinedRelNames.add(chosen.getRelation().getCanonicalName());
remainRelNames.remove(chosen.getRelation().getCanonicalName());
lastOne = lastJoinNode;
// If the relation set is empty, stop this loop.