Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SmartKeyerror/reading-source-code-of-leveldb-1.23
leveldb 源码阅读,分析 DB 运作流程与 WAL、SSTable 等文件格式与 Compaction 过程。
https://github.com/SmartKeyerror/reading-source-code-of-leveldb-1.23
Last synced: 7 days ago
JSON representation
leveldb 源码阅读,分析 DB 运作流程与 WAL、SSTable 等文件格式与 Compaction 过程。
- Host: GitHub
- URL: https://github.com/SmartKeyerror/reading-source-code-of-leveldb-1.23
- Owner: SmartKeyerror
- License: bsd-3-clause
- Created: 2021-07-24T14:12:41.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-24T08:24:55.000Z (about 3 years ago)
- Last Synced: 2024-07-10T16:00:56.567Z (4 months ago)
- Language: C++
- Homepage:
- Size: 2.73 MB
- Stars: 553
- Watchers: 4
- Forks: 129
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
## leveldb 源码阅读
![](leveldb.png)
### 1. Build && Install && Debug
leveldb 本身是一个 Key-Value 存储引擎,因此并没有提供 `main` 入口函数,所以需要自行添加。笔者将其放到了 `debug/leveldb_debug.cc` 文件中,并在 `CMakeLists.txtx` 中将其加入:
```bash
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")
``````bash
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 中的常用数据结构](/debug/articles/02-data-structure/README.md)
3. [leveldb 中的 varint 与 Key 组成](/debug/articles/03-varint-and-key-format/README.md)
4. [leveldb Key-Value 写入流程分析](/debug/articles/04-write-process/README.md)
5. [leveldb 预写日志格式及其读写流程](/debug/articles/05-WAL/README.md)
6. [SSTable(01)—概览与 Data Block](/debug/articles/06-SSTable-data-block/README.md)
7. [SSTable(02)—Bloom Filter 与 Meta Block](/debug/articles/07-SSTable-meta-block/README.md)
8. [SSTable(03)—SSTable 之索引](/debug/articles/08-SSTable-index/README.md)
9. [SSTable(04)—Table Builder](/debug/articles/09-SSTable-table-builder/README.md)
10. [Compaction(01)—Minor Compaction](/debug/articles/10-minor-compaction/README.md)
11. [leveldb 版本控制概览](/debug/articles/11-version-control-overview/README.md)
12. Compaction(02)—Major Compaction