Skip to main content

RowSampler

Struct RowSampler 

Source
pub struct RowSampler { /* 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.

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

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: Vec<String>)

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<Vec<String>>

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 Debug for RowSampler

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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