def route.record.words
mylsm-lsm-store@0.6.0.1 · src/scan/ByteBlockReader.bend:757
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/StorageBytes.bend as StorageBytes
import mylsm-lsm-store@0.6.0.1/src/scan/BlockIndexFormatPolicy.bend as BlockIndexFormatPolicy
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
757def route.record.words(
758 file: File,
759 state: State,
760 context: RouteContext,
761 key: Bytes.Bytes,
762 search: BlockRoutePolicy.Search,
763 mid: Nat,
764 words: Maybe<&2, U32> & Maybe<&2, U32>
765) -> RouteState:
766 match context:
767 case RouteContext{+size, +index_offset, +block_count}:
768 match words:
769 case (Some{+offset}, Some{+length}):
770 +index_length = Nat.sub(size, Nat.add(index_offset, 44n))
771 +fixed_bytes = Nat.add(8n, Nat.mul(block_count, 16n))
772 +region_length = Nat.sub(index_length, fixed_bytes)
773 +separator_start = Nat.add(index_offset, fixed_bytes)
774 route.record.bounds(file, state, context, key, search, mid,
775 offset, length, separator_start,
776 BlockIndexFormatPolicy.separator_valid(U32.to_nat(offset),
777 U32.to_nat(length), region_length) &&
778 U32.is_le(length, StorageBytes.MAX_BLOCK_BYTES()))
779 case _:
780 RouteFailed{file, corruption("byte SST separator fields are missing")}