-
Notifications
You must be signed in to change notification settings - Fork 111
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
Adds the ability to read an Ion int as a Java double, Decimal, or BigDecimal for consistency with the previous implementation. #675
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #675 +/- ##
============================================
+ Coverage 67.06% 67.23% +0.17%
- Complexity 5469 5481 +12
============================================
Files 159 159
Lines 22970 22995 +25
Branches 4116 4121 +5
============================================
+ Hits 15404 15460 +56
+ Misses 6286 6257 -29
+ Partials 1280 1278 -2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving assuming concern about arbitrary size ints is addressed.
scalarConverter.addValue(decimalValue()); | ||
scalarConverter.setAuthoritativeType(_Private_ScalarConversions.AS_TYPE.decimal_value); | ||
scalarConverter.cast(scalarConverter.get_conversion_fnid(_Private_ScalarConversions.AS_TYPE.double_value)); | ||
value = scalarConverter.getDouble(); | ||
scalarConverter.clear(); | ||
} else if (valueTid.type == IonType.INT) { | ||
scalarConverter.addValue(longValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know that the previous implementation only worked for Ion Ints that fit in a long?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I double-checked and unfortunately it looks like it would work, so I added support.
next(IonType.INT), doubleValue(255.0), | ||
next(null) | ||
); | ||
closeAndCount(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether we support coercing arbitrary size Ints or not we should have a test for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
…Decimal for consistency with the previous implementation.
a0c28d2
to
06452e0
Compare
Revision 2: added conversions to Decimal and BigDecimal; added support for conversions from int values that require BigInteger. |
Issue #, if available:
Closes #674
Closes #677
Description of changes:
See the linked issue. Note: I am not changing the documentation or associated error messages to officially endorse doing this. In fact, this would be one of the conversions we'd want to remove as part of #523. For now, we preserve the previous undocumented behavior to avoid breaking a small number of users that depend on it.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.