pub struct SamplingState { /* private fields */ }Expand description
The cross-row state that stateful strategies need.
One instance lives for a whole scan. Recreating it per row — which is what a stateless helper amounts to — makes every stateful strategy behave as if each row were the first, which is how stratified sampling came to return nothing and reservoir sampling came to return everything.
Implementations§
Source§impl SamplingState
impl SamplingState
pub fn new() -> Self
Sourcepub fn progressive_taken(&self) -> usize
pub fn progressive_taken(&self) -> usize
Rows a Progressive stage has taken so far.
Sourcepub fn record_progressive(&mut self)
pub fn record_progressive(&mut self)
Record that a Progressive stage took a row.
Sourcepub fn take_from_stratum(
&mut self,
row: RowView<'_>,
key_columns: &[String],
samples_per_stratum: usize,
) -> bool
pub fn take_from_stratum( &mut self, row: RowView<'_>, key_columns: &[String], samples_per_stratum: usize, ) -> bool
Take row for its stratum if that stratum still has room.
The stratum key is the joined values of key_columns. A row missing any
key column belongs to no stratum and is not sampled — silently folding
it into a partial key would merge unrelated rows into one stratum.
Sourcepub fn strata_seen(&self) -> usize
pub fn strata_seen(&self) -> usize
Number of distinct strata observed so far.
Trait Implementations§
Source§impl Debug for SamplingState
impl Debug for SamplingState
Source§impl Default for SamplingState
impl Default for SamplingState
Source§fn default() -> SamplingState
fn default() -> SamplingState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SamplingState
impl RefUnwindSafe for SamplingState
impl Send for SamplingState
impl Sync for SamplingState
impl Unpin for SamplingState
impl UnsafeUnpin for SamplingState
impl UnwindSafe for SamplingState
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