Skip to main content

InputElement

Trait InputElement 

Source
pub unsafe trait InputElement: 'static {
    type Column;
    type View<'a>: ViewLen;
    type Elem<'a>;

    const DENSE_SAFE: bool;
    const DECODE_INFALLIBLE: bool;

    // Required methods
    fn validate(dtype: &DType) -> VortexResult<()>;
    fn decode(
        array: ArrayRef,
        ctx: &mut ExecutionCtx,
    ) -> VortexResult<Self::Column>;
    fn get(column: &Self::Column, index: usize) -> Self::Elem<'_>;
    fn view(column: &Self::Column) -> Self::View<'_>;
    fn get_from_view<'a>(view: &Self::View<'a>, index: usize) -> Self::Elem<'a>
       where Self: 'a;

    // Provided methods
    fn can_decode_null_tolerant(_array: &ArrayRef) -> VortexResult<bool> { ... }
    fn decode_null_tolerant(
        array: ArrayRef,
        ctx: &mut ExecutionCtx,
    ) -> VortexResult<Option<Self::Column>> { ... }
    unsafe fn get_from_view_unchecked<'a>(
        view: &Self::View<'a>,
        index: usize,
    ) -> Self::Elem<'a>
       where Self: 'a { ... }
}
Expand description

An element type that can be read row-wise out of an input column.

§Safety

  • For each view returned by view, every index below ViewLen::len must satisfy the contract of get_from_view_unchecked.
  • The view length and its addressable indices must remain stable while the view exists. Interior mutability exposed through an element must not change either property.
  • Shared execution checks the length once before unchecked reads. Violating these requirements can cause undefined behavior.

Required Associated Constants§

Source

const DENSE_SAFE: bool

Whether every dense decode and access path tolerates rows that are null in the input.

Arrays guarantee payloads only for valid rows. Set this to true only when every decode and access method remains safe for null rows. Dense execution can pass unspecified values from null rows to the row closure.

Source

const DECODE_INFALLIBLE: bool

Whether decode is infallible for legal input data.

This excludes infrastructural failures such as IO or allocation.

Required Associated Types§

Source

type Column

The decoded column representation supporting O(1) row access.

Source

type View<'a>: ViewLen

The row-loop view of a decoded column.

This can borrow a cheaper representation than Column. Primitive elements, for example, expose a slice so its pointer and length are loop invariants rather than re-reading a Buffer descriptor for every row.

Source

type Elem<'a>

The borrowed element value handed to a row closure.

Required Methods§

Source

fn validate(dtype: &DType) -> VortexResult<()>

Validate that dtype is an acceptable input column dtype for this element type.

Source

fn decode(array: ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<Self::Column>

Decode array into its column representation.

Called once per row-kernel invocation. Hoist dtype checks, downcasts, and other invocation-invariant work into this method.

Source

fn get(column: &Self::Column, index: usize) -> Self::Elem<'_>

Read one row without repeating batch-constant work from decode.

Source

fn view(column: &Self::Column) -> Self::View<'_>

Borrow the representation used when this argument varies within the batch.

Called once before the hot loop. Constants do not use this view because the tuple adapter keeps their one-row decoded representation separate.

Source

fn get_from_view<'a>(view: &Self::View<'a>, index: usize) -> Self::Elem<'a>
where Self: 'a,

Read one row from a View.

Provided Methods§

Source

fn can_decode_null_tolerant(_array: &ArrayRef) -> VortexResult<bool>

Whether decode_null_tolerant can decode this array.

The conservative default declines. An implementation whose ordinary decode is safe and infallible over null payloads can return true. Other implementations can inspect array and opt in only for supported representations.

Source

fn decode_null_tolerant( array: ArrayRef, ctx: &mut ExecutionCtx, ) -> VortexResult<Option<Self::Column>>

Decode array without assuming every row is valid, or return Ok(None) when this element cannot decode this particular array.

Override this for a non-dense-safe representation that can still place safe placeholders in null slots. Valid-row execution never reads those slots.

Source

unsafe fn get_from_view_unchecked<'a>( view: &Self::View<'a>, index: usize, ) -> Self::Elem<'a>
where Self: 'a,

Read one row without checking that index is in bounds.

§Safety

index must be less than ViewLen::len for view.

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 InputElement for bool

Source§

const DENSE_SAFE: bool = true

Source§

const DECODE_INFALLIBLE: bool = true

Source§

type Column = BitBuffer

Source§

type View<'a> = &'a BitBuffer

Source§

type Elem<'a> = bool

Source§

fn validate(dtype: &DType) -> VortexResult<()>

Source§

fn decode(array: ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<Self::Column>

Source§

fn can_decode_null_tolerant(_array: &ArrayRef) -> VortexResult<bool>

Source§

fn get(column: &Self::Column, index: usize) -> bool

Source§

fn view(column: &Self::Column) -> Self::View<'_>

Source§

fn get_from_view<'a>(view: &Self::View<'a>, index: usize) -> bool
where Self: 'a,

Source§

unsafe fn get_from_view_unchecked<'a>( view: &Self::View<'a>, index: usize, ) -> bool
where Self: 'a,

Implementors§

Source§

impl<T: NativePType> InputElement for T

Source§

const DENSE_SAFE: bool = true

Source§

const DECODE_INFALLIBLE: bool = true

Source§

type Column = Buffer<T>

Source§

type View<'a> = &'a [T]

Source§

type Elem<'a> = T