/** * Get hash code. WARNING: The hash code is based on data in the criteria. * If data values are changed, the hash code will change - don't hash this * object and change values. * @return Hash code */ public int hashCode() { int hc = 0; hc = HashCodeUtil.hashCode(hc, getLeftExpression()); hc = HashCodeUtil.hashCode(hc, getRightExpression()); return hc; }
/** * Get hash code. WARNING: The hash code is based on data in the criteria. * If data values are changed, the hash code will change - don't hash this * object and change values. * @return Hash code */ public int hashCode() { int hc = 0; hc = HashCodeUtil.hashCode(hc, getLeftExpression()); hc = HashCodeUtil.hashCode(hc, getRightExpression()); return hc; }
/** * Get hash code. WARNING: The hash code is based on data in the criteria. * If data values are changed, the hash code will change - don't hash this * object and change values. * @return Hash code */ public int hashCode() { int hc = 0; hc = HashCodeUtil.hashCode(hc, getLeftExpression()); hc = HashCodeUtil.hashCode(hc, getRightExpression()); return hc; }
void resolveMatchCriteria(MatchCriteria mcrit) throws QueryResolverException { setDesiredType(mcrit.getLeftExpression(), mcrit.getRightExpression().getType(), mcrit); mcrit.setLeftExpression(resolveMatchCriteriaExpression(mcrit, mcrit.getLeftExpression())); setDesiredType(mcrit.getRightExpression(), mcrit.getLeftExpression().getType(), mcrit); mcrit.setRightExpression(resolveMatchCriteriaExpression(mcrit, mcrit.getRightExpression())); }
void resolveMatchCriteria(MatchCriteria mcrit) throws QueryResolverException { setDesiredType(mcrit.getLeftExpression(), mcrit.getRightExpression().getType(), mcrit); mcrit.setLeftExpression(resolveMatchCriteriaExpression(mcrit, mcrit.getLeftExpression())); setDesiredType(mcrit.getRightExpression(), mcrit.getLeftExpression().getType(), mcrit); mcrit.setRightExpression(resolveMatchCriteriaExpression(mcrit, mcrit.getRightExpression())); }
/** * TODO: does not check for escape char * or if it will contain single match chars */ private static float estimateMatchCost(float childCost, float ndv, MatchCriteria criteria) { Expression matchExpression = criteria.getRightExpression(); if(matchExpression instanceof Constant && ((Constant)matchExpression).getType().equals(DataTypeManager.DefaultDataClasses.STRING)) { String compareValue = (String) ((Constant)matchExpression).getValue(); if(criteria.getMode() != MatchMode.REGEX && criteria.getEscapeChar() == MatchCriteria.NULL_ESCAPE_CHAR && compareValue != null && compareValue.indexOf('%') < 0) { return (childCost / 2) * (1 / 3f + 1 / ndv); //without knowing length constraints we'll make an average guess } } else if (EvaluatableVisitor.willBecomeConstant(criteria.getLeftExpression())) { if (ndv > Math.sqrt(childCost)) { return (float) Math.sqrt(childCost - ndv); } return childCost/ndv; } return childCost / 3; }
void resolveMatchCriteria(MatchCriteria mcrit) throws QueryResolverException { setDesiredType(mcrit.getLeftExpression(), mcrit.getRightExpression().getType(), mcrit); mcrit.setLeftExpression(resolveMatchCriteriaExpression(mcrit, mcrit.getLeftExpression())); setDesiredType(mcrit.getRightExpression(), mcrit.getLeftExpression().getType(), mcrit); mcrit.setRightExpression(resolveMatchCriteriaExpression(mcrit, mcrit.getRightExpression())); }
/** * TODO: does not check for escape char * or if it will contain single match chars */ private static float estimateMatchCost(float childCost, float ndv, MatchCriteria criteria) { Expression matchExpression = criteria.getRightExpression(); if(matchExpression instanceof Constant && ((Constant)matchExpression).getType().equals(DataTypeManager.DefaultDataClasses.STRING)) { String compareValue = (String) ((Constant)matchExpression).getValue(); if(criteria.getMode() != MatchMode.REGEX && criteria.getEscapeChar() == MatchCriteria.NULL_ESCAPE_CHAR && compareValue != null && compareValue.indexOf('%') < 0) { return (childCost / 2) * (1 / 3f + 1 / ndv); //without knowing length constraints we'll make an average guess } } else if (EvaluatableVisitor.willBecomeConstant(criteria.getLeftExpression())) { if (ndv > Math.sqrt(childCost)) { return (float) Math.sqrt(childCost - ndv); } return childCost/ndv; } return childCost / 3; }
/** * Deep copy of object * @return Deep copy of object */ public Object clone() { Expression leftCopy = null; if(getLeftExpression() != null) { leftCopy = (Expression) getLeftExpression().clone(); } Expression rightCopy = null; if(getRightExpression() != null) { rightCopy = (Expression) getRightExpression().clone(); } MatchCriteria criteriaCopy = new MatchCriteria(leftCopy, rightCopy, getEscapeChar()); criteriaCopy.setNegated(isNegated()); criteriaCopy.mode = mode; return criteriaCopy; }
public void visit(MatchCriteria obj) { preVisitVisitor(obj); visitNode(obj.getLeftExpression()); visitNode(obj.getRightExpression()); postVisitVisitor(obj); } public void visit(NotCriteria obj) {
/** * @see org.teiid.query.sql.LanguageVisitor#visit(MatchCriteria) */ public void visit(MatchCriteria obj) { obj.setLeftExpression( replaceExpression(obj.getLeftExpression()) ); obj.setRightExpression( replaceExpression(obj.getRightExpression()) ); }
/** * @see org.teiid.query.sql.LanguageVisitor#visit(MatchCriteria) */ public void visit(MatchCriteria obj) { obj.setLeftExpression( replaceExpression(obj.getLeftExpression()) ); obj.setRightExpression( replaceExpression(obj.getRightExpression()) ); }
public void visit(MatchCriteria obj) { preVisitVisitor(obj); visitNode(obj.getLeftExpression()); visitNode(obj.getRightExpression()); postVisitVisitor(obj); } public void visit(NotCriteria obj) {
/** * Deep copy of object * @return Deep copy of object */ public Object clone() { Expression leftCopy = null; if(getLeftExpression() != null) { leftCopy = (Expression) getLeftExpression().clone(); } Expression rightCopy = null; if(getRightExpression() != null) { rightCopy = (Expression) getRightExpression().clone(); } MatchCriteria criteriaCopy = new MatchCriteria(leftCopy, rightCopy, getEscapeChar()); criteriaCopy.setNegated(isNegated()); criteriaCopy.mode = mode; return criteriaCopy; }
/** * @see org.teiid.query.sql.LanguageVisitor#visit(MatchCriteria) */ public void visit(MatchCriteria obj) { obj.setLeftExpression( replaceExpression(obj.getLeftExpression()) ); obj.setRightExpression( replaceExpression(obj.getRightExpression()) ); }
public void visit(MatchCriteria obj) { preVisitVisitor(obj); visitNode(obj.getLeftExpression()); visitNode(obj.getRightExpression()); postVisitVisitor(obj); } public void visit(NotCriteria obj) {
/** * Deep copy of object * @return Deep copy of object */ public Object clone() { Expression leftCopy = null; if(getLeftExpression() != null) { leftCopy = (Expression) getLeftExpression().clone(); } Expression rightCopy = null; if(getRightExpression() != null) { rightCopy = (Expression) getRightExpression().clone(); } MatchCriteria criteriaCopy = new MatchCriteria(leftCopy, rightCopy, getEscapeChar()); criteriaCopy.setNegated(isNegated()); criteriaCopy.mode = mode; return criteriaCopy; }
Like translate(MatchCriteria criteria) { Character escapeChar = null; if(criteria.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) { escapeChar = new Character(criteria.getEscapeChar()); } Like like = new Like(translate(criteria.getLeftExpression()), translate(criteria.getRightExpression()), escapeChar, criteria.isNegated()); like.setMode(criteria.getMode()); return like; }
Like translate(MatchCriteria criteria) { Character escapeChar = null; if(criteria.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) { escapeChar = new Character(criteria.getEscapeChar()); } Like like = new Like(translate(criteria.getLeftExpression()), translate(criteria.getRightExpression()), escapeChar, criteria.isNegated()); like.setMode(criteria.getMode()); return like; }
Like translate(MatchCriteria criteria) { Character escapeChar = null; if(criteria.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) { escapeChar = new Character(criteria.getEscapeChar()); } Like like = new Like(translate(criteria.getLeftExpression()), translate(criteria.getRightExpression()), escapeChar, criteria.isNegated()); like.setMode(criteria.getMode()); return like; }