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 annotations. #666

Merged
merged 4 commits into from
Dec 14, 2023

Conversation

tgregg
Copy link
Contributor

@tgregg tgregg commented Dec 9, 2023

Description of changes:

This required adding FlexSym support, which is why this PR is bigger than the title might suggest. You'll notice there are some methods that look similar to others, and may be candidates for DRYing up. I'd like to leave that for a future pass where we can set aside the time to analyze the potential performance impacts.

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 December 9, 2023 01:29
Copy link

codecov bot commented Dec 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (ion-11-encoding@f74e7e0). Click here to learn what that means.

Additional details and impacted files
@@                Coverage Diff                 @@
##             ion-11-encoding     #666   +/-   ##
==================================================
  Coverage                   ?   65.01%           
  Complexity                 ?     5811           
==================================================
  Files                      ?      200           
  Lines                      ?    25001           
  Branches                   ?     4461           
==================================================
  Hits                       ?    16254           
  Misses                     ?     7434           
  Partials                   ?     1313           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tgregg tgregg force-pushed the ion-11-encoding-annotations branch from 6246dbe to b349cf4 Compare December 13, 2023 01:05
src/main/java/com/amazon/ion/impl/IonCursorBinary.java Outdated Show resolved Hide resolved
annotationSequenceMarker.endIndex = annotationSequenceMarker.startIndex + annotationsLength;
peekIndex = annotationSequenceMarker.endIndex;
} else {
// At this point the value must have at least one more byte for each annotation VarSym (one for lower
Copy link
Contributor

Choose a reason for hiding this comment

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

FlexSym?

Suggested change
// At this point the value must have at least one more byte for each annotation VarSym (one for lower
// At this point the value must have at least one more byte for each annotation FlexSym (one for lower

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, some of this was written when these were still named "VarSym" and clearly I forgot to clean up all the comments.

markerToSet.startIndex = peekIndex;
markerToSet.endIndex = peekIndex;
} else if (nextByte != OpCodes.DELIMITED_END_MARKER) {
throw new IonException("FlexSyms may only wrap symbol zero, empty string, or delimited end.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
throw new IonException("FlexSyms may only wrap symbol zero, empty string, or delimited end.");
throw new IonException("FlexSym 0 may only precede symbol zero, empty string, or delimited end.");

markerToSet.startIndex = peekIndex;
markerToSet.endIndex = peekIndex;
} else if (nextByte != OpCodes.DELIMITED_END_MARKER) {
throw new IonException("VarSyms may only wrap symbol zero, empty string, or delimited end.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
throw new IonException("VarSyms may only wrap symbol zero, empty string, or delimited end.");
throw new IonException("FlexSym 0 may only precede symbol zero, empty string, or delimited end.");

Comment on lines 4384 to 4387
"E4 09 50 E5 0F 09 50 E6 07 09 0F 0D 50", // SIDs
"E7 F9 6E 61 6D 65 50 E8 0F F9 6E 61 6D 65 50 E9 1D F9 6E 61 6D 65 0F F3 69 6D 70 6F 72 74 73 50", // FlexSyms
"E4 12 00 50 E5 0F 24 00 00 50 E6 0E 00 09 0F 0D 50", // SIDs (multi-byte FlexUInts)
"E7 F2 FF 6E 61 6D 65 50 E8 3C 00 00 F9 6E 61 6D 65 50 E9 F8 00 00 00 F9 6E 61 6D 65 0F E6 FF 69 6D 70 6F 72 74 73 50", // Multi-byte FlexSyms
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put each test case in a separate line? E.g.

"E4 09 50",
"E5 0F 09 50",
"E6 07 09 0F 0D 50",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I do that, I can't reuse the same assertions for all of the parameters. What I can do is use string concatenation to put individual values of each test case on separate lines.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I didn't realize that these were all supposed to be the same data encoded in different ways.

Comment on lines 4418 to 4419
"E7 01 80 50 E7 01 90 50 E8 01 80 01 90 50 E9 09 01 90 01 80 50",
"E7 02 00 80 50 E7 04 00 00 90 50 E8 08 00 00 00 80 02 00 90 50 E9 90 00 00 00 00 01 90 01 80 50"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please put each test case on a separate csv line so that they are run separately? It's easier to read and it's easier to debug a failure because the different test cases get run in isolation from each other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my comment on your related comment. Structuring them this way reduces the number of distinct test methods we need, which I like. I can reformat the CSV lines to be more readable.

@tgregg tgregg merged commit 0255c1a into ion-11-encoding Dec 14, 2023
8 of 32 checks passed
@tgregg tgregg deleted the ion-11-encoding-annotations branch December 14, 2023 21:01
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