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 Support for 32-bit Floats #84

Merged
merged 2 commits into from
Jul 19, 2016
Merged

Conversation

hohle
Copy link
Contributor

@hohle hohle commented Apr 28, 2016

IonReaderBinaryRawX has learned to read the length of the float
type.

IonRawBinaryWriter has learned how to write 32-bit float values
when there will be no loss in precision.

Ref: http://amznlabs.github.io/ion-docs/float.html

buffer.writeUInt8(FLOAT_TYPE);
buffer.writeUInt64(doubleToRawLongBits(value));

if (value == ((double) ((float) value))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit, the code does have a legacy style convention that we should follow (braces on its own line).

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be a good idea to make this behavior configurable. binary32 support was added as a relatively late feature in Ion and to maximize compatibility with other clients we should make this an opt-in.

The other ancillary benefit to opt-in is avoiding the narrow/widening/comparison machinery needed to do this which could have (probably marginal) performance implication.

@almann
Copy link
Contributor

almann commented Apr 28, 2016

Overall, this is an excellent fix--thanks for working on it!

A couple top-level comments. We should make the writer support opt-in for the auto-sizing capability. This is mostly for compatibility (this was one of the latent adds to the specification before release). The best way to do this is probably through the builder interface in IonBinaryWriterBuilder. If we split out the reader changes as its own pull, we can get that in sooner.

I've added amazon-ion/ion-tests#11 separately track adding this to the test vector suite.

hohle added 2 commits May 13, 2016 07:16
IonReaderBinaryRawX has learned to read the length of the float
type.

Ref: http://amznlabs.github.io/ion-docs/float.html
IonBinarWriterBuilder gained several methods for configuring Binary32
support. When enabled IonBinaryWriters conditionally write floats
as Binary32 when there will be no loss in precision.

Ref: http://amznlabs.github.io/ion-docs/float.html
@hohle hohle force-pushed the 32-bit-floats branch 2 times, most recently from 4e109bd to 000a83a Compare May 13, 2016 22:21
@hohle
Copy link
Contributor Author

hohle commented May 13, 2016

Broke the PR up into two commits; the first adds support for reading 32-bit floats, the second adds support for conditionally writing them based on configuration and precision.

@toddjonker
Copy link
Contributor

Almann, I don't understand why we'd opt-in this feature. What do we need to be compatible with? This library has no users of older software.

@almann
Copy link
Contributor

almann commented May 18, 2016

@toddjonker - I'm being conservative about what software this library may interact with. If you think I'm being too conservative, then I am happy to consider changing things--but having a switch to control this serialization seems like an easy way to make that a non-issue.

@almann almann merged commit 000a83a into amazon-ion:master Jul 19, 2016
@almann
Copy link
Contributor

almann commented Jul 19, 2016

Thanks again @hohle! My apologies for taking a bit to merge this in.

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.

3 participants