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 reading binary Ion 1.1 nulls, booleans, ints, and floats. #641

Merged
merged 4 commits into from
Nov 20, 2023

Conversation

tgregg
Copy link
Contributor

@tgregg tgregg commented Nov 16, 2023

Description of changes:
Adds support for reading binary Ion 1.1 nulls, booleans, ints, and floats.

The trickiest part of this was actually the typed nulls, since they now require looking ahead one byte rather than relying on the type being baked into the precomputed type ID. For convenience and simplicity, we solve this by replacing the reader's type ID with the Ion 1.0 typed null IonTypeID instance for the given type, once the type is determined.

Note that for float values, the only changes required were in the type ID assignments, which happened in #639.

The test parameters are once again copied from IonEncoder_1_1Test.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@tgregg tgregg requested a review from popematt November 16, 2023 23:43
" -2147483648, 54 00 00 00 80", // Integer.MIN_VALUE
" -72624976668147841, 58 7F BF DF EF F7 FB FD FE",
" -9223372036854775808, 58 00 00 00 00 00 00 00 80", // Long.MIN_VALUE
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be cases for reading variable-length integers as int and long?
For example "1, F5 03 01" and "1, F5 09 01 00 00 00" and "0, F5 01"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes there should be, somewhere. I hadn't intended these unit test parameters to cover all edge cases, thinking that would be a better job for the ion-tests files. But I'm happy to add some more cases here for now, giving us a head start on developing a more exhaustive Ion 1.1 ion-tests corpus.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +3808 to +3810
" NaN, 5C 7F C0 00 00",
" Infinity, 5C 7F 80 00 00",
" -Infinity, 5C FF 80 00 00",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be able to read these as any size of float.

Suggested change
" NaN, 5C 7F C0 00 00",
" Infinity, 5C 7F 80 00 00",
" -Infinity, 5C FF 80 00 00",
" NaN, 5C 7F C0 00 00",
" Infinity, 5C 7F 80 00 00",
" -Infinity, 5C FF 80 00 00",
" NaN, 5D 7F C0 00 00 00 00 00 00",
" Infinity, 5D 7F 80 00 00 00 00 00 00",
" -Infinity, 5D FF 80 00 00 00 00 00 00",

Copy link
Contributor Author

Choose a reason for hiding this comment

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


@ParameterizedTest
@CsvSource({
" 0.0, 5A",
Copy link
Contributor

Choose a reason for hiding this comment

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

Test cases to make sure it can read 0 of any size.

Suggested change
" 0.0, 5A",
" 0.0, 5A",
" 0.0, 5B 00 00",
" 0.0, 5C 00 00 00 00",
" 0.0, 5D 00 00 00 00 00 00 00 00",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

" 0, 50",
" 1, 51 01",
" 17, 51 11",
" 127, 51 7F",
Copy link
Contributor

Choose a reason for hiding this comment

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

Numbers such as 127 can be encoded using more than one op code. We should add tests for that here (and in the other integer tests).

Suggested change
" 127, 51 7F",
" 127, 51 7F",
" 127, 52 7F 00",
" 127, 54 7F 00 00 00",
" 127, 58 7F 00 00 00 00 00 00 00",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tgregg tgregg merged commit 7b9305e into ion-11-encoding-read-pr2 Nov 20, 2023
2 checks passed
@tgregg tgregg deleted the ion-11-encoding-read-pr3 branch November 20, 2023 22:43
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.

2 participants