@Test public void shouldAddAccessNodeAboveSourceNode() { PlanNode project = new PlanNode(Type.PROJECT, selector("Selector1")); PlanNode source = new PlanNode(Type.SOURCE, project, selector("Selector1")); PlanNode result = rule.execute(context, project, new LinkedList<OptimizerRule>()); assertThat(result, is(sameInstance(project))); PlanNode access = project.getFirstChild(); assertThat(access.getType(), is(Type.ACCESS)); assertSelectors(access, "Selector1"); assertChildren(access, source); assertChildren(source); }
@Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode source : plan.findAllAtOrBelow(Type.SOURCE)) { if (source.getChildCount() != 0) continue; PlanNode access = new PlanNode(Type.ACCESS); access.addSelectors(source.getSelectors()); source.insertAsParent(access); } return plan; }
AddAccessNodes implements OptimizerRule { @Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode source : plan.findAllAtOrBelow(Type.SOURCE)) { if (source.getChildCount() != 0) continue; PlanNode access = new PlanNode(Type.ACCESS); access.addSelectors(source.getSelectors()); source.insertAsParent(access); } return plan; } }
AddAccessNodes implements OptimizerRule { @Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode source : plan.findAllAtOrBelow(Type.SOURCE)) { if (source.getChildCount() != 0) continue; PlanNode access = new PlanNode(Type.ACCESS); access.addSelectors(source.getSelectors()); source.insertAsParent(access); } return plan; }  }
AddAccessNodes implements OptimizerRule { @Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode source : plan.findAllAtOrBelow(Type.SOURCE)) { if (source.getChildCount() != 0) continue; PlanNode access = new PlanNode(Type.ACCESS); access.addSelectors(source.getSelectors()); source.insertAsParent(access); } return plan; }  @Override PlanNode execute( QueryContext context,
                             PlanNode plan,
                             LinkedList<OptimizerRule> ruleStack ); @Override String toString(); }
AddAccessNodes implements OptimizerRule { @Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode source : plan.findAllAtOrBelow(Type.SOURCE)) { if (source.getChildCount() != 0) continue; PlanNode access = new PlanNode(Type.ACCESS); access.addSelectors(source.getSelectors()); source.insertAsParent(access); } return plan; }  @Override PlanNode execute( QueryContext context,
                             PlanNode plan,
                             LinkedList<OptimizerRule> ruleStack ); @Override String toString(); static final AddAccessNodes INSTANCE; }