rgwml 2.0.0

Typed, local-first tabular data library with columnar in-memory storage.
Documentation
use super::Bitmap;

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum RowSelection {
    All,
    Range { offset: u32, len: u32 },
    Indices(Vec<u32>),
    Bitmap(Bitmap),
}

impl RowSelection {
    pub fn all() -> Self {
        Self::All
    }

    pub fn range(offset: u32, len: u32) -> Self {
        Self::Range { offset, len }
    }

    pub fn is_all(&self) -> bool {
        matches!(self, Self::All)
    }

    pub fn len(&self, total_rows: u32) -> u32 {
        match self {
            Self::All => total_rows,
            Self::Range { len, .. } => *len,
            Self::Indices(indices) => indices.len() as u32,
            Self::Bitmap(bitmap) => bitmap.count_ones(),
        }
    }
}