Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.MatchCriteria


                }
            } else { //GE, LE, GT, LT
                cost = getCostForComparison(childCost, metadata, compCrit, unknownChildCost);
            }
        } else if(predicateCriteria instanceof MatchCriteria) {
            MatchCriteria matchCriteria = (MatchCriteria)predicateCriteria;
            if (unknownChildCost) {
                return UNKNOWN_VALUE;
            }
            cost = estimateMatchCost(childCost, ndv, matchCriteria);
           
            isNegatedPredicateCriteria = matchCriteria.isNegated();

        } else if(predicateCriteria instanceof SetCriteria) {
            SetCriteria setCriteria = (SetCriteria) predicateCriteria;
            if (unknownChildCost) {
                return UNKNOWN_VALUE;
View Full Code Here


        super(name);
    }

    public static MatchCriteria helpExample(String right, char escape, boolean negated) {
        ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
        MatchCriteria match = new MatchCriteria(e1, new Constant(right), escape);
        match.setNegated(negated);
        return match;
    }
View Full Code Here

public class TestCriteriaEvaluator {

  // ################################## TEST HELPERS ################################
 
    private void helpTestMatch(String value, String pattern, char escape, boolean negated, boolean expectedMatch) throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
        MatchCriteria crit = new MatchCriteria(new Constant(value), new Constant(pattern), escape);
        crit.setNegated(negated);
        boolean actualMatch = Evaluator.evaluate(crit);
        // Compare actual and expected match
        assertEquals("Match criteria test failed for value=[" + value + "], pattern=[" + pattern + "], hasEscape=" + (escape != MatchCriteria.NULL_ESCAPE_CHAR) + ": ", expectedMatch, actualMatch); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    }
View Full Code Here

          if (i > 0) {
            critIter.remove();
            continue;
          }
          if (criteria instanceof MatchCriteria) {
            MatchCriteria matchCriteria = (MatchCriteria)criteria;
            if (matchCriteria.isNegated() || !matchCriteria.getLeftExpression().equals(keyColumn) || !(matchCriteria.getRightExpression() instanceof Constant)) {
              continue;
            }
            Constant value = (Constant)matchCriteria.getRightExpression();
            String pattern = (String)value.getValue();
            boolean escaped = false;
            StringBuilder prefix = new StringBuilder();
            for (int j = 0; i < pattern.length(); j++) {
                    char character = pattern.charAt(j);
                   
                    if (character == matchCriteria.getEscapeChar() && character != MatchCriteria.NULL_ESCAPE_CHAR) {
                        if (escaped) {
                            prefix.append(character);
                            escaped = false;
                        } else {
                            escaped = true;
View Full Code Here

        ArrayList crits = new ArrayList(1);
        CompareCriteria crit2 = new CompareCriteria(g1e2, CompareCriteria.EQ, g2e2);
        crits.add(crit2);

        Criteria atomicCrit1 = null;
        Criteria atomicCrit2 = new MatchCriteria(g2e1, new Constant(new String("ab%"))); //$NON-NLS-1$
        int expected = RIGHT_SIDE;
        helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);       
        expected = LEFT_SIDE;
        helpTestChooseSiblingAndMarkDependent(group2, atomicCrit2, group1, atomicCrit1, crits, expected);       
    }
View Full Code Here

        Criteria atomicCrit1 = null;

        Criteria crit1 = new CompareCriteria(g2e1, CompareCriteria.EQ, new Constant(new Integer(5)));
        Criteria crit2 = new CompareCriteria(g2e1, CompareCriteria.EQ, new Constant(new Integer(7)));
        CompoundCriteria atomicCrit2 = new CompoundCriteria(CompoundCriteria.AND, crit1, crit2);
        Criteria crit3 = new MatchCriteria(g2e1, new Constant(new String("ab"))); //$NON-NLS-1$
        atomicCrit2 = new CompoundCriteria(CompoundCriteria.OR, atomicCrit2, crit3);
       
        int expected = LEFT_SIDE;
        helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);       
        expected = RIGHT_SIDE;
View Full Code Here

        Criteria atomicCrit1 = null;

        Criteria crit1 = new CompareCriteria(g2e1, CompareCriteria.GT, new Constant(new Integer(5)));
        Criteria crit2 = new CompareCriteria(g2e1, CompareCriteria.LT, new Constant(new Integer(7)));
        Criteria atomicCrit2 = new CompoundCriteria(CompoundCriteria.AND, crit1, crit2);
        Criteria crit3 = new MatchCriteria(g2e1, new Constant(new String("cd%"))); //$NON-NLS-1$
        atomicCrit2 = new CompoundCriteria(CompoundCriteria.OR, atomicCrit2, crit3);
        atomicCrit2 = new NotCriteria(atomicCrit2);
       
        int expected = RIGHT_SIDE;
        helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);       
View Full Code Here

  public void testJoinType5() {
    helpTest(JoinType.JOIN_FULL_OUTER, "FULL OUTER JOIN");     //$NON-NLS-1$
  }

  public void testMatchCriteria1() {
    MatchCriteria mc = new MatchCriteria();
    mc.setLeftExpression(new ElementSymbol("m.g.e1"));     //$NON-NLS-1$
    mc.setRightExpression(new Constant("abc")); //$NON-NLS-1$
   
    helpTest(mc, "m.g.e1 LIKE 'abc'"); //$NON-NLS-1$
  }
View Full Code Here

   
    helpTest(mc, "m.g.e1 LIKE 'abc'"); //$NON-NLS-1$
  }
 
  public void testMatchCriteria2() {
    MatchCriteria mc = new MatchCriteria();
    mc.setLeftExpression(new ElementSymbol("m.g.e1"));     //$NON-NLS-1$
    mc.setRightExpression(new Constant("%")); //$NON-NLS-1$
    mc.setEscapeChar('#');
   
    helpTest(mc, "m.g.e1 LIKE '%' ESCAPE '#'"); //$NON-NLS-1$
  }
View Full Code Here

   
    helpTest(mc, "m.g.e1 LIKE '%' ESCAPE '#'"); //$NON-NLS-1$
  }
 
    public void testMatchCriteria3() {
        MatchCriteria mc = new MatchCriteria();
        mc.setLeftExpression(new ElementSymbol("m.g.e1"));     //$NON-NLS-1$
        mc.setRightExpression(new Constant("abc")); //$NON-NLS-1$
        mc.setNegated(true);
        helpTest(mc, "m.g.e1 NOT LIKE 'abc'"); //$NON-NLS-1$
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.MatchCriteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.