Support for feeding via bytebuffers
TuomasKiviaho opened this issue · 2 comments
Jackson has had NonBlockingByteBufferJsonParser
from 2.14.
Could NonBlockingParser
be upgraded to accommodate to ByteBufferFeeder
to avoid having to do memory copying when source is ByteBuffer
Currently JacksonResumableParser´ can't be extended to accommodate bytebuffers in similar way that
JacksonNonblockingParser` does. I suggest changing the class at least as protected to allow inheritance in case the implementation is not fit to be included to the project.
There are couple of simple and backwards compatible ways how to enhance the JacksonResumableParser
that I spotted to do repeatable doPare
calls minimal state testing inside the tight loop.
JsonProvider
could be held on to as an instance variable in the construction time sincePrimitiveHolder
treat is as immutable already.- Test only if there are
JsonToken
s to begin with sinceJsonSaxHandler
does the context state testing. Currently it's return values are not utilized as tight loop breaking points. Immediate stop should return true from the method and break from the tight loop immediately. - EOF handling could be moved out from the method to both
parse
andresume
methods where it belongs by returning null from thedoPare
NOT_AVAILABLE
should not pause the context but should instead break from the tight loop by returning false to conform with the return values of those fromJsonSaxHandler
.
With these changes the doPare
could be called multiple times when the feeding process has not been ended either by EOF or immediate stop and context pausing can hence be handled outside of the tight-loop to better meet the demands back-propagation concept of reactive streaming for instance.
Hi @TuomasKiviaho , Thanks so much for the suggestion. I will look into it this week.