src/ByteMemTable.bend checks
raw source on the hub · import mylsm-lsm-store@0.6.0.0/src/ByteMemTable.bend as ByteMemTable
3 imports
import Base import ./Keys.bend as Keys import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes
Types
type Entry source · line 6 · raw
Type
Affine byte key and value pair stored newest-first.
Entry@key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @val:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Entry
type Table source · line 10 · raw
Type
Owns the complete newest-first mutation log.
Table@entries:List<&1, Entry> -> Table
type Lookup source · line 14 · raw
Type
Carries rebuilt table ownership alongside an optional cloned value.
Lookup@entries:List<&1, Entry> -> @value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @found:Bool -> Lookup
type Probe source · line 18 · raw
Type
Distinguishes no delta mutation, a tombstone, and a live delta value.
AbsentProbe
DeletedProbe
Present@value:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Probe
type LengthProbe source · line 24 · raw
Data
Carries the state for LengthProbe.
LengthAbsentLengthProbe
LengthDeletedLengthProbe
LengthPresent@value_bytes:U32 -> LengthProbe
type LengthLookup source · line 30 · raw
Type
Carries the state for LengthLookup.
LengthLookup@entries:List<&1, Entry> -> @result:LengthProbe -> @found:Bool -> LengthLookup
type LengthSearch source · line 34 · raw
Type
Carries the state for LengthSearch.
LengthSearch@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @entries:List<&1, Entry> -> @prefix:List<&1, Entry> -> @order:Cmp -> LengthSearch
type Search source · line 39 · raw
Type
Carries affine search state across lexicographic comparisons.
Search@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @entries:List<&1, Entry> -> @prefix:List<&1, Entry> -> @order:Cmp -> Search
type OrderedMergeState source · line 43 · raw
Type
Carries the pending entry through a unique-key insertion into sorted entries.
OrderedMergeState@newer:List<&1, Entry> -> @older:List<&1, Entry> -> @reversed:List<&1, Entry> -> OrderedMergeState
Definitions
def empty source · line 47 · raw
Table
Creates a byte table with no mutations.
def put source · line 51 · raw
@table:Table -> @key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @value:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Table
Prepends a byte value mutation without decoding either buffer.
def del source · line 57 · raw
@table:Table -> @key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Table
Prepends a tombstone for an arbitrary byte key.
def count.go source · line 63 · raw
@entries:List<&1, Entry> -> @total:Nat -> Nat
Counts each owned mutation in a byte table.
def count source · line 71 · raw
@table:Table -> Nat
Returns the number of mutations, including tombstones.
def count.keep.go source · line 77 · raw
@entries:List<&1, Entry> -> @reversed:List<&1, Entry> -> @total:Nat -> Pair(List<&1, Entry>, Nat)
Counts entries while preserving the list for a subsequent lookup.
def count.keep source · line 89 · raw
@entries:List<&1, Entry> -> Pair(List<&1, Entry>, Nat)
Returns both the original entry order and its size.
def bytes.clone.pair source · line 93 · raw
@+len:U32 -> @copied:Pair(Array<U32>, Array<U32>) -> Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes)
Reifies the two independently owned buffers returned by the copy effect.
def bytes.clone source · line 99 · raw
@bytes:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes)
Duplicates a byte buffer only when ownership must be retained by the table.
def value.clone.pair source · line 105 · raw
@pair:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> Pair(Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>, Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>)
Wraps the original and copied buffers as independent optional values.
def value.clone source · line 111 · raw
@value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Pair(Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>, Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>)
Clones only a present value while preserving absence.
def entry.clone.fields source · line 119 · raw
@keys:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @values:Pair(Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>, Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>) -> Pair(Entry, Entry)
Rebuilds two independently owned entries from cloned fields.
def entry.clone source · line 130 · raw
@entry:Entry -> Pair(Entry, Entry)
Clones both buffers and the optional value in one entry.
def entry.key.copy.pair source · line 135 · raw
@copies:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Pair(Entry, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes)
def entry.key.copy source · line 142 · raw
@entry:Entry -> Pair(Entry, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes)
def entry.live.keep source · line 147 · raw
@entry:Entry -> Pair(Entry, Bool)
def entry.live.matches source · line 154 · raw
@pair:Pair(Entry, Bool) -> Bool
def entries.clone.push source · line 161 · raw
@head:Pair(Entry, Entry) -> @tail:Pair(List<&1, Entry>, List<&1, Entry>) -> Pair(List<&1, Entry>, List<&1, Entry>)
Prepends cloned heads to the corresponding entry lists.
def entries.clone source · line 172 · raw
@entries:List<&1, Entry> -> Pair(List<&1, Entry>, List<&1, Entry>)
Clones an affine entry list while preserving its order.
def append source · line 179 · raw
@left:List<&1, Entry> -> @right:List<&1, Entry> -> List<&1, Entry>
Appends the remaining search suffix after the reversed visited prefix.
def lookup.result source · line 186 · raw
@prefix:List<&1, Entry> -> @remaining:List<&1, Entry> -> @value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @found:Bool -> Lookup
def lookup.hit source · line 195 · raw
@prefix:List<&1, Entry> -> @key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @tail:List<&1, Entry> -> @copies:Pair(Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>, Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>) -> Lookup
Restores a found entry and preserves its value for the caller.
def lookup.hit.value source · line 206 · raw
@value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @prefix:List<&1, Entry> -> @key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @tail:List<&1, Entry> -> Lookup
Clones a found value so the table remains readable after the lookup.
def lookup.state source · line 219 · raw
@prefix:List<&1, Entry> -> @value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @tail:List<&1, Entry> -> @comparison:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Cmp)) -> Search
Associates comparison output with the entry that produced it.
def lookup.advance.state source · line 230 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @tail:List<&1, Entry> -> @prefix:List<&1, Entry> -> Search
Advances the affine scan while retaining the prior entry in its prefix.
def lookup.go source · line 245 · raw
@fuel:Nat -> @state:Search -> Lookup
Searches newest-first entries under a structural recursion bound.
def lookup.start.table source · line 267 · raw
@result:Lookup -> Pair(Table, Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>)
Restores the table and surfaces the optional lookup value.
def lookup.start.probe.value source · line 272 · raw
@table:Table -> @value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @found:Bool -> Pair(Table, Probe)
def lookup.start.probe source · line 283 · raw
@result:Lookup -> Pair(Table, Probe)
def lookup.start.counted.lookup source · line 288 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @entries:List<&1, Entry> -> @count:Nat -> Lookup
def lookup.start.counted source · line 300 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @entries:List<&1, Entry> -> @count:Nat -> Pair(Table, Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>)
Starts a lookup with a bound computed from the list length.
def lookup.start.counted.probe source · line 307 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @entries:List<&1, Entry> -> @count:Nat -> Pair(Table, Probe)
def lookup.start.counted.pair source · line 315 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @counted:Pair(List<&1, Entry>, Nat) -> Pair(Table, Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>)
Unpacks the preserved list and count before scanning.
def lookup.start source · line 321 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @entries:List<&1, Entry> -> Pair(Table, Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>)
Counts and scans a table while preserving its ownership.
def lookup.start.probe.pair source · line 324 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @counted:Pair(List<&1, Entry>, Nat) -> Pair(Table, Probe)
def probe source · line 332 · raw
@table:Table -> @query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Pair(Table, Probe)
Looks up a key while preserving whether the newest delta mutation exists.
def lookup.length.result source · line 337 · raw
@prefix:List<&1, Entry> -> @remaining:List<&1, Entry> -> @result:LengthProbe -> @found:Bool -> LengthLookup
def lookup.length.hit source · line 346 · raw
@prefix:List<&1, Entry> -> @key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @tail:List<&1, Entry> -> @val:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> LengthLookup
def lookup.length.state source · line 361 · raw
@prefix:List<&1, Entry> -> @val:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @tail:List<&1, Entry> -> @comparison:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Cmp)) -> LengthSearch
def lookup.length.advance source · line 371 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @val:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @tail:List<&1, Entry> -> @prefix:List<&1, Entry> -> LengthSearch
def lookup.length.go source · line 385 · raw
@fuel:Nat -> @state:LengthSearch -> LengthLookup
def lookup.length.output source · line 407 · raw
@result:LengthLookup -> Pair(Table, LengthProbe)
def lookup.length.start source · line 411 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @entries:List<&1, Entry> -> @count:Nat -> Pair(Table, LengthProbe)
def lookup.length.start.counted source · line 423 · raw
@query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @counted:Pair(List<&1, Entry>, Nat) -> Pair(Table, LengthProbe)
def probe.length source · line 430 · raw
@table:Table -> @query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Pair(Table, LengthProbe)
def get source · line 436 · raw
@table:Table -> @query:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Pair(Table, Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>)
Reads a byte key and returns the still-owned table with the result.
def payload.value source · line 442 · raw
@value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Nat
Measures a value by its exact encoded byte length.
def payload.go source · line 450 · raw
@entries:List<&1, Entry> -> @total:Nat -> Nat
Sums key and present-value byte lengths over the mutation log.
def payload_bytes source · line 458 · raw
@table:Table -> Nat
Returns exact key/value payload bytes, excluding structural overhead.
def retained.go source · line 464 · raw
@entries:List<&1, Entry> -> @total:Nat -> Nat
Adds a fixed per-entry estimate to encoded payload bytes for retention limits.
def retained_bytes source · line 472 · raw
@table:Table -> Nat
Estimates packed payload and entry metadata retained by a snapshot copy.
def retained_bytes.keep.go source · line 477 · raw
@entries:List<&1, Entry> -> @reversed:List<&1, Entry> -> @total:Nat -> Pair(List<&1, Entry>, Nat)
def retained_bytes.keep.finish source · line 500 · raw
@pair:Pair(List<&1, Entry>, Nat) -> Pair(Table, Nat)
def retained_bytes.keep source · line 504 · raw
@table:Table -> Pair(Table, Nat)
def compact.live source · line 510 · raw
@entries:List<&1, Entry> -> List<&1, Entry>
Drops tombstones after all older byte runs have been folded into one table.
def ordered.strict.order source · line 520 · raw
@comparison:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Cmp)) -> Bool
Accepts only a strict ascending comparison for neighboring ordered keys.
def ordered.merge.take_newer source · line 527 · raw
@order:Cmp -> Bool
def ordered.strict.go source · line 534 · raw
@fuel:Nat -> @entries:List<&1, Entry> -> Bool
Checks strict key order with fuel derived from the number of entries.
def ordered.strict.counted source · line 549 · raw
@measured:Pair(List<&1, Entry>, Nat) -> Bool
Unpacks an ordered list and its preserved recursion bound.
def ordered.strict source · line 555 · raw
@entries:List<&1, Entry> -> Bool
Checks that a sorted entry list is strictly increasing by byte key.
def ordered.merge.decisions source · line 558 · raw
@+order:Cmp -> Pair(Bool, Bool)
def ordered.merge.resolve source · line 561 · raw
@decisions:Pair(Bool, Bool) -> @newer:List<&1, Entry> -> @older:List<&1, Entry> -> @reversed:List<&1, Entry> -> @newer_key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @newer_value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @older_key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @older_value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> OrderedMergeState
def ordered.merge.compared source · line 588 · raw
@state:OrderedMergeState -> @newer_value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @older_value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @retained_keys:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @comparison:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Cmp)) -> OrderedMergeState
def ordered.merge.cloned source · line 604 · raw
@state:OrderedMergeState -> @newer_value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @older_value:Maybe<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @copies:Pair(Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes), Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes)) -> OrderedMergeState
def ordered.merge.compare source · line 615 · raw
@state:OrderedMergeState -> @newer:Entry -> @older:Entry -> OrderedMergeState
def ordered.merge.finish source · line 625 · raw
@state:OrderedMergeState -> List<&1, Entry>
def ordered.merge.go source · line 630 · raw
@fuel:Nat -> @state:OrderedMergeState -> List<&1, Entry>
def ordered.merge.counted source · line 644 · raw
@newer:Pair(List<&1, Entry>, Nat) -> @older:Pair(List<&1, Entry>, Nat) -> List<&1, Entry>
def ordered.merge_newer source · line 655 · raw
@newer:List<&1, Entry> -> @older:List<&1, Entry> -> List<&1, Entry>
def ordered.singleton_runs source · line 658 · raw
@entries:List<&1, Entry> -> List<&1, List<&1, Entry>>
def ordered.merge_round source · line 664 · raw
@runs:List<&1, List<&1, Entry>> -> List<&1, List<&1, Entry>>
def ordered.merge_many.go source · line 671 · raw
@fuel:Nat -> @runs:List<&1, List<&1, Entry>> -> List<&1, Entry>
def ordered.materialize.measured source · line 685 · raw
@measured:Pair(List<&1, Entry>, Nat) -> List<&1, Entry>
def ordered_entries source · line 692 · raw
@table:Table -> List<&1, Entry>
Produces strict byte-ordered unique entries with newest mutations winning.