Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more arithmetic scalar functions #14671

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

xiangfu0
Copy link
Contributor

@xiangfu0 xiangfu0 commented Dec 17, 2024

This pull request introduces several new scalar functions to the ArithmeticFunctions class in pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ArithmeticFunctions.java. These functions aim to enhance the mathematical operations available in the codebase, providing more robust and versatile arithmetic capabilities.

New scalar functions added:

  • intDiv and intDivOrZero: Perform integer division, with intDivOrZero returning zero for division by zero or when dividing a minimal negative number by minus one.
  • isFinite, isInfinite, and isNaN: Check if a double value is finite, infinite, or NaN, respectively.
  • ifNotFinite: Returns a default value if the given value is not finite.
  • moduloOrZero and positiveModulo: Variants of the modulo operation, with moduloOrZero returning zero for division by zero or when dividing a minimal negative number by minus one.
  • negate: Returns the negation of a double value.
  • gcd and lcm: Calculate the greatest common divisor and least common multiple of two long values, respectively.
  • hypot: Computes the hypotenuse of a right-angled triangle given the lengths of the other two sides.
  • byteswapInt and byteswapLong: Perform byte swapping on integer and long values.

@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.

Project coverage is 63.98%. Comparing base (59551e4) to head (41370e2).
Report is 1478 commits behind head on master.

Files with missing lines Patch % Lines
...ot/common/function/scalar/ArithmeticFunctions.java 88.23% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #14671      +/-   ##
============================================
+ Coverage     61.75%   63.98%   +2.23%     
- Complexity      207     1605    +1398     
============================================
  Files          2436     2703     +267     
  Lines        133233   148938   +15705     
  Branches      20636    22819    +2183     
============================================
+ Hits          82274    95304   +13030     
- Misses        44911    46639    +1728     
- Partials       6048     6995     +947     
Flag Coverage Δ
custom-integration1 100.00% <ø> (+99.99%) ⬆️
integration 100.00% <ø> (+99.99%) ⬆️
integration1 100.00% <ø> (+99.99%) ⬆️
integration2 0.00% <ø> (ø)
java-11 63.96% <88.23%> (+2.25%) ⬆️
java-21 63.88% <88.23%> (+2.26%) ⬆️
skip-bytebuffers-false 63.98% <88.23%> (+2.23%) ⬆️
skip-bytebuffers-true 63.86% <88.23%> (+36.13%) ⬆️
temurin 63.98% <88.23%> (+2.23%) ⬆️
unittests 63.98% <88.23%> (+2.23%) ⬆️
unittests1 56.30% <88.23%> (+9.41%) ⬆️
unittests2 34.43% <0.00%> (+6.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xiangfu0 xiangfu0 force-pushed the more-arithmetic-functions branch from 4fa8ce6 to 41370e2 Compare December 17, 2024 08:47
@xiangfu0 xiangfu0 requested a review from yashmayya December 17, 2024 09:35
@xiangfu0 xiangfu0 merged commit becb57e into apache:master Dec 22, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants