Skip to content
Permalink
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
IWKV
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:
[u1:flags,lvl:u1,lkl:u1,pnum:u1,p0:u4,kblk:u4,pi:u1[32],n:u4[24],lk:u116]:u256
V2 SBLK layout:
[flags:u1,lvl:u1,lkl:u1,pnum:u1,p0:u4,kblk:u4,pi:u1[32],n:u4[24],bpos:u1,lk:u115]:u256
\
KVBLK
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:u4,dbflg:u1,dbid:u4,next_db_blk:u4,p0:u4,n[24]:u4,c[24]:u4,meta_blk:u4,meta_len:u4]:217
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
HEADER:
[magic:u4,u8:fistdb_addr]
magic - File magic number 0x69776b76
fistdb_addr - Address of the first db in the DB chain
------------------------------------------------------------
WAL
1. Extra rdb methods
You can’t perform that action at this time.