def index.page.start

mylsm-lsm-store@0.6.0.1 · src/scan/ByteBlockReader.bend:1643

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
import mylsm-lsm-store@0.6.0.1/src/hub_sha/sha256.bend as SHA

1643def index.page.start(file: File, state: State) -> IO(Result<&1, &1, U32 & String, Step>):
1644  match state:
1645    case State{+size, _, +index_offset, _, +total, _, _, _, root_hash,
1646        index_hash, _, _}:
1647      +remaining = Nat.sub(size, Nat.add(index_offset, 44n))
1648      +index_length = U32.from_nat(remaining)
1649      +page_bytes = BlockIndexPolicy.max_bytes()
1650      +pages = Nat.div(Nat.add(remaining, Nat.sub(page_bytes, 1n)), page_bytes)
1651      +fuel = Nat.add(Nat.mul(3n, pages), 1n)
1652      index.page.loop(fuel, IndexPageNeed{file,
1653        IndexMeta{total, index_length, index_hash}, index_offset, remaining,
1654        SHA.stream.initial(), root_hash})

Uses (18)

Used by (1)