42 bool priorTupleOp =
false;
44 if (isA<Aggregate>(node.get())) {
46 assert(tupleOp !=
nullptr &&
"aggregate conversion to tuple operation failed");
47 if (
rla->
getLevel(tupleOp) == -1 && !priorTupleOp) {
50 assert(newAgg !=
nullptr &&
"failed to make a clone");
53 }
else if (isA<TupleOperation>(node.get())) {
61 if (newAgg !=
nullptr) {
71 int priorOpLevel = -1;
74 if (isA<AbstractAggregate>(node.get())) {
76 assert(tupleOp !=
nullptr &&
"aggregate conversion to nested operation failed");
78 if (dataDepLevel != -1 && dataDepLevel < tupleOp->getTupleId() - 1) {
82 if (dataDepLevel != priorOpLevel) {
84 newLevel = dataDepLevel;
86 assert(newAgg !=
nullptr &&
"failed to make a clone");
90 }
else if (
const TupleOperation* tupleOp =
dynamic_cast<TupleOperation*
>(node.get())) {
91 priorOpLevel = tupleOp->getTupleId();
94 if (
auto* search =
dynamic_cast<TupleOperation*
>(node.get())) {
95 if (newAgg !=
nullptr && search->getTupleId() == newLevel) {
96 newAgg->rewrite(&newAgg->getOperation(),
souffle::clone(&search->getOperation()));
97 search->rewrite(&search->getOperation(), std::move(newAgg));