Skip to main content

Selection

Struct Selection 

Source
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

Source

pub fn empty() -> Self

A selection of nothing.

Source

pub fn with_capacity(capacity: usize) -> Self

A selection of nothing, with room for capacity positions.

Source

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.

Source

pub fn from_predicate(len: usize, keep: impl Fn(usize) -> bool) -> Self

A selection of the positions a predicate accepts.

Source

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.

Source

pub fn len(&self) -> usize

How many positions survived.

Source

pub fn is_empty(&self) -> bool

Whether nothing survived.

Source

pub fn get(&self, slot: usize) -> Option<usize>

The position at slot, where slot counts through the survivors.

Source

pub fn indices(&self) -> &[u32]

The positions, in order.

Source

pub fn iter(&self) -> impl Iterator<Item = usize> + '_

The positions as usize, in order.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Selection

Source§

fn clone(&self) -> Selection

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Selection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Selection

Source§

fn default() -> Selection

Returns the “default value” for a type. Read more
Source§

impl Eq for Selection

Source§

impl PartialEq for Selection

Source§

fn eq(&self, other: &Selection) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Selection

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.