def seek.block.index.read

mylsm-lsm-store@0.6.0.1 · src/scan/ByteBlockReader.bend:593

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/Fs.bend as Fs
import mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend as SstStreamIo
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

593def seek.block.index.read(
594  file: File,
595  state: State,
596  index_offset: Nat,
597  indices: U32 & U32
598) -> IO(Result<&1, &1, U32 & String, Reader>):
599  match indices:
600    case (address_index, read_index):
601      do IO<Result<&1, &1, U32 & String, Reader>>:
602        pair : File & Result<&1, &1, U32 & String, Bytes.Bytes> <-
603          Fs.read_at(file, U32.from_nat(Nat.add(index_offset,
604            Nat.add(8n, Nat.mul(U32.to_nat(address_index), 16n)))), 8)
605        exact : File & Result<&1, &1, U32 & String, SstStreamIo.ExactResult> =
606          read_at.exact.pair(8, pair)
607        seek.block.read(state, read_index, SstStreamIo.read.exact.state(exact))

Uses (21)

Used by (1)