ToplingZipTable

简介

在 ToplingZipTable 中,有两个核心概念:CO-Index 和 PA-Zip

  • CO-Index: 即 Compressed Ordered Index,把一个类型为 ByteArray 的 Key,映射到一个整数 ID,这个 ID 用来访问 PA-Zip 中相应的那条 Value。
  • PA-Zip: Point Accessible Zip,可以看做是一个抽象的 array,核心功能是把 ID 作为抽象数组的下标,去访问该抽象数组的元素,当然,这些元素都是压缩存储的。

CO-Index 和 PA-Zip 一起,构成一个逻辑上的 map<Key, Value>

在这里,Key 是 RocksDB 中的 InternalKey: {UserKey, Seq, OpType} 三元组。

CO-Index 在 ToplingDB 中最典型的实现是 NestLoudsTrie,PA-Zip 在 ToplingDB 中最典型的实现是 DictZipBlobStore,两者都是内存压缩的,也就是说,它们在内存中的形态是压缩的,所有的搜索、读取操作都是在内存压缩的形态上执行的。

ToplingZipTable 压缩的计算开销较大(大约是 zstd 的两倍),所以,在 ToplingDB 中,主要是将它通过 DispatchTable 配置在 LSM 的较下层,并通过分布式Compact执行压缩。

配置

ToplingZipTable 是通过 SidePlugin 进行配置的,在(yaml)配置文件中,举例如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
TableFactory:
zip:
class: ToplingZipTable
params:
localTempDir: "/dev/shm/tmp"
indexType: Mixed_XL_256_32_FL
indexNestLevel: 3
indexNestScale: 8
indexTempLevel: 0
indexCacheRatio: 0
warmupLevel: kIndex
compressGlobalDict: false
optimizeCpuL3Cache: true
enableEntropyStore: false
offsetArrayBlockUnits: 128
sampleRatio: 0.01
checksumLevel: 0
entropyAlgo: kNoEntropy
debugLevel: 0
softZipWorkingMemLimit: 16G
hardZipWorkingMemLimit: 32G
smallTaskMemory: 1G
minDictZipValueSize: 30
keyPrefixLen: 0
minPreadLen: 64

完整配置可参考 lcompact_enterprise.yaml