ByteDurableDb.batch.stats.loop: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend as ByteDurableDb Lines 1656-1711 of mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend&start_line=1656&end_line=1711 import Base import mylsm-lsm-store@0.6.0.1/src/ByteMemTable.bend as ByteMemTable import mylsm-lsm-store@0.6.0.1/src/scan/VisibleStats.bend as VisibleStats import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes def batch.stats.loop(fuel: Nat, state: BatchStatsState) -> IO(Handle & Result<&1, &1, Error, BatchPrepared>): match fuel: case 0n: batch.stats.exhausted(state) case 1n+rest: match state: case BatchNeed{handle, mutations, entries, original_stats, base_stats}: match handle: case Handle{path, lock, table, state, _}: match entries: case Nil{}: IO.pure(Handle & Result<&1, &1, Error, BatchPrepared>, (Handle{path, lock, table, state, original_stats}, Done{Prepared{mutations, base_stats}})) case Con{ByteMemTable.Entry{key, _}, tail}: batch.stats.loop(rest, BatchKey{ Handle{path, lock, table, state, VisibleStats.Stats{0n, 0n}}, mutations, tail, original_stats, base_stats, batch.keys(key)}) case BatchKey{handle, mutations, entries, original_stats, base_stats, keys}: match handle: case Handle{path, lock, table, state, _}: match keys: case (probe_key, (read_key, stats_key)): match stats_key: case Bytes.Bytes{+key_len, _}: batch.stats.loop(rest, BatchProbe{ Handle{path, lock, ByteMemTable.empty(), state, VisibleStats.Stats{0n, 0n}}, mutations, entries, original_stats, base_stats, U32.to_nat(key_len), read_key, ByteMemTable.probe(table, probe_key)}) case BatchProbe{handle, mutations, entries, original_stats, base_stats, key_bytes, key, result}: match handle: case Handle{path, lock, _, state, _}: match result: case (table, ByteMemTable.Absent{}): do IO>: pair : Handle & Result<&1, &1, Error, Maybe<&1, Bytes.Bytes>> <- get(Handle{path, lock, table, state, VisibleStats.Stats{0n, 0n}}, key) batch.stats.loop(rest, BatchRead{pair, mutations, entries, original_stats, base_stats, key_bytes}) case (table, _): batch.stats.loop(rest, BatchNeed{ Handle{path, lock, table, state, VisibleStats.Stats{0n, 0n}}, mutations, entries, original_stats, base_stats}) case BatchRead{pair, mutations, entries, original_stats, base_stats, key_bytes}: match pair: case (handle, Fail{error}): IO.pure(Handle & Result<&1, &1, Error, BatchPrepared>, (batch.restore.handle(original_stats, handle), Fail{error})) case (Handle{path, lock, table, state, _}, Done{old_value}): batch.stats.loop(rest, BatchNeed{ Handle{path, lock, table, state, VisibleStats.Stats{0n, 0n}}, mutations, entries, original_stats, stats.remove.base.length(base_stats, key_bytes, old_value)}) Uses (25): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.pure https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma 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/ByteDurableDb.bend&name=BatchPrepared https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend&name=BatchStatsState https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend&name=Error https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend&name=Handle https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend&name=batch.keys https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend&name=batch.restore.handle https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend&name=batch.stats.exhausted https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend&name=get https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend&name=stats.remove.base.length https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteMemTable.bend&name=Entry https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteMemTable.bend&name=Probe https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteMemTable.bend&name=empty https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/ByteMemTable.bend&name=probe https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/VisibleStats.bend&name=Stats