LevelDB
I've been playing with the LevelDB library recently, so I took some time digging around its source code (https://github.com/google/leveldb) and reading articles/papers. In this post, I’m going to share some things related to LevelDB that I most enjoyed learning about. If you don’t know much about LevelDB, here’s a quick overview: LevelDB is a C++ library that stores key value pairs of byte arrays sorted by key. Operations include Put(key, value), Get(key) and Delete(key). It’s called LevelDB because it is arranged by levels: cache, log, level 0, level 1, level 2 … In general, after Level x reaches a limit of 10^x MB, one of its files gets compacted (merged periodically) into Level x+1. Level 0 is a special level: when it hits its limit of 4 files, at least one of its file gets compacted into Level 1. Furthermore, the files in Level 0 can contain overlapping keys, whereas the keys in the files in the other levels cannot. One of the things that interested me was the underlying d...