Skip to main content

TidyView

Struct TidyView 

Source
pub struct TidyView { /* private fields */ }
Expand description

Zero-copy virtual view over a shared DataFrame.

The base data is behind an Rc and never modified. Filters create bitmasks, selects narrow projections, sorts store permutation vectors. Data is only copied when you explicitly materialize or mutate.

Implementations§

Source§

impl TidyView

Source

pub fn new(df: DataFrame) -> Self

Create a new TidyView over the entire DataFrame.

Source

pub fn from_rc(base: Rc<DataFrame>) -> Self

Create from a shared Rc.

Source

pub fn nrows(&self) -> usize

Number of visible rows.

Source

pub fn ncols(&self) -> usize

Number of visible columns.

Source

pub fn mask(&self) -> &BitMask

Get the bitmask (for auditing).

Source

pub fn base(&self) -> &DataFrame

Get the base DataFrame (for auditing).

Source

pub fn filter(&self, predicate: &DExpr) -> Result<TidyView, TidyError>

Filter rows by predicate. Returns a new TidyView with an updated bitmask. No data is copied — just bits are flipped.

Source

pub fn select(&self, cols: &[&str]) -> Result<TidyView, TidyError>

Select specific columns by name. Returns a new TidyView with a narrowed projection. No data is copied.

Source

pub fn mutate( &self, assignments: &[(&str, DExpr)], ) -> Result<DataFrame, TidyError>

Add or replace columns. Materializes the view and returns a new DataFrame.

Uses snapshot semantics: all column references resolve against the column list frozen before any assignments execute.

Source

pub fn group_by(&self, keys: &[&str]) -> Result<GroupedTidyView, TidyError>

Group rows by one or more key columns.

Groups appear in first-occurrence order (deterministic, not hash-dependent).

Source

pub fn arrange(&self, keys: &[ArrangeKey]) -> Result<TidyView, TidyError>

Sort visible rows by one or more keys. Stores the result as a lazy permutation vector — no data is materialized.

Source

pub fn slice_head(&self, n: usize) -> TidyView

Take the first N visible rows.

Source

pub fn slice_tail(&self, n: usize) -> TidyView

Take the last N visible rows.

Source

pub fn slice_sample(&self, n: usize, seed: u64) -> TidyView

Deterministic random sample of N rows. Same seed = same rows, always.

Source

pub fn distinct(&self, cols: &[&str]) -> Result<TidyView, TidyError>

Keep only unique rows by the given column subset.

Source

pub fn inner_join( &self, right: &TidyView, on: &[(&str, &str)], ) -> Result<DataFrame, TidyError>

Inner join: rows where keys match in both tables.

Source

pub fn left_join( &self, right: &TidyView, on: &[(&str, &str)], ) -> Result<DataFrame, TidyError>

Left join: all left rows, matched right rows or defaults.

Source

pub fn materialize(&self) -> Result<DataFrame, TidyError>

Materialize the view into a new DataFrame (mask + projection applied).

Source

pub fn column_names(&self) -> Vec<String>

Column names visible through the current projection.

Trait Implementations§

Source§

impl Clone for TidyView

Source§

fn clone(&self) -> TidyView

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TidyView

Source§

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

Formats the value using the given formatter. Read more

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.