ella_tensor

Trait TensorValue

Source
pub trait TensorValue:
    Debug
    + Clone
    + PartialEq
    + PartialOrd
    + Send
    + Sync
    + 'static {
    type Array: Array + Clone + 'static;
    type Masked: TensorValue<Array = Self::Array>;
    type Unmasked: TensorValue<Array = Self::Array>;

    const TENSOR_TYPE: TensorType;
    const NULLABLE: bool;

    // Required methods
    fn value(array: &Self::Array, i: usize) -> Self;
    unsafe fn value_unchecked(array: &Self::Array, i: usize) -> Self;
    fn to_masked(value: Self) -> Self::Masked;
    fn to_unmasked(value: Self) -> Self::Unmasked;
    fn from_iter_masked<I>(iter: I) -> Self::Array
       where I: IntoIterator<Item = Self::Masked>;
    fn from_vec(values: Vec<Self>) -> Self::Array;
    unsafe fn from_trusted_len_iter_masked<I>(iter: I) -> Self::Array
       where I: IntoIterator<Item = Self::Masked>;
    fn slice(array: &Self::Array, offset: usize, length: usize) -> Self::Array;
    fn from_array_data(data: ArrayData) -> Self::Array;
    fn format(&self, f: &mut Formatter<'_>) -> Result<(), Error>;

    // Provided methods
    fn from_iter<I>(iter: I) -> Self::Array
       where I: IntoIterator<Item = Self> { ... }
    unsafe fn from_trusted_len_iter<I>(iter: I) -> Self::Array
       where I: IntoIterator<Item = Self> { ... }
}
Expand description

A trait for data that can be stored as in a tensor.

Required Associated Constants§

Source

const TENSOR_TYPE: TensorType

Source

const NULLABLE: bool

Whether this type is nullable/maskable. Should be false for all types except Option<T>.

Required Associated Types§

Source

type Array: Array + Clone + 'static

Arrow array type used to store raw values.

Source

type Masked: TensorValue<Array = Self::Array>

Masked value type. For Option<T> this is Option<T>. For all other T this should be Option<T>.

Source

type Unmasked: TensorValue<Array = Self::Array>

Unmasked value type. For Option<T> this is T. For all other T this should be T.

Required Methods§

Source

fn value(array: &Self::Array, i: usize) -> Self

Returns the value at index i in array. Panics if i >= array.len().

Source

unsafe fn value_unchecked(array: &Self::Array, i: usize) -> Self

Returns the value at index i without bounds checking.

§Safety

Calling this method where i >= array.len() is undefined behavior.

Source

fn to_masked(value: Self) -> Self::Masked

Wrap value in its masked type.

For Option<T> this is a no-op. For all other types this returns Some(T).

Source

fn to_unmasked(value: Self) -> Self::Unmasked

Unwrap the inner value from its masked type.

For Option<T> this method panics unless value is Some(T). For all other types this is a no-op.

Source

fn from_iter_masked<I>(iter: I) -> Self::Array
where I: IntoIterator<Item = Self::Masked>,

Constructs an array from an iterator of masked values.

Source

fn from_vec(values: Vec<Self>) -> Self::Array

Source

unsafe fn from_trusted_len_iter_masked<I>(iter: I) -> Self::Array
where I: IntoIterator<Item = Self::Masked>,

Constructs an array from an iterator of masked values.

iter must implement ExactSizeIterator.

§Safety

Calling this method with an iterator that doesn’t correctly report its length is undefined behavior.

Source

fn slice(array: &Self::Array, offset: usize, length: usize) -> Self::Array

Returns a slice of array from offset to offset + length.

Panics if offset + length > array.len().

Source

fn from_array_data(data: ArrayData) -> Self::Array

Constructs an array from ArrayData.

Panics if data is not convertable to Self::Array.

Source

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

Writes the value of self to formatter f.

Provided Methods§

Source

fn from_iter<I>(iter: I) -> Self::Array
where I: IntoIterator<Item = Self>,

Constructs an array from an iterator of values.

Source

unsafe fn from_trusted_len_iter<I>(iter: I) -> Self::Array
where I: IntoIterator<Item = Self>,

Constructs an array from an iterator of values.

iter must implement ExactSizeIterator.

§Safety

Calling this method with an iterator that doesn’t correctly report its length is undefined behavior.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TensorValue for bool

Source§

const TENSOR_TYPE: TensorType = TensorType::Bool

Source§

const NULLABLE: bool = false

Source§

type Array = BooleanArray

Source§

type Masked = Option<bool>

Source§

type Unmasked = bool

Source§

fn value(array: &<bool as TensorValue>::Array, i: usize) -> bool

Source§

unsafe fn value_unchecked( array: &<bool as TensorValue>::Array, i: usize, ) -> bool

Source§

fn to_masked(value: bool) -> <bool as TensorValue>::Masked

Source§

fn to_unmasked(value: bool) -> <bool as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <bool as TensorValue>::Array
where I: IntoIterator<Item = <bool as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<bool>) -> <bool as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <bool as TensorValue>::Array
where I: IntoIterator<Item = <bool as TensorValue>::Masked>,

Source§

fn slice( array: &<bool as TensorValue>::Array, offset: usize, length: usize, ) -> <bool as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <bool as TensorValue>::Array

Source§

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

Source§

impl TensorValue for f32

Source§

const TENSOR_TYPE: TensorType = TensorType::Float32

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<Float32Type>

Source§

type Masked = Option<f32>

Source§

type Unmasked = f32

Source§

fn value(array: &<f32 as TensorValue>::Array, i: usize) -> f32

Source§

unsafe fn value_unchecked(array: &<f32 as TensorValue>::Array, i: usize) -> f32

Source§

fn to_masked(value: f32) -> <f32 as TensorValue>::Masked

Source§

fn to_unmasked(value: f32) -> <f32 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <f32 as TensorValue>::Array
where I: IntoIterator<Item = <f32 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<f32>) -> <f32 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <f32 as TensorValue>::Array
where I: IntoIterator<Item = <f32 as TensorValue>::Masked>,

Source§

fn slice( array: &<f32 as TensorValue>::Array, offset: usize, length: usize, ) -> <f32 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <f32 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for f64

Source§

const TENSOR_TYPE: TensorType = TensorType::Float64

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<Float64Type>

Source§

type Masked = Option<f64>

Source§

type Unmasked = f64

Source§

fn value(array: &<f64 as TensorValue>::Array, i: usize) -> f64

Source§

unsafe fn value_unchecked(array: &<f64 as TensorValue>::Array, i: usize) -> f64

Source§

fn to_masked(value: f64) -> <f64 as TensorValue>::Masked

Source§

fn to_unmasked(value: f64) -> <f64 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <f64 as TensorValue>::Array
where I: IntoIterator<Item = <f64 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<f64>) -> <f64 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <f64 as TensorValue>::Array
where I: IntoIterator<Item = <f64 as TensorValue>::Masked>,

Source§

fn slice( array: &<f64 as TensorValue>::Array, offset: usize, length: usize, ) -> <f64 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <f64 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for i8

Source§

const TENSOR_TYPE: TensorType = TensorType::Int8

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<Int8Type>

Source§

type Masked = Option<i8>

Source§

type Unmasked = i8

Source§

fn value(array: &<i8 as TensorValue>::Array, i: usize) -> i8

Source§

unsafe fn value_unchecked(array: &<i8 as TensorValue>::Array, i: usize) -> i8

Source§

fn to_masked(value: i8) -> <i8 as TensorValue>::Masked

Source§

fn to_unmasked(value: i8) -> <i8 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <i8 as TensorValue>::Array
where I: IntoIterator<Item = <i8 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<i8>) -> <i8 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>(iter: I) -> <i8 as TensorValue>::Array
where I: IntoIterator<Item = <i8 as TensorValue>::Masked>,

Source§

fn slice( array: &<i8 as TensorValue>::Array, offset: usize, length: usize, ) -> <i8 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <i8 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for i16

Source§

const TENSOR_TYPE: TensorType = TensorType::Int16

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<Int16Type>

Source§

type Masked = Option<i16>

Source§

type Unmasked = i16

Source§

fn value(array: &<i16 as TensorValue>::Array, i: usize) -> i16

Source§

unsafe fn value_unchecked(array: &<i16 as TensorValue>::Array, i: usize) -> i16

Source§

fn to_masked(value: i16) -> <i16 as TensorValue>::Masked

Source§

fn to_unmasked(value: i16) -> <i16 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <i16 as TensorValue>::Array
where I: IntoIterator<Item = <i16 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<i16>) -> <i16 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <i16 as TensorValue>::Array
where I: IntoIterator<Item = <i16 as TensorValue>::Masked>,

Source§

fn slice( array: &<i16 as TensorValue>::Array, offset: usize, length: usize, ) -> <i16 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <i16 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for i32

Source§

const TENSOR_TYPE: TensorType = TensorType::Int32

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<Int32Type>

Source§

type Masked = Option<i32>

Source§

type Unmasked = i32

Source§

fn value(array: &<i32 as TensorValue>::Array, i: usize) -> i32

Source§

unsafe fn value_unchecked(array: &<i32 as TensorValue>::Array, i: usize) -> i32

Source§

fn to_masked(value: i32) -> <i32 as TensorValue>::Masked

Source§

fn to_unmasked(value: i32) -> <i32 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <i32 as TensorValue>::Array
where I: IntoIterator<Item = <i32 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<i32>) -> <i32 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <i32 as TensorValue>::Array
where I: IntoIterator<Item = <i32 as TensorValue>::Masked>,

Source§

fn slice( array: &<i32 as TensorValue>::Array, offset: usize, length: usize, ) -> <i32 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <i32 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for i64

Source§

const TENSOR_TYPE: TensorType = TensorType::Int64

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<Int64Type>

Source§

type Masked = Option<i64>

Source§

type Unmasked = i64

Source§

fn value(array: &<i64 as TensorValue>::Array, i: usize) -> i64

Source§

unsafe fn value_unchecked(array: &<i64 as TensorValue>::Array, i: usize) -> i64

Source§

fn to_masked(value: i64) -> <i64 as TensorValue>::Masked

Source§

fn to_unmasked(value: i64) -> <i64 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <i64 as TensorValue>::Array
where I: IntoIterator<Item = <i64 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<i64>) -> <i64 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <i64 as TensorValue>::Array
where I: IntoIterator<Item = <i64 as TensorValue>::Masked>,

Source§

fn slice( array: &<i64 as TensorValue>::Array, offset: usize, length: usize, ) -> <i64 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <i64 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for u8

Source§

const TENSOR_TYPE: TensorType = TensorType::UInt8

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<UInt8Type>

Source§

type Masked = Option<u8>

Source§

type Unmasked = u8

Source§

fn value(array: &<u8 as TensorValue>::Array, i: usize) -> u8

Source§

unsafe fn value_unchecked(array: &<u8 as TensorValue>::Array, i: usize) -> u8

Source§

fn to_masked(value: u8) -> <u8 as TensorValue>::Masked

Source§

fn to_unmasked(value: u8) -> <u8 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <u8 as TensorValue>::Array
where I: IntoIterator<Item = <u8 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<u8>) -> <u8 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>(iter: I) -> <u8 as TensorValue>::Array
where I: IntoIterator<Item = <u8 as TensorValue>::Masked>,

Source§

fn slice( array: &<u8 as TensorValue>::Array, offset: usize, length: usize, ) -> <u8 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <u8 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for u16

Source§

const TENSOR_TYPE: TensorType = TensorType::UInt16

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<UInt16Type>

Source§

type Masked = Option<u16>

Source§

type Unmasked = u16

Source§

fn value(array: &<u16 as TensorValue>::Array, i: usize) -> u16

Source§

unsafe fn value_unchecked(array: &<u16 as TensorValue>::Array, i: usize) -> u16

Source§

fn to_masked(value: u16) -> <u16 as TensorValue>::Masked

Source§

fn to_unmasked(value: u16) -> <u16 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <u16 as TensorValue>::Array
where I: IntoIterator<Item = <u16 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<u16>) -> <u16 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <u16 as TensorValue>::Array
where I: IntoIterator<Item = <u16 as TensorValue>::Masked>,

Source§

fn slice( array: &<u16 as TensorValue>::Array, offset: usize, length: usize, ) -> <u16 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <u16 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for u32

Source§

const TENSOR_TYPE: TensorType = TensorType::UInt32

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<UInt32Type>

Source§

type Masked = Option<u32>

Source§

type Unmasked = u32

Source§

fn value(array: &<u32 as TensorValue>::Array, i: usize) -> u32

Source§

unsafe fn value_unchecked(array: &<u32 as TensorValue>::Array, i: usize) -> u32

Source§

fn to_masked(value: u32) -> <u32 as TensorValue>::Masked

Source§

fn to_unmasked(value: u32) -> <u32 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <u32 as TensorValue>::Array
where I: IntoIterator<Item = <u32 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<u32>) -> <u32 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <u32 as TensorValue>::Array
where I: IntoIterator<Item = <u32 as TensorValue>::Masked>,

Source§

fn slice( array: &<u32 as TensorValue>::Array, offset: usize, length: usize, ) -> <u32 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <u32 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for u64

Source§

const TENSOR_TYPE: TensorType = TensorType::UInt64

Source§

const NULLABLE: bool = false

Source§

type Array = PrimitiveArray<UInt64Type>

Source§

type Masked = Option<u64>

Source§

type Unmasked = u64

Source§

fn value(array: &<u64 as TensorValue>::Array, i: usize) -> u64

Source§

unsafe fn value_unchecked(array: &<u64 as TensorValue>::Array, i: usize) -> u64

Source§

fn to_masked(value: u64) -> <u64 as TensorValue>::Masked

Source§

fn to_unmasked(value: u64) -> <u64 as TensorValue>::Unmasked

Source§

fn from_iter_masked<I>(iter: I) -> <u64 as TensorValue>::Array
where I: IntoIterator<Item = <u64 as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<u64>) -> <u64 as TensorValue>::Array

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <u64 as TensorValue>::Array
where I: IntoIterator<Item = <u64 as TensorValue>::Masked>,

Source§

fn slice( array: &<u64 as TensorValue>::Array, offset: usize, length: usize, ) -> <u64 as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <u64 as TensorValue>::Array

Source§

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

Source§

impl TensorValue for String

Source§

impl TensorValue for Duration

Source§

impl TensorValue for OffsetDateTime

Source§

impl<T> TensorValue for Option<T>
where T: TensorValue<Masked = Option<T>>,

Source§

const TENSOR_TYPE: TensorType = T::TENSOR_TYPE

Source§

const NULLABLE: bool = true

Source§

type Array = <T as TensorValue>::Array

Source§

type Masked = Option<T>

Source§

type Unmasked = T

Source§

fn value(array: &<Option<T> as TensorValue>::Array, i: usize) -> Option<T>

Source§

unsafe fn value_unchecked( array: &<Option<T> as TensorValue>::Array, i: usize, ) -> Option<T>

Source§

fn to_masked(value: Option<T>) -> <Option<T> as TensorValue>::Masked

Source§

fn to_unmasked(value: Option<T>) -> <Option<T> as TensorValue>::Unmasked

Source§

unsafe fn from_trusted_len_iter_masked<I>( iter: I, ) -> <Option<T> as TensorValue>::Array
where I: IntoIterator<Item = <Option<T> as TensorValue>::Masked>,

Source§

unsafe fn from_trusted_len_iter<I>(iter: I) -> <Option<T> as TensorValue>::Array
where I: IntoIterator<Item = Option<T>>,

Source§

fn from_iter_masked<I>(iter: I) -> <Option<T> as TensorValue>::Array
where I: IntoIterator<Item = <Option<T> as TensorValue>::Masked>,

Source§

fn from_vec(values: Vec<Option<T>>) -> <Option<T> as TensorValue>::Array

Source§

fn slice( array: &<Option<T> as TensorValue>::Array, offset: usize, length: usize, ) -> <Option<T> as TensorValue>::Array

Source§

fn from_array_data(data: ArrayData) -> <Option<T> as TensorValue>::Array

Source§

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

Implementors§