Skip to main content

Module sampler

Module sampler 

Source
Expand description

The runtime that applies a SamplingStrategy to a stream of rows.

Strategies fall into two families, and the difference is not cosmetic:

  • Streaming strategies (Systematic, Stratified, Progressive, Importance) decide each row on the spot, so a row can be folded into the running statistics immediately and memory stays bounded.
  • Fixed-size strategies (Reservoir, Random) cannot. Whether row 5 belongs in a uniform sample of 10 is not known until the stream ends — row 5 may be evicted at row 900. Streaming statistics are not retractable, so a row that was folded in and later evicted would silently corrupt the profile. These strategies therefore buffer the candidate rows and hand the final sample back at end of stream, costing size rows of memory.

RowSampler hides that split behind one interface so every engine treats sampling identically. Consult RowSampler::is_buffered to know which of RowSampler::accept or RowSampler::offer to call.

Structs§

RowSampler
Applies a SamplingStrategy to a stream of rows, holding all the state the strategy needs across rows.
RowView
A borrowed view of one row, addressable by column name.