Search code examples
hashmapsnapshotkey-value-store

What is a efficient way of storing snapshots of an in-memory key-value store in Java?


I am trying to design an in-memory key-value store that maps strings to strings of variable length. I also want to give it the ability to take snapshots of its key-value data sets for any particular moment in time. Moreover, modifications to the key-value store should not affect past snapshots. I am currently using a HashMap for this, and for snapshots I maintain a mapping of timestamps to deep-copies of the respective HashMap's entry sets (with simple String compression). Are there any other more effective methods of doing this in-memory?

I am wondering, is it perhaps more memory-efficient, since I am working with strings of characters, to use tries instead?


Solution

  • Interesting. A little research shows that a Ctrie might be what you are looking for. Wiki: https://en.wikipedia.org/wiki/Ctrie

    ctrie: Concurrent Tries with Efficient Non-Blocking Snapshots

    Looks like there is code available in multiple languages java haskell python C++

    Found related : Creating a ConcurrentHashMap that supports "snapshots"

    and searching Stackoverflow: https://stackoverflow.com/search?q=ctrie