Skip to main content

ReadableVec

Trait ReadableVec 

Source
pub trait ReadableVec<I: VecIndex, T: VecValue>: AnyVec {
Show 39 methods // Required methods fn read_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>); fn for_each_range_dyn_at( &self, from: usize, to: usize, f: &mut dyn FnMut(T), ); fn fold_range_at<B, F: FnMut(B, T) -> B>( &self, from: usize, to: usize, init: B, f: F, ) -> B where Self: Sized; fn try_fold_range_at<B, E, F: FnMut(B, T) -> Result<B, E>>( &self, from: usize, to: usize, init: B, f: F, ) -> Result<B, E> where Self: Sized; // Provided methods fn read_into(&self, from: I, to: I, buf: &mut Vec<T>) { ... } fn cursor(&self) -> Cursor<'_, I, T, Self> where Self: Sized { ... } fn for_each_range_dyn(&self, from: I, to: I, f: &mut dyn FnMut(T)) { ... } fn fold_range<B, F: FnMut(B, T) -> B>( &self, from: I, to: I, init: B, f: F, ) -> B where Self: Sized { ... } fn try_fold_range<B, E, F: FnMut(B, T) -> Result<B, E>>( &self, from: I, to: I, init: B, f: F, ) -> Result<B, E> where Self: Sized { ... } fn for_each_range<F: FnMut(T)>(&self, from: I, to: I, f: F) where Self: Sized { ... } fn collect_range(&self, from: I, to: I) -> Vec<T> where Self: Sized { ... } fn collect_one(&self, index: I) -> Option<T> { ... } fn min(&self, from: I, to: I) -> Option<T> where Self: Sized, T: PartialOrd { ... } fn max(&self, from: I, to: I) -> Option<T> where Self: Sized, T: PartialOrd { ... } fn sum(&self, from: I, to: I) -> Option<T> where Self: Sized, T: AddAssign + From<u8> { ... } fn for_each_range_at<F: FnMut(T)>(&self, from: usize, to: usize, f: F) where Self: Sized { ... } fn try_for_each_range_at<E, F: FnMut(T) -> Result<(), E>>( &self, from: usize, to: usize, f: F, ) -> Result<(), E> where Self: Sized { ... } fn for_each<F: FnMut(T)>(&self, f: F) where Self: Sized { ... } fn fold<B, F: FnMut(B, T) -> B>(&self, init: B, f: F) -> B where Self: Sized { ... } fn collect_range_at(&self, from: usize, to: usize) -> Vec<T> where Self: Sized { ... } fn collect_range_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>) { ... } fn collect_range_dyn(&self, from: usize, to: usize) -> Vec<T> { ... } fn collect(&self) -> Vec<T> where Self: Sized { ... } fn collect_one_at(&self, index: usize) -> Option<T> { ... } fn collect_first(&self) -> Option<T> { ... } fn collect_last(&self) -> Option<T> { ... } fn collect_signed_range(&self, from: Option<i64>, to: Option<i64>) -> Vec<T> where Self: Sized { ... } fn collect_signed_range_dyn( &self, from: Option<i64>, to: Option<i64>, ) -> Vec<T> { ... } fn collect_dyn(&self) -> Vec<T> { ... } fn read_sorted_into_at(&self, indices: &[usize], out: &mut Vec<T>) { ... } fn read_sorted_at(&self, indices: &[usize]) -> Vec<T> { ... } fn read_sorted_into(&self, indices: &[I], out: &mut Vec<T>) { ... } fn read_sorted(&self, indices: &[I]) -> Vec<T> { ... } fn min_at(&self, from: usize, to: usize) -> Option<T> where Self: Sized, T: PartialOrd { ... } fn min_dyn(&self, from: usize, to: usize) -> Option<T> where T: PartialOrd { ... } fn max_at(&self, from: usize, to: usize) -> Option<T> where Self: Sized, T: PartialOrd { ... } fn max_dyn(&self, from: usize, to: usize) -> Option<T> where T: PartialOrd { ... } fn sum_at(&self, from: usize, to: usize) -> Option<T> where Self: Sized, T: AddAssign + From<u8> { ... } fn sum_dyn(&self, from: usize, to: usize) -> Option<T> where T: AddAssign + From<u8> { ... }
}
Expand description

