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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * Override equals() method. * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { // Use super.equals() to check obvious stuff and variable if(obj == this) { return true; } if(!(obj instanceof MatchCriteria)) { return false; } MatchCriteria mc = (MatchCriteria)obj; if (isNegated() != mc.isNegated()) { return false; } if (this.mode != mc.mode) { return false; } return getEscapeChar() == mc.getEscapeChar() && EquivalenceUtil.areEqual(getLeftExpression(), mc.getLeftExpression()) && EquivalenceUtil.areEqual(getRightExpression(), mc.getRightExpression()); }
/** * Override equals() method. * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { // Use super.equals() to check obvious stuff and variable if(obj == this) { return true; } if(!(obj instanceof MatchCriteria)) { return false; } MatchCriteria mc = (MatchCriteria)obj; if (isNegated() != mc.isNegated()) { return false; } if (this.mode != mc.mode) { return false; } return getEscapeChar() == mc.getEscapeChar() && EquivalenceUtil.areEqual(getLeftExpression(), mc.getLeftExpression()) && EquivalenceUtil.areEqual(getRightExpression(), mc.getRightExpression()); }
/** * Override equals() method. * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { // Use super.equals() to check obvious stuff and variable if(obj == this) { return true; } if(!(obj instanceof MatchCriteria)) { return false; } MatchCriteria mc = (MatchCriteria)obj; if (isNegated() != mc.isNegated()) { return false; } if (this.mode != mc.mode) { return false; } return getEscapeChar() == mc.getEscapeChar() && EquivalenceUtil.areEqual(getLeftExpression(), mc.getLeftExpression()) && EquivalenceUtil.areEqual(getRightExpression(), mc.getRightExpression()); }
/** * 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; }
/** * 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; }
char escape = criteria.getEscapeChar();
result = match(rightValue, criteria.getEscapeChar(), leftValue, criteria.getMode());
char escape = criteria.getEscapeChar();
result = match(rightValue, criteria.getEscapeChar(), leftValue, criteria.getMode());
char escape = criteria.getEscapeChar();
/** * 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; }
if (obj.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) { append(SPACE); append(ESCAPE); append(SPACE); outputLiteral(String.class, false, obj.getEscapeChar());
if (obj.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) { append(SPACE); append(ESCAPE); append(SPACE); outputLiteral(String.class, false, obj.getEscapeChar());
if (obj.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) { append(SPACE); append(ESCAPE); append(SPACE); outputLiteral(String.class, false, obj.getEscapeChar());