ARTEMIS-3962 porting changes from AMQ-9052
Optimisations to improve the efficiency of the selectors.
This commit is contained in:
parent
9d20d7b87f
commit
f0ff385c7c
|
@ -232,6 +232,31 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
|
|||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Filterable message) throws FilterException {
|
||||
Object lv = left.evaluate(message);
|
||||
Object rv = right.evaluate(message);
|
||||
|
||||
// If one of the values is null
|
||||
if (lv == null ^ rv == null) {
|
||||
return false;
|
||||
}
|
||||
if (lv == rv || lv.equals(rv)) {
|
||||
return true;
|
||||
}
|
||||
if (lv.getClass() == rv.getClass()) {
|
||||
// same class, but 'equals' return false, and they are not the same object
|
||||
// there is no point in doing 'compare'
|
||||
// this case happens often while comparing non equals Strings
|
||||
return false;
|
||||
}
|
||||
if (lv instanceof Comparable && rv instanceof Comparable) {
|
||||
Boolean compareResult = compare((Comparable) lv, (Comparable) rv);
|
||||
return compareResult != null && compareResult;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean asBoolean(int answer) {
|
||||
return answer == 0;
|
||||
|
|
|
@ -139,6 +139,16 @@ public abstract class UnaryExpression implements Expression {
|
|||
return !lvalue.booleanValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Filterable message) throws FilterException {
|
||||
Boolean lvalue = (Boolean) right.evaluate(message);
|
||||
if (lvalue == null) {
|
||||
// NOT NULL returns NULL that eventually fails the selector
|
||||
return false;
|
||||
}
|
||||
return !lvalue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpressionSymbol() {
|
||||
return "NOT";
|
||||
|
|
Loading…
Reference in New Issue