def seek_key_after_validation

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

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/scan/BlockRoutePolicy.bend as BlockRoutePolicy
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

921# Routes a lower key to the last block whose separator does not exceed it.
922def seek_key_after_validation(
923  reader: Reader,
924  key: Bytes.Bytes
925) -> IO(Result<&1, &1, U32 & String, Reader>):
926  match reader:
927    case Reader{file, state}:
928      match state:
929        case State{+size, header, +index_offset, used, total,
930            +block_count, next_block, decoded, root_hash, index_hash,
931            last_key, selected}:
932          +count = U32.to_nat(block_count)
933          +fuel = Nat.add(Nat.mul(8n, count), 8n)
934          context : RouteContext = RouteContext{size, index_offset, count}
935          retained_state : State = State{size, header, index_offset, used, total, block_count,
936            next_block, decoded, root_hash, index_hash, last_key, selected}
937          route.loop(fuel, RouteNeed{file, retained_state, context, key,
938            BlockRoutePolicy.Search{0n, count, 0n}})

Uses (15)

Used by (2)