Skip to main content

Column

Struct Column 

Source
#[non_exhaustive]
pub struct Column { pub name: String, pub values: ColumnValues, pub validity: Option<Vec<bool>>, pub unit: Option<String>, pub metadata: BTreeMap<String, String>, }
Available on crate feature data only.
Expand description

One column with its name, type, validity, and metadata.

§Example

use crisol_core::data::Column;

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: String

Column name.

§values: ColumnValues

Storage and type.

§validity: Option<Vec<bool>>

A false entry marks a null cell. None means every cell is valid.

§unit: Option<String>

Unit text, such as V or s.

§metadata: BTreeMap<String, String>

Free-form metadata (source, precision, labels).

Implementations§

Source§

impl Column

Source

pub fn new(name: impl Into<String>, values: ColumnValues) -> Self

A column from storage.

Source

pub fn floats(name: impl Into<String>, values: impl Into<Arc<[f64]>>) -> Self

A float column.

Source

pub fn ints(name: impl Into<String>, values: impl Into<Arc<[i64]>>) -> Self

An integer column.

Source

pub fn bools(name: impl Into<String>, values: impl Into<Arc<[bool]>>) -> Self

A boolean column.

Source

pub fn text( name: impl Into<String>, values: impl IntoIterator<Item = impl Into<String>>, ) -> Self

A text column.

Source

pub fn dates(name: impl Into<String>, values: impl Into<Arc<[i64]>>) -> Self

A date column (days since the Unix epoch).

Source

pub fn times(name: impl Into<String>, values: impl Into<Arc<[i64]>>) -> Self

A time column (nanoseconds since the Unix epoch).

Source

pub fn categories( name: impl Into<String>, values: impl IntoIterator<Item = impl Into<String>>, ) -> Self

A category column.

Source

pub fn with_unit(self, unit: impl Into<String>) -> Self

Set the unit.

Source

pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Add metadata.

Source

pub fn with_validity(self, validity: impl IntoIterator<Item = bool>) -> Self

Set the validity mask. A shorter mask marks trailing cells invalid.

Source

pub fn kind(&self) -> ColumnType

The type.

Source

pub fn len(&self) -> usize

Number of values.

Source

pub fn is_empty(&self) -> bool

Whether the column is empty.

Source

pub fn is_valid(&self, row: usize) -> bool

Whether row has a value.

Source

pub fn cell(&self, row: usize) -> CellValue<'_>

A borrowed cell value.

Source

pub fn slice(&self, range: Range<usize>) -> Self

A copy of rows in range.

Source§

impl Column

Source

pub fn converted(&self, unit: &str) -> Result<Self, UnitError>

Convert this numeric column to unit, preserving nulls and metadata.

§Errors

When either unit is unknown or the column is not numeric.

Trait Implementations§

Source§

impl Clone for Column

Source§

fn clone(&self) -> Self

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 Column

Source§

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

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

impl<'de> Deserialize<'de> for Column

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Column

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Column

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Column

Auto Trait Implementations§

§

impl Forget for Column

§

impl Freeze for Column
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<[f64]> is !null: Freeze, PhantomData<ArcInner<[f64]>>: Freeze, *const ArcInner<[i64]> is !null: Freeze, PhantomData<ArcInner<[i64]>>: Freeze, *const ArcInner<[bool]> is !null: Freeze, PhantomData<ArcInner<[bool]>>: Freeze, *const ArcInner<[String]> is !null: Freeze, PhantomData<ArcInner<[String]>>: Freeze, PhantomData<bool>: Freeze, *const LeafNode<String, String> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, String)>>: Freeze,

§

impl Move for Column

§

impl RefUnwindSafe for Column

§

impl Send for Column
where RawVecInner: Send, Arc<[f64]>: Send, Arc<[i64]>: Send, Arc<[bool]>: Send, Arc<[String]>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send,

§

impl Sync for Column
where RawVecInner: Sync, Arc<[f64]>: Sync, Arc<[i64]>: Sync, Arc<[bool]>: Sync, Arc<[String]>: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync,

§

impl Unpin for Column
where *const u8 is !null: Unpin, Arc<[f64]>: Unpin, Arc<[i64]>: Unpin, Arc<[bool]>: Unpin, Arc<[String]>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin,

§

impl UnsafeUnpin for Column
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<[f64]> is !null: UnsafeUnpin, PhantomData<ArcInner<[f64]>>: UnsafeUnpin, *const ArcInner<[i64]> is !null: UnsafeUnpin, PhantomData<ArcInner<[i64]>>: UnsafeUnpin, *const ArcInner<[bool]> is !null: UnsafeUnpin, PhantomData<ArcInner<[bool]>>: UnsafeUnpin, *const ArcInner<[String]> is !null: UnsafeUnpin, PhantomData<ArcInner<[String]>>: UnsafeUnpin, PhantomData<bool>: UnsafeUnpin, *const LeafNode<String, String> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, String)>>: UnsafeUnpin,

§

impl UnwindSafe for Column

Blanket Implementations§

Source§

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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, 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<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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.