Skip to main content

PersistentResultCacheWriter

Struct PersistentResultCacheWriter 

Source
pub struct PersistentResultCacheWriter { /* private fields */ }
Expand description

The PersistentResultCacheWriter. The query thread calls PersistentResultCacheWriter::enqueue_store / [enqueue_remove] / enqueue_clear; the worker calls [drain_one] in a loop and re-validates the op before publishing.

Implementations§

Source§

impl PersistentResultCacheWriter

Source

pub fn new(metrics: LookupMetrics, limits: WriterLimits) -> Self

Source

pub fn enqueue_store(&self, entry: PersistableEntry)

Enqueue a Store op. Coalesces with a previous Store for the same key (the new entry supersedes the old one — old bytes are subtracted from the queue’s approx_bytes first). Drops the op and increments the dropped counter when the queue is full.

Source

pub fn enqueue_remove(&self, key: u64)

Enqueue a Remove op. Always supersedes any pending Store for the same key (its bytes are subtracted so the queue can free capacity before the worker actually deletes the file).

Source

pub fn enqueue_clear(&self)

Advance the global clear generation and enqueue a Clear op so the worker performs the actual file deletion. The in-memory pending map is also dropped because every existing op is now stale.

Source

pub fn drain_one(&self) -> Option<DrainedOp>

Pop the next pending op, waiting on the condvar until one is queued or shutdown is requested. Returns None only after shutdown AND the queue is empty — the worker drains remaining ops before exit.

Source

pub fn try_drain_one(&self) -> Option<DrainedOp>

Non-blocking variant: returns Some(op) if any op is queued, else None. Used by flush_persistent_cache(deadline) to drain the queue under a deadline.

Source

pub fn shutdown(&self)

Mark the writer as shutdown. The worker drains remaining ops until the queue is empty or the optional deadline expires; anything still queued at that point is counted as abandoned.

Source

pub fn pending_count(&self) -> u64

Count the ops still queued at the moment of the call. Used to compute the abandoned count on shutdown.

Source

pub fn drain_all_as_abandoned(&self) -> u64

Drain every remaining op synchronously, accumulating their per-op byte estimates into abandoned_bytes and counting each as abandoned. Returns the number of abandoned ops. Used by shutdown_persistent_cache(deadline) to clear the queue on close.

Source

pub fn record_outcome(&self, outcome: DrainOutcome)

Source

pub fn enqueued_total(&self) -> u64

Source

pub fn coalesced_total(&self) -> u64

Source

pub fn dropped_total(&self) -> u64

Source

pub fn remove_total(&self) -> u64

Source

pub fn stale_total(&self) -> u64

Source

pub fn errors_total(&self) -> u64

Source

pub fn abandoned_total(&self) -> u64

Source

pub fn queue_depth(&self) -> usize

Source

pub fn writes_in_flight(&self) -> u64

Number of I/O operations the worker has not yet completed.

Source

pub fn persist_snapshot(&self) -> LookupMetricsSnapshot

Point-in-time copy of the persistent-cache publish counters. Exposed so external integration tests can assert on the writer’s bookkeeping without going through Table::lookup_metrics_snapshot.

Source

pub fn for_test(limits: WriterLimits) -> Self

Construct a writer with a fresh LookupMetrics (the canonical metrics type is pub(crate) and not constructible from external integration tests).

Source

pub fn bump_persist_generation(&self, key: u64) -> u64

Bump the writer’s per-key generation for key and return the new generation. Used by the cache when it allocates a fresh entry generation just before enqueueing, so a subsequent invalidation (Remove / Clear) is observed as newer.

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<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, 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> 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.