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 评价一下。

  • 相关阅读:
    Octave/Matlab初步学习
    week_3
    week_2
    week_1
    清除input[type=number]的默认样式
    js,获取和设置cookie、 localStorage
    php表单提交时获取不到post数据的解决方法
    console.log 简写
    JS合并两个数组的方法
    javascript ES5、ES6的一些知识
  • 原文地址:https://www.cnblogs.com/bettersky/p/6106527.html
Copyright © 2011-2022 走看看