netopyr / wurmloch-crdt

Experimental CRDT-implementations for the JVM
Apache License 2.0
116 stars 20 forks source link

How to sync to remote Map using CRDT #3

Open anidotnet opened 4 years ago

anidotnet commented 4 years ago

I have two remote maps of signature Map<String, Map<String, Object>>. I want to sync these two maps using CRDT. How do I implement this?

PS: I am the developer of an embedded database dizitart/nitrite-database and planning to use CRDT for replication. Any help would be highly appreciated.

netopyr commented 4 years ago

Usually you would use a Set to implement a Map, where each element is a pair consisting of the key and the value. Which one of the Set implementations you should use depends on the use case, because all of them have advantages and disadvantages.

Implementing nested Maps is going to be interesting. :) Maybe you can flatten them.

I believe the biggest challenge will be memory footprint. How is your database usually used?

anidotnet commented 4 years ago

My database is used as an embedded database mainly in android. It is mainly being used as a POJO store. The db marshalls the POJO into a Map<String, Object> entry. Each entry gets stored in a map as Map<String, Map<String, Object>> and this map gets persisted into the disk.

So in my case, as it is a map, do I need to keep track of addition, deletion and updation also?