Skip to main content

TurboCollectionState

Struct TurboCollectionState 

Source
pub struct TurboCollectionState {
    pub dim: usize,
    pub metric: DistanceMetric,
    pub index: Mutex<RawMutex, TurboQuantIndex>,
    pub extent: Mutex<RawMutex, Option<TurboExtent>>,
    /* private fields */
}
Expand description

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

index is the in-memory TurboQuant index that owns the encoded codes + raw vectors; extent is the per-collection page-backed payload buffer when the store is in paged mode (None for in-memory runtimes). Both are wrapped in Mutex because INSERTs serialize on the per-collection state — the contention point lives here rather than on the global store lock.

Fields§

§dim: usize§metric: DistanceMetric§index: Mutex<RawMutex, TurboQuantIndex>§extent: Mutex<RawMutex, Option<TurboExtent>>

Implementations§

Source§

impl TurboCollectionState

Source

pub fn new( dim: usize, metric: DistanceMetric, pager: Option<&Arc<Pager>>, ) -> TurboCollectionState

Source

pub fn set_snapshot_path(&self, path: Option<PathBuf>)

Set (or clear) the .tv snapshot path for this collection. Called by RedDB::turbo_state once the resolved TieredLayoutPaths is known.

Source

pub fn snapshot_path(&self) -> Option<PathBuf>

Current .tv snapshot path, if any.

Source

pub fn is_ready(&self) -> bool

Returns the current readiness flag. true means the background rebuild (or lazy populate) has completed and the in-memory index reflects every WAL-acked INSERT.

Source

pub fn wait_until_ready(&self, timeout: Duration) -> bool

Block the caller (with a bounded timeout) until the collection becomes ready. Returns true if ready within the timeout, false if the timeout fired. A zero-or-negative timeout still does one fast-path check.

Source

pub fn ensure_populated(&self, store: &UnifiedStore, collection: &str)

Lazily populate the in-memory index from any vector entities already persisted in the collection, then drain any WAL-replayed VectorInsert records captured at store-open time (issue #694).

Boot-time recovery: the WAL VectorInsert records are the authoritative source for vectors that may not have made it into the entity manager’s persisted state (e.g. a crash between WAL fsync and the next paged flush). Replaying them in WAL order under a fixed codec seed reconstructs the in-memory TurboQuantIndex deterministically — including the partial-block tail introduced by ADR 0024.

Non-vector traffic does not block on this rebuild: the runtime only takes this path on the first turbo INSERT/SEARCH after boot. #673 wires the per-collection ready: bool flag on top of this hook to keep vector traffic from observing a half-built index while the rebuild is in flight.

Source

pub fn dump_snapshot_async(self: &Arc<TurboCollectionState>, lsn: u64)

Capture the current in-memory index state and dump it to the configured .tv path on a worker thread (#674). The next caller (typically the next WAL checkpoint cycle) blocks on the previous worker before starting a new one — bounded backpressure of at most one dump in flight per collection. The WAL checkpoint itself never waits for the snapshot fsync.

No-op when snapshot_path is None (StorageLayout::Minimal or embedded mode) — preserves the single-file portability story.

Source

pub fn wait_snapshot(&self)

Join the in-flight snapshot worker, if any. Used by RedDB::Drop to make sure no .tv write outlives the runtime, and by tests that want to assert the on-disk state synchronously.

Source

pub fn background_rebuild(&self, store: &UnifiedStore, collection: &str)

Background-rebuild hook (#694 / #673). Drives the same code path as ensure_populated; safe to call from a worker thread. On completion the per-collection readiness flag flips and any SEARCH callers parked on wait_until_ready are woken.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more