google / leveldb

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.
BSD 3-Clause "New" or "Revised" License
36.29k stars 7.8k forks source link

Question: Each KV pair has 2 copies in arena? #1148

Open azuredream opened 1 year ago

azuredream commented 1 year ago

I'm a C++ beginner, please correct me if I was wrong. Is it possible to save a pointer to Key rather than a Key object in node?

First copy: MemTable::Add(): char* buf = arena_.Allocate(encoded_len);

Second copy: template <typename Key, class Comparator> struct SkipList<Key, Comparator>::Node { explicit Node(const Key& k) : key(k) {}

Key const key; ... }