Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (56 sloc) 2.63 KB
block size: u128
max key+value size: 268435455 (~255Mb)
max data file size: 512G
SBLK - Skip list node with pointers to next nodes and pointer to KVBLK (key/value pairs block).
SBLK has fixed size (256 bytes). SBLK file position (block adress) within a file is
fixed and cannot be changed.
V1 SBLK layout:
V2 SBLK layout:
flags - Persistent block flags (1 byte)
lvl - Skiplist level of this block (1 byte)
lkl - Length of the lower key in this block (1 byte)
pnum - Number of active kv indexes in `SBLK::pi`
p0 - Address of previous sblk block at zero level
kblk - Block number of associated KVBLK. (4 bytes)
pi[32] - Array of key/value pair indexes in KVBLK block.
Indexes are sorted by keys. (32 bytes)
n[24] - Pointers to next SBLK blocks in skiplist (96 bytes)
bpos - Position of SBLK in a page block starting with 1 (zero means SBLK deleted)
lk - Buffer for the lowest key among all key/value pairs stored in KVBLK
KVBLK - Data block stored a set of key/value pairs associated with SBLK
[szpow:u1,idxsz:u2,KVI[32] ___free space___ [[KV],...]]
szpow - KVBLK length as power of 2
idxsz - Length of KVI array in bytes
KVI[32] - [ps:vn, pl:vn]
ps: key/value pair block offset on i-th place variable length encoded number.
This offset is relative to end of KVBLK block
pl: key/value pair block length on i-th place variable length encoded number
KV - [klen:vn,key,value]
Key/value pair
klen: Key length as variable length encoded number
key: Key data buffer
value: Value data buffer
DB header block:
magic - DB magic number 0x69776462
dbflg - Database flags
next_db_blk - Next database meta block number or zero
dbid - Database ID
p0 - Last database block
n24 - Skiplist next pointers to `SBLK`
c24 - SBLK count per level,
/* since file format v1 */
meta_blk - Database metadata block number
meta_blkn - Database metadata block count
magic - File magic number 0x69776b76
fistdb_addr - Address of the first db in the DB chain
1. Extra rdb methods
You can’t perform that action at this time.