SstFile.blocks.pack.go: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/SstFile.bend as SstFile Lines 296-329 of mylsm-lsm-store@0.6.0.1/src/SstFile.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/SstFile.bend&start_line=296&end_line=329 import Base import mylsm-lsm-store@0.6.0.1/src/MemTable.bend as MemTable import mylsm-lsm-store@0.6.0.1/src/StorageBytes.bend as StorageBytes # Pack records into blocks capped by encoded payload bytes, preserving order. def blocks.pack.go( entries: List<&2, MemTable.Entry>, current: List<&2, MemTable.Entry>, +size: U32, acc: List<&2, List<&2, MemTable.Entry>>, measured: BlockMeasure ) -> List<&2, List<&2, MemTable.Entry>>: match entries: case Nil{}: blocks.pack.finish(current, acc) case Con{entry, +rest}: match current: case Nil{}: match measured: case InvalidRecord{}: blocks.pack.go(rest, Con{entry, Nil{}}, StorageBytes.MAX_BLOCK_BYTES(), acc, blocks.measure.next(rest, StorageBytes.MAX_BLOCK_BYTES())) case Measured{+length, fits}: blocks.pack.go(rest, Con{entry, Nil{}}, length, acc, blocks.measure.next(rest, length)) case Con{_, _}: match measured: case InvalidRecord{}: blocks.pack.go(rest, Con{entry, Nil{}}, StorageBytes.MAX_BLOCK_BYTES(), Con{List.reverse(&2, MemTable.Entry, current), acc}, blocks.measure.next(rest, StorageBytes.MAX_BLOCK_BYTES())) case Measured{+length, False{}}: blocks.pack.go(rest, Con{entry, Nil{}}, length, Con{List.reverse(&2, MemTable.Entry, current), acc}, blocks.measure.next(rest, length)) case Measured{+length, True{}}: blocks.pack.go(rest, Con{entry, current}, (size + length : U32), acc, blocks.measure.next(rest, (size + length : U32))) Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool 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=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/MemTable.bend&name=Entry https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstFile.bend&name=BlockMeasure https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstFile.bend&name=blocks.measure.next https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstFile.bend&name=blocks.pack.finish https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/StorageBytes.bend&name=MAX_BLOCK_BYTES