Liking cljdoc? Tell your friends :D

vaelii.impl.disk.backend

The durable-store entry point: open (once per directory) a DiskRecordStore and/or a KvIndexStore over a DiskKvBackend, take the single-writer lock, and wire what was opened to the durability daemon.

The two halves open independently. A KB's records and its index are chosen on separate axes (vaelii.impl.kb), and only one of the combinations that reach here wants both: :disk is durable records and a durable index, while :disk-memory / :disk-dense / :disk-columnar keep the derived index in RAM and want the record store alone — no index log, no index WAL, nothing written to the directory but the records. So each component is opened on first use rather than as a pair, and the registry records which ones a directory actually has. A directory opened both ways in one JVM therefore shares its record store across both KBs and hands the RAM-index one no durable index at all.

A process-global registry keyed by canonical directory mirrors the memory backend's space registry: two KBs constructed over the same directory share one set of stores — so a KB "restarted" over the same directory in one JVM (the recovery tests) sees the durable records the first wrote, with its own fresh taxonomy/TMS, and the file handles + durability registration + lock are taken once rather than leaking across the suite's hundreds of KB constructions. A true cross-JVM restart opens the directory fresh and rebuilds the RAM state from the durable logs.

The durable-store entry point: open (once per directory) a `DiskRecordStore` and/or a
`KvIndexStore` over a `DiskKvBackend`, take the single-writer lock, and wire what was
opened to the durability daemon.

**The two halves open independently.**  A KB's records and its index are chosen on
separate axes (`vaelii.impl.kb`), and only one of the combinations that reach here
wants both: `:disk` is durable records *and* a durable index, while `:disk-memory` /
`:disk-dense` / `:disk-columnar` keep the derived index in RAM and want the record store
alone — no index log, no index WAL, nothing written to the directory but the records.  So each
component is opened on first use rather than as a pair, and the registry records which
ones a directory actually has.  A directory opened both ways in one JVM therefore
shares its record store across both KBs and hands the RAM-index one no durable index
at all.

A process-global registry keyed by canonical directory mirrors the memory backend's
space registry: two KBs constructed over the same directory share one set of
stores — so a KB "restarted" over the same directory in one JVM (the recovery
tests) sees the durable records the first wrote, with its own fresh taxonomy/TMS, and
the file handles + durability registration + lock are taken once rather than leaking
across the suite's hundreds of KB constructions.  A true cross-JVM restart opens the
directory fresh and rebuilds the RAM state from the durable logs.
raw docstring

canonical-dirclj

(canonical-dir dir)

dir's canonical path — the identity a directory's stores are keyed by, and what anything else keying state off a disk KB's directory (the derived index's shared state, vaelii.impl.kb) must key on too, so two spellings of one directory are one KB rather than two.

`dir`'s canonical path — the identity a directory's stores are keyed by, and what
anything else keying state off a disk KB's directory (the derived index's shared
state, `vaelii.impl.kb`) must key on too, so two spellings of one directory are one
KB rather than two.
raw docstring

close-dir!clj

(close-dir! dir)

Close and forget the stores for dir: fsync + close whichever components are open, deregister them from the durability daemon, and release the lock. For explicit shutdown and test teardown — ordinary operation leaves the stores open for the JVM's life (the shutdown hook closes them).

Close and forget the stores for `dir`: fsync + close whichever components are open,
deregister them from the durability daemon, and release the lock.  For explicit
shutdown and test teardown — ordinary operation leaves the stores open for the JVM's
life (the shutdown hook closes them).
raw docstring

disk-dirclj

(disk-dir {:keys [dir record-space index-space]
           :or {record-space 0 index-space 1}})

The directory a disk KB lives in. :dir names it explicitly; otherwise it derives from the space numbers under a base (vaelii.disk.dir, else <tmpdir>/vaelii-disk), so the record/index space pair the other backends key on still names a distinct store.

The directory a disk KB lives in.  `:dir` names it explicitly; otherwise it derives
from the space numbers under a base (`vaelii.disk.dir`, else `<tmpdir>/vaelii-disk`), so
the record/index space pair the other backends key on still names a distinct store.
raw docstring

index-forclj

(index-for dir)

The durable IndexStore for dir — the KvIndexStore over a write-ahead-logged DiskKvBackend.

The durable `IndexStore` for `dir` — the `KvIndexStore` over a write-ahead-logged
`DiskKvBackend`.
raw docstring

openedclj

(opened dir)

What is currently open for dir: the subset of #{:records :index :overlay-meta} this JVM holds stores for. Empty when the directory has never been opened (or has been closed).

What is currently open for `dir`: the subset of `#{:records :index :overlay-meta}` this
JVM holds stores for.  Empty when the directory has never been opened (or has been
closed).
raw docstring

overlay-meta-forclj

(overlay-meta-for dir)

The durable KvBackend holding a fork's record-level bookkeeping for dir (vaelii.impl.overlay.mount). Opened only for a directory that actually hosts a fork's overlay.

The durable `KvBackend` holding a fork's record-level bookkeeping for `dir`
(`vaelii.impl.overlay.mount`).  Opened only for a directory that actually hosts a
fork's overlay.
raw docstring

records-forclj

(records-for dir)

The durable RecordStore for dir. Opens no index — the record half alone is what a RAM-index mode (:disk-memory, :disk-dense, :disk-columnar) wants durable.

The durable `RecordStore` for `dir`.  Opens no index — the record half alone is what
a RAM-index mode (`:disk-memory`, `:disk-dense`, `:disk-columnar`) wants durable.
raw docstring

register-index-snapshot!clj

(register-index-snapshot! dir save-fn)

Register save-fn (a thunk) as dir's derived-index snapshot writer.

A derived index is not one of the components above — nothing here opens it, and it has no file handle to close — but the image of it is written to this directory and has to be written by whoever last held it, while the records it is stamped against are still open. So it hangs off the directory's registry entry and runs at the front of close-dir!, and on JVM shutdown through the durability daemon.

Idempotent per directory: open-kb runs for every KB constructed over a directory and they all share one index, so the first registration is the one that stands.

Register `save-fn` (a thunk) as `dir`'s derived-index snapshot writer.

A derived index is not one of the components above — nothing here opens it, and it has
no file handle to close — but the *image* of it is written to this directory and has to
be written by whoever last held it, while the records it is stamped against are still
open.  So it hangs off the directory's registry entry and runs at the front of
`close-dir!`, and on JVM shutdown through the durability daemon.

Idempotent per directory: `open-kb` runs for every KB constructed over a directory and
they all share one index, so the first registration is the one that stands.
raw 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