1IWKV 2 3block size: u128 4max key+value size: 268435455 (~255Mb) 5max data file size: 512G 6 7SBLK - Skip list node with pointers to next nodes and pointer to KVBLK (key/value pairs block). 8 SBLK has fixed size (256 bytes). SBLK file position (block adress) within a file is 9 fixed and cannot be changed. 10 11V1 SBLK layout: 12 13 [u1:flags,lvl:u1,lkl:u1,pnum:u1,p0:u4,kblk:u4,pi:u1[32],n:u4[24],lk:u116]:u256 14 15V2 SBLK layout: 16 17 [flags:u1,lvl:u1,lkl:u1,pnum:u1,p0:u4,kblk:u4,pi:u1[32],n:u4[24],bpos:u1,lk:u115]:u256 18 \ 19 KVBLK 20 21 flags - Persistent block flags (1 byte) 22 lvl - Skiplist level of this block (1 byte) 23 lkl - Length of the lower key in this block (1 byte) 24 pnum - Number of active kv indexes in `SBLK::pi` 25 p0 - Address of previous sblk block at zero level 26 kblk - Block number of associated KVBLK. (4 bytes) 27 pi[32] - Array of key/value pair indexes in KVBLK block. 28 Indexes are sorted by keys. (32 bytes) 29 n[24] - Pointers to next SBLK blocks in skiplist (96 bytes) 30 bpos - Position of SBLK in a page block starting with 1 (zero means SBLK deleted) 31 lk - Buffer for the lowest key among all key/value pairs stored in KVBLK 32 33 34KVBLK - Data block stored a set of key/value pairs associated with SBLK 35 36[szpow:u1,idxsz:u2,KVI[32] ___free space___ [[KV],...]] 37 38 szpow - KVBLK length as power of 2 39 idxsz - Length of KVI array in bytes 40 KVI[32] - [ps:vn, pl:vn] 41 ps: key/value pair block offset on i-th place variable length encoded number. 42 This offset is relative to end of KVBLK block 43 pl: key/value pair block length on i-th place variable length encoded number 44 45 KV - [klen:vn,key,value] 46 Key/value pair 47 klen: Key length as variable length encoded number 48 key: Key data buffer 49 value: Value data buffer 50 51DB header block: 52 53 [magic:u4,dbflg:u1,dbid:u4,next_db_blk:u4,p0:u4,n[24]:u4,c[24]:u4,meta_blk:u4,meta_len:u4]:217 54 55 magic - DB magic number 0x69776462 56 dbflg - Database flags 57 next_db_blk - Next database meta block number or zero 58 dbid - Database ID 59 p0 - Last database block 60 n24 - Skiplist next pointers to `SBLK` 61 c24 - SBLK count per level, 62 /* since file format v1 */ 63 meta_blk - Database metadata block number 64 meta_blkn - Database metadata block count 65 66HEADER: 67 68 [magic:u4,u8:fistdb_addr] 69 70 magic - File magic number 0x69776b76 71 fistdb_addr - Address of the first db in the DB chain 72 73------------------------------------------------------------ 74 75WAL 76 771. Extra rdb methods 78 79 80 81 82