share / sharedb

Realtime database backend based on Operational Transformation (OT)
Other
6.1k stars 444 forks source link

How can i use it with Google diff match patch library #532

Open ankush-dcoder opened 2 years ago

ankush-dcoder commented 2 years ago

Our client app is Android and written in Java, we use Google's diff-match-patch library extensively. How do we use sharedb with this as ot type?

curran commented 2 years ago

It's not an OT type, but this diffing library can translate output from Google's diff-match-patch into JSON0 or JSON1 ops: https://github.com/kbadk/json0-ot-diff

ankush-dcoder commented 2 years ago

Thanks for the answer @curran. One more thing, the use case we have is based on real time editing of json document, and I see json0 ot type as a great fit for this use case, unfortunately i couldn't find a client library implementation for json0 diffs in java for Android app client. Is there a supported library written in java for json0?

curran commented 2 years ago

I don't believe there are any Java implementations for json0.

ankush-dcoder commented 2 years ago

That seems like a deadend. I found this json diff library for java zjsonpatch . Can you guide me if i want to use it, do i need to implement this as a new ot-type library by providing definition for all the required functions?

curran commented 2 years ago

I have no experience with ShareDB + Java. I don't think anyone does. It would probably be quite difficult to build a ShareDB client in Java. Perhaps you can use JavaScript within your Android app?

ankush-dcoder commented 2 years ago

Android doesn't run js natively, it's really difficult to run js as logic in as a part of native app.

On the other note I think i'll be able rewrite some part of google-diff algo and produce ot-text like diffs to send, but i was worried about using text ot for a json document, one character wrong patch can make the whole document unusable with json parsing errors. In your experience have you seen ot text working well for json documents too? (As in the end each json can be presented as text.)

curran commented 2 years ago

You're right that text OT is not suitable for JSON, as like you say, one wrong patch can make the whole thing unstable.

ankush-dcoder commented 2 years ago

Thanks for all the help, saved me some experimentation time.

curran commented 1 year ago

Suggest to close this issue.