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 all the state the strategy needs across rows.

A fresh state per row — which is what calling a stateless helper amounts to — silently disables every stateful strategy, so engines must 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, validating that it can be applied.

Rejects here rather than mid-scan: a caller learns that a strategy is unusable before the source is read, not after a partial profile exists.

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, row: RowView<'_>) -> bool

Decide whether a row passes the streaming filters.

Always call this, including on the buffered path, so the filters of a multi-stage strategy run before the fixed-size stage sees a row.

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.

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> Freeze for RowSampler<R>
where Option<SampleBuffer<R>>: Freeze,

§

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