LevelDB Source Reading (2): Read Write Last blog introduces the structure of leveldb, this blog will introduce how leveldb handle reading/writing and some related question. Reading Reading Procedure: check memtable (skiplist) check immutable memtable iterate sorted table in different level[0…] to find possible file using table index ([key => offset]) to find the suitable block via binary search binary search in restart array to find the last restart point with a key < target linear search possible entries between two restarting point to check Step 1 & 2: // dp_impl.cc // First look in the memtable, then in the immutable memtable (if any). LookupKey lkey ( key , snapshot ) ; if ( mem - > Get ( lkey , value , & s ) ) { // Done } else if ( imm != NULL && imm - > Get ( lkey , value , & s ) ) { // Done Step 3: // version_set.cc: Version::Get // We can search level-by-level since entries ne...
Learn programming, still on the way