src/Store.bend fails
raw source on the hub · import ber-core-store@0.1.2.0/src/Store.bend as Store
4 imports
import Base import mylsm-lsm-store@0.3.2.0/mylsm.bend as MyLsmStore import mylsm-lsm-store@0.3.2.0/src/Db.bend as DbTypes import mylsm-lsm-store@0.3.2.0/src/Wal.bend as WalTypes
Types
type Journal source · line 21 · raw
Data
Journal rope: O(1) per-bind combination (no calls, just nesting); flattened once at flush with an explicit work stack (constant native stack) into chronological order. Reads build Empty spines that flatten to Nil.
JEmptyJournal
JOne@mut:0x9b667819f2297aa52572c1e6523fa301/src/Wal.Mut -> Journal
JMore@prior:Journal -> @post:Journal -> Journal
type Op source · line 60 · raw
@-a:Quant -> @-A:Kind(a) -> Kind(a <&> &1)
One session step chain: a Db transition answering with its journal.
Op@-a:Quant -> @-A:Kind(a) -> @run:(@_:0x9b667819f2297aa52572c1e6523fa301/src/Db.Db -> Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, A), Journal)) -> Op<a, A>
type Handle source · line 64 · raw
Type
An opened store handle; affine, threaded through run_op.
Handle@db:0x9b667819f2297aa52572c1e6523fa301/src/Db.Db -> Handle
Definitions
def rope_nodes source · line 27 · raw
@+journal:Journal -> Nat
Counts rope nodes structurally; the work loop below visits each once.
def flatten_go source · line 38 · raw
@fuel:Nat -> @+work:List<&2, Journal> -> @+acc:List<&2, 0x9b667819f2297aa52572c1e6523fa301/src/Wal.Mut> -> List<&2, 0x9b667819f2297aa52572c1e6523fa301/src/Wal.Mut>
Flattens a rope oldest-first with an explicit work stack; the accumulator holds the reversed prefix. Fuel covers nodes plus the final empty check.
def flatten_journal source · line 56 · raw
@+journal:Journal -> List<&2, 0x9b667819f2297aa52572c1e6523fa301/src/Wal.Mut>
Materializes a journal rope into its chronological mutation list.
def Op.inner source · line 68 · raw
@-b:Quant -> @-B:Kind(b) -> @op:Op<b, B> -> @_:0x9b667819f2297aa52572c1e6523fa301/src/Db.Db -> Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, B), Journal)
Unwraps the inner transition for translators like bind and run_op.
def Op.pure source · line 74 · raw
@-a:Quant -> @-A:Kind(a) -> @val:A -> Op<a, A>
Lifts a pure value with an empty journal.
def Op.seq2 source · line 78 · raw
@-a:Quant -> @-B:Kind(a) -> @+prior:Journal -> @second:Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, B), Journal) -> Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, B), Journal)
Concatenates a prior journal before a later one, finishing the second step.
def Op.seq source · line 84 · raw
@-a:Quant -> @-A:Kind(a) -> @-B:Kind(a) -> @first:Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, A), Journal) -> @fun:(@_:A -> Op<a, B>) -> Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, B), Journal)
Runs the next op on the first answer, threading Db and journal.
def Op.bind source · line 90 · raw
@-a:Quant -> @-A:Kind(a) -> @-B:Kind(a) -> @op:Op<a, A> -> @fun:(@_:A -> Op<a, B>) -> Op<a, B>
Sequences two ops, concatenating journals in execution order.
def pair_put source · line 96 · raw
@+key:String -> @+val:String -> @db_next:0x9b667819f2297aa52572c1e6523fa301/src/Db.Db -> Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, Unit), Journal)
Pairs a finished point write with its journaled mutation.
def oput source · line 100 · raw
@+key:String -> @+val:String -> Op<&2, Unit>
Writes one key and journals the mutation.
def pair_get source · line 104 · raw
@finished:Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, Maybe<&2, String>) -> Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, Maybe<&2, String>), Journal)
Pairs a finished point read with an empty journal.
def oget source · line 110 · raw
@+key:String -> Op<&2, Maybe<&2, String>>
Reads one key; missing reads as None. Reads journal nothing.
def pair_del source · line 114 · raw
@+key:String -> @db_next:0x9b667819f2297aa52572c1e6523fa301/src/Db.Db -> Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, Unit), Journal)
Pairs a finished point delete with its journaled mutation.
def odel source · line 118 · raw
@+key:String -> Op<&2, Unit>
Deletes one key and journals the mutation.
def open_store source · line 122 · raw
@+dir:String -> Handle
Opens a store handle over a directory label (pure; no IO touched).
def open_default_store source · line 126 · raw
Handle
Default store label for CLI use (pure; no IO touched).
def wrap_reopened source · line 130 · raw
@reopened:Result<&1, &1, Pair(U32, String), 0x9b667819f2297aa52572c1e6523fa301/src/Db.Db> -> Result<&1, &1, Pair(U32, String), Handle>
Wraps a reopened database; IO errors propagate as Fail.
def open_durable source · line 139 · raw
@+dir:String -> IO(Result<&1, &1, Pair(U32, String), Handle>)
Opens a durable handle, replaying wal.log when present; missing file answers empty. The caller ensures the directory exists.
def tracked_journal source · line 145 · raw
@-a:Quant -> @-A:Kind(a) -> @tracked:Pair(Pair(Handle, A), Journal) -> List<&2, 0x9b667819f2297aa52572c1e6523fa301/src/Wal.Mut>
Projects the materialized journal out of a tracked run (laws observe this).
def rewrap_pair source · line 151 · raw
@-a:Quant -> @-A:Kind(a) -> @computed:Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, A), Journal) -> Pair(Handle, A)
Rewraps a computed runner pair into Handle form, dropping the journal.
def run_op source · line 157 · raw
@-a:Quant -> @-A:Kind(a) -> @store:Handle -> @op:Op<a, A> -> Pair(Handle, A)
Executes a whole op chain against a handle (pure; journal dropped).
def rewrap_tracked source · line 163 · raw
@-a:Quant -> @-A:Kind(a) -> @computed:Pair(Pair(0x9b667819f2297aa52572c1e6523fa301/src/Db.Db, A), Journal) -> Pair(Pair(Handle, A), Journal)
Rewraps a tracked runner pair, keeping the journal.
def run_op_tracked source · line 169 · raw
@-a:Quant -> @-A:Kind(a) -> @store:Handle -> @op:Op<a, A> -> Pair(Pair(Handle, A), Journal)
Executes a whole op chain, exposing the journal for the WAL runner.
def wrap_written source · line 175 · raw
@-a:Quant -> @-A:Kind(a) -> @written:Result<&1, &1, Pair(U32, String), 0x9b667819f2297aa52572c1e6523fa301/src/Db.Db> -> @answer:A -> Result<&1, &1, Pair(U32, String), Pair(Handle, A)>
Wraps a written database with its answer; IO errors propagate as Fail.
def flush_clean source · line 183 · raw
@-a:Quant -> @-A:Kind(a) -> @store_next:Handle -> @answer:A -> IO(Result<&1, &1, Pair(U32, String), Pair(Handle, A)>)
Skips the WAL when the journal is empty (pure reads never fsync).
def flush_dirty source · line 189 · raw
@-a:Quant -> @-A:Kind(a) -> @store_next:Handle -> @answer:A -> @+head_mut:0x9b667819f2297aa52572c1e6523fa301/src/Wal.Mut -> @+tail_muts:List<&2, 0x9b667819f2297aa52572c1e6523fa301/src/Wal.Mut> -> IO(Result<&1, &1, Pair(U32, String), Pair(Handle, A)>)
Flushes a nonempty journal through one WAL frame plus fsync.
def flush_list source · line 197 · raw
@-a:Quant -> @-A:Kind(a) -> @store_next:Handle -> @answer:A -> @+mutations:List<&2, 0x9b667819f2297aa52572c1e6523fa301/src/Wal.Mut> -> IO(Result<&1, &1, Pair(U32, String), Pair(Handle, A)>)
Dispatches on journal emptiness without matching computed values.
def flush_tracked source · line 205 · raw
@-a:Quant -> @-A:Kind(a) -> @tracked:Pair(Pair(Handle, A), Journal) -> IO(Result<&1, &1, Pair(U32, String), Pair(Handle, A)>)
Splits a tracked runner pair for the flush dispatch.
def run_op_durable source · line 212 · raw
@-a:Quant -> @-A:Kind(a) -> @store:Handle -> @op:Op<a, A> -> IO(Result<&1, &1, Pair(U32, String), Pair(Handle, A)>)
Executes a whole op chain durably: pure run, then one WAL append plus fsync of exactly the journaled mutations.