awelless commented on code in PR #10030:
URL: https://github.com/apache/nifi/pull/10030#discussion_r2161121249


##########
nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/filter/NumericBinaryOperatorFilter.java:
##########
@@ -65,10 +65,10 @@ protected boolean test(final FieldValue fieldValue, final 
Object rhsValue) {
         }
 
         final String fieldName = fieldValue.getField() == null ? "<Anonymous 
Inner Field>" : fieldValue.getField().getFieldName();
-        final Number lhsNumber = lhsLongCompatible ? 
DataTypeUtils.toLong(value, fieldName) : DataTypeUtils.toDouble(value, 
fieldName);
-        final Number rhsNumber = rhsLongCompatible ? 
DataTypeUtils.toLong(rhsValue, fieldName) : DataTypeUtils.toDouble(rhsValue, 
fieldName);
-        return compare(lhsNumber, rhsNumber);
+        return lhsLongCompatible && rhsLongCompatible
+                ? test(DataTypeUtils.toLong(value, fieldName), 
DataTypeUtils.toLong(rhsValue, fieldName))
+                : test(DataTypeUtils.toDouble(value, fieldName), 
DataTypeUtils.toDouble(rhsValue, fieldName));
     }
 
-    protected abstract boolean compare(final Number lhsNumber, final Number 
rhsNumber);
+    protected abstract boolean test(final Number lhsNumber, final Number 
rhsNumber);

Review Comment:
   The concern was that not all subclasses of `NumericBinaryOperatorFilter` 
would care about the specific types. But since there are only comparison 
operators for now, we should be good with introducing 2 separate methods for 
longs and doubles.
   Changed.



-- 
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