pub struct SharedReservoirSampler<T: Copy + 'static> { /* private fields */ }Implementations§
pub fn create( path: impl AsRef<Path>, capacity: usize, ) -> Result<Self, ReservoirError>
pub fn open( path: impl AsRef<Path>, expected_capacity: usize, ) -> Result<Self, ReservoirError>
pub fn capacity(&self) -> usize
pub fn total_seen(&self) -> u64
Sourcepub fn record(&self, value: T) -> Option<usize>
pub fn record(&self, value: T) -> Option<usize>
Record a value. Returns the slot index it landed in, or None if the value was rejected (the reservoir kept its existing sample for this position).
Sourcepub fn snapshot(&self) -> Vec<T>
pub fn snapshot(&self) -> Vec<T>
Snapshot the current reservoir. Returns min(total_seen, k) slots filled so far; the rest are unused.
Sourcepub fn reset(&self)
pub fn reset(&self)
Reset to empty (total_seen = 0; slots become invalid but not zeroed - next record overwrites them).
pub fn flush(&self) -> Result<(), ReservoirError>
pub fn flush_async(&self) -> Result<(), ReservoirError>
Trait Implementations§
fn header(&self) -> &HandshakeHeader
fn ring(&self) -> &ObservationRing
fn make_policy(&self) -> Box<dyn Policy>
Source§fn apply_migration(&self, new_tag: u32)
fn apply_migration(&self, new_tag: u32)
Called by the sidecar when the policy returns a new strategy
tag. Default implementation: just set the tag on the header.
Primitives that need heavier migration (data-layout swap)
override this to perform the swap before (or after) updating
the tag.
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more