@Test public void testElementsInCritieria1() throws Exception { String criteria = "e1 = '1' and ((e1 = '2' OR e1 = '4') AND e2 = 3) or e2 is null"; Set<ElementSymbol> expected = new HashSet<ElementSymbol>(Arrays.asList(new ElementSymbol("e2"))); assertEquals(expected, RulePushSelectCriteria.getElementsIncriteria(QueryParser.getQueryParser().parseCriteria(criteria))); }
static Collection<ElementSymbol> getElementsIncriteria(Criteria crit) { Collection<ElementSymbol> elements = new HashSet<ElementSymbol>(); boolean first = true; if(crit instanceof CompoundCriteria) { CompoundCriteria compCrit = (CompoundCriteria) crit; for(Criteria subCrit : compCrit.getCriteria()) { if(compCrit.getOperator() == CompoundCriteria.AND || first) { first = false; elements.addAll(getElementsIncriteria(subCrit)); } else { elements.retainAll(getElementsIncriteria(subCrit)); } } } else { elements.addAll(ElementCollectorVisitor.getElements(crit, true)); } return elements; }
RulePushSelectCriteria implements OptimizerRule { static Collection<ElementSymbol> getElementsIncriteria(Criteria crit) { Collection<ElementSymbol> elements = new HashSet<ElementSymbol>(); boolean first = true; if(crit instanceof CompoundCriteria) { CompoundCriteria compCrit = (CompoundCriteria) crit; for(Criteria subCrit : compCrit.getCriteria()) { if(compCrit.getOperator() == CompoundCriteria.AND || first) { first = false; elements.addAll(getElementsIncriteria(subCrit)); } else { elements.retainAll(getElementsIncriteria(subCrit)); } } } else { elements.addAll(ElementCollectorVisitor.getElements(crit, true)); } return elements; } }
RulePushSelectCriteria implements OptimizerRule { static Collection<ElementSymbol> getElementsIncriteria(Criteria crit) { Collection<ElementSymbol> elements = new HashSet<ElementSymbol>(); boolean first = true; if(crit instanceof CompoundCriteria) { CompoundCriteria compCrit = (CompoundCriteria) crit; for(Criteria subCrit : compCrit.getCriteria()) { if(compCrit.getOperator() == CompoundCriteria.AND || first) { first = false; elements.addAll(getElementsIncriteria(subCrit)); } else { elements.retainAll(getElementsIncriteria(subCrit)); } } } else { elements.addAll(ElementCollectorVisitor.getElements(crit, true)); } return elements; }  }
RulePushSelectCriteria implements OptimizerRule { static Collection<ElementSymbol> getElementsIncriteria(Criteria crit) { Collection<ElementSymbol> elements = new HashSet<ElementSymbol>(); boolean first = true; if(crit instanceof CompoundCriteria) { CompoundCriteria compCrit = (CompoundCriteria) crit; for(Criteria subCrit : compCrit.getCriteria()) { if(compCrit.getOperator() == CompoundCriteria.AND || first) { first = false; elements.addAll(getElementsIncriteria(subCrit)); } else { elements.retainAll(getElementsIncriteria(subCrit)); } } } else { elements.addAll(ElementCollectorVisitor.getElements(crit, true)); } return elements; }  List<PlanNode> getCreatedNodes(); void setCreatedNodes(List<PlanNode> createdNodes); PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context); String toString(); }
RulePushSelectCriteria implements OptimizerRule { static Collection<ElementSymbol> getElementsIncriteria(Criteria crit) { Collection<ElementSymbol> elements = new HashSet<ElementSymbol>(); boolean first = true; if(crit instanceof CompoundCriteria) { CompoundCriteria compCrit = (CompoundCriteria) crit; for(Criteria subCrit : compCrit.getCriteria()) { if(compCrit.getOperator() == CompoundCriteria.AND || first) { first = false; elements.addAll(getElementsIncriteria(subCrit)); } else { elements.retainAll(getElementsIncriteria(subCrit)); } } } else { elements.addAll(ElementCollectorVisitor.getElements(crit, true)); } return elements; }  List<PlanNode> getCreatedNodes(); void setCreatedNodes(List<PlanNode> createdNodes); PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context); String toString();  }