Skip to content

Async Smile streaming support #127

Closed

Description

@sdeleuze

As part of SPR-16151 and due to various users asking such support, we try to support Smile Async streaming in the upcoming Spring Framework 5.0.3, in a similar fashion we currently support JSON Async streaming.

I have done various changes to support that, but my integration tests with serialization/deserialization of 2 POJOs generates the following error:

JSON: com.fasterxml.jackson.core.JsonParseException: Still have 21 undecoded bytes, should not call 'feedInput' at [Source: UNKNOWN; line: -1, column: 18]

Data are concatenated without separator.

Could you please check if this use case is currently supported, and if not support it?

Activity

  1. cowtowncoder commented on Dec 18, 2017

    @cowtowncoder
    Member

    Thanks, hope to look into this soon. I can first verify if this is tested or not; and if not, try to think of what the conceptual limitations might be (if any).

  2. sdeleuze commented on Jan 8, 2018

    @sdeleuze
    Author

    Hey, any chance to have a look on this one in order to allow us to support Smile streaming in our upcoming 5.0.4 release expected on February 15th?

  3. cowtowncoder commented on Jan 8, 2018

    @cowtowncoder
    Member

    @sdeleuze haven't had a chance, but should have time week. Thanks for reminder.
    I am planning on getting 2.9.4 release out sometime in January, due to some important (some for unexpected backwards compatibility issues, others for minor improvements wrt security handling for CVEs). So evaluating this should occur before that release.

  4. sdeleuze commented on Jan 9, 2018

    @sdeleuze
    Author

    Thanks for the heads up.

  5. cowtowncoder commented on Jan 10, 2018

    @cowtowncoder
    Member

    I guess it would be really useful if there was a bit more isolated test, basically taking active calls into a unit test to show the problem. I assume that things work with both json and smile with regular blocking i/o, and individual objects via async for both as well. But that sequence of multiple object not so much with Smile.

  6. sdeleuze commented on Jan 12, 2018

    @sdeleuze
    Author

    Please find a minimal repro use case in this repository. The same test works with JSON but fails with Smile.

  7. cowtowncoder commented on Jan 26, 2018

    @cowtowncoder
    Member

    @sdeleuze Ah. I may know what is going on here. Brief version is that between Smile documents -- ones separated by header bytes and/or end marker, will return null token to indicate end of document. This does NOT necessarily indicate end of the whole stream, but rather that there is document boundary. To test if stream is done there are couple of ways; either getting another null, or, perhaps better, see if parser.isClosed() returns true. Or best maybe, needMoreInput (of NonBlockingInputFeeder) which indicates there is content to decode.
    JSON, on the other hand, has no means for indicating document boundaries.

    It is also possible, actually, to create Smile document "streams" without boundaries, if neither header nor end-marker is output. Such content would be exposed without intervening null tokens.

    I am not sure what to think of this discrepancy: it is not ideal, obviously, but at the same time it does reflect actual difference between formats, as Smile has bit more metadata.
    But in practical terms I think behavior can not be changed since this is part of API at this point -- as far as I can see this is not special for async API but would work same way on blocking API too.

    Does this make sense?

  8. sdeleuze commented on Jan 27, 2018

    @sdeleuze
    Author

    Yes that makes sense, thank for your guidance, I will update our implementation accordingly. I will close this issue after checking it works as expected with parser.isClosed() or needMoreInput.

  9. cowtowncoder commented on Jan 28, 2018

    @cowtowncoder
    Member

    @sdeleuze Thanks. Good catch, sorry it took so long for me to take a look. Good thing is that there was a test for root value handling, wrt separate documents. I may need to additionally consider use with the alternative of appending root-level values without closing stream (or, disabling start and end marker), which is represented differently but should still work without exceptions or failures (but omitting null marker in stream).

  10. sdeleuze commented on Jan 29, 2018

    @sdeleuze
    Author

    FYI it works only when checking double null, other methods don't work.

  11. cowtowncoder commented on Jan 29, 2018

    @cowtowncoder
    Member

    @sdeleuze Ok. Yeah, probably isClosed() can't work with async the same way, without caller actually indicating "no more input" at point where needsMoreInput() would be true.

    The intended logic is, I think, that needsMoreInput() only returns true after consuming all input being given. So if this is the case (returns true) AND there is no more input to feed, then there can not be more to read. But double-null is probably the best way at this point, simplest, should work.

  12. sdeleuze commented on Jan 30, 2018

    @sdeleuze
    Author

    Yes I chose the double-null path, thanks for your feedback, Smile streaming will be supported in Spring Framework 5.0.4.

  13. cowtowncoder commented on Jan 30, 2018

    @cowtowncoder
    Member

    Excellent, I saw the announcement. This is great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions