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

[incubator-kie-drools-6180] accumulate min doesn't evaluate correctly… #6186

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tkobayas
Copy link
Contributor

@tkobayas tkobayas commented Dec 5, 2024

… with more than 18 digits BigDecimal

Issue:

At first, I thought I can use MinAccumulateFunction for BigDecimal and BigInteger. However, its getResultType() returns Comparable.class, so it causes a compile error when using methods like $min.intValue(). We may change the strategy to cache accumulate function instances (currently, per function name) to make MinAccumulateFunction work for various types, but I followed the current approach which is easier to understand, so I added 4 function classes BigDecimalMinAccumulateFunction (minBD), BigIntegerMinAccumulateFunction (minBI), BigDecimalMaxAccumulateFunction (maxBD), BigIntegerMaxAccumulateFunction (maxBI)

@tkobayas tkobayas marked this pull request as ready for review December 6, 2024 01:15
@tkobayas tkobayas marked this pull request as draft December 6, 2024 01:59
@tkobayas tkobayas marked this pull request as ready for review December 6, 2024 03:52
@tkobayas tkobayas force-pushed the incubator-kie-drools-6180-minBD branch from 1a431a7 to 14db10e Compare December 6, 2024 05:22
Copy link
Contributor

@pibizza pibizza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check comments to see if they are relevants for the tests.

"then\n" +
" results.add($min);\n" +
// to confirm if $min is BigInteger at build time (Not Comparable)
// The return value isn't important to assert
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these comments relevant? it seems that we are asserting the result values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is to explain the below code " System.out.println($min.nextProbablePrime());\n" . I'll rewrite it better. Thanks.

" results.add($min);\n" +
// to confirm if $min is BigInteger at build time (Not Comparable)
// The return value isn't important to assert
" System.out.println($min.nextProbablePrime());\n" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to printout this value? if possible a test should not print values, only check them in assertions.

Copy link
Contributor Author

@tkobayas tkobayas Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nextProbablePrime() is specific to BigInteger class. So, this line is to check that drl build doesn't raise a compile error, so we can confirm that $min is treated as BigInteger in the internally generated java code. The return value of nextProbablePrime() is not guaranteed, so we cannot assert the value is not important, I didn't assert.

Having said that, I can avoid System.out.println anyway. I'll fix the PR. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants