~/bend-docscommunity

src/ByteWalIo.bend relies on unsafe/foreign

raw source on the hub · import mylsm-lsm-store@0.6.0.1/src/ByteWalIo.bend as ByteWalIo

8 imports
import Base
import ./ByteMemTable.bend as ByteMemTable
import ./ByteWal.bend as ByteWal
import ./Fs.bend as Fs
import ./SstStreamIo.bend as SstStreamIo
import ./Wal.bend as Wal
import ./CrashPoint.bend as CrashPoint
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

Types

type RecoveryState source · line 11 · raw

Type

Tracks the owned file and bounded phase state during byte WAL replay.

Definitions

def corruption_error_code source · line 34 · raw

U32

Assigns the stable file-corruption category used by this reader.

def error source · line 38 · raw

@message:String -> Pair(U32, String)

Pairs a corruption category with its diagnostic text.

def u32.read source · line 41 · raw

@pair:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Cursor, Maybe<&2, U32>) -> Maybe<&2, U32>

def frame.length source · line 46 · raw

@bytes:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Maybe<&2, U32>

def frame.count source · line 49 · raw

@bytes:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Maybe<&2, U32>

def recover.at source · line 52 · raw

@file:File -> @+size:Nat -> @+offset:Nat -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> RecoveryState

def recover.prefix.next source · line 61 · raw

@file:File -> @+size:Nat -> @+offset:Nat -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> @prefix:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @parsed:Maybe<&2, U32> -> RecoveryState

def recover.prefix.cloned source · line 77 · raw

@file:File -> @pair:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @+size:Nat -> @+offset:Nat -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> RecoveryState

def recover.counted source · line 89 · raw

@file:File -> @+size:Nat -> @+offset:Nat -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> @prefix:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @count_bytes:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+frame_length:U32 -> @parsed:Maybe<&2, U32> -> RecoveryState

def recover.count.cloned source · line 106 · raw

@file:File -> @pair:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @+size:Nat -> @+offset:Nat -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> @prefix:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+frame_length:U32 -> RecoveryState

def apply.batch.loop source · line 120 · raw

@fuel:Nat -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> @mutations:List<&1, 0xdd46804cd6318755b753109f15ff3725/src/ByteWal.Mutation> -> 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table

def mutations.count.go source · line 137 · raw

@mutations:List<&1, 0xdd46804cd6318755b753109f15ff3725/src/ByteWal.Mutation> -> @reversed:List<&1, 0xdd46804cd6318755b753109f15ff3725/src/ByteWal.Mutation> -> @count:Nat -> Pair(List<&1, 0xdd46804cd6318755b753109f15ff3725/src/ByteWal.Mutation>, Nat)

def mutations.count source · line 148 · raw

@mutations:List<&1, 0xdd46804cd6318755b753109f15ff3725/src/ByteWal.Mutation> -> Pair(List<&1, 0xdd46804cd6318755b753109f15ff3725/src/ByteWal.Mutation>, Nat)

def apply.batch.counted source · line 151 · raw

@table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> @pair:Pair(List<&1, 0xdd46804cd6318755b753109f15ff3725/src/ByteWal.Mutation>, Nat) -> 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table

def apply.batch source · line 159 · raw

@table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> @batch:0xdd46804cd6318755b753109f15ff3725/src/ByteWal.Batch -> 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table

def close.failed source · line 164 · raw

@file:File -> @failure:Pair(U32, String) -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def close.done source · line 169 · raw

@file:File -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def recover.exhausted source · line 174 · raw

@state:RecoveryState -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def recover.length.completed source · line 201 · raw

@+path:String -> @file:File -> @+size:Nat -> @+offset:Nat -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> @bytes:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @complete:Bool -> RecoveryState

def recover.count.completed source · line 216 · raw

@+path:String -> @file:File -> @+size:Nat -> @+offset:Nat -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> @prefix:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @bytes:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @complete:Bool -> @+frame_length:U32 -> RecoveryState

def tail.synced source · line 233 · raw

@result:Result<&1, &1, Pair(U32, String), Unit> -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def tail.truncated source · line 243 · raw

@result:Result<&1, &1, Pair(U32, String), Unit> -> @+path:String -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def tail.closed source · line 256 · raw

