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 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 shis is T. For all other T this should be T.

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 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::Arraywhere 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::Arraywhere 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 [ArrowData].

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::Arraywhere I: IntoIterator<Item = Self>,

Constructs an array from an iterator of values.

source

unsafe fn from_trusted_len_iter<I>(iter: I) -> Self::Arraywhere 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.

Implementations on Foreign Types§

source§

impl TensorValue for u16

§

type Array = PrimitiveArray<UInt16Type>

§

type Masked = Option<u16>

§

type Unmasked = u16

source§

const TENSOR_TYPE: TensorType = TensorType::UInt16

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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 bool

§

type Array = BooleanArray

§

type Masked = Option<bool>

§

type Unmasked = bool

source§

const TENSOR_TYPE: TensorType = TensorType::Bool

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

§

type Array = PrimitiveArray<Int16Type>

§

type Masked = Option<i16>

§

type Unmasked = i16

source§

const TENSOR_TYPE: TensorType = TensorType::Int16

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

§

type Array = GenericByteArray<GenericStringType<i32>>

§

type Masked = Option<String>

§

type Unmasked = String

source§

const TENSOR_TYPE: TensorType = TensorType::String

source§

const NULLABLE: bool = false

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

§

type Array = <T as TensorValue>::Array

§

type Masked = Option<T>

§

type Unmasked = T

source§

const TENSOR_TYPE: TensorType = T::TENSOR_TYPE

source§

const NULLABLE: bool = true

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::Arraywhere I: IntoIterator<Item = Self::Masked>,

source§

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

source§

fn from_iter_masked<I>(iter: I) -> Self::Arraywhere 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

source§

impl TensorValue for i32

§

type Array = PrimitiveArray<Int32Type>

§

type Masked = Option<i32>

§

type Unmasked = i32

source§

const TENSOR_TYPE: TensorType = TensorType::Int32

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

§

type Array = PrimitiveArray<UInt8Type>

§

type Masked = Option<u8>

§

type Unmasked = u8

source§

const TENSOR_TYPE: TensorType = TensorType::UInt8

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

§

type Array = PrimitiveArray<Int64Type>

§

type Masked = Option<i64>

§

type Unmasked = i64

source§

const TENSOR_TYPE: TensorType = TensorType::Int64

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

§

type Array = PrimitiveArray<Float64Type>

§

type Masked = Option<f64>

§

type Unmasked = f64

source§

const TENSOR_TYPE: TensorType = TensorType::Float64

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

§

type Array = PrimitiveArray<Float32Type>

§

type Masked = Option<f32>

§

type Unmasked = f32

source§

const TENSOR_TYPE: TensorType = TensorType::Float32

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

§

type Array = PrimitiveArray<Int8Type>

§

type Masked = Option<i8>

§

type Unmasked = i8

source§

const TENSOR_TYPE: TensorType = TensorType::Int8

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

§

type Array = PrimitiveArray<UInt64Type>

§

type Masked = Option<u64>

§

type Unmasked = u64

source§

const TENSOR_TYPE: TensorType = TensorType::UInt64

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

§

type Array = PrimitiveArray<UInt32Type>

§

type Masked = Option<u32>

§

type Unmasked = u32

source§

const TENSOR_TYPE: TensorType = TensorType::UInt32

source§

const NULLABLE: bool = false

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::Arraywhere 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::Arraywhere 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

Implementors§

source§

impl TensorValue for Duration

§

type Array = PrimitiveArray<DurationNanosecondType>

§

type Masked = Option<Duration>

§

type Unmasked = Duration

source§

const TENSOR_TYPE: TensorType = TensorType::Duration

source§

const NULLABLE: bool = false

source§

impl TensorValue for OffsetDateTime

§

type Array = PrimitiveArray<TimestampNanosecondType>

§

type Masked = Option<OffsetDateTime>

§

type Unmasked = OffsetDateTime

source§

const TENSOR_TYPE: TensorType = TensorType::Timestamp

source§

const NULLABLE: bool = false

source§

impl TensorValue for Time

§

type Array = PrimitiveArray<TimestampNanosecondType>

§

type Masked = Option<Time>

§

type Unmasked = Time

source§

const TENSOR_TYPE: TensorType = TensorType::Timestamp

source§

const NULLABLE: bool = false