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

Add peekToken(), mostly to support non-blocking parsing #375

Closed
cowtowncoder opened this issue May 11, 2017 · 2 comments
Closed

Add peekToken(), mostly to support non-blocking parsing #375

cowtowncoder opened this issue May 11, 2017 · 2 comments
Labels
3.x Issues to be only tackled for Jackson 3.x, not 2.x

Comments

@cowtowncoder
Copy link
Member

With upcoming support for non-blocking parsing (see #57 for json, but also for other formats) there may be need to add more methods to help with some specific aspects.

One such aspect is that due to input handling there is no way to properly implement "lazy" decoding for most events: since intent to skip is not known early enough, nextToken() must buffer all content.
This is fine in many cases (start/end markers, small numbers, property names that must be retained), but can be sub-optimal for larger values (binary, long text).
Now, adding something like skipToken() might work, but assumes that type of next token is fully known from context; this may or may not be known.

But it should be possible to add a new variant of nextToken(); one that does advance input enough to detect type of token, but without requiring anything more than peeking one byte (or couple, retaining them). This method specifically should not advance logical token stream so that:

  1. It should be possible to call this new method (peekToken()?) multiple times and get same result (that is: it's idempotent)
  2. When calling nextToken(), returned type must be same as what peekToken() returned

Now: although this method mostly makes sense for non-blocking use case, it might be useful for blocking I/O too, so let's expect support to be added there too, over time.

And since this is new addition operation has to be optional: that is, initial default implementation should return JsonToken.NOT_AVAILABLE (alternative would be throwing an exception).

@cowtowncoder cowtowncoder added 2.9 3.x Issues to be only tackled for Jackson 3.x, not 2.x and removed 2.9 labels May 20, 2017
@cowtowncoder
Copy link
Member Author

Based on bit of experimentation (with non-blocking Smile codec) implementation does not appear straight-forward even for this case. So, let's postpone this, perhaps tackle for 3.0.

@cowtowncoder
Copy link
Member Author

No movement here, and I think that the complexity of implementing this for all backends might make this of questionable value. I also do not have an actual use case, just speculation.

If anyone has real use case, need, may be re-opened, but closing for now due to no plans/work being done in years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issues to be only tackled for Jackson 3.x, not 2.x
Projects
None yet
Development

No branches or pull requests

1 participant