@+path:String -> @+offset:Nat -> @table:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def recover.result source · line 265 · raw

@+path:String -> @fuel:Nat -> @state:RecoveryState -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def header.checked source · line 347 · raw

@+path:String -> @file:File -> @+size:Nat -> @result:Result<&1, &1, 0xdd46804cd6318755b753109f15ff3725/src/Wal.Error, Unit> -> @initial:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def header.valid source · line 361 · raw

@+path:String -> @file:File -> @+size:Nat -> @result:Result<&1, &1, Pair(U32, String), 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @initial:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def header.pair source · line 374 · raw

@+path:String -> @+size:Nat -> @pair:Pair(File, Result<&1, &1, Pair(U32, String), 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes>) -> @initial:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def recover.opened source · line 384 · raw

@+path:String -> @+size:Nat -> @opened:Result<&1, &1, Pair(U32, String), File> -> @initial:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def recover.size.checked source · line 399 · raw

@+path:String -> @+size:Nat -> @valid:Bool -> @initial:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def recover.sized source · line 414 · raw

@+path:String -> @result:Result<&1, &1, Pair(U32, String), Nat> -> @initial:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def recover.from source · line 427 · raw

@+path:String -> @initial:0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

def recover source · line 433 · raw

@+path:String -> IO(Result<&1, &1, Pair(U32, String), 0xdd46804cd6318755b753109f15ff3725/src/ByteMemTable.Table>)

Replays the byte WAL over an empty initial mutation table.

def create.closed source · line 437 · raw

@result:Result<&1, &1, Pair(U32, String), Unit> -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Publishes a fresh WAL header without exposing a partially truncated active file.

def create.written source · line 447 · raw

@pair:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

def create.opened source · line 457 · raw

@opened:Result<&1, &1, Pair(U32, String), File> -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

def create source · line 471 · raw

@+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Creates and durably publishes an empty generation-four byte WAL.

def reset.directory.synced source · line 476 · raw

@+directory:String -> @result:Result<&1, &1, Pair(U32, String), Unit> -> IO(Result<&1, &1, Pair(U32, String), Unit>)

def reset.published source · line 488 · raw

@+directory:String -> @result:Result<&1, &1, Pair(U32, String), Unit> -> IO(Result<&1, &1, Pair(U32, String), Unit>)

def reset_atomic source · line 504 · raw

@+directory:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Replaces the active WAL only after its new header is synced.

def append.synced source · line 510 · raw

@result:Result<&1, &1, Pair(U32, String), Unit> -> @file:File -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

def append.written source · line 525 · raw

@pair:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

def append.slice source · line 534 · raw

@pair:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes

Retains the requested portion of a duplicated WAL frame.

def append.first.written source · line 539 · raw

@pair:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> @remaining:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Stops between WAL chunks or writes the remaining frame before sync.

def append.chunked.rest source · line 558 · raw

@file:File -> @first:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @remaining:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Writes the first bounded WAL chunk and continues through the split point.

def append.chunked.cloned source · line 570 · raw

@file:File -> @sources:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @total:U32 -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Splits duplicated frame buffers around one bounded WAL write chunk.

def append.chunked.slices source · line 584 · raw

@file:File -> @frame:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @total:U32 -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Clones a large WAL frame before forming its bounded append chunks.

def append.opened.checked source · line 596 · raw

@file:File -> @frame:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @total:U32 -> @+path:String -> @large:Bool -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Selects full-frame or chunked writing after opening the WAL.

def append.opened.frame source · line 613 · raw

@file:File -> @frame:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Routes an opened WAL frame according to its encoded byte length.

def append.opened source · line 623 · raw

@opened:Result<&1, &1, Pair(U32, String), File> -> @frame:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

def append.encoded source · line 637 · raw

@result:Result<&1, &1, 0xdd46804cd6318755b753109f15ff3725/src/Wal.Error, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @+path:String -> IO(Result<&1, &1, Pair(U32, String), Unit>)

def append source · line 651 · raw

@+path:String -> @batch:0xdd46804cd6318755b753109f15ff3725/src/ByteWal.Batch -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Appends one encoded batch and syncs the resulting WAL file.