~/bend-docscommunity

mylsm.bend relies on unsafe/foreign

raw source on the hub · import mylsm-lsm-store@0.5.0.0/mylsm.bend as Mylsm

15 imports
import Base
import ./src/Keys.bend as Keys
import ./src/MemTable.bend as MemTable
import ./src/SortedRun.bend as SortedRun
import ./src/Sstable.bend as Sstable
import ./src/SstFile.bend as SstFile
import ./src/Wal.bend as Wal
import ./src/Manifest.bend as Manifest
import ./src/MergeIter.bend as MergeIter
import ./src/Db.bend as Db
import ./src/Recover.bend as Recover
import ./src/DurableDb.bend as DurableDb
import ./src/DurableError.bend as DurableError
import ./src/DurableDbPolicy.bend as DurableDbPolicy
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

Types

type InMemory.Session source · line 17 · raw

@-a:Quant -> @-A:Kind(a) -> Kind(a <&> &1)

type ErrorKind source · line 157 · raw

Data

Lists the error categories exposed by the durable API.

type Error source · line 169 · raw

Data

Carries structured error details for API callers.

type Handle source · line 173 · raw

Type

Owns the database and its process lock.

type SessionError source · line 177 · raw

Data

Carries failures from scoped session execution.

type Session source · line 184 · raw

@-a:Quant -> @-A:Kind(a) -> Kind(a <&> &1)

Holds durable operations that thread one owned handle.

type DurableStats source · line 188 · raw

Data

Reports database size, cache use, errors, and maintenance state.

type MaintenanceStatus source · line 192 · raw

Data

Reports whether post-commit maintenance completed.

type WriteOutcome source · line 197 · raw

Data

Reports maintenance status for a confirmed write.

type Mutation source · line 201 · raw

Data

Describes a public key/value update or deletion.

Definitions

def cmp source · line 21 · raw

@+s1:String -> @+s2:String -> Cmp

--- Level 2: part control (1:1 delegates) ---

def eq source · line 25 · raw

@+s1:String -> @+s2:String -> Bool

Key equality: true exactly for identical strings.

def mem_empty source · line 29 · raw

0x4fcd94fa965aa1443134557fd075a483/src/MemTable.MemTable

Empty MemTable: no entries, count zero.

def mem_put source · line 33 · raw

@tab:0x4fcd94fa965aa1443134557fd075a483/src/MemTable.MemTable -> @key:String -> @val:String -> 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.MemTable

MemTable with one live version prepended (newest-first log).

def mem_del source · line 37 · raw

@tab:0x4fcd94fa965aa1443134557fd075a483/src/MemTable.MemTable -> @key:String -> 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.MemTable

MemTable with one tombstone prepended; hides older versions on read.

def mem_get source · line 41 · raw

@tab:0x4fcd94fa965aa1443134557fd075a483/src/MemTable.MemTable -> @+key:String -> Maybe<&2, String>

Newest-first read; a tombstone answers None and hides older versions.

def mem_count source · line 45 · raw

@tab:0x4fcd94fa965aa1443134557fd075a483/src/MemTable.MemTable -> Nat

Number of log entries, live and tombstoned.

def sort_newest source · line 49 · raw

@entries:List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.Entry> -> List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.Entry>

Canonicalize newest-first entries into a strict ordered run.

def range_scan source · line 53 · raw

@+merged:List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.Entry> -> @lo:String -> @hi:String -> List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.Entry>

Range scan over a merged run: lo <= key < hi, tombstones dropped.

def sst_build source · line 57 · raw

@+entries:List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.Entry> -> @level:Nat -> @est_keys:Nat -> 0x4fcd94fa965aa1443134557fd075a483/src/Sstable.Table

Build an SSTable, canonicalizing entries newest-first.

def sst_from_sorted_unique source · line 61 · raw

@+entries:List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.Entry> -> @level:Nat -> 0x4fcd94fa965aa1443134557fd075a483/src/Sstable.Table

Build an SSTable trusting an already strict, unique run (no sorting).

def sst_build_sorted source · line 65 · raw

@+entries:List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.Entry> -> @level:Nat -> @est_keys:Nat -> 0x4fcd94fa965aa1443134557fd075a483/src/Sstable.Table

Build an SSTable from a sorted run with an explicit key estimate.

