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
impl RowSampler
Sourcepub fn new(strategy: &SamplingStrategy) -> Result<Self, DataProfilerError>
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.
Sourcepub fn is_buffered(&self) -> bool
pub fn is_buffered(&self) -> bool
Sourcepub fn accept(&mut self, row: RowView<'_>) -> bool
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.
Sourcepub fn offer(&mut self, values: Vec<String>)
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.
Sourcepub fn take_sample(&mut self) -> Vec<Vec<String>>
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.
Sourcepub fn iterated_rows(&self) -> usize
pub fn iterated_rows(&self) -> usize
Rows the sampler has seen, sampled or not.
Sourcepub fn sampled_rows(&self) -> usize
pub fn sampled_rows(&self) -> usize
Rows that ended up in the sample.