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
impl PersistentResultCacheWriter
pub fn new(metrics: LookupMetrics, limits: WriterLimits) -> Self
Sourcepub fn enqueue_store(&self, entry: PersistableEntry)
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.
Sourcepub fn enqueue_remove(&self, key: u64)
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).
Sourcepub fn enqueue_clear(&self)
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.
Sourcepub fn drain_one(&self) -> Option<DrainedOp>
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.
Sourcepub fn try_drain_one(&self) -> Option<DrainedOp>
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.
Sourcepub fn shutdown(&self)
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.
Sourcepub fn pending_count(&self) -> u64
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.
Sourcepub fn drain_all_as_abandoned(&self) -> u64
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.
pub fn record_outcome(&self, outcome: DrainOutcome)
pub fn enqueued_total(&self) -> u64
pub fn coalesced_total(&self) -> u64
pub fn dropped_total(&self) -> u64
pub fn remove_total(&self) -> u64
pub fn stale_total(&self) -> u64
pub fn errors_total(&self) -> u64
pub fn abandoned_total(&self) -> u64
pub fn queue_depth(&self) -> usize
Sourcepub fn writes_in_flight(&self) -> u64
pub fn writes_in_flight(&self) -> u64
Number of I/O operations the worker has not yet completed.
Sourcepub fn persist_snapshot(&self) -> LookupMetricsSnapshot
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.
Sourcepub fn for_test(limits: WriterLimits) -> Self
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).
Sourcepub fn bump_persist_generation(&self, key: u64) -> u64
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§
impl !Freeze for PersistentResultCacheWriter
impl RefUnwindSafe for PersistentResultCacheWriter
impl Send for PersistentResultCacheWriter
impl Sync for PersistentResultCacheWriter
impl Unpin for PersistentResultCacheWriter
impl UnsafeUnpin for PersistentResultCacheWriter
impl UnwindSafe for PersistentResultCacheWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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