def wal_encode source · line 69 · raw

@batch:0x4fcd94fa965aa1443134557fd075a483/src/Wal.Batch -> Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/Wal.Error, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>

Handle wal encode in the public module exports.

def wal_decode source · line 73 · raw

@encoded:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/Wal.Error, 0x4fcd94fa965aa1443134557fd075a483/src/Wal.Batch>

Handle wal decode in the public module exports.

def sst_encode source · line 77 · raw

@+entries:List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/MemTable.Entry> -> @+level:U32 -> Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/SstFile.Error, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>

Encode an SST as packed v3 bytes.

def sst_parse source · line 84 · raw

@encoded:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/SstFile.Error, 0x4fcd94fa965aa1443134557fd075a483/src/Sstable.Table>

Parse packed v3 bytes with strict bounds and checksum verification.

def mfst_serialize source · line 90 · raw

@mfst:0x4fcd94fa965aa1443134557fd075a483/src/Manifest.Manifest -> Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/Manifest.Error, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>

Serialize a Manifest to its exact on-disk bytes.

def mfst_parse source · line 94 · raw

@encoded:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Maybe<&2, 0x4fcd94fa965aa1443134557fd075a483/src/Manifest.Manifest>

Handle mfst parse in the public module exports.

def InMemory.Session.pure source · line 97 · raw

@-a:Quant -> @-A:Kind(a) -> @value:A -> InMemory.Session<a, A>

def InMemory.Session.run source · line 100 · raw

@-a:Quant -> @-A:Kind(a) -> @session:InMemory.Session<a, A> -> @database:0x4fcd94fa965aa1443134557fd075a483/src/Db.Db -> Pair(0x4fcd94fa965aa1443134557fd075a483/src/Db.Db, A)

def InMemory.Session.apply source · line 104 · raw

@-a:Quant -> @-A:Kind(a) -> @-b:Quant -> @-B:Kind(b) -> @pair:Pair(0x4fcd94fa965aa1443134557fd075a483/src/Db.Db, A) -> @next:(@_:A -> InMemory.Session<b, B>) -> Pair(0x4fcd94fa965aa1443134557fd075a483/src/Db.Db, B)

def InMemory.Session.bind source · line 108 · raw

@-a:Quant -> @-A:Kind(a) -> @-B:Kind(a) -> @session:InMemory.Session<a, A> -> @next:(@_:A -> InMemory.Session<a, B>) -> InMemory.Session<a, B>

def InMemory.open source · line 111 · raw

@+path:String -> 0x4fcd94fa965aa1443134557fd075a483/src/Db.Db

def InMemory.put_database source · line 114 · raw

@+database:0x4fcd94fa965aa1443134557fd075a483/src/Db.Db -> @+key:String -> @+value:String -> 0x4fcd94fa965aa1443134557fd075a483/src/Db.Db

def InMemory.delete_database source · line 119 · raw

@+database:0x4fcd94fa965aa1443134557fd075a483/src/Db.Db -> @+key:String -> 0x4fcd94fa965aa1443134557fd075a483/src/Db.Db

def InMemory.write_database_batch source · line 124 · raw

@+database:0x4fcd94fa965aa1443134557fd075a483/src/Db.Db -> @+mutations:List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/Wal.Mut> -> 0x4fcd94fa965aa1443134557fd075a483/src/Db.Db

def InMemory.read_database source · line 129 · raw

@+database:0x4fcd94fa965aa1443134557fd075a483/src/Db.Db -> @+key:String -> Pair(0x4fcd94fa965aa1443134557fd075a483/src/Db.Db, Maybe<&2, String>)

def InMemory.Session.put source · line 132 · raw

@+key:String -> @+value:String -> InMemory.Session<&2, Unit>

def InMemory.Session.delete source · line 135 · raw

@+key:String -> InMemory.Session<&2, Unit>

def InMemory.Session.write_batch source · line 138 · raw

@+mutations:List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/Wal.Mut> -> InMemory.Session<&2, Unit>

def InMemory.Session.get source · line 141 · raw

@+key:String -> InMemory.Session<&2, Maybe<&2, String>>

def InMemory.run_session source · line 144 · raw

