乐趣区

关于rocksdb:RocksDB剖析系列-BlockBasedTableBuilder源码解读

参考:

  • https://www.jianshu.com/p/9b5…
  • https://zhuanlan.zhihu.com/p/…

SST File Format

之前在 LSM-Tree 局部有提过,但过后理解的比拟浅

<beginning_of_file>
[data block 1]
[data block 2]
...
[data block N]
[meta block 1: filter block]                  
[meta block 2: index block]
[meta block 3: compression dictionary block]  
[meta block 4: range deletion block]          
[meta block 5: stats block]                   
...
[meta block K: future extended block]  (More meta blocks may be added in the future)
[metaindex block]
[Footer]                               (fixed size; starts at file_size - sizeof(Footer))
<end_of_file>

与 BlockBasedTableBuilder 相干的类有以下几个

  • BlockBasedTable, 该类封装了用于读取磁盘 BlockBasedTable 类型的 SST 表的逻辑。
  • BlockBasedTableBuilder, 该类用于在磁盘上构建一个 BlockBasedTable 类型的 SST 表。
  • BlockBasedTableFactory, 该类是 BlockBasedTable 工厂办法的实现,用于创立 BlockBasedTable/BlockBasedTableBuilder。

Write Block 的程序:

Write meta blocks, metaindex block and footer in the following order.

  1. [meta block: filter]
  2. [meta block: index]
  3. [meta block: compression dictionary]
  4. [meta block: range deletion tombstone]
  5. [meta block: properties]
  6. [metaindex block]
  7. Footer
退出移动版