def flush.stats.entries

mylsm-lsm-store@0.6.0.1 · src/ByteDurableDb.bend:632

import mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend as ByteDurableDb
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

632# Keeps the original state when SST or WAL checkpoint publication fails.
633# Counts the visible entries and payload bytes in the newly published SST.
634def flush.stats.entries(
635  entries: List<&1, ByteMemTable.Entry>,
636  current: VisibleStats.Stats
637) -> VisibleStats.Stats:
638  match entries:
639    case Nil{}: current
640    case Con{ByteMemTable.Entry{Bytes.Bytes{+key_len, _}, value}, tail}:
641      match value:
642        case None{}: flush.stats.entries(tail, current)
643        case Some{Bytes.Bytes{+value_len, _}}:
644          flush.stats.entries(tail, VisibleStats.result(VisibleStats.apply(
645            current, U32.to_nat(key_len), None{}, Some{U32.to_nat(value_len)})))

Uses (8)

Used by (1)