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

Adds the ability to read an Ion int as a Java double, Decimal, or BigDecimal for consistency with the previous implementation. #675

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

tgregg
Copy link
Contributor

@tgregg tgregg commented Dec 15, 2023

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.

Copy link

codecov bot commented Dec 15, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (b0d3dcc) 67.06% compared to head (06452e0) 67.23%.

Files Patch % Lines
...mazon/ion/impl/IonReaderContinuableCoreBinary.java 90.47% 0 Missing and 4 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@rmarrowstone rmarrowstone left a 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());
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 know that the previous implementation only worked for Ion Ints that fit in a long?

Copy link
Contributor Author

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();
}
Copy link
Contributor

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.

Copy link
Contributor Author

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.
@tgregg tgregg changed the title Adds the ability to read an Ion int as a Java double for consistency with the previous implementation. Adds the ability to read an Ion int as a Java double, Decimal, or BigDecimal for consistency with the previous implementation. Dec 16, 2023
@tgregg
Copy link
Contributor Author

tgregg commented Dec 16, 2023

Revision 2: added conversions to Decimal and BigDecimal; added support for conversions from int values that require BigInteger.

@tgregg tgregg merged commit 56bada5 into master Dec 21, 2023
17 of 34 checks passed
@tgregg tgregg deleted the int-as-double branch December 21, 2023 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants