ella_common

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;

    // 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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

Source§

impl TensorValue for String

Source§

const TENSOR_TYPE: TensorType = TensorType::String

Source§

const NULLABLE: bool = false

Source§

type Array = GenericByteArray<GenericStringType<i32>>

Source§

type Masked = Option<String>

Source§

type Unmasked = String

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

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

Source§

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

Source§

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

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: &Self::Array, i: usize) -> Self

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§