Liking cljdoc? Tell your friends :D

igeldb.sstable


apply-editclj

(apply-edit version {:keys [added deleted]})

Fold one version edit (bloom filters as objects) into the per-level table vector: drop every :deleted ID from all levels, then insert each :added table at its :level (levels kept dense; within a level ordered by ID).

Fold one version edit (bloom filters as *objects*) into the per-level table
vector: drop every `:deleted` ID from all levels, then insert each `:added`
table at its `:level` (levels kept dense; within a level ordered by ID).
sourceraw docstring

channel-forclj

(channel-for tree id)

The cached read channel for SSTable id, opening and caching it on first use. Racing openers are harmless: the loser closes its channel and uses the winner's.

The cached read channel for SSTable `id`, opening and caching it on first use.
Racing openers are harmless: the loser closes its channel and uses the winner's.
sourceraw docstring

close-all-channels!clj

(close-all-channels! tree)

Close every cached channel (store shutdown). A leaked channel is an fd leak.

Close every cached channel (store shutdown). A leaked channel is an fd leak.
sourceraw docstring

close-channels!clj

(close-channels! tree ids)

Close and evict the cached channels for ids. Called at the delete site while the write lock is held, so no reader can be mid-read on those files.

Close and evict the cached channels for `ids`. Called at the delete site while
the write lock is held, so no reader can be mid-read on those files.
sourceraw docstring

close-table!clj

(close-table! writer level)

Close the final block, append the index region + trailer, fsync and close. Returns the table entry for a manifest edit. :index / :index-start are the in-memory read structure -- derived from the file, NOT stored in the manifest.

Close the final block, append the index region + trailer, fsync and close.
Returns the table entry for a manifest edit. `:index` / `:index-start` are the
in-memory read structure -- derived from the file, NOT stored in the manifest.
sourceraw docstring

commit-edit!clj

(commit-edit! tree edit)

The single durable commit path for flush and compaction. Serialized across callers by the manifest lock: append+fsync the edit to the manifest (the commit point), then atomically swap the new version into current-version.

The swap needs no lock -- readers grab @current-version once (an immutable snapshot), so they never see a half-applied switch. The read/write lock instead arbitrates readers vs. physical file deletion (Step 5), not this swap.

The edit carries bloom filters as objects; the manifest copy stores them as bytes. Any IO failure propagates so the caller's fail-stop wrapper poisons the store.

The single durable commit path for flush and compaction. Serialized across
callers by the manifest lock: append+fsync the edit to the manifest (the commit
point), then atomically swap the new version into `current-version`.

The swap needs no lock -- readers grab `@current-version` once (an immutable
snapshot), so they never see a half-applied switch. The read/write lock instead
arbitrates readers vs. physical file deletion (Step 5), not this swap.

The edit carries bloom filters as objects; the manifest copy stores them as
bytes. Any IO failure propagates so the caller's fail-stop wrapper poisons the
store.
sourceraw docstring

delete-inputs!clj

(delete-inputs! tree ids)

Physically delete superseded SSTable files, AFTER the committed version has stopped referencing them. Acquires the write lock: once held, every reader has released the read lock, so none is mid-read on these files -- the delete is safe (no FileNotFoundException), with no reference counting.

A file already gone (a delete lost to a prior crash) is tolerated and logged; any other delete failure is a real IO error and propagates (the caller applies fail-stop). A lost delete is non-fatal for correctness: startup ignores SSTables the manifest does not reference.

Physically delete superseded SSTable files, AFTER the committed version has
stopped referencing them. Acquires the write lock: once held, every reader has
released the read lock, so none is mid-read on these files -- the delete is
safe (no `FileNotFoundException`), with no reference counting.

A file already gone (a delete lost to a prior crash) is tolerated and logged;
any other delete failure is a real IO error and propagates (the caller applies
fail-stop). A lost delete is non-fatal for correctness: startup ignores
SSTables the manifest does not reference.
sourceraw docstring

get-sstable-pathclj

(get-sstable-path id dir)
source

next-id!clj

(next-id! sstable-id)

Atomically allocate the next monotonic SSTable id. Safe against concurrent callers (the flush worker and the compaction worker both allocate ids).

Atomically allocate the next monotonic SSTable id. Safe against concurrent
callers (the flush worker and the compaction worker both allocate ids).
sourceraw docstring

open-table!clj

(open-table! id {:keys [sstable-dir bloom-filter sstable-block-size]})

Open a new SSTable for writing.

Open a new SSTable for writing.
sourceraw docstring

restore-tree-storeclj

(restore-tree-store {:keys [sstable-dir] :as config})

Rebuild the table set by replaying the manifest (no directory scan). Returns [tree next-sstable-id manifest-max-seq]. Files on disk not referenced by the replayed state are ignored. next-sstable-id is one past the highest ID ever assigned (from any edit's :added) so a deleted table's ID is never reused. manifest-max-seq is the highest InternalKey seq any edit committed -- part of next-seq recovery (the newest seq may live only in SSTables after a clean shutdown; see igeldb.core/gen-kvs).

Rebuild the table set by replaying the manifest (no directory scan). Returns
`[tree next-sstable-id manifest-max-seq]`. Files on disk not referenced by the
replayed state are ignored. `next-sstable-id` is one past the highest ID ever
assigned (from any edit's `:added`) so a deleted table's ID is never reused.
`manifest-max-seq` is the highest InternalKey seq any edit committed -- part of
next-seq recovery (the newest seq may live only in SSTables after a clean
shutdown; see `igeldb.core/gen-kvs`).
sourceraw docstring

table-bytesclj

(table-bytes writer)

Bytes written so far (entries only, excluding the not-yet-written footer).

Bytes written so far (entries only, excluding the not-yet-written footer).
sourceraw docstring

with-versionclj

(with-version tree f)

Run (f version-snapshot) while holding the read lock, releasing it in a finally. The snapshot is an immutable value, so a concurrent commit swapping in a new version is never observed half-applied. Holding the read lock also blocks file deletion (Step 5) until this reader is done with the version's files.

Run `(f version-snapshot)` while holding the read lock, releasing it in a
finally. The snapshot is an immutable value, so a concurrent commit swapping in
a new version is never observed half-applied. Holding the read lock also blocks
file deletion (Step 5) until this reader is done with the version's files.
sourceraw docstring

write-entry!clj

(write-entry! writer ikey data)

Append one InternalKey entry (value or tombstone). A block is cut only once the accumulated bytes reach sstable-block-size AND the user_key changes, so a single user_key's versions are never split across blocks (a block may therefore exceed the target size when one key has many versions).

Append one InternalKey entry (value or tombstone). A block is cut only once the
accumulated bytes reach `sstable-block-size` AND the user_key changes, so a
single user_key's versions are never split across blocks (a block may therefore
exceed the target size when one key has many versions).
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close