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, asPrimitivedoes. It must returnOk(None)whenValidity::trivially_cast_nullabilitydoes, and the encoding implementsCastKernelfor 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
Dictbreak this with nulls that no code references.
test_cast_conformance checks both forms with a partially valid array.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl CastReduce for Bool
impl CastReduce for Chunked
impl CastReduce for Constant
impl CastReduce for Decimal
impl CastReduce for Dict
impl CastReduce for Extension
impl CastReduce for FixedSizeList
Cast implementation for FixedSizeListArray.
Recursively casts the inner elements array to the target element type while preserving the list structure.