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 writing Ion 1.1 sexps and structs #665

Merged

Conversation

popematt
Copy link
Contributor

@popematt popematt commented Dec 7, 2023

Issue #, if available:

None

Description of changes:

Adds support for SExp and Structs in the IonRawBinaryWriter_1_1.

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

@@ -236,7 +236,7 @@ private IonTypeID(byte id, int minorVersion) {
(upperNibble == 0xD && lowerNibble >= 0x2)
|| id == DELIMITED_STRUCT
|| id == VARIABLE_LENGTH_INLINE_SYMBOL
|| id == VARIABLE_LENGTH_STRUCT_WITH_FLEXSYMS
|| id == VARIABLE_LENGTH_STRUCT_WITH_FLEX_SYMS
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This got renamed so that the FLEX_SYMS is consistent with FlexSyms.

*/
fun stepInStruct(delimited: Boolean, useFlexSym: Boolean)
fun stepInStruct(delimited: Boolean)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we're automatically switching to FlexSyms when needed, this method parameter isn't really needed (for now) it can always be added back again later.

/**
* A byte representing zero, encoded as a FlexInt (or FlexUInt).
*/
const val ZERO: Byte = 0x01
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 introduced this because when we know that we're writing a FlexInt 0 (e.g. for a FlexSym), we may as well skip the conversion logic and write this byte directly.

/**
* Clears this [ContainerInfo] of old data and initializes it with the given new data.
*/
fun reset(type: ContainerType? = null, position: Long = -1, isDelimited: Boolean = false) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The clear() method was useful, but it set all the fields to the default values, and then we had to set them to the correct values. The new reset() method skips some of the unnecessary field assignments.

@popematt popematt requested a review from tgregg December 7, 2023 22:32
Comment on lines +32 to +33
* The string may contain multiple lines. Anything after a `|` character on a line is ignored, so
* you can use `|` to add comments.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is nice

Copy link

codecov bot commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@                Coverage Diff                 @@
##             ion-11-encoding     #665   +/-   ##
==================================================
  Coverage                   ?   64.71%           
  Complexity                 ?     5722           
==================================================
  Files                      ?      199           
  Lines                      ?    24727           
  Branches                   ?     4393           
==================================================
  Hits                       ?    16001           
  Misses                     ?     7428           
  Partials                   ?     1298           

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

@popematt popematt merged commit b92edd7 into amazon-ion:ion-11-encoding Dec 8, 2023
8 of 32 checks passed
@popematt popematt deleted the ion11writer-containers branch December 8, 2023 04:42
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