pub struct Selection { /* private fields */ }Expand description
Which positions of a vector are still in play, as indices into it.
An empty selection means nothing survived, which is different from no selection at all. The
distinction is why this is a type rather than an Option<Vec<u32>> that everybody interprets
slightly differently.
Implementations§
Source§impl Selection
impl Selection
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
A selection of nothing, with room for capacity positions.
Sourcepub fn identity(len: usize) -> Self
pub fn identity(len: usize) -> Self
A selection of the first len positions in order.
Materialized rather than represented as an absent selection, so this is what a caller uses when it genuinely wants the identity written down. A scan that has not filtered anything carries no selection at all, which is cheaper and is the common case.
Sourcepub fn from_predicate(len: usize, keep: impl Fn(usize) -> bool) -> Self
pub fn from_predicate(len: usize, keep: impl Fn(usize) -> bool) -> Self
A selection of the positions a predicate accepts.
Sourcepub fn push(&mut self, index: usize)
pub fn push(&mut self, index: usize)
Adds a position to the end.
§Panics
If the index does not fit in a u32. A vector holds 1024 values and a row group holds
122,880, so an index that large is a bug several layers up rather than a large query.
Sourcepub fn get(&self, slot: usize) -> Option<usize>
pub fn get(&self, slot: usize) -> Option<usize>
The position at slot, where slot counts through the survivors.
Sourcepub fn selectivity(&self, len: usize) -> f64
pub fn selectivity(&self, len: usize) -> f64
What fraction of len positions survived.
This is the number the compaction decision is made on, and it is measured rather than assumed, per section 7.1. Zero length reports 1.0, because a filter over nothing has not rejected anything.
Sourcepub fn compose(&self, earlier: &Self) -> Self
pub fn compose(&self, earlier: &Self) -> Self
This selection composed with an earlier one, so that filtering twice does not need the intermediate to be materialized.
self indexes into earlier, and the result indexes into whatever earlier indexed into.
Getting this backwards produces a query that returns the wrong rows rather than an error,
which is why the direction is spelled out here and tested below.