Extract IterativeOptimizer#transform
it's going to be needed in next commit
@@ -125,12 +125,28 @@ public class IterativeOptimizer
continue;
}
+ Optional<PlanNode> transformed = transform(node, rule, context);
+
+ if (transformed.isPresent()) {
+ node = context.getMemo().replace(group, transformed.get(), rule.getClass().getName());
+
+ done = false;
+ progress = true;
+ }
+ }
+ }
+
+ return progress;
+ }
+
+ private Optional<PlanNode> transform(PlanNode node, Rule rule, Context context)
+ {
Optional<PlanNode> transformed;
Match<?> match = DEFAULT_MATCHER.match(rule.getPattern(), node);
if (match.isEmpty()) {
- continue;
+ return Optional.empty();
}
long duration;
@@ -145,16 +161,7 @@ public class IterativeOptimizer
}
stats.record(rule, duration, transformed.isPresent());
- if (transformed.isPresent()) {
- node = context.getMemo().replace(group, transformed.get(), rule.getClass().getName());
-
- done = false;
- progress = true;
- }
- }
- }
-
- return progress;
+ return transformed;
}
private boolean isTimeLimitExhausted(Context context)
