Expose structural indexes#449
Open
mitghi wants to merge 1 commit intosimd-lite:mainfrom
Open
Conversation
Stage-1 already computes byte offsets of every JSON structural char.
Today the result lives in a private field; downstream callers must
either rerun stage-1 or unsafe-transmute the buffer to read it.
Adds a public read-only accessor:
pub fn structural_indexes(&self) -> &[u32]
Zero alloc, zero copy. Slice valid until the next parse reusing the
same Buffers.
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.
Hello 👋,
Thanks for this great library.
I would like to ask if its suitable to expose the structural indexes of Stage 1?
Stage 1 already computes the byte offsets of every json structural character.
I've been writing a tool that wants to reuse those offsets rather than recompute them,
otherwise the work which simd-json already does needs to done again in order to build
structural indexes. I find this to useful for cases such as deep scan on byte buffer, and based
on a byte's position, the structural index could be used to build a map from byte range to simd-json
Tape and other useful algorithms that this data enables.
This is an example for the use-case, every value's byte span derived correctly from
Buffers::structural_indexes() + tape walk and given a byte index, the inner object associated
with that position can be found.
I appreciate if you could please give me a feedback whether this change makes sense.
Thanks