ByteSstIo.read.loop: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/ByteSstIo.bend as ByteSstIo Lines 184-214 of mylsm-lsm-store@0.6.0.1/src/ByteSstIo.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstIo.bend&start_line=184&end_line=214 import Base import mylsm-lsm-store@0.6.0.1/src/ByteMemTable.bend as ByteMemTable import mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend as ByteBlockReader def read.loop(fuel: Nat, state: ReadState) -> IO(Result<&1, &1, U32 & String, ByteMemTable.Table>): match fuel: case 0n: match state: case ReadNeed{reader, _}: do IO>: _closed : Result<&1, &1, U32 & String, Unit> <- ByteBlockReader.close(reader) return Fail{corruption("byte SST block count exceeded reader limit")} case ReadStep{result, _}: match result: case Done{ByteBlockReader.Block{reader, _}}: do IO>: _closed : Result<&1, &1, U32 & String, Unit> <- ByteBlockReader.close(reader) return Fail{corruption("byte SST block count exceeded reader limit")} case _: IO.pure(Result<&1, &1, U32 & String, ByteMemTable.Table>, Fail{corruption("byte SST reader exhausted its transition limit")}) case 1n+rest: match state: case ReadNeed{reader, table}: do IO>: result : Result<&1, &1, U32 & String, ByteBlockReader.Step> <- ByteBlockReader.next(reader) read.loop(rest, ReadStep{result, table}) case ReadStep{result, table}: match result: case Fail{error}: IO.pure(Result<&1, &1, U32 & String, ByteMemTable.Table>, Fail{error}) case Done{ByteBlockReader.End{}}: IO.pure(Result<&1, &1, U32 & String, ByteMemTable.Table>, Done{table}) case Done{ByteBlockReader.Block{reader, entries}}: read.loop(rest, ReadNeed{reader, read.fold(entries, table)}) Uses (16): 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=IO.pure 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=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteMemTable.bend&name=Table https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstIo.bend&name=ReadState https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstIo.bend&name=corruption https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstIo.bend&name=read.fold 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 https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=next