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

atomic patch application #115

Open
johanneswilm opened this issue Nov 14, 2020 · 3 comments
Open

atomic patch application #115

johanneswilm opened this issue Nov 14, 2020 · 3 comments
Labels

Comments

@johanneswilm
Copy link

Hey,
I have a situation in which I am restrained in terms of memory, so I patch the the original object in place. That works fine, except that the patches are user provided, so sometimes they don't apply fully. If the patch has multiple steps, only the first steps up to the failure are applied. Fro example:

[
    {op: 'add', path: '/attrs/language', value: 'de-DE'},  # 1, valid
    {op: 'add', path: '/attrs/country', value: 'US'},  # 2, valid
    {op: 'remove', path: '/fish'},  # 3, invalid
    {op: 'remove', path: '/attrs/copyright'} # 4, valid 
]

What happens in this situation is that 1 and 2 are applied, then an error is thrown. Unfortunately, it is not possible for me to find out which steps are applied or to undo those steps, as far as I can tell. Is there a way I can have it unapply 1 and 2 after 3 threw an error?

@Alanscut
Copy link
Contributor

Hi @johanneswilm, it seems that the original object is not changed only when in_place is set to false, as you mentioned, this will take up some memory. I think the un_apply API will make sense.
May I ask what system are you using? what the size of your original object?

@johanneswilm
Copy link
Author

Hey @Alanscut what do you mean by "system"? I can say that I am using this library within https://github.com/fiduswriter/fiduswriter to receive changes within a document from clients on the server. So the documents will be of varying sizes but there will normally be many documents opened by many different users at the same time. Where can I find more about the un_apply API? I did look at the documentation and didn't find it there.

@Alanscut
Copy link
Contributor

I mean OS, never mind it. This lib doesn't have un_apply now, I just think this suggestion makes sense.

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

No branches or pull requests

2 participants