ByteBlockReader.index.page.loop: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend as ByteBlockReader Lines 1598-1641 of mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&start_line=1598&end_line=1641 import Base import mylsm-lsm-store@0.6.0.1/src/Fs.bend as Fs import mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend as SstStreamIo import mylsm-lsm-store@0.6.0.1/src/scan/BlockIndexPolicy.bend as BlockIndexPolicy import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes def index.page.loop(fuel: Nat, state: IndexPageState) -> IO(Result<&1, &1, U32 & String, Step>): match fuel: case 0n: match state: case IndexPageNeed{file, _, _, _, _, _}: close.failed(file, resource_limit("SST index page traversal limit exceeded")) case IndexPageRead{pair, _, _, _, _, _}: match pair: case (file, _): close.failed(file, resource_limit("SST index page traversal limit exceeded")) case IndexPageParsed{file, _}: close.failed(file, resource_limit("SST index page traversal limit exceeded")) case 1n+rest: match state: case IndexPageNeed{file, reader, +offset, +remaining, actual_hash, root_hash}: match remaining: case 0n: index.page.footer.read(file, reader, offset, root_hash) case 1n+_: +needed = U32.from_nat(BlockIndexPolicy.read_bytes(remaining)) do IO>: raw : File & Result<&1, &1, U32 & String, Bytes.Bytes> <- Fs.read_at(file, U32.from_nat(offset), needed) index.page.loop(rest, IndexPageRead{ read_at.exact.pair(needed, raw), reader, offset, remaining, actual_hash, root_hash}) case IndexPageRead{pair, reader, +offset, +remaining, actual_hash, root_hash}: match pair: case (file, Fail{error}): close.failed(file, error) case (file, Done{SstStreamIo.ExactResult{bytes, complete}}): index.page.loop(rest, IndexPageParsed{file, index.page.decode(reader, offset, remaining, actual_hash, root_hash, bytes, complete)}) case IndexPageParsed{file, result}: match result: case Fail{error}: close.failed(file, error) case Done{IndexPageData{reader, offset, remaining, actual_hash, root_hash}}: index.page.loop(rest, IndexPageNeed{file, reader, offset, remaining, actual_hash, root_hash}) case Done{_}: close.failed(file, corruption("invalid SST index traversal state")) Uses (23): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=File https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat https://jend.leeeet.dev/definition.txt?path=bend-kit-bytes@0.3.3.0/bytes.bend&name=Bytes https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/Fs.bend&name=read_at https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=ExactResult https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/BlockIndexPolicy.bend&name=read_bytes https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=IndexPageData https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=IndexPageState https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=Step https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=close.failed https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=corruption https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=index.page.decode https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=index.page.footer.read https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=read_at.exact.pair https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=resource_limit