(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).
(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.
(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.
(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.
(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.
(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.
(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.
(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).
(open-table! id {:keys [sstable-dir bloom-filter sstable-block-size]})Open a new SSTable for writing.
Open a new SSTable for writing.
(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`).
(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).
(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.
(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).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |