Search code examples
nosqlrocksdb

Session-only memtable updates / merges in RocksDB


RocksDB newbie here.

In runtime, I only use RocksDB to read the data. Sometimes, I need to merge session-specific records from other sources.

I don't want them to be merged into the main database. I want them to exist only during the session lifetime for that specific session.

I can, of course, use a regular std::vector or something and merge the RocksDB and the other sources, but that would duplicate the data.

I see a bunch of concepts like memtable and merge, which sound like they might be used or exploited. For example, if I can tell memtable to never commit, and just abandon the changes, that should work. Is it doable?


Solution

  • The easiest way is probably to separate them into different column families, and just dropping the one you don't want to persist, when you shut down your application. If you need per-entry lifetime, you will probably have to consider something custom like a RAII-holder class, if you are using c++, which inserts on construction and deletes on destruction. I would still go with a separate column family to have the data cleanly separated, in case of a crash-failure.