Optimized text for full unicode and some escape sequences#129169
Merged
jordan-powers merged 7 commits intoelastic:mainfrom Jun 12, 2025
Merged
Optimized text for full unicode and some escape sequences#129169jordan-powers merged 7 commits intoelastic:mainfrom
jordan-powers merged 7 commits intoelastic:mainfrom
Conversation
Collaborator
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
7 tasks
martijnvg
approved these changes
Jun 10, 2025
Member
martijnvg
left a comment
There was a problem hiding this comment.
LGTM
I think a review from @elastic/es-core-infra is also required here.
martijnvg
reviewed
Jun 10, 2025
| protected int stringEnd = -1; | ||
| protected int stringLength; | ||
|
|
||
| private final List<Integer> backslashes = new ArrayList<>(); |
Member
There was a problem hiding this comment.
Maybe use Lucene's IntArrayList here, so that primitive ints can be collected?
Contributor
Author
There was a problem hiding this comment.
Unfortunately, Lucene isn't available in libs/x-content/impl
If we completely consume the input buffer before finding a quote character ending the string, we should return null and fall back to jackson's native getValueAsString() which has logic to load more data into the input buffer.
Collaborator
💚 Backport successful
|
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jun 12, 2025
…129360) Follow-up to #126492 to apply the json parsing optimization to strings containing unicode characters and some backslash-escaped characters. Supporting backslash-escaped strings is tricky as it requires modifying the string. There are two types of modification: some just remove the backslash (e.g. \", \\), and some replace the whole escape sequence with a new character (e.g. \n, \r, \u00e5). In this implementation, the optimization only supports the first case--removing the backslash. This is done by making a copy of the data, skipping the backslash. It should still be more optimized than full String decoding, but it won't be as fast as non-backslashed strings where we can directly reference the input bytes. Relates to #129072.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #126492 to apply the json parsing optimization to strings containing unicode characters and some backslash-escaped characters.
Supporting backslash-escaped strings is tricky as it requires modifying the string. There are two types of modification: some just remove the backslash (e.g.
\",\\), and some replace the whole escape sequence with a new character (e.g.\n,\r,\u00e5). In this implementation, the optimization only support the first case--removing the backslash. This is done by making a copy of the data, skipping the backslash. It should still be more optimized than fullStringdecoding, but it won't be as fast as non-backslashed strings where we can directly reference the input bytes.Relates to #129072.