def parse.records.go
mylsm-lsm-store@0.6.0.1 · src/SstFile.bend:813
import mylsm-lsm-store@0.6.0.1/src/SstFile.bend as SstFile
import Base
import mylsm-lsm-store@0.6.0.1/src/MemTable.bend as MemTable
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes
813def parse.records.go(
814 remaining: Nat,
815 decision: RecordDecision,
816 +payload_left: U32,
817 acc: List<&2, MemTable.Entry>
818) -> Bytes.Cursor & Result<&1, &1, Error, ParsedEntries>:
819 match remaining:
820 case 0n:
821 parse.records.empty(decision)
822 case 1n++rest:
823 match decision:
824 case Rejected{cursor, error}:
825 (cursor, Fail{error})
826 case OutOfBounds{cursor}:
827 (cursor, Fail{Malformed{}})
828 case OutOfOrder{cursor}:
829 (cursor, Fail{InvalidOrder{}})
830 case LastMalformed{cursor}:
831 (cursor, Fail{Malformed{}})
832 case LastRecord{cursor, entry, +key}:
833 (cursor, Done{Entries{Con{entry, acc}, Some{key}}})
834 case MoreRecords{cursor, entry, +key, +used}:
835 +payload_after = (payload_left - used : U32)
836 parse.records.go(rest,
837 parse.records.decision(parse.record.read(cursor, payload_after,
838 Some{key}, Nat.is_eq(rest, 1n))),
839 payload_after, Con{entry, acc})