Snapshot

A fixed view of the store, taken at a sequence number.

It pins three things, and each for its own reason. The sequence number is the filter: nothing committed after it is visible. The Version keeps the segments the view needs from being deleted by a compaction that has already replaced them. The StoreState keeps the memtables reachable, which matters precisely when a flush has moved their contents into a segment the newer version knows about and this one does not.

A snapshot also holds back compaction: an older version of a key may not be dropped while a snapshot that could still ask for it exists. Holding one open for a long time therefore costs disk space, which is the honest trade and the reason this is AutoCloseable rather than something the collector tidies up.

store.snapshot().use { snapshot ->
store.get(key, snapshot) // unchanged by anything written from here on
}

Properties

Link copied to clipboard

Whether this view may see documents that are not in a segment.

Link copied to clipboard

The segments the version this view pinned is made of.

Link copied to clipboard

The sequence number this view is taken at. Nothing newer is visible through it.

Functions

Link copied to clipboard
open override fun close()

Releases the segments and the compaction headroom this view was holding. Idempotent.

Link copied to clipboard
open override fun toString(): String