Skip to main content

BlockView

Struct BlockView 

Source
pub struct BlockView<'a> { /* private fields */ }
Expand description

A borrowed, read-only view of a Block.

Keys are &str references into the original Block’s key strings. Values are ColumnViews that borrow the underlying array data.

Implementations§

Source§

impl<'a> BlockView<'a>

Source

pub fn new() -> BlockView<'a>

Creates an empty BlockView.

Source

pub fn insert(&mut self, key: &'a str, col: ColumnView<'a>)

Inserts a column view under the given key.

If the BlockView was empty, nrows is set from the column’s axis-0 length. Subsequent insertions are not validated for consistency (caller is responsible).

Source

pub fn len(&self) -> usize

Number of columns in the view.

Source

pub fn is_empty(&self) -> bool

Returns true if the view contains no columns.

Source

pub fn nrows(&self) -> Option<usize>

Returns the common axis-0 length, or None if empty.

Source

pub fn contains_key(&self, key: &str) -> bool

Returns true if the view contains the specified key.

Source

pub fn get(&self, key: &str) -> Option<&ColumnView<'a>>

Gets an immutable reference to the column view for key if present.

Source

pub fn get_float( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&'a f64>, Dim<IxDynImpl>>>

Gets a float array view for key if present and of correct type.

Source

pub fn get_int( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&'a i32>, Dim<IxDynImpl>>>

Gets an int array view for key if present and of correct type.

Source

pub fn get_bool( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&'a bool>, Dim<IxDynImpl>>>

Gets a bool array view for key if present and of correct type.

Source

pub fn get_uint( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&'a u32>, Dim<IxDynImpl>>>

Gets a uint array view for key if present and of correct type.

Source

pub fn get_u8( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&'a u8>, Dim<IxDynImpl>>>

Gets a u8 array view for key if present and of correct type.

Source

pub fn get_string( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&'a String>, Dim<IxDynImpl>>>

Gets a string array view for key if present and of correct type.

Source

pub fn iter(&self) -> impl Iterator<Item = (&&'a str, &ColumnView<'a>)>

Returns an iterator over (&str, &ColumnView).

Source

pub fn keys(&self) -> impl Iterator<Item = &&'a str>

Returns an iterator over column keys.

Source

pub fn values(&self) -> impl Iterator<Item = &ColumnView<'a>>

Returns an iterator over column view references.

Source

pub fn dtype(&self, key: &str) -> Option<DType>

Returns the data type of the column with the given key, if it exists.

Source

pub fn to_owned(&self) -> Block

Creates an owned Block by cloning all viewed data.

Trait Implementations§

Source§

impl BlockAccess for BlockView<'_>

Source§

fn get_float_view( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&f64>, Dim<IxDynImpl>>>

Gets a float array view for key if present and of correct type.
Source§

fn get_int_view( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&i32>, Dim<IxDynImpl>>>

Gets an int array view for key if present and of correct type.
Source§

fn get_bool_view( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&bool>, Dim<IxDynImpl>>>

Gets a bool array view for key if present and of correct type.
Source§

fn get_uint_view( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&u32>, Dim<IxDynImpl>>>

Gets a uint array view for key if present and of correct type.
Source§

fn get_u8_view( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&u8>, Dim<IxDynImpl>>>

Gets a u8 array view for key if present and of correct type.
Source§

fn get_string_view( &self, key: &str, ) -> Option<ArrayBase<ViewRepr<&String>, Dim<IxDynImpl>>>

Gets a string array view for key if present and of correct type.
Source§

fn nrows(&self) -> Option<usize>

Returns the common axis-0 length, or None if empty.
Source§

fn len(&self) -> usize

Number of columns.
Source§

fn is_empty(&self) -> bool

Returns true if there are no columns.
Source§

fn contains_key(&self, key: &str) -> bool

Returns true if the block contains the specified key.
Source§

fn column_keys(&self) -> Vec<&str>

Returns column keys as a Vec.
Source§

fn column_dtype(&self, key: &str) -> Option<DType>

Returns the data type of the column with the given key, if it exists.
Source§

fn column_shape(&self, key: &str) -> Option<Vec<usize>>

Returns the shape of the column with the given key, if it exists.
Source§

impl Debug for BlockView<'_>

Source§

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

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

impl<'a> Default for BlockView<'a>

Source§

fn default() -> BlockView<'a>

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

impl<'a> From<&'a Block> for BlockView<'a>

Source§

fn from(block: &'a Block) -> BlockView<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for BlockView<'a>

§

impl<'a> RefUnwindSafe for BlockView<'a>

§

impl<'a> Send for BlockView<'a>

§

impl<'a> Sync for BlockView<'a>

§

impl<'a> Unpin for BlockView<'a>

§

impl<'a> UnsafeUnpin for BlockView<'a>

§

impl<'a> UnwindSafe for BlockView<'a>

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> 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, 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.