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
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.
Source§impl<R> RowSampler<R>
impl<R> RowSampler<R>
Sourcepub fn for_rows(strategy: &SamplingStrategy) -> Result<Self, DataProfilerError>
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.
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: R)
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.
Sourcepub fn take_sample(&mut self) -> Vec<R>
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.
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.