Skip to content

Adds support for writing binary Ion 1.1 data.#1

Open
tgregg wants to merge 1 commit into2.18-ion-11from
2.18-ion-11-binary
Open

Adds support for writing binary Ion 1.1 data.#1
tgregg wants to merge 1 commit into2.18-ion-11from
2.18-ion-11-binary

Conversation

@tgregg
Copy link
Owner

@tgregg tgregg commented May 9, 2024

Basic support for binary Ion 1.1. Support for Ion 1.1 text will come later. The boolean feature flag isn't my favorite, but I haven't yet found a better way that fits with Jackson's conventions (though that doesn't mean there isn't one).

Copy link

@popematt popematt left a comment

Choose a reason for hiding this comment

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

LGTM. I've got a couple questions, but nothing that would block the PR.

Comment on lines +69 to +75

/**
* Whether to use the Ion 1.1 encoding (true) or the Ion 1.0 encoding (false). Disabled by default.
*
* @since 2.18 // TODO change according to the minor version this lands in.
*/
ION_VERSION_1_1(false),
Copy link

Choose a reason for hiding this comment

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

Is it possible to set something up so that instead of it being true/false, we have a "feature" that can accept an Ion Version enum?

Copy link
Owner Author

Choose a reason for hiding this comment

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

That's what I'd prefer too (see my comment in the PR description), but I haven't seen an example of that yet within Jackson. These enums implement a Jackson core interface so that they can be used in various places in that code, and so far I've only seen them set by booleans. I'll keep looking though.

ctxt.setEncoding(enc);
ion = _system.newBinaryWriter(out);
if (IonGenerator.Feature.ION_VERSION_1_1.enabledIn(_ionGeneratorFeatures)) {
ion = IonEncodingVersion.ION_1_1.binaryWriterBuilder().build(out);
Copy link

Choose a reason for hiding this comment

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

I'm guessing the answer is "no", but does the IonObjectMapper allow you to provide your own IonWriterBuilder either when configuring the mapper or writing a value?

Copy link
Owner Author

Choose a reason for hiding this comment

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

You can achieve this in a few ways:

  1. You can create an IonObjectMapper using an IonFactory. You can provide an IonSystem to an IonFactory. You can provide text or binary writer builders to an IonSystem.
  2. You can provide an IonWriter instance to an IonGenerator or to IonObjectMapper.writeValue.

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