1 Star 0 Fork 1

CocamanZ / reading-source-code-of-leveldb-1.23

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

leveldb 源码阅读

1. Build && Install && Debug

leveldb 本身是一个 Key-Value 存储引擎,因此并没有提供 main 入口函数,所以需要自行添加。笔者将其放到了 debug/leveldb_debug.cc 文件中,并在 CMakeLists.txtx 中将其加入:

  leveldb_test("util/env_test.cc")
  leveldb_test("util/status_test.cc")
  leveldb_test("util/no_destructor_test.cc")
  
  if(NOT BUILD_SHARED_LIBS)
    leveldb_test("debug/leveldb_debug.cc")    # 个人可执行文件
    leveldb_test("db/autocompact_test.cc")
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug .. && cmake --build .
make && make install
gdb leveldb_debug   # 此时 leveldb_debug 就在 build 目录下,可直接进行 gdb 调试

如果使用 CLion 的话,可以直接对 leveldb_debug.cc 进行 debug,比 gdb 要更方便一些。

2. leveldb 核心流程梳理

  1. leveldb 概述与 LSM-Tree
  2. leveldb 中的常用数据结构
  3. leveldb 中的 varint 与 Key 组成
  4. leveldb Key-Value 写入流程分析
  5. leveldb 预写日志格式及其读写流程
  6. SSTable(01)—概览与 Data Block
  7. SSTable(02)—Bloom Filter 与 Meta Block
  8. SSTable(03)—SSTable 之索引
  9. SSTable(04)—Table Builder
  10. Compaction(01)—Minor Compaction
  11. leveldb 版本控制概览
  12. Compaction(02)—Major Compaction
Copyright (c) 2011 The LevelDB Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

leveldb 1.23 源码阅读 展开 收起
C++
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/cocamanz/reading-source-code-of-leveldb-1.23.git
git@gitee.com:cocamanz/reading-source-code-of-leveldb-1.23.git
cocamanz
reading-source-code-of-leveldb-1.23
reading-source-code-of-leveldb-1.23
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891