ls.add(s);
PlanOptimizer optimizer = new MyPlanOptimizer(plan, ls, 3);
optimizer.optimize();
assertEquals(plan.getPredecessors(filter).get(0), join);
Operator next = plan.getSuccessors(filter).get(0);
assertEquals(LOFilter.class, next.getClass());
next = plan.getSuccessors(next).get(0);
assertEquals(LOStore.class, next.getClass());
// run push up filter rule
r = new PushUpFilter("PushUpFilter");
s = new HashSet<Rule>();
s.add(r);
ls = new ArrayList<Set<Rule>>();
ls.add(s);
optimizer = new MyPlanOptimizer(plan, ls, 3);
optimizer.optimize();
// both filters should be moved up to be after each load
next = plan.getSuccessors(load1).get(0);
assertEquals(next.getClass(), LOFilter.class);
assertEquals(plan.getSuccessors(next).get(0), join);
next = plan.getSuccessors(load2).get(0);
assertEquals(next.getClass(), LOFilter.class);
assertEquals(plan.getSuccessors(next).get(0), join);
assertEquals(plan.getSuccessors(join).get(0), store);
// run merge filter rule
r = new MergeFilter("MergeFilter");
s = new HashSet<Rule>();
s.add(r);
ls = new ArrayList<Set<Rule>>();
ls.add(s);
optimizer = new MyPlanOptimizer(plan, ls, 3);
optimizer.optimize();
// the filters should the same as before, nothing to merge
next = plan.getSuccessors(load1).get(0);
assertEquals(next.getClass(), LOFilter.class);
assertEquals(plan.getSuccessors(next).get(0), join);
next = plan.getSuccessors(load2).get(0);
assertEquals(next.getClass(), LOFilter.class);
assertEquals(plan.getSuccessors(next).get(0), join);
assertEquals(plan.getSuccessors(join).get(0), store);
}