High-performance reading of vector values.

This is the primary trait for reading data from any vec type — stored, compressed, lazy, or computed. All methods see the full state including uncommitted (pushed) values.

§Method overview

MethodUse when
for_each / for_each_rangeProcessing every element, static dispatch
fold / fold_rangeAccumulating a result (SIMD-optimized on stored vecs)
collect / collect_rangeMaterializing values into a Vec<T>
collect_one / collect_first / collect_lastMaterializing a single value
for_each_range_dynTrait-object contexts (&dyn ReadableVec)
try_fold_rangeFold with early exit on error
read_into / cursorSequential access with buffer reuse

§Typed vs _at methods

Methods like collect_one(I), fold_range(I, I, …) accept the typed index I. The _at variants (collect_one_at(usize), fold_range_at(usize, usize, …)) accept raw usize and are what implementations override.

§Point reads

For raw vecs, use VecReader::get() for O(1) random access. For any vec through the trait, use collect_one(i) — this materializes a single value (decodes a page for compressed vecs).

§Performance

Stored vecs override fold_range_at and try_fold_range_at to delegate to their internal source’s optimized fold(), enabling SIMD auto-vectorization.

The default fold_range_at uses chunked read_into_at calls with a monomorphized inner loop — LLVM can auto-vectorize this without &mut dyn FnMut overhead.

For maximum throughput on stored vecs, prefer fold_range / for_each_range with static dispatch (&impl ReadableVec or concrete type).

Required Methods§

Source

fn read_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>)

Appends elements in [from, to) to buf.

Implementations MUST NOT clear buf — they only append. This enables chunked fold (clear + fill per chunk) and multi-range reads (append multiple ranges into one buffer).

Object-safe: &mut Vec<T> is a concrete type, no Self: Sized needed.

Source

fn for_each_range_dyn_at(&self, from: usize, to: usize, f: &mut dyn FnMut(T))

Iterates over [from, to) by raw index, calling f for each value.

Object-safe: callable on &dyn ReadableVec. Every implementor must provide this — there is intentionally no default to prevent silent fallback to a slow buffered path.

Source

fn fold_range_at<B, F: FnMut(B, T) -> B>( &self, from: usize, to: usize, init: B, f: F, ) -> B
where Self: Sized,

Folds over [from, to) by raw index with an accumulator.

Every implementor must provide an optimal path — there is intentionally no default to prevent silent fallback to a slow buffered path.

Source

fn try_fold_range_at<B, E, F: FnMut(B, T) -> Result<B, E>>( &self, from: usize, to: usize, init: B, f: F, ) -> Result<B, E>
where Self: Sized,

Fallible fold over [from, to) by raw index with early exit on error.

Every implementor must provide an optimal path — there is intentionally no default to prevent silent fallback to a slow buffered path.

Provided Methods§

Source

fn read_into(&self, from: I, to: I, buf: &mut Vec<T>)

Appends elements in [from, to) to buf using typed indices.

Source

fn cursor(&self) -> Cursor<'_, I, T, Self>
where Self: Sized,

Creates a forward-only Cursor that reuses an internal buffer across chunked read_into_at calls. One allocation for the lifetime of the cursor.

Source

fn for_each_range_dyn(&self, from: I, to: I, f: &mut dyn FnMut(T))

Iterates over [from, to) by typed index, calling f for each value (object-safe).

Source

fn fold_range<B, F: FnMut(B, T) -> B>(&self, from: I, to: I, init: B, f: F) -> B
where Self: Sized,

Folds over [from, to) by typed index with an accumulator.

Source

fn try_fold_range<B, E, F: FnMut(B, T) -> Result<B, E>>( &self, from: I, to: I, init: B, f: F, ) -> Result<B, E>
where Self: Sized,

Fallible fold over [from, to) by typed index with early exit on error.

Source

fn for_each_range<F: FnMut(T)>(&self, from: I, to: I, f: F)
where Self: Sized,

Calls f for each value in [from, to) by typed index. Requires Sized.

Source

fn collect_range(&self, from: I, to: I) -> Vec<T>
where Self: Sized,

Collects values in [from, to) by typed index into a Vec<T>.

Source

fn collect_one(&self, index: I) -> Option<T>

Collects a single value at typed index, or None if out of bounds.

Source

fn min(&self, from: I, to: I) -> Option<T>
where Self: Sized, T: PartialOrd,

Returns the minimum value in [from, to) by typed index, or None if empty.

Source

fn max(&self, from: I, to: I) -> Option<T>
where Self: Sized, T: PartialOrd,

Returns the maximum value in [from, to) by typed index, or None if empty.

Source

fn sum(&self, from: I, to: I) -> Option<T>
where Self: Sized, T: AddAssign + From<u8>,

Returns the sum of values in [from, to) by typed index, or None if empty.

Source

fn for_each_range_at<F: FnMut(T)>(&self, from: usize, to: usize, f: F)
where Self: Sized,

Calls f for each value in [from, to) by raw index. Requires Sized (static dispatch).

Source

fn try_for_each_range_at<E, F: FnMut(T) -> Result<(), E>>( &self, from: usize, to: usize, f: F, ) -> Result<(), E>
where Self: Sized,

Fallible for-each over [from, to) by raw index with early exit on error.

Source

fn for_each<F: FnMut(T)>(&self, f: F)
where Self: Sized,

Calls f for every value in the vector.

Source

fn fold<B, F: FnMut(B, T) -> B>(&self, init: B, f: F) -> B
where Self: Sized,

Folds over all values with an accumulator.

Source

fn collect_range_at(&self, from: usize, to: usize) -> Vec<T>
where Self: Sized,

Collects values in [from, to) by raw index into a Vec<T>.

Source

fn collect_range_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>)

Clears buf then fills it with values in [from, to). Reuses the buffer allocation.

Source

fn collect_range_dyn(&self, from: usize, to: usize) -> Vec<T>

Collects values in [from, to) into a Vec<T> (object-safe).

Source

fn collect(&self) -> Vec<T>
where Self: Sized,

Collects all values into a Vec<T>.

Source

fn collect_one_at(&self, index: usize) -> Option<T>

Collects a single value at raw index, or None if out of bounds.

Uses for_each_range_dyn_at with a stack-local Option. Stored vecs override for_each_range_dyn_atfold_range_at for zero-alloc reads; lazy vecs override collect_one_at directly.

Source

fn collect_first(&self) -> Option<T>

Collects the first value, or None if empty.

Source

fn collect_last(&self) -> Option<T>

Collects the last value, or None if empty.

Source

fn collect_signed_range(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>
where Self: Sized,

Collects values using signed indices. Negative indices count from the end (Python-style): -1 is the last element, -2 is second-to-last, etc.

Source

fn collect_signed_range_dyn(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>

Collects values using signed indices (object-safe).

Source

fn collect_dyn(&self) -> Vec<T>

Collects all values into a Vec<T> (object-safe).

Source

fn read_sorted_into_at(&self, indices: &[usize], out: &mut Vec<T>)

Reads values at specific sorted indices (ascending), skipping holes.

Default uses a forward-only Cursor — each underlying page is read at most once. Lazy vecs override to map indices to their source and call this method recursively, bottoming out at stored vecs.

indices must be sorted ascending. Output order matches indices.

Source

fn read_sorted_at(&self, indices: &[usize]) -> Vec<T>

Reads values at specific sorted indices (ascending), returning a new Vec.

Source

fn read_sorted_into(&self, indices: &[I], out: &mut Vec<T>)

Reads values at specific sorted typed indices, appending to out.

Source

fn read_sorted(&self, indices: &[I]) -> Vec<T>

Reads values at specific sorted typed indices, returning a new Vec.

Source

fn min_at(&self, from: usize, to: usize) -> Option<T>
where Self: Sized, T: PartialOrd,

Returns the minimum value in [from, to) by raw index, or None if empty.

Source

fn min_dyn(&self, from: usize, to: usize) -> Option<T>
where T: PartialOrd,

Returns the minimum value in [from, to), or None if empty (object-safe).

Source

fn max_at(&self, from: usize, to: usize) -> Option<T>
where Self: Sized, T: PartialOrd,

Returns the maximum value in [from, to) by raw index, or None if empty.

Source

fn max_dyn(&self, from: usize, to: usize) -> Option<T>
where T: PartialOrd,

Returns the maximum value in [from, to), or None if empty (object-safe).

Source

fn sum_at(&self, from: usize, to: usize) -> Option<T>
where Self: Sized, T: AddAssign + From<u8>,

Returns the sum of values in [from, to) by raw index, or None if empty.

Source

fn sum_dyn(&self, from: usize, to: usize) -> Option<T>
where T: AddAssign + From<u8>,

Returns the sum of values in [from, to), or None if empty (object-safe).

Implementors§

Source§

impl<I, O, S1I, S2T, S1T, Strat> ReadableVec<I, O> for LazyAggVec<I, O, S1I, S2T, S1T, Strat>
where I: VecIndex, O: VecValue, S1I: VecIndex, S2T: VecValue, S1T: VecValue, Strat: AggFold<O, S1I, S2T, S1T>,

Source§

impl<I, S, T, Op> ReadableVec<I, T> for LazyDeltaVec<I, S, T, Op>
where I: VecIndex, S: VecValue, T: VecValue, Op: DeltaOp<S, T>,

Source§

impl<I, T> ReadableVec<I, T> for BytesVec<I, T>
where I: VecIndex, T: BytesVecValue,

Source§

impl<I, T> ReadableVec<I, T> for LZ4Vec<I, T>
where I: VecIndex, T: LZ4VecValue,

Source§

impl<I, T> ReadableVec<I, T> for PcoVec<I, T>
where I: VecIndex, T: PcoVecValue,

Source§

impl<I, T> ReadableVec<I, T> for ZeroCopyVec<I, T>

Source§

impl<I, T> ReadableVec<I, T> for ZstdVec<I, T>
where I: VecIndex, T: ZstdVecValue,

Source§

impl<I, T, S1I, S1T> ReadableVec<I, T> for LazyVecFrom1<I, T, S1I, S1T>
where I: VecIndex, T: VecValue, S1I: VecIndex, S1T: VecValue,

Source§

impl<I, T, S1I, S1T, S2I, S2T> ReadableVec<I, T> for LazyVecFrom2<I, T, S1I, S1T, S2I, S2T>
where I: VecIndex, T: VecValue, S1I: VecIndex, S1T: VecValue, S2I: VecIndex, S2T: VecValue,

Source§

impl<I, T, S1I, S1T, S2I, S2T, S3I, S3T> ReadableVec<I, T> for LazyVecFrom3<I, T, S1I, S1T, S2I, S2T, S3I, S3T>
where I: VecIndex, T: VecValue, S1I: VecIndex, S1T: VecValue, S2I: VecIndex, S2T: VecValue, S3I: VecIndex, S3T: VecValue,

Source§

impl<I, T, S> ReadableVec<I, T> for ReadOnlyCompressedVec<I, T, S>

Source§

impl<I, T, S> ReadableVec<I, T> for ReadOnlyRawVec<I, T, S>
where I: VecIndex, T: VecValue, S: RawStrategy<T>,

Source§

impl<I, T, S> ReadableVec<I, T> for ReadWriteRawVec<I, T, S>
where I: VecIndex, T: VecValue, S: RawStrategy<T>,

Source§

impl<V> ReadableVec<<V as TypedVec>::I, <V as TypedVec>::T> for EagerVec<V>
where V: StoredVec,

Source§

impl<V: TypedVec + ReadableVec<V::I, V::T>> ReadableVec<<V as TypedVec>::I, <V as TypedVec>::T> for CachedVec<V>