zoukankan      html  css  js  c++  java
  • Leveldb之version与version_set详细对比

    version类包含的重要变量:

      


    VersionSet* vset_; // VersionSet to which this Version belongs
    Version* next_; // Next version in linked list
    Version* prev_; // Previous version in linked list

      double compaction_score_;

      int compaction_level_;

      std::vector<FileMetaData*> files_[config::kNumLevels];

    构造函数:

    explicit Version(VersionSet* vset)
    : vset_(vset), next_(this), prev_(this), refs_(0),
    file_to_compact_(NULL),
    file_to_compact_level_(-1),
    compaction_score_(-1),
    compaction_level_(-1) {
    }

    VersionSet 类包含的重要变量:

      Version* current_;        // == dummy_versions_.prev_

      TableCache* const table_cache_;

    const std::string dbname_;

    构造函数:

    VersionSet::VersionSet(const std::string& dbname,
    const Options* options,
    TableCache* table_cache,
    const InternalKeyComparator* cmp)
    : env_(options->env),
    dbname_(dbname),
    options_(options),
    table_cache_(table_cache),
    icmp_(*cmp),
    next_file_number_(2),
    manifest_file_number_(0), // Filled by Recover()
    last_sequence_(0),
    log_number_(0),
    prev_log_number_(0),
    descriptor_file_(NULL),
    descriptor_log_(NULL),
    dummy_versions_(this),
    current_(NULL) {
    AppendVersion(new Version(this));

    }

    一切都从 dbimpl 开始,

    该类包含一个 VersionSet变量   VersionSet* versions_;

    所有对与 version有关的东西都以这个变量为入口。

    那么,首先来看其初始化。

    versions_ = new VersionSet(dbname_, &options_, table_cache_, &internal_comparator_);

    和上面的声明非常一致。

    这个初始化就是给这个对象的一些启动变量进行赋值,后面肯定要对关键变量赋值。

    首先调用恢复函数恢复出一个版本  Status s = impl->Recover(&edit);

    该recover调用versionset的recover,读取manifest,创建builder,将builder保存到v,然后将current_指向v

    保存之前,先调用Finalize 评价一下。

  • 相关阅读:
    js 复制到剪切板
    200-api网关工程过滤器设置
    199-Zuul配置文件
    198-Feign有什么方便之处呢?
    12-sublime中文配置
    098-Servlet为什么直接相应给浏览器的信息会出现乱码?
    097-为什么我们在SpirngBoot中设置了响应头的编码,浏览器解析出来依然回事乱码呢?
    196-为什么SpringBoot框架中不能直接使用@WebServlet的注解?
    195-如何获取Spring容器中的对象?
    194-Spring注入属性的几个注解?
  • 原文地址:https://www.cnblogs.com/bettersky/p/6106527.html
Copyright © 2011-2022 走看看