def next.body.output.count
mylsm-lsm-store@0.6.0.1 · src/scan/ByteBlockReader.bend:1178
import mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend as ByteBlockReader
import Base
import mylsm-lsm-store@0.6.0.1/src/ByteMemTable.bend as ByteMemTable
import mylsm-lsm-store@0.6.0.1/src/hub_sha/sha256.bend as SHA
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes
1178def next.body.output.count(
1179 file: File,
1180 +size: Nat,
1181 header: Bytes.Bytes,
1182 +index_offset: Nat,
1183 +used: Nat,
1184 total: U32,
1185 block_count: U32,
1186 next_block: U32,
1187 decoded: U32,
1188 root_hash: SHA.Stream,
1189 index_hash: SHA.Stream,
1190 block_bytes: Bytes.Bytes,
1191 +payload_length: U32,
1192 entry_count: U32,
1193 entries: List<&1, ByteMemTable.Entry>,
1194 last_key: Maybe<&1, Bytes.Bytes>,
1195 valid: Bool,
1196 selected: Bool
1197) -> IO(Result<&1, &1, U32 & String, Step>):
1198 match valid:
1199 case False{}:
1200 close.failed(file, corruption("byte SST keys are not strictly ordered"))
1201 case True{}:
1202 +block_length = U32.add(40, payload_length)
1203 +checksum_offset = U32.add(8, payload_length)
1204 block_checksum = bytes.slice.result(Bytes.slice(block_bytes,
1205 checksum_offset, 32))
1206 +next_used = Nat.add(used, U32.to_nat(block_length))
1207 +next_decoded = U32.add(decoded, entry_count)
1208 +next_number = U32.add(next_block, 1)
1209 next.body.output.hashes(file, size, header, index_offset, next_used,
1210 total, block_count, next_number, next_decoded, last_key, entries,
1211 block_checksum, root_hash, index_hash, selected)