Skip to main content

Module vector_turbo_kind

Module vector_turbo_kind 

Source
Expand description

Foundation for KIND vector.turbo collections (PRD #668, issue #693).

Mirrors blockchain_kind for the marker side of the contract: red.collection.{name}.kind = "turbo" is the durable signal that distinguishes a TurboQuant-backed vector collection from the legacy vector kind. Routing in impl_ddl, create_vector, and the vector-search executor reads is_turbo to branch.

The per-collection runtime state (TurboCollectionState) owns the in-memory TurboQuantIndex and a TurboExtent when a pager is available, plus the codec dimension / metric inherited from the collection contract.

Structs§

TurboCollectionState
Per-collection runtime state for a vector.turbo collection.

Constants§

TURBO_CODEC_SEED
Deterministic codec seed shared by every turbo collection in this process. The seed feeds the rotation matrix + codebook; a fixed seed guarantees that re-encoding the same vector across restarts produces the same code, which is what makes lazy re-population from the persisted vector entities safe.
TURBO_KIND_TAG
Value stored under red.collection.{name}.kind for vector.turbo collections. Must be distinct from blockchain_kind::CHAIN_KIND_TAG and from any future kind marker.

Functions§

is_turbo
True if mark_as_turbo was ever called for this collection. Cheap (one config-tree read) and safe to call on every INSERT/SEARCH — the legacy vector path takes the false branch with no extra cost beyond the lookup.
mark_as_turbo
Persist the turbo kind marker. Called once at collection creation. Idempotent against IF NOT EXISTS: re-stamping the same value is a no-op at the config-tree layer.
ready_flag_from_catalog
Read the persisted readiness flag from the catalog. Used by admin/introspection paths that don’t hold the runtime TurboCollectionState (e.g. SHOW COLLECTION metadata, cross- process tooling). The in-memory TurboCollectionState::is_ready is the authoritative live signal; this is the persisted shadow.
spawn_background_rebuild
Public hook (#673) — issued by RedDB::turbo_state the first time a turbo collection’s state is materialised. Spawns a worker thread that drains the WAL replay buffer + persisted vector entities and flips the readiness flag. Non-vector traffic never blocks on this; vector SEARCH/INSERT against a not-yet-ready collection observes the flag via is_ready / wait_until_ready.