ranganathg commented on code in PR #1701:
URL: https://github.com/apache/phoenix/pull/1701#discussion_r1346869825


##########
phoenix-core/src/main/java/org/apache/phoenix/expression/ComparisonExpression.java:
##########
@@ -352,7 +356,139 @@ public boolean evaluate(Tuple tuple, 
ImmutableBytesWritable ptr) {
         ptr.set(ByteUtil.compare(op, comparisonResult) ? PDataType.TRUE_BYTES 
: PDataType.FALSE_BYTES);
         return true;
     }
-    
+
+    @Override
+    public boolean contains (Expression other) {
+        if (!(other instanceof ComparisonExpression || other instanceof 
IsNullExpression)) {
+                return false;
+        }
+        if (other instanceof IsNullExpression) {
+            return !((IsNullExpression) other).isNegate();
+        }
+
+        BaseTerminalExpression lhsA = 
WhereCompiler.getBaseTerminalExpression(this.getChildren().get(0));
+        BaseTerminalExpression lhsB = 
WhereCompiler.getBaseTerminalExpression(other.getChildren().get(0));
+        if (!lhsA.equals(lhsB)) {
+            return false;
+        }
+        CompareOperator opA = this.getFilterOp();
+        CompareOperator opB = ((ComparisonExpression) other).getFilterOp();
+        BaseTerminalExpression rhs = WhereCompiler.getBaseTerminalExpression(
+                this.getChildren().get(1));
+        if (rhs instanceof ColumnExpression) {
+            BaseTerminalExpression rhsB = 
WhereCompiler.getBaseTerminalExpression(
+                    other.getChildren().get(1));
+            if (!rhs.equals(rhsB)) {
+                return false;
+            }
+            switch (opA) {
+                case LESS:
+                    if (opB == LESS) {
+                        return true;
+                    }
+                    return false;
+                case LESS_OR_EQUAL:
+                    if (opB == LESS || opB == LESS_OR_EQUAL || opB == EQUAL) {
+                        return true;
+                    }
+                    return false;
+                case EQUAL:
+                case NOT_EQUAL:
+                    if (opA == opB) {
+                        return true;
+                    }
+                    return false;
+                case GREATER_OR_EQUAL:
+                    if (opB == GREATER || opB == GREATER_OR_EQUAL || opB == 
EQUAL) {
+                        return true;
+                    }
+                    return false;
+                case GREATER:
+                    if (opB == GREATER) {
+                        return true;
+                    }
+                    return false;
+                default:
+                    throw new IllegalArgumentException("Unexpected CompareOp 
of " + opA);

Review Comment:
   opB is not required?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to