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 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.
Required Associated Types§
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. Hoist dtype checks, downcasts, and other invocation-invariant work into this method.
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.
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".