pub unsafe trait InputElement: 'static {
type Column;
type Constant;
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 decode_constant(
array: ArrayRef,
ctx: &mut ExecutionCtx,
) -> VortexResult<Self::Constant>;
fn get(column: &Self::Column, index: usize) -> Self::Elem<'_>;
fn get_constant(constant: &Self::Constant) -> 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 belowViewLen::lenmust satisfy the contract ofget_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§
Sourceconst DENSE_SAFE: bool
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.
Sourceconst DECODE_INFALLIBLE: bool
const DECODE_INFALLIBLE: bool
Whether decode is infallible for legal input data.
This excludes infrastructural failures such as IO or allocation.
It is independent of
RowFn::INFALLIBLE, which describes
the row operation rather than input decoding.
Required Associated Types§
Sourcetype Constant
type Constant
The decoded representation of one non-null batch-constant input.
This representation stores one logical value regardless of the input array’s batch length.
Required Methods§
Sourcefn validate(dtype: &DType) -> VortexResult<()>
fn validate(dtype: &DType) -> VortexResult<()>
Validate that dtype is an acceptable input column dtype for this element type.
Sourcefn decode(array: ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<Self::Column>
fn decode(array: ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<Self::Column>
Decode array into its column representation.
Called once per row-kernel invocation. Retrying a partially valid batch after a dense deferred error starts a second invocation over valid rows. Hoist dtype checks, downcasts, and other invocation-invariant work into this method.
Sourcefn decode_constant(
array: ArrayRef,
ctx: &mut ExecutionCtx,
) -> VortexResult<Self::Constant>
fn decode_constant( array: ArrayRef, ctx: &mut ExecutionCtx, ) -> VortexResult<Self::Constant>
Decode one non-null batch-constant input.
array retains its logical batch length. Implementations can extract one value directly
without slicing or materializing a one-row column.
Sourcefn get(column: &Self::Column, index: usize) -> Self::Elem<'_>
fn get(column: &Self::Column, index: usize) -> Self::Elem<'_>
Read one row without repeating batch-constant work from decode.
Sourcefn get_constant(constant: &Self::Constant) -> Self::Elem<'_>
fn get_constant(constant: &Self::Constant) -> Self::Elem<'_>
Read the element stored in a decoded batch constant.
Provided Methods§
Sourcefn can_decode_null_tolerant(_array: &ArrayRef) -> VortexResult<bool>
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.
Sourcefn decode_null_tolerant(
array: ArrayRef,
ctx: &mut ExecutionCtx,
) -> VortexResult<Option<Self::Column>>
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.
Sourceunsafe fn get_from_view_unchecked<'a>(
view: &Self::View<'a>,
index: usize,
) -> Self::Elem<'a>where
Self: 'a,
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".