Skip to main content

CastReduce

Trait CastReduce 

Source
pub trait CastReduce: VTable {
    // Required method
    fn cast(
        array: ArrayView<'_, Self>,
        dtype: &DType,
    ) -> VortexResult<Option<ArrayRef>>;
}
Expand description

Reduce rule for cast: restructure the array without reading buffers.

Encodings implement this to push cast operations through their structure. For example, RunEnd pushes cast down to its values array, ZigZag transforms the target dtype to unsigned and pushes to its encoded array.

Returns Ok(None) if the rule doesn’t apply to this array/dtype combination.

§Nullability

A cast to a non-nullable dtype must fail when the array has a null row. A rule cannot execute, so it handles this in one of two ways:

  • It builds a new Validity, as Primitive does. It must return Ok(None) when Validity::trivially_cast_nullability does, and the encoding implements CastKernel for that case.
  • It pushes the cast into the children that hold its validity, as FoR does, and the casts of those children check the nulls. Every null in those children must reach a row of the array. The values of Dict break this with nulls that no code references.

test_cast_conformance checks both forms with a partially valid array.

Required Methods§

Source

fn cast( array: ArrayView<'_, Self>, dtype: &DType, ) -> VortexResult<Option<ArrayRef>>

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl CastReduce for Bool

Source§

impl CastReduce for Chunked

Source§

impl CastReduce for Constant

Source§

impl CastReduce for Decimal

Source§

impl CastReduce for Dict

Source§

impl CastReduce for Extension

Source§

impl CastReduce for FixedSizeList

Cast implementation for FixedSizeListArray.

Recursively casts the inner elements array to the target element type while preserving the list structure.

Source§

impl CastReduce for List

Source§

impl CastReduce for ListView

Source§

impl CastReduce for Map

Source§

impl CastReduce for Null

Source§

impl CastReduce for Primitive

Source§

impl CastReduce for RunEnd

Source§

impl CastReduce for VarBin

Source§

impl CastReduce for VarBinView

Source§

impl CastReduce for Widen