Skip to main content

RowSampler

Struct RowSampler 

Source
pub struct RowSampler<R = Vec<String>> { /* private fields */ }
Expand description

Applies a SamplingStrategy to a stream of rows, holding the state the strategy needs across rows.

Engines create one sampler per scan and keep it for the whole scan.

R is what the fixed-size stage holds for each row until the stream ends. It is the row’s field values unless an engine has to keep something about the row that its values cannot say, and must then get it back with exactly the rows that were sampled.

Implementations§

Source§

impl RowSampler

Source

pub fn new(strategy: &SamplingStrategy) -> Result<Self, DataProfilerError>

Build a sampler for strategy.

Source§

impl<R> RowSampler<R>

Source

pub fn for_rows(strategy: &SamplingStrategy) -> Result<Self, DataProfilerError>

As RowSampler::new, for a sampler whose fixed-size stage holds R for each row rather than its field values alone.

Source

pub fn is_buffered(&self) -> bool

Whether rows must be handed to offer instead of being folded in as accept approves them.

Source

pub fn is_noop(&self) -> bool

Whether this sampler can ever exclude a row.

Source

pub fn accept(&mut self) -> bool

Decide whether the next row passes the systematic filter.

Call this for every row, including on the buffered path, so the row count stays exact.

Source

pub fn offer(&mut self, values: R)

Hand a row that passed accept to the fixed-size stage.

Only meaningful when is_buffered is true.

Source

pub fn take_sample(&mut self) -> Vec<R>

The final sample from the fixed-size stage, ready to fold into the statistics. Empty for a purely streaming strategy.

Source

pub fn iterated_rows(&self) -> usize

Rows the sampler has seen, sampled or not.

Source

pub fn sampled_rows(&self) -> usize

Rows that ended up in the sample.

Source

pub fn rows_against_cap(&self) -> usize

Rows a max_rows cap counts so far.

A streaming strategy folds rows in as it keeps them, so the cap bounds the rows kept: a systematic interval under max_rows(n) reads until it has kept n. A fixed-size strategy has kept nothing until the stream ends, so the cap bounds the rows read and the sample is drawn from those; counting kept rows would let reservoir(100) under max_rows(20) return 100 rows. Engines check the cap per row and per chunk, and both checks use this count, so the rows analyzed do not depend on where a chunk ends.

Trait Implementations§

Source§

impl<R: Debug> Debug for RowSampler<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Forget for RowSampler<R>

§

impl<R> Freeze for RowSampler<R>
where Option<SampleBuffer<R>>: Freeze,

§

impl<R> Move for RowSampler<R>

§

impl<R> RefUnwindSafe for RowSampler<R>
where Option<SampleBuffer<R>>: RefUnwindSafe,

§

impl<R> Send for RowSampler<R>
where Option<SampleBuffer<R>>: Send,

§

impl<R> Sync for RowSampler<R>
where Option<SampleBuffer<R>>: Sync,

§

impl<R> Unpin for RowSampler<R>
where Option<SampleBuffer<R>>: Unpin,

§

impl<R> UnsafeUnpin for RowSampler<R>
where Option<SampleBuffer<R>>: UnsafeUnpin,

§

impl<R> UnwindSafe for RowSampler<R>
where Option<SampleBuffer<R>>: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V