DurableBatchPolicy.byte_batch.measure.loop: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/DurableBatchPolicy.bend as DurableBatchPolicy Lines 69-106 of mylsm-lsm-store@0.6.0.1/src/DurableBatchPolicy.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/DurableBatchPolicy.bend&start_line=69&end_line=106 import Base import mylsm-lsm-store@0.6.0.1/src/ByteWal.bend as ByteWal import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes # Advances a bounded no-copy byte-batch size pass. def byte_batch.measure.loop( fuel: Nat, state: ByteBatchMeasureState ) -> ByteBatchMeasurement: match fuel: case 0n: match state: case MeasureNeed{Nil{}, reversed, count, record_bytes}: BatchMeasured{List.reverse(&1, ByteWal.Mutation, reversed), count, frame_bytes(record_bytes)} case MeasureNeed{Con{_, _}, _, _, _}: BatchTooMany{} case 1n+rest: match state: case MeasureNeed{Nil{}, reversed, count, record_bytes}: BatchMeasured{List.reverse(&1, ByteWal.Mutation, reversed), count, frame_bytes(record_bytes)} case MeasureNeed{Con{ByteWal.Delete{key}, tail}, reversed, count, record_bytes}: match key: case Bytes.Bytes{+key_len, key_buffer}: byte_batch.measure.loop(rest, MeasureNeed{tail, Con{ByteWal.Delete{Bytes.Bytes{key_len, key_buffer}}, reversed}, Nat.add(count, 1n), Nat.add(record_bytes, delete_record_bytes(U32.to_nat(key_len)))}) case MeasureNeed{Con{ByteWal.Put{key, value}, tail}, reversed, count, record_bytes}: match key: case Bytes.Bytes{+key_len, key_buffer}: match value: case Bytes.Bytes{+value_len, value_buffer}: byte_batch.measure.loop(rest, MeasureNeed{tail, Con{ByteWal.Put{Bytes.Bytes{key_len, key_buffer}, Bytes.Bytes{value_len, value_buffer}}, reversed}, Nat.add(count, 1n), Nat.add(record_bytes, put_record_bytes(U32.to_nat(key_len), U32.to_nat(value_len)))}) Uses (12): 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=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=mylsm-lsm-store@0.6.0.1/src/ByteWal.bend&name=Mutation https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/DurableBatchPolicy.bend&name=ByteBatchMeasureState https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/DurableBatchPolicy.bend&name=ByteBatchMeasurement https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/DurableBatchPolicy.bend&name=delete_record_bytes https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/DurableBatchPolicy.bend&name=frame_bytes https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/DurableBatchPolicy.bend&name=put_record_bytes