Skip to main content

IndexedSourceExt

Trait IndexedSourceExt 

Source
pub trait IndexedSourceExt: IndexedSource + Sized {
    // Provided methods
    fn try_map_masked_into<R, F>(
        self,
        mask: &BitBuffer,
        out: &mut [MaybeUninit<R>],
        f: F,
    ) -> Result<(), usize>
       where R: Copy + Default,
             F: FnMut(Self::Item) -> Option<R> { ... }
    fn map_into<R, F>(self, out: &mut [MaybeUninit<R>], f: F)
       where F: FnMut(Self::Item) -> R { ... }
    fn try_map_into<R, F>(
        self,
        out: &mut [MaybeUninit<R>],
        f: F,
    ) -> Result<(), usize>
       where R: Copy + Default,
             F: FnMut(Self::Item) -> Option<R> { ... }
}
Expand description

Extension trait providing out-of-place lane-kernel methods on any IndexedSource.

All methods have default implementations and are inherited via the blanket impl<S: IndexedSource> IndexedSourceExt for S below. Bring the trait into scope (use vortex_compute::lane_kernels::IndexedSourceExt;) to call them with method syntax: values.try_map_masked_into(&mask, &mut out, f).

Provided Methods§

Source

fn try_map_masked_into<R, F>( self, mask: &BitBuffer, out: &mut [MaybeUninit<R>], f: F, ) -> Result<(), usize>
where R: Copy + Default, F: FnMut(Self::Item) -> Option<R>,

Fallible map with mask-aware error attribution. f returns Option<R>; None indicates a per-lane failure (e.g. range overflow on a narrowing cast).

Null-lane failures are filtered automatically. The closure is called on every lane regardless of validity; if a null lane’s stored value causes f(v) to return None, the kernel does not propagate that as Err. The per-lane is_none() flags are bit-packed into a u64 at the lane’s position, then AND-combined with the chunk’s validity bitmap — null-lane bits vanish.

The closure shape is the same as try_map_into (FnMut(Item) -> Option<R>); the mask parameter is what makes this kernel mask-aware. Callers that need to distinguish null lanes inside the closure (e.g. to short-circuit an expensive computation) should construct their own per-lane validity check externally; for the common case, the kernel’s automatic filter is sufficient.

On failure returns Err(failing_lane_index). Lanes whose f returned None write R::default() into out, but the contents of out must not be relied upon when this function returns Err.

§Panics

Panics if self.len() != mask.len() or out.len() != self.len().

Source

fn map_into<R, F>(self, out: &mut [MaybeUninit<R>], f: F)
where F: FnMut(Self::Item) -> R,

Apply f(value) lane-by-lane with no validity awareness at all — every closure invocation is treated as “happened”, regardless of whether the lane is null. Use this only when the input is known non-nullable.

§Panics

Panics if out.len() != self.len().

Source

fn try_map_into<R, F>( self, out: &mut [MaybeUninit<R>], f: F, ) -> Result<(), usize>
where R: Copy + Default, F: FnMut(Self::Item) -> Option<R>,

Fallible map with no validity awareness at all — every None returned by the closure is treated as a failure, even at null lanes.

§Use this only for non-nullable inputs.

For nullable inputs with a fallible closure, use try_map_masked_into — it has the same value-only closure shape (and the same perf win) but correctly suppresses null-lane failures via per-chunk fail_bits & mask_chunk.

Using this kernel on a nullable input where a null lane’s stored value would cause f to return None will produce a spurious Err. This is a correctness footgun on purpose — the name and this doc are how the API signals “you must know your input has no nulls.”

On failure returns Err(failing_lane_index).

§Panics

Panics if out.len() != self.len().

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§