ByteSstFile.blocks.collect.go: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend as ByteSstFile Lines 676-736 of mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend&start_line=676&end_line=736 import Base import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes def blocks.collect.go( fuel: Nat, fits: Bool, remaining: List<&1, EncodedBlock>, parts: List<&1, Bytes.Bytes>, checksums: List<&1, Bytes.Bytes>, index_entries: List<&1, Bytes.Bytes>, separators: List<&1, Bytes.Bytes>, +offset: Nat, +separator_offset: Nat, block_count: U32, entry_count: U32 ) -> Result<&1, &1, Error, BlocksCollected>: match fuel: case 0n: match fits: case False{}: Fail{TooLarge{}} case True{}: match remaining: case Nil{}: +count = U32.to_nat(block_count) Done{BlocksCollected{ Bytes.concat(List.reverse(&1, Bytes.Bytes, parts)), Bytes.concat(List.reverse(&1, Bytes.Bytes, checksums)), Bytes.concat([index.magic(), u32.bytes(U32.from_nat(count)), Bytes.concat([Bytes.concat(List.reverse(&1, Bytes.Bytes, index_entries)), Bytes.concat(List.reverse(&1, Bytes.Bytes, separators))])]), U32.from_nat(count), entry_count}} case _: Fail{Malformed{}} case 1n+rest: match fits: case False{}: Fail{TooLarge{}} case True{}: match remaining: case Nil{}: +count = U32.to_nat(block_count) Done{BlocksCollected{ Bytes.concat(List.reverse(&1, Bytes.Bytes, parts)), Bytes.concat(List.reverse(&1, Bytes.Bytes, checksums)), Bytes.concat([index.magic(), u32.bytes(U32.from_nat(count)), Bytes.concat([Bytes.concat(List.reverse(&1, Bytes.Bytes, index_entries)), Bytes.concat(List.reverse(&1, Bytes.Bytes, separators))])]), U32.from_nat(count), entry_count}} case Con{EncodedBlock{bytes, +byte_length, checksum, count, separator, +separator_length}, tail}: +length_nat = U32.to_nat(byte_length) +separator_length_nat = U32.to_nat(separator_length) blocks.collect.go(rest, fits && Nat.is_le(Nat.add(offset, length_nat), 4294967295n) && Nat.is_le(Nat.add(separator_offset, separator_length_nat), 4294967295n), tail, Con{bytes, parts}, Con{checksum, checksums}, Con{Bytes.concat([u32.bytes(U32.from_nat(offset)), u32.bytes(byte_length), u32.bytes(U32.from_nat(separator_offset)), u32.bytes(separator_length)]), index_entries}, Con{separator, separators}, Nat.add(offset, length_nat), Nat.add(separator_offset, separator_length_nat), (block_count + 1 : U32), (entry_count + count : U32)) Uses (19): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.reverse https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_le https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_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=bend-kit-bytes@0.3.3.0/bytes.bend&name=concat https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend&name=BlocksCollected https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend&name=EncodedBlock https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend&name=Error https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend&name=index.magic https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend&name=u32.bytes