Skip to main content

LogicalType

Trait LogicalType 

Source
pub trait LogicalType {
    type Typed: Clone;
    type Value<'a>
       where Self: 'a;
    type Owned;

    const NULLABLE: bool = false;

    // Required methods
    fn downcast(array: &dyn Array) -> Result<Self::Typed, ColumnError>;
    fn is_null(typed: &Self::Typed, index: usize) -> bool;
    fn value(typed: &Self::Typed, index: usize) -> Self::Value<'_>;
    fn to_owned_value(value: Self::Value<'_>) -> Self::Owned;
}
Expand description

A logical column type, e.g. Utf8, Option<i64>, or List<Utf8>.

Option<L> means the values at this nesting level may be null.

The primitive Rust types implement it directly, and Option<L> adds nullability at any nesting level:

use quiver::Column;

let numbers = Column::<i64>::from_values([1, 2, 3]);
assert_eq!(numbers.value(0), 1);
assert_eq!(numbers.as_slice(), &[1, 2, 3]); // bulk, zero-copy (not for `bool`)

let maybe = Column::<Option<i64>>::from_values([Some(1), None]);
assert_eq!(maybe.value(1), None);

Provided Associated Constants§

Source

const NULLABLE: bool = false

May the values at this level be null? (true only for Option<…>)

Required Associated Types§

Source

type Typed: Clone

The fully-downcast, validated representation of one column of this datatype. Cheap to clone (arrow arrays are reference-counted).

Source

type Value<'a> where Self: 'a

Zero-copy element view: &'a str for Utf8, i64 for i64, an iterator for List<T>, Option<…> for Option<T>.

Source

type Owned

The owned value of one element, used by the convenience constructors: String for Utf8, Option<i64> for Option<i64>, Vec<…> for List<…>, etc.

Required Methods§

Source

fn downcast(array: &dyn Array) -> Result<Self::Typed, ColumnError>

Validates that array has an acceptable datatype, then recursively downcasts it — checking the nulls of all children along the way.

This is the single validation+downcast hook, called once per column at the boundary (Column::try_new). It must reject any array whose datatype this logical type does not accept (returning ColumnError::WrongDatatype), including datatype parameters not encoded in the concrete arrow array’s Rust type — a FixedSizeBinary / FixedSizeList size, a Timestamp timezone, etc. The leaf type check comes from the concrete-array downcast; nested element types are validated by recursing into the children’s downcast.

Multi-encoding types like AnyList inspect array.data_type() and dispatch to the matching encoding.

Nulls at the level of array itself are the responsibility of the caller (the parent datatype, or Column::try_new at the top level), because only the caller knows if this level is wrapped in an Option.

§Errors

Errors on a datatype mismatch, or on unexpected nulls in children.

Source

fn is_null(typed: &Self::Typed, index: usize) -> bool

Is the value at index null?

Source

fn value(typed: &Self::Typed, index: usize) -> Self::Value<'_>

The value at index.

Contract: index is in bounds, and the value is non-null unless Self is an Option.

Source

fn to_owned_value(value: Self::Value<'_>) -> Self::Owned

Converts a borrowed element value into an owned one, e.g. &strString.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl LogicalType for bool

Source§

impl LogicalType for f32

Source§

impl LogicalType for f64

Source§

impl LogicalType for i8

Source§

type Typed = PrimitiveArray<Int8Type>

Source§

type Value<'a> = i8

Source§

type Owned = i8

Source§

fn downcast( array: &dyn Array, ) -> Result<<i8 as LogicalType>::Typed, ColumnError>

Source§

fn is_null(typed: &<i8 as LogicalType>::Typed, index: usize) -> bool

Source§

fn value( typed: &<i8 as LogicalType>::Typed, index: usize, ) -> <i8 as LogicalType>::Value<'_>

Source§

fn to_owned_value( value: <i8 as LogicalType>::Value<'_>, ) -> <i8 as LogicalType>::Owned

Source§

impl LogicalType for i16

Source§

impl LogicalType for i32

Source§

impl LogicalType for i64

Source§

impl LogicalType for u8

Source§

type Typed = PrimitiveArray<UInt8Type>

Source§

type Value<'a> = u8

Source§

type Owned = u8

Source§

fn downcast( array: &dyn Array, ) -> Result<<u8 as LogicalType>::Typed, ColumnError>

Source§

fn is_null(typed: &<u8 as LogicalType>::Typed, index: usize) -> bool

Source§

fn value( typed: &<u8 as LogicalType>::Typed, index: usize, ) -> <u8 as LogicalType>::Value<'_>

Source§

fn to_owned_value( value: <u8 as LogicalType>::Value<'_>, ) -> <u8 as LogicalType>::Owned

Source§

impl LogicalType for u16

Source§

impl LogicalType for u32

Source§

impl LogicalType for u64

Source§

impl<L> LogicalType for Option<L>
where L: LogicalType,

Option<L>: the values at this level may be null.

Source§

const NULLABLE: bool = true

Source§

type Typed = <L as LogicalType>::Typed

Source§

type Value<'a> = Option<<L as LogicalType>::Value<'a>> where Option<L>: 'a

Source§

type Owned = Option<<L as LogicalType>::Owned>

Source§

fn downcast( array: &dyn Array, ) -> Result<<Option<L> as LogicalType>::Typed, ColumnError>

Source§

fn is_null(typed: &<Option<L> as LogicalType>::Typed, index: usize) -> bool

Source§

fn value( typed: &<Option<L> as LogicalType>::Typed, index: usize, ) -> <Option<L> as LogicalType>::Value<'_>

Source§

fn to_owned_value( value: <Option<L> as LogicalType>::Value<'_>, ) -> <Option<L> as LogicalType>::Owned

Implementors§

Source§

impl LogicalType for AnyBinary

Source§

impl LogicalType for AnyUtf8

Source§

impl LogicalType for Binary

Source§

impl LogicalType for BinaryView

Source§

impl LogicalType for Date32

Source§

impl LogicalType for Date64

Source§

impl LogicalType for LargeBinary

Source§

impl LogicalType for LargeUtf8

Source§

impl LogicalType for Time32Millisecond

Source§

impl LogicalType for Time32Second

Source§

impl LogicalType for Time64Microsecond

Source§

impl LogicalType for Time64Nanosecond

Source§

impl LogicalType for Utf8

Source§

impl LogicalType for Utf8View

Source§

impl LogicalType for f16

Source§

impl<K, V> LogicalType for Dictionary<K, V>
where K: DictionaryKey + 'static, V: LogicalType + 'static,

Source§

impl<K, V> LogicalType for Map<K, V>
where K: LogicalType + 'static, V: LogicalType + 'static,

Source§

type Typed = TypedMap<K, V>

Source§

type Value<'a> = MapValue<'a, K, V> where Map<K, V>: 'a

Source§

type Owned = Vec<(<K as LogicalType>::Owned, <V as LogicalType>::Owned)>

Source§

impl<L, const N: usize> LogicalType for FixedSizeList<L, N>
where L: LogicalType + 'static,

Source§

type Typed = TypedFixedSizeList<L>

Source§

type Value<'a> = ListValue<'a, L> where FixedSizeList<L, N>: 'a

Source§

type Owned = [<L as LogicalType>::Owned; N]

Source§

impl<L> LogicalType for AnyList<L>
where L: LogicalType + 'static,

Source§

type Typed = AnyTypedList<L>

Source§

type Value<'a> = ListValue<'a, L> where AnyList<L>: 'a

Source§

type Owned = Vec<<L as LogicalType>::Owned>

Source§

impl<L> LogicalType for LargeList<L>
where L: LogicalType + 'static,

Source§

type Typed = TypedLargeList<L>

Source§

type Value<'a> = ListValue<'a, L> where LargeList<L>: 'a

Source§

type Owned = Vec<<L as LogicalType>::Owned>

Source§

impl<L> LogicalType for LargeListView<L>
where L: LogicalType + 'static,

Source§

impl<L> LogicalType for List<L>
where L: LogicalType + 'static,

Source§

type Typed = TypedList<L>

Source§

type Value<'a> = ListValue<'a, L> where List<L>: 'a

Source§

type Owned = Vec<<L as LogicalType>::Owned>

Source§

impl<L> LogicalType for ListView<L>
where L: LogicalType + 'static,

Source§

type Typed = TypedListView<L>

Source§

type Value<'a> = ListValue<'a, L> where ListView<L>: 'a

Source§

type Owned = Vec<<L as LogicalType>::Owned>

Source§

impl<R, V> LogicalType for Run<R, V>
where R: RunEndType + 'static, V: LogicalType + 'static,

Source§

type Typed = TypedRun<R, V>

Source§

type Value<'a> = <V as LogicalType>::Value<'a>

Source§

type Owned = <V as LogicalType>::Owned

Source§

impl<T, Repr> LogicalType for As<T, Repr>
where T: 'static + From<<Repr as LogicalType>::Owned>, Repr: LogicalType + 'static, <Repr as LogicalType>::Owned: From<T>,

Source§

const NULLABLE: bool = Repr::NULLABLE

Source§

type Typed = <Repr as LogicalType>::Typed

Source§

type Value<'a> = <Repr as LogicalType>::Value<'a> where As<T, Repr>: 'a

Source§

type Owned = T

Source§

impl<U, Z> LogicalType for Timestamp<U, Z>
where U: TimeUnitSpec + 'static, Z: TimezoneSpec + 'static,

Source§

impl<U> LogicalType for Duration<U>
where U: TimeUnitSpec + 'static,

Source§

impl<const N: usize> LogicalType for FixedSizeBinary<N>