def flush.manifest.loaded
mylsm-lsm-store@0.6.0.1 · src/ByteDurableDb.bend:915
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/ByteManifest.bend as ByteManifest
import mylsm-lsm-store@0.6.0.1/src/ByteManifestIo.bend as ByteManifestIo
import mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend as ByteSstFile
import mylsm-lsm-store@0.6.0.1/src/ByteSstIo.bend as ByteSstIo
import mylsm-lsm-store@0.6.0.1/src/DbLock.bend as DbLock
import mylsm-lsm-store@0.6.0.1/src/scan/VisibleStats.bend as VisibleStats
915def flush.manifest.loaded(
916 +path: String,
917 lock: DbLock.Lock,
918 table: ByteMemTable.Table,
919 result: Result<&1, &1, ByteManifestIo.Error, ByteManifest.ManifestValue>
920) -> IO(Handle & Result<&1, &1, Error, Unit>):
921 match table:
922 case ByteMemTable.Table{entries}:
923 match result:
924 case Fail{ByteManifestIo.Invalid{_}}:
925 IO.pure(Handle & Result<&1, &1, Error, Unit>,
926 (Handle{path, lock, ByteMemTable.Table{entries}, Open{}, VisibleStats.Stats{0n, 0n}}, Fail{Corruption{"byte manifest validation failed"}}))
927 case Fail{ByteManifestIo.Host{code, message}}:
928 IO.pure(Handle & Result<&1, &1, Error, Unit>,
929 (Handle{path, lock, ByteMemTable.Table{entries}, Open{}, VisibleStats.Stats{0n, 0n}}, Fail{Io{code, message}}))
930 case Done{ByteManifest.Empty{}}:
931 flush.cloned(path, lock, ByteSstFile.entries.clone(entries))
932 case Done{ByteManifest.GenerationEmpty{}}:
933 flush.cloned(path, lock, ByteSstFile.entries.clone(entries))
934 case Done{ByteManifest.HasSst{}}:
935 do IO<Handle & Result<&1, &1, Error, Unit>>:
936 base : Result<&1, &1, U32 & String, ByteMemTable.Table> <-
937 ByteSstIo.read(path ++ "/SST")
938 flush.sst.loaded(path, lock, ByteMemTable.Table{entries}, base)
939 case Done{ByteManifest.GenerationSst{file_id}}:
940 do IO<Handle & Result<&1, &1, Error, Unit>>:
941 base : Result<&1, &1, U32 & String, ByteMemTable.Table> <-
942 ByteSstIo.read(ByteManifest.sst.generation.path(path, file_id))
943 flush.sst.loaded(path, lock, ByteMemTable.Table{entries}, base)