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

Support for patching/updating #10

Open
chenliu0831 opened this issue Nov 13, 2018 · 1 comment
Open

Support for patching/updating #10

chenliu0831 opened this issue Nov 13, 2018 · 1 comment

Comments

@chenliu0831
Copy link

Hi Ion team,

Great work! I can't wait to get my hand dirty with this. Just curious (and might be a stupid question), can I use the same API and path syntax to mutate or patch a nested value in an Ion stream?

Thanks,
Peter

@raganhan
Copy link
Contributor

In short no.

The path extractor works on top of an IonReader which is only able to read the Ion stream. Another problem is that the path extractor optimizes the traversal by skipping values that have won't match any search path. It'd be cumbersome to try to leverage it as a stream transformer.

The path extractor is more suited for a sparse read use case which could be combined with a transform. For example it's suited for reading a limited number of struct fields from an Ion stream and performing a transform on them but not reading all fields and only performing a transform in a limited number of them.

I can see what you are asking as a another tool that using the same search path syntax. It'd traverse the whole document writing values to a provided OutputStream and invoking a callback with an IonReader and an IonWriter for registered search paths. Users would be in charge of writing the value, or transformed value, for matched search paths. Won't benefit from skip scanning as it'd need to read all the stream, but could leverage the stream copy writers to get better performance.

I'm curious to hear more on your use case this could be a tool worh supporting. At the bare minimum we'd be happy to lend a hand on a community owned tool :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants