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

Support application implementation of IonWriter #10

Closed
almann opened this issue Apr 17, 2016 · 8 comments
Closed

Support application implementation of IonWriter #10

almann opened this issue Apr 17, 2016 · 8 comments
Labels

Comments

@almann
Copy link
Contributor

almann commented Apr 17, 2016

We need to stabilize the interface so applications can implement it.

Imported from ION-182,IONJAVA-160

@jonwilsdon
Copy link

We need to investigate if this is useful.

@san2488
Copy link

san2488 commented Dec 27, 2018

What is the guidance here? Is this interface stable enough to create custom implementations?

@raganhan
Copy link
Contributor

raganhan commented Jan 2, 2019

Although the interface is fairly stable many places in ion-java explicitly expect one of the included implementations of IonWriter. So trying to use a custom implementation may result in a ClassCastException.

We are open to fixing this to allow custom implementations if there are valuable use cases for doing so.

@san2488
Copy link

san2488 commented Jan 3, 2019

Thanks. Can you give an example of where such an expectation is made?

I'm evaluating writing an implementation that would stream to S3 transparently. I was expecting to use IonValue.writeTo(IonWriter).

@raganhan
Copy link
Contributor

raganhan commented Jan 3, 2019

IonWriter interface is intended to abstract away how to write Ion data in one of the serialization formats to an output source. A quote from its javadoc:

Writes Ion data to an output source.

This interface allows the user to write Ion data without being concerned about which output format is being used.

Since S3 is an output source I don't think an IonWriter implementation is the correct abstraction here. Generally speaking an OutputStream implementation would be a better abstraction for an output source, e.g. file, in memory, socket.

I may be wrong here but AFAIK S3 does not support streaming. All its APIs require a content-length header so your component would need to fake the streaming behavior by buffering and sending complete objects to S3. For that I'd implementing something that sits on top of an IonWriter using it to write out values to the buffer ensuring that each ion document is valid with the necessary symbol tables.

That being said one example of the expectation I mentioned: https://github.com/amzn/ion-java/blob/master/src/software/amazon/ion/impl/lite/IonValueLite.java#L886. Important to note that there are many, many others.

@raganhan
Copy link
Contributor

raganhan commented Jan 7, 2019

After talking to the team I'm closing this issue as we don't intend to allow a "from scratch" custom implementation of the IonWriter interface.

However we'd be open to provide a way for users to utilize the base capabilities of a writer, e.g. how to correctly write a binary Ion int, to build specialized writers with extra features for example triggering an action when some specific value is written. We are not sure how this capabilities would be exposed though as it would be better to design them with a user use case in mind.

@raganhan raganhan closed this as completed Jan 7, 2019
@wsargent
Copy link

@dlurton
Copy link
Contributor

dlurton commented Aug 10, 2020

Technically, no.

I would say that IonWriter is "stable" in the sense that it will remain source-compatible in future releases until at least the next major version bump and likely longer.

This library still doesn't support customer supplied implementations of the interface, however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants