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 map_bits_into<F>(self, words: &mut [u64], f: F)
where F: FnMut(Self::Item) -> bool { ... }
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§
Sourcefn try_map_masked_into<R, F>(
self,
mask: &BitBuffer,
out: &mut [MaybeUninit<R>],
f: F,
) -> Result<(), usize>
fn try_map_masked_into<R, F>( self, mask: &BitBuffer, out: &mut [MaybeUninit<R>], f: F, ) -> Result<(), usize>
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().
Sourcefn map_into<R, F>(self, out: &mut [MaybeUninit<R>], f: F)
fn map_into<R, F>(self, out: &mut [MaybeUninit<R>], f: F)
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().
Sourcefn map_bits_into<F>(self, words: &mut [u64], f: F)
fn map_bits_into<F>(self, words: &mut [u64], f: F)
Apply the predicate f(value) lane-by-lane and bit-pack the results into
words, LSB-first, 64 lanes per u64.
This is the kernel shape behind comparison operators: each lane read is an
independent indexed load (drive two columns via LaneZip) and the 64
per-lane booleans of a chunk reduce into a single word with OR + shift,
which the autovectorizer lowers to a vector compare plus movemask.
Words are written with = (not |=), so words need not be
zero-initialised. Bits at positions >= self.len() in the last word are
written as zero.
Like map_into, this kernel has no validity awareness; pair the packed
bits with a separately computed validity mask.
§Panics
Panics if words.len() < self.len().div_ceil(64).
Sourcefn try_map_into<R, F>(
self,
out: &mut [MaybeUninit<R>],
f: F,
) -> Result<(), usize>
fn try_map_into<R, F>( self, out: &mut [MaybeUninit<R>], f: F, ) -> Result<(), usize>
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".