def transition.budget.state
mylsm-lsm-store@0.6.0.1 · src/scan/ByteBlockReader.bend:98
import mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend as ByteBlockReader
import Base
import mylsm-lsm-store@0.6.0.1/src/scan/BlockIndexPolicy.bend as BlockIndexPolicy
98
99def transition.budget.state(file: File, state: State) -> Nat & Reader:
100 match state:
101 case State{+size, header, +index_offset, used, total, +block_count,
102 next_block, decoded, root_hash, index_hash, last_key, selected}:
103 +blocks = U32.to_nat(block_count)
104 +index_bytes = Nat.sub(size, Nat.add(index_offset, 44n))
105 +page_bytes = BlockIndexPolicy.max_bytes()
106 +pages = Nat.div(Nat.add(index_bytes, Nat.sub(page_bytes, 1n)), page_bytes)
107 (Nat.add(Nat.add(Nat.mul(4n, blocks), Nat.mul(3n, pages)), 4n),
108 Reader{file, State{size, header, index_offset, used, total, block_count,
109 next_block, decoded, root_hash, index_hash, last_key, selected}})