@-a:Quant -> @-A:Kind(a) -> @database:0x4fcd94fa965aa1443134557fd075a483/src/Db.Db -> @session:InMemory.Session<a, A> -> Pair(0x4fcd94fa965aa1443134557fd075a483/src/Db.Db, A)

def InMemory.value_of source · line 147 · raw

@-a:Quant -> @-A:Kind(a) -> @pair:Pair(0x4fcd94fa965aa1443134557fd075a483/src/Db.Db, A) -> A

def open_recovering source · line 152 · raw

@+dir:String -> IO(Result<&1, &1, Pair(U32, String), 0x4fcd94fa965aa1443134557fd075a483/src/Db.Db>)

Recover a persisted database from its directory.

def to_storage_mut source · line 206 · raw

@mutation:Mutation -> 0x4fcd94fa965aa1443134557fd075a483/src/Wal.Mut

Converts a public mutation to the WAL representation.

def to_storage_muts source · line 212 · raw

@+mutations:List<&2, Mutation> -> List<&2, 0x4fcd94fa965aa1443134557fd075a483/src/Wal.Mut>

Converts each public mutation to its WAL representation.

def public_error_kind source · line 218 · raw

@kind:0x4fcd94fa965aa1443134557fd075a483/src/DurableError.ErrorKind -> ErrorKind

Maps internal error categories to the public error kind.

def public_error source · line 231 · raw

@error:0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error -> Error

Builds the public error while preserving its structured details.

def public_error_result source · line 237 · raw

@result:Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Unit> -> Result<&1, &1, Error, Unit>

Converts an internal result to the public error type.

def public_open_result source · line 243 · raw

@result:Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, 0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.Handle> -> Result<&1, &1, Error, Handle>

Converts a durable open result to the public handle.

def create source · line 249 · raw

@+dir:String -> IO(Result<&1, &1, Error, Handle>)

Creates a database and returns its owned durable handle.

def open_existing source · line 255 · raw

@+dir:String -> IO(Result<&1, &1, Error, Handle>)

Opens and recovers an existing database under its lock.

def public_maybe_result source · line 261 · raw

@result:Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Maybe<&2, String>> -> Result<&1, &1, Error, Maybe<&2, String>>

Converts an optional stored value and its error.

def durable_get_result source · line 269 · raw

@pair:Pair(0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.Handle, Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Maybe<&2, String>>) -> Pair(Handle, Result<&1, &1, Error, Maybe<&2, String>>)

Converts a durable read result to the public value type.

def get source · line 276 · raw

@handle:Handle -> @+key:String -> IO(Pair(Handle, Result<&1, &1, Error, Maybe<&2, String>>))

Reads a key from the owned durable database handle.

def public_maintenance source · line 284 · raw

@maintenance:0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.Maintenance -> MaintenanceStatus

Maps internal maintenance state to its public status.

def public_write_result source · line 290 · raw

@result:Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, 0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.WriteOutcome> -> Result<&1, &1, Error, WriteOutcome>

Converts a confirmed write outcome to the public type.

def durable_write_result source · line 298 · raw

@pair:Pair(0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.Handle, Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Unit>) -> Pair(Handle, Result<&1, &1, Error, Unit>)

Preserves maintenance status while converting write errors.

def durable_batch_result source · line 305 · raw

@pair:Pair(0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.Handle, Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, 0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.WriteOutcome>) -> Pair(Handle, Result<&1, &1, Error, WriteOutcome>)

Converts a batch outcome while preserving handle ownership.

def write_batch source · line 312 · raw

@handle:Handle -> @mutations:List<&2, Mutation> -> IO(Pair(Handle, Result<&1, &1, Error, WriteOutcome>))

Validates and commits a public mutation batch atomically.

def put source · line 320 · raw

@handle:Handle -> @+key:String -> @+value:String -> IO(Pair(Handle, Result<&1, &1, Error, WriteOutcome>))

Writes one key and value through the durable handle.

def delete source · line 328 · raw

@handle:Handle -> @+key:String -> IO(Pair(Handle, Result<&1, &1, Error, WriteOutcome>))

Deletes one key through the durable handle.

def flush source · line 336 · raw

@handle:Handle -> IO(Pair(Handle, Result<&1, &1, Error, Unit>))

Flushes the durable handle and returns maintenance status.

def compact source · line 344 · raw

@handle:Handle -> IO(Pair(Handle, Result<&1, &1, Error, Unit>))

Compacts the durable handle and returns maintenance status.

def public_stats source · line 352 · raw

@result:Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, 0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.Stats> -> Result<&1, &1, Error, DurableStats>

Maps internal counters to the public stats record.

def durable_stats_result source · line 361 · raw

@pair:Pair(0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.Handle, Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, 0x4fcd94fa965aa1443134557fd075a483/src/DurableDb.Stats>) -> Pair(Handle, Result<&1, &1, Error, DurableStats>)

Converts durable stats errors to the public error type.

def stats source · line 368 · raw

@handle:Handle -> IO(Pair(Handle, Result<&1, &1, Error, DurableStats>))

Reads bounded operational stats from the durable handle.

def close source · line 376 · raw

@handle:Handle -> IO(Result<&1, &1, Error, Unit>)

Closes the durable handle and releases its database lock.

def Session.pure source · line 383 · raw

@-a:Quant -> @-A:Kind(a) -> @value:A -> Session<a, A>

def Session.run source · line 386 · raw

@-a:Quant -> @-A:Kind(a) -> @session:Session<a, A> -> @handle:Handle -> IO(Pair(Handle, Result<&1, &1, Error, A>))

def Session.bind_result source · line 390 · raw

@-a:Quant -> @-A:Kind(a) -> @-B:Kind(a) -> @pair:Pair(Handle, Result<&1, &1, Error, A>) -> @next:(@_:A -> Session<a, B>) -> IO(Pair(Handle, Result<&1, &1, Error, B>))

def Session.bind source · line 397 · raw

@-a:Quant -> @-A:Kind(a) -> @-B:Kind(a) -> @session:Session<a, A> -> @next:(@_:A -> Session<a, B>) -> Session<a, B>

def Session.put source · line 404 · raw

@+key:String -> @+value:String -> Session<&2, WriteOutcome>

def Session.delete source · line 407 · raw

@+key:String -> Session<&2, WriteOutcome>

def Session.write_batch source · line 410 · raw

@mutations:List<&2, Mutation> -> Session<&2, WriteOutcome>

def Session.get source · line 413 · raw

@+key:String -> Session<&2, Maybe<&2, String>>

def Session.flush source · line 416 · raw

Session<&2, Unit>

def Session.compact source · line 419 · raw

Session<&2, Unit>

def Session.stats source · line 422 · raw

Session<&2, DurableStats>

def Session.finish_result source · line 425 · raw

@-a:Quant -> @-A:Kind(a) -> @result:Result<&1, &1, Error, A> -> @close_result:Result<&1, &1, Error, Unit> -> Result<&1, &1, SessionError, A>

def Session.finish source · line 433 · raw

@-a:Quant -> @-A:Kind(a) -> @handle:Handle -> @result:Result<&1, &1, Error, A> -> IO(Result<&1, &1, SessionError, A>)

def Session.finish_pair source · line 438 · raw

@-a:Quant -> @-A:Kind(a) -> @pair:Pair(Handle, Result<&1, &1, Error, A>) -> IO(Result<&1, &1, SessionError, A>)

def Session.run_opened source · line 442 · raw

@-a:Quant -> @-A:Kind(a) -> @opened:Result<&1, &1, Error, Handle> -> @session:Session<a, A> -> IO(Result<&1, &1, SessionError, A>)

def run_session source · line 452 · raw

@-a:Quant -> @-A:Kind(a) -> @handle:Handle -> @session:Session<a, A> -> IO(Pair(Handle, Result<&1, &1, Error, A>))

Runs a program and returns its still-owned handle.

def create_database source · line 456 · raw

@-a:Quant -> @-A:Kind(a) -> @+path:String -> @session:Session<a, A> -> IO(Result<&1, &1, SessionError, A>)

Creates, runs, and closes a scoped durable session.

def open_database source · line 462 · raw

@-a:Quant -> @-A:Kind(a) -> @+path:String -> @session:Session<a, A> -> IO(Result<&1, &1, SessionError, A>)

Opens, runs, and closes a scoped durable session.

def error_is_already_exists source · line 468 · raw

@error:Error -> Bool

Checks whether the public error means the path exists.

def error_is_busy source · line 474 · raw

@error:Error -> Bool

Checks whether the public error means the database is locked.