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
impl RowSampler
Sourcepub fn new(strategy: &SamplingStrategy) -> Result<Self, DataProfilerError>
pub fn new(strategy: &SamplingStrategy) -> Result<Self, DataProfilerError>
Build a sampler for strategy.
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) -> bool
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.
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.