Struct Cube

Source
#[repr(C, align(64))]
pub struct Cube { pub tables: Vec<Table>, pub n_rows: Vec<usize>, pub name: String, pub third_dim_index: Option<Vec<String>>, }
Expand description

§Cube - 3D Type for Advanced Analysis Use Cases

Holds a vector of tables unified by some value, often Time, for special indexing. Useful for data analysis.

§Purpose

Useful when the tables represent discrete time snapshots, or a category dimension. This enables comparing data without losing the underlying grain through aggregation, whilst still supporting that.

§Description

This is an optional extra enabled by the cube feature, and is not part of the Apache Arrow framework.

§Under Development

⚠️ Unstable API and WIP: expect future development. Breaking changes will be minimised, but avoid using this in production unless you are ready to wear API adjustments.

Fields§

§tables: Vec<Table>

Table entries forming the cube (rectangular prism)

§n_rows: Vec<usize>

Number of rows in each table

§name: String

Cube name

§third_dim_index: Option<Vec<String>>

Implementations§

Source§

impl Cube

Source

pub fn new( name: String, cols: Option<Vec<FieldArray>>, third_dim_index: Option<Vec<String>>, ) -> Self

Constructs a new Cube with a specified name and optional set of columns. If cols is provided, the columns are used to create the first table. The number of rows will be inferred from the first column. If the name is empty or whitespace, a unique default name is assigned. If no columns are provided, the Cube will be empty.

Source

pub fn new_empty() -> Self

Constructs a new, empty Cube with a globally unique name.

Source

pub fn add_table(&mut self, table: Table)

Adds a table to the cube.

Source

pub fn schema(&self) -> Vec<Arc<Field>>

Gets the schemea from the first table as representative of the rest

Source

pub fn n_tables(&self) -> usize

Returns the number of tables.

Source

pub fn n_cols(&self) -> usize

Returns the number of columns.

Source

pub fn is_empty(&self) -> bool

Returns true if the cube is empty (no tables, no columns or no rows).

Source

pub fn table(&self, idx: usize) -> Option<&Table>

Returns a reference to a table by index.

Source

pub fn table_mut(&mut self, idx: usize) -> Option<&mut Table>

Returns a mutable reference to a table by index.

Source

pub fn table_names(&self) -> Vec<&str>

Returns the names of all tables in the cube.

Source

pub fn table_index(&self, name: &str) -> Option<usize>

Returns the index of a table by name.

Source

pub fn has_table(&self, name: &str) -> bool

Checks if a table with the given name exists.

Source

pub fn remove_table_at(&mut self, idx: usize) -> bool

Removes a table by index.

Source

pub fn remove_table(&mut self, name: &str) -> bool

Removes a table by name.

Source

pub fn clear(&mut self)

Clears all tables and resets row counts.

Source

pub fn tables(&self) -> &[Table]

Returns an immutable reference to all tables.

Source

pub fn tables_mut(&mut self) -> &mut [Table]

Returns a mutable reference to all tables.

Source

pub fn iter_tables(&self) -> Iter<'_, Table>

Returns an iterator over all tables.

Source

pub fn iter_tables_mut(&mut self) -> IterMut<'_, Table>

Source

pub fn col_names(&self) -> Vec<&str>

Returns the list of column names (from the first table).

Source

pub fn col_index(&self, name: &str) -> Option<usize>

Returns the index of a column by name (from the first table).

Source

pub fn has_col(&self, name: &str) -> bool

Returns true if the cube has a column of the given name (in all tables).

Source

pub fn col(&self, idx: usize) -> Option<Vec<&FieldArray>>

Returns all columns (FieldArrays) with the given index across all tables.

Source

pub fn col_by_name(&self, name: &str) -> Option<Vec<&FieldArray>>

Returns all columns (FieldArrays) with the given name across all tables.

Source

pub fn cols(&self) -> Vec<Vec<&FieldArray>>

Returns all columns for all tables as Vec<Vec<&FieldArray>>.

Source

pub fn remove_col(&mut self, name: &str) -> bool

Removes a column by name from all tables. Returns true if removed from all.

Source

pub fn remove_col_at(&mut self, idx: usize) -> bool

Removes a column by index from all tables. Returns true if removed from all.

Source

pub fn iter_cols( &self, col_idx: usize, ) -> Option<impl Iterator<Item = &FieldArray>>

Returns an iterator over the specified column across all tables.

Source

pub fn iter_cols_by_name<'a>( &'a self, name: &'a str, ) -> Option<impl Iterator<Item = &'a FieldArray> + 'a>

Returns an iterator over the named column across all tables.

Source

pub fn set_third_dim_index<S: Into<String>>(&mut self, cols: Vec<S>)

Sets the third dimensional index

Source

pub fn third_dim_index(&self) -> Option<&[String]>

Retrieves the third dimensional index

Source

pub fn slice_clone(&self, offset: usize, len: usize) -> Self

Returns a new owned Cube containing rows [offset, offset+len) for all tables.

Source

pub fn slice(&self, offset: usize, len: usize) -> CubeV

Returns a zero-copy view over rows [offset, offset+len) for all tables.

Source

pub fn par_iter_tables(&self) -> Iter<'_, Table>

Returns a parallel iterator over all tables.

Source

pub fn par_iter_tables_mut(&mut self) -> IterMut<'_, Table>

Returns a parallel mutable iterator over all tables.

Trait Implementations§

Source§

impl Clone for Cube

Source§

fn clone(&self) -> Cube

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 Cube

Source§

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

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

impl Default for Cube

Source§

fn default() -> Cube

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

impl From<Cube> for Value

Source§

fn from(v: Cube) -> Self

Converts to this type from the input type.
Source§

impl<'a> IntoIterator for &'a Cube

Source§

type Item = &'a Table

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Table>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a mut Cube

Source§

type Item = &'a mut Table

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, Table>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for Cube

Source§

type Item = Table

The type of the elements being iterated over.
Source§

type IntoIter = <Vec<Table> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Cube

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Value> for Cube

Source§

type Error = MinarrowError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Cube

Auto Trait Implementations§

§

impl Freeze for Cube

§

impl RefUnwindSafe for Cube

§

impl Send for Cube

§

impl Sync for Cube

§

impl Unpin for Cube

§

impl UnwindSafe for Cube

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> CustomValue for T
where T: Any + Send + Sync + Clone + PartialEq + Debug,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Downcasts the type as Any
Source§

fn deep_clone(&self) -> Arc<dyn CustomValue>

Returns a deep clone of the object. Read more
Source§

fn eq_box(&self, other: &(dyn CustomValue + 'static)) -> bool

Performs semantic equality on the boxed object. Read more
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<I> IntoStreamingIterator for I
where I: IntoIterator,

Source§

fn into_streaming_iter(self) -> Convert<Self::IntoIter>

Source§

fn into_streaming_iter_ref<'a, T>(self) -> ConvertRef<'a, Self::IntoIter, T>
where Self: IntoIterator<Item = &'a T>, T: ?Sized,

Turns an IntoIterator of references into a StreamingIterator. Read more
Source§

fn into_streaming_iter_mut<'a, T>(self) -> ConvertMut<'a, Self::IntoIter, T>
where Self: IntoIterator<Item = &'a mut T>, T: ?Sized,

Turns an IntoIterator of mutable references into a StreamingIteratorMut. Read more
Source§

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

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T