OptimizedPlan plan = new PlanFinalizer().createFinalPlan(bestPlanSinks, program.getJobName(), program, memoryPerInstance);
plan.setInstanceTypeName(instanceName);
// swap the binary unions for n-ary unions. this changes no strategies or memory consumers whatsoever, so
// we can do this after the plan finalization
plan.accept(new BinaryUnionReplacer());
// post pass the plan. this is the phase where the serialization and comparator code is set
postPasser.postPass(plan);
return plan;