Macan's Blog

chaotic thoughts


LevelDB 源码分析

Condition Variable与Mutex的比较
Mutexes are low-level primitives used to coordinate concurrent access to mutable data.If one thread has locked a mutex, then another thread attempting to lock that same mutex will wait until the first thread is done



SSTable and Log Structured Storage: LevelDB

//A helper class useful for DBImpl::Get()
class LookupKey {
    const char *start_;     //user key length varint32 
    const char *kstart_;    //user key  char[klength]
    const char *end_;       //sequence number + value type uint64
    char space_[200];       //Avoid allocation for short keys
    struct FileMetaData {
        int refs;                   
        int allowed_seeks;          // Seeks allowed until compaction
        uint64_t number;
        uint64_t file_size;         // File size in bytes
        InternalKey smallest;       // Smallest internal key served by table
        InternalKey largest;        // Largest internal key served by table

        FileMetaData() : refs(0), allowed_seeks(1 << 30), file_size(0) {}