Riza Suminto has posted comments on this change. ( http://gerrit.cloudera.org:8080/22897 )
Change subject: IMPALA-14071: Refactor MathUtil.saturatingMultiplyCardinalities() ...................................................................... Patch Set 7: (1 comment) http://gerrit.cloudera.org:8080/#/c/22897/7/fe/src/main/java/org/apache/impala/util/MathUtil.java File fe/src/main/java/org/apache/impala/util/MathUtil.java: http://gerrit.cloudera.org:8080/#/c/22897/7/fe/src/main/java/org/apache/impala/util/MathUtil.java@28 PS7, Line 28: : // Multiply two numbers. If the multiply would overflow, return either Long.MIN_VALUE : // (if a xor b is negative) or Long.MAX_VALUE otherwise. The overflow path is not : // optimised at all and may be somewhat slow. : public static long saturatingMultiply(long a, long b) { : try { : return LongMath.checkedMultiply(a, b); : } catch (ArithmeticException e) { : return a < 0 != b < 0 ? Long.MIN_VALUE : Long.MAX_VALUE; : } : } : : // Add two numbers. If the add would overflow, return either Long.MAX_VALUE if both are : // positive or Long.MIN_VALUE if both are negative. The overflow path is not optimised : // at all and may be somewhat slow. : public static long saturatingAdd(long a, long b) { : try { : return LongMath.checkedAdd(a, b); : } catch (ArithmeticException e) { return a < 0 ? Long.MIN_VALUE : Long.MAX_VALUE; } : } Looks like it is safe to change it to simply wrap LongMath.saturatedAdd() and LongMath.saturatedMultiply(). -- To view, visit http://gerrit.cloudera.org:8080/22897 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I505ab11cfa1024feb4ceac4cffe9c3283be228ce Gerrit-Change-Number: 22897 Gerrit-PatchSet: 7 Gerrit-Owner: Riza Suminto <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Jason Fehr <[email protected]> Gerrit-Reviewer: Riza Suminto <[email protected]> Gerrit-Reviewer: Wenzhe Zhou <[email protected]> Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]> Gerrit-Comment-Date: Wed, 14 May 2025 17:58:48 +0000 Gerrit-HasComments: Yes
