def legacy.apply.loop
mylsm-lsm-store@0.6.0.1 · src/transfer/Migrate.bend:109
import mylsm-lsm-store@0.6.0.1/src/transfer/Migrate.bend as Migrate
import Base
import mylsm-lsm-store@0.6.0.1/src/ByteMemTable.bend as ByteMemTable
109def legacy.apply.loop(
110 fuel: Nat,
111 state: LegacyApplyState
112) -> Result<&1, &1, U32 & String, ByteMemTable.Table>:
113 match fuel:
114 case 0n:
115 match state:
116 case LegacyApplyNeed{_, table}: Done{table}
117 case LegacyApplyConverted{_, _, Fail{error}}: Fail{error}
118 case LegacyApplyConverted{_, table, Done{_}}: Done{table}
119 case 1n+rest:
120 match state:
121 case LegacyApplyNeed{entries, table}:
122 match entries:
123 case Nil{}: Done{table}
124 case Con{entry, tail}:
125 legacy.apply.loop(rest, LegacyApplyConverted{tail, table,
126 legacy.entry.bytes(entry)})
127 case LegacyApplyConverted{tail, table, result}:
128 match result:
129 case Fail{error}: Fail{error}
130 case Done{ByteMemTable.Entry{key, value}}:
131 match value:
132 case None{}:
133 legacy.apply.loop(rest, LegacyApplyNeed{tail,
134 ByteMemTable.del(table, key)})
135 case Some{bytes}:
136 legacy.apply.loop(rest, LegacyApplyNeed{tail,
137 ByteMemTable.put(table, key, bytes)})