def pick_ix

mylsm-lsm-store@0.3.2.0 · src/Sstable.bend:468

import mylsm-lsm-store@0.3.2.0/src/Sstable.bend as Sstable
import Base
import mylsm-lsm-store@0.3.2.0/src/Keys.bend as Keys
import mylsm-lsm-store@0.3.2.0/src/MemTable.bend as MemTable

468# Block-scoped lookup. Checker constraints (proven by scratch experiments):
469# multi-scrutinee matches follow declaration order, and only Nat answers flow
470# through match arms — so selection returns an index, picked up by chunk_at_go.
471def pick_ix(bt: List<&2, String>, ct: List<&2, List<&2, MemTable.Entry>>, ix: Nat, +key: String, order: Cmp) -> Nat:
472  match bt ct order:
473    case _ _ GT{}:
474      Nat.sub(ix, 1n)
475    case Nil{} _ _:
476      ix
477    case _ Nil{} _:
478      ix
479    case Con{b2, bt2} Con{d2, ct2} LT{}:
480      pick_ix(bt2, ct2, Nat.add(ix, 1n), key, Keys.cmp(b2, key))
481    case Con{b2, bt2} Con{d2, ct2} EQ{}:
482      ix

Uses (8)

Used by (1)