Skip to main content

EagerVec

Struct EagerVec 

Source
pub struct EagerVec<V>(/* private fields */);
Expand description

Wrapper for computing and storing derived values from source vectors.

EagerVec wraps any StoredVec and provides computation methods to derive and persist calculated values. Results are stored on disk and automatically recomputed when:

  • Source data versions change
  • The vector’s computation logic version changes

§Key Features

  • Incremental Updates: Only computes missing values, not the entire dataset
  • Automatic Versioning: Detects stale data and recomputes automatically
  • Batched Writes: Flushes periodically to prevent excessive memory usage

§Common Operations

  • Transformations: compute_transform(), compute_range()
  • Arithmetic: compute_add(), compute_subtract(), compute_multiply(), compute_divide()
  • Moving statistics: compute_sma(), compute_ema(), compute_sum(), compute_max(), compute_min()
  • Lookback calculations: compute_change(), compute_percentage_change()

Implementations§

Source§

impl<V> EagerVec<V>
where V: StoredVec,

Source

pub fn compute_sum_of_others<O>( &mut self, max_from: V::I, others: &[&O], exit: &Exit, ) -> Result<()>
where O: ReadableVec<V::I, V::T>, V::T: Add<V::T, Output = V::T>,

Source

pub fn compute_min_of_others<O>( &mut self, max_from: V::I, others: &[&O], exit: &Exit, ) -> Result<()>
where O: ReadableVec<V::I, V::T>, V::T: Add<V::T, Output = V::T> + Ord,

Source

pub fn compute_max_of_others<O>( &mut self, max_from: V::I, others: &[&O], exit: &Exit, ) -> Result<()>
where O: ReadableVec<V::I, V::T>, V::T: Add<V::T, Output = V::T> + Ord,

Source

pub fn compute_weighted_average_of_others<W, OW, OV>( &mut self, max_from: V::I, weights: &[&OW], values: &[&OV], exit: &Exit, ) -> Result<()>
where W: VecValue + Into<f64>, OW: ReadableVec<V::I, W>, OV: ReadableVec<V::I, V::T>, V::T: Into<f64> + From<f64>,

Computes weighted average: sum(weight_i * value_i) / sum(weight_i)

Takes parallel slices of weight and value vecs from multiple sources. For each index, computes the weighted average across all sources. Returns zero if total weight is zero.

Source

pub fn compute_sum_from_indexes<A, B>( &mut self, max_from: V::I, first_indexes: &impl ReadableVec<V::I, A>, indexes_count: &impl ReadableVec<V::I, B>, source: &(impl ReadableVec<A, V::T> + Sized), exit: &Exit, ) -> Result<()>

Source

pub fn compute_filtered_sum_from_indexes<A, B>( &mut self, max_from: V::I, first_indexes: &impl ReadableVec<V::I, A>, indexes_count: &impl ReadableVec<V::I, B>, source: &(impl ReadableVec<A, V::T> + Sized), filter: impl FnMut(&V::T) -> bool, exit: &Exit, ) -> Result<()>

Source

pub fn compute_count_from_indexes<A, B>( &mut self, max_from: V::I, first_indexes: &impl ReadableVec<V::I, A>, other_to_else: &impl ReadableVec<A, B>, exit: &Exit, ) -> Result<()>
where V::T: From<A>, A: VecValue + VecIndex + Copy + Add<usize, Output = A> + CheckedSub<A> + TryInto<V::T> + Default, <A as TryInto<V::T>>::Error: Error + 'static, B: VecValue,

Source

pub fn compute_filtered_count_from_indexes<A, B>( &mut self, max_from: V::I, first_indexes: &impl ReadableVec<V::I, A>, other_to_else: &impl ReadableVec<A, B>, filter: impl FnMut(A) -> bool, exit: &Exit, ) -> Result<()>
where V::T: From<A>, A: VecValue + VecIndex + Copy + Add<usize, Output = A> + CheckedSub<A> + TryInto<V::T> + Default, B: VecValue, <A as TryInto<V::T>>::Error: Error + 'static,

Source§

impl<V> EagerVec<V>
where V: StoredVec,

Source

pub fn compute_add( &mut self, max_from: V::I, added: &impl ReadableVec<V::I, V::T>, adder: &impl ReadableVec<V::I, V::T>, exit: &Exit, ) -> Result<()>
where V::T: Add<Output = V::T>,

Source

pub fn compute_subtract( &mut self, max_from: V::I, subtracted: &impl ReadableVec<V::I, V::T>, subtracter: &impl ReadableVec<V::I, V::T>, exit: &Exit, ) -> Result<()>
where V::T: CheckedSub,

Source

pub fn compute_multiply<A, B>( &mut self, max_from: V::I, multiplied: &impl ReadableVec<V::I, A>, multiplier: &impl ReadableVec<V::I, B>, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, V::T: From<A> + Mul<B, Output = V::T>,

Source

pub fn compute_divide<A, B>( &mut self, max_from: V::I, divided: &impl ReadableVec<V::I, A>, divider: &impl ReadableVec<V::I, B>, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, V::T: From<A> + Div<B, Output = V::T>,

Source

pub fn compute_percentage<A, B>( &mut self, max_from: V::I, divided: &impl ReadableVec<V::I, A>, divider: &impl ReadableVec<V::I, B>, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, V::T: From<A> + From<B> + From<u8> + Mul<V::T, Output = V::T> + Div<V::T, Output = V::T> + Sub<V::T, Output = V::T> + Copy,

Source

pub fn compute_percentage_difference<A, B>( &mut self, max_from: V::I, divided: &impl ReadableVec<V::I, A>, divider: &impl ReadableVec<V::I, B>, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, V::T: From<A> + From<B> + From<u8> + Mul<V::T, Output = V::T> + Div<V::T, Output = V::T> + Sub<V::T, Output = V::T> + Copy,

Source§

impl<V> EagerVec<V>
where V: StoredVec,

Source

pub fn compute_cumulative<S>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, S>, exit: &Exit, ) -> Result<()>
where S: VecValue + Into<V::T>, V::T: Default + AddAssign + Copy,

Compute cumulative sum from a source vec.

Each value in the result is the sum of all values from the source up to and including that index.

Source

pub fn compute_cumulative_binary<S1, S2>( &mut self, max_from: V::I, source1: &impl ReadableVec<V::I, S1>, source2: &impl ReadableVec<V::I, S2>, exit: &Exit, ) -> Result<()>
where S1: VecValue + Into<V::T>, S2: VecValue + Into<V::T>, V::T: Default + AddAssign + Add<Output = V::T> + Copy,

Compute cumulative sum from adding two source vecs element-wise.

Each value in the result is the cumulative sum of source1[i] + source2[i] for all indices up to and including i.

Source

pub fn compute_cumulative_transformed_binary<S1, S2, F>( &mut self, max_from: V::I, source1: &impl ReadableVec<V::I, S1>, source2: &impl ReadableVec<V::I, S2>, transform: F, exit: &Exit, ) -> Result<()>
where S1: VecValue, S2: VecValue, V::T: Default + AddAssign + Copy, F: FnMut(S1, S2) -> V::T,

Compute cumulative sum from a custom binary transform of two source vecs.

Each value in the result is the cumulative sum of transform(source1[i], source2[i]) for all indices up to and including i.

Source

pub fn compute_cumulative_count<S, P>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, S>, predicate: P, exit: &Exit, ) -> Result<()>
where S: VecValue, V::T: From<usize> + AddAssign + Copy, P: Fn(&S) -> bool,

Compute cumulative count of values matching a predicate.

Each value in the result is the count of values from the source up to and including that index where the predicate returns true.

Source

pub fn compute_rolling_count<S, P>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, S>, window_size: usize, predicate: P, exit: &Exit, ) -> Result<()>
where S: VecValue, V::T: From<usize> + Into<usize> + Copy, P: Fn(&S) -> bool,

Compute rolling count of values matching a predicate within a window.

Source

pub fn compute_cumulative_count_from<S, P>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, S>, from: V::I, predicate: P, exit: &Exit, ) -> Result<()>
where S: VecValue, V::T: From<usize> + AddAssign + Copy, P: Fn(&S) -> bool,

Compute cumulative count of values matching a predicate, starting from a specific index.

Values before from will be 0. Starting at from, counts values where predicate is true.

Source§

impl<V> EagerVec<V>
where V: StoredVec, V::I: CheckedSub,

Source

pub fn compute_previous_value<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, len: usize, exit: &Exit, ) -> Result<()>
where A: VecValue + Default, f32: From<A>, V::T: From<f32>,

Source

pub fn compute_change<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, len: usize, exit: &Exit, ) -> Result<()>
where A: VecValue + Default + Into<V::T>, V::T: CheckedSub + Default,

Compute N-period change. Converts source values to output type before subtraction to properly handle negative changes (e.g., unsigned source to signed output).

Source

pub fn compute_ratio_change<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, len: usize, exit: &Exit, ) -> Result<()>
where A: VecValue + Default, f32: From<A>, V::T: From<f32>,

Source

pub fn compute_percentage_change<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, len: usize, exit: &Exit, ) -> Result<()>
where A: VecValue + Default, f32: From<A>, V::T: From<f32>,

Source

pub fn compute_rolling_from_window_starts<A, F>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, values: &impl ReadableVec<V::I, A>, exit: &Exit, compute: F, ) -> Result<()>
where A: VecValue, f64: From<A>, V::T: From<f64>, F: Fn(f64, f64) -> f64,

Shared helper for rolling computations using variable window starts.

Source

pub fn compute_rolling_ratio_change<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, values: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue, f64: From<A>, V::T: From<f64>,

Compute ratio change using variable window starts (lookback vec). For each index i, computes values[i] / values[window_starts[i]] - 1.

Source

pub fn compute_rolling_percentage_change<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, values: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue, f64: From<A>, V::T: From<f64>,

Compute percentage change using variable window starts (lookback vec). For each index i, computes (values[i] / values[window_starts[i]] - 1) * 100.

Source

pub fn compute_rolling_change<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, values: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue, f64: From<A>, V::T: From<f64>,

Compute change using variable window starts (lookback vec). For each index i, computes values[i] - values[window_starts[i]].

Source

pub fn compute_cagr<A>( &mut self, max_from: V::I, percentage_returns: &impl ReadableVec<V::I, A>, days: usize, exit: &Exit, ) -> Result<()>
where A: VecValue + Default, f32: From<A>, V::T: From<f32>,

Source

pub fn compute_lookback<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, source: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue, V::T: From<A>,

For each index i, output[i] = source[window_starts[i]]. Efficiently caches lookups since window_starts are monotonically non-decreasing.

Source§

impl<V> EagerVec<V>
where V: StoredVec,

Source

pub fn compute_max<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, window: usize, exit: &Exit, ) -> Result<()>
where A: VecValue + Ord, V::T: From<A>,

Source

pub fn compute_min<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, window: usize, exit: &Exit, ) -> Result<()>
where A: VecValue + Ord, V::T: From<A>,

Source

pub fn compute_sum<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, window: usize, exit: &Exit, ) -> Result<()>
where V::T: Add<V::T, Output = V::T> + From<A> + Default + CheckedSub, A: VecValue,

Source

pub fn compute_rolling_sum<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, values: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue, V::T: From<A> + Default + AddAssign + SubAssign,

Compute rolling sum with variable window starts. For each index i, computes sum of values from window_starts[i] to i (inclusive).

Source

pub fn compute_rolling_average<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, values: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue, f64: From<A> + From<V::T>, V::T: From<f64> + Default,

Compute rolling average with variable window starts. For each index i, computes mean of values from window_starts[i] to i (inclusive).

Source

pub fn compute_rolling_sd<A, B>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, values: &impl ReadableVec<V::I, A>, mean: &impl ReadableVec<V::I, B>, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, f64: From<A> + From<B> + From<V::T>, V::T: From<f64>,

Compute rolling standard deviation with variable window starts. For each index i, computes SD of values from window_starts[i] to i (inclusive), using the provided rolling mean. SD = sqrt(E[X²] - E[X]²) where E[X²] is the rolling mean of squares and E[X] is the rolling mean from the mean parameter.

Source

pub fn compute_expanding_sd<A, B>( &mut self, max_from: V::I, values: &impl ReadableVec<V::I, A>, mean: &impl ReadableVec<V::I, B>, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, f64: From<A> + From<B> + From<V::T>, V::T: From<f64>,

Compute expanding (all-time) standard deviation. For each index i, computes SD of all values from 0 to i (inclusive). SD = sqrt(E[X²] - E[X]²).

Source

pub fn compute_rolling_ema<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, values: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue, f64: From<A> + From<V::T>, V::T: From<f64> + Default,

Compute rolling EMA with variable window starts. For each index i, computes an exponential moving average with α = 2/(span+1) where span = i - window_starts[i] + 1.

Source

pub fn compute_rolling_rma<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, values: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue, f64: From<A> + From<V::T>, V::T: From<f64> + Default,

Compute rolling RMA (Wilder’s smoothing) with variable window starts. α = 1/span where span = i - window_starts[i] + 1.

Source

pub fn compute_rolling_max_from_starts<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, source: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue + Ord, V::T: From<A>,

Compute rolling maximum with variable window starts (deque-based).

Source

pub fn compute_rolling_min_from_starts<A>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, source: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where A: VecValue + Ord, V::T: From<A>,

Compute rolling minimum with variable window starts (deque-based).

Source

pub fn compute_rolling_ratio<A, B>( &mut self, max_from: V::I, window_starts: &impl ReadableVec<V::I, V::I>, numerator: &impl ReadableVec<V::I, A>, denominator: &impl ReadableVec<V::I, B>, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, f64: From<A> + From<B> + From<V::T>, V::T: From<f64>,

Compute rolling ratio with variable window starts. For each index i, computes sum(numerator[window_starts[i]..=i]) / denominator[i].

Source

pub fn compute_sma<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, sma: usize, exit: &Exit, ) -> Result<()>
where V::T: Add<V::T, Output = V::T> + From<A> + From<f32>, A: VecValue, f32: From<V::T> + From<A>,

Source

pub fn compute_sma_<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, window: usize, exit: &Exit, min_i: Option<V::I>, ) -> Result<()>
where V::T: Add<V::T, Output = V::T> + From<A> + From<f32>, A: VecValue, f32: From<V::T> + From<A>,

Source

pub fn compute_rolling_median<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, window: usize, exit: &Exit, ) -> Result<()>
where V::T: From<f32>, A: VecValue, f32: From<A>,

Source

pub fn compute_ema<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, ema: usize, exit: &Exit, ) -> Result<()>
where V::T: From<A> + From<f32>, A: VecValue, f32: From<A> + From<V::T>,

Source

pub fn compute_ema_<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, ema: usize, exit: &Exit, min_i: Option<V::I>, ) -> Result<()>
where V::T: From<A> + From<f32>, A: VecValue, f32: From<A> + From<V::T>,

Source

pub fn compute_rma<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, period: usize, exit: &Exit, ) -> Result<()>
where V::T: From<A> + From<f32>, A: VecValue, f32: From<A> + From<V::T>,

Compute Wilder’s Running Moving Average (RMA). Uses alpha = 1/period instead of EMA’s 2/(period+1). This is the standard smoothing method for RSI.

Source

pub fn compute_all_time_high<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where V::T: From<A> + Ord + Default, A: VecValue,

Computes the all time high of a source. This version is more optimized than compute_max with a window set to usize::MAX.

Source

pub fn compute_all_time_low<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where V::T: From<A> + Ord + Default, A: VecValue,

Computes the all time low of a source. This version is more optimized than compute_min with a window set to usize::MAX.

Source

pub fn compute_all_time_low_<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, exit: &Exit, exclude_default: bool, ) -> Result<()>
where V::T: From<A> + Ord + Default, A: VecValue,

Computes the all time low of a source. This version is more optimized than compute_min with a window set to usize::MAX.

Source

pub fn compute_all_time_high_from<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, from: V::I, exit: &Exit, ) -> Result<()>
where V::T: From<A> + Ord + Default + Copy, A: VecValue,

Computes the all time high starting from a specific index. Values before from will be the default value (typically 0).

Source

pub fn compute_all_time_low_from<A>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, from: V::I, exit: &Exit, ) -> Result<()>
where V::T: From<A> + Ord + Default + Copy, A: VecValue,

Computes the all time low starting from a specific index. Values before from will be the default value (typically 0).

Source

pub fn compute_zscore<A, B, C>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, sma: &impl ReadableVec<V::I, B>, sd: &impl ReadableVec<V::I, C>, exit: &Exit, ) -> Result<()>
where V::T: From<f32>, A: VecValue + Sub<B, Output = A> + Div<C, Output = V::T>, B: VecValue, C: VecValue, f32: From<A> + From<B> + From<C>,

Source§

impl<V> EagerVec<V>
where V: StoredVec,

Source

pub fn compute_to<F>( &mut self, max_from: V::I, to: usize, version: Version, t: F, exit: &Exit, ) -> Result<()>
where F: FnMut(V::I) -> (V::I, V::T),

Source

pub fn compute_range<A, F>( &mut self, max_from: V::I, other: &impl ReadableVec<V::I, A>, t: F, exit: &Exit, ) -> Result<()>
where A: VecValue, F: FnMut(V::I) -> (V::I, V::T),

Source

pub fn compute_from_index<A>( &mut self, max_from: V::I, other: &impl ReadableVec<V::I, A>, exit: &Exit, ) -> Result<()>
where V::T: From<V::I>, A: VecValue,

Source

pub fn compute_transform<A, F>( &mut self, max_from: V::I, source: &impl ReadableVec<V::I, A>, t: F, exit: &Exit, ) -> Result<()>
where A: VecValue, F: FnMut((V::I, A, &Self)) -> (V::I, V::T),

Source

pub fn compute_transform2<A, B, F>( &mut self, max_from: V::I, other1: &impl ReadableVec<V::I, A>, other2: &impl ReadableVec<V::I, B>, t: F, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, F: FnMut((V::I, A, B, &Self)) -> (V::I, V::T),

Source

pub fn compute_binary<A, B, F>( &mut self, max_from: V::I, source1: &impl ReadableVec<V::I, A>, source2: &impl ReadableVec<V::I, B>, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, F: BinaryTransform<A, B, V::T>,

Source

pub fn compute_transform3<A, B, C, F>( &mut self, max_from: V::I, other1: &impl ReadableVec<V::I, A>, other2: &impl ReadableVec<V::I, B>, other3: &impl ReadableVec<V::I, C>, t: F, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, C: VecValue, F: FnMut((V::I, A, B, C, &Self)) -> (V::I, V::T),

Source

pub fn compute_transform4<A, B, C, D, F>( &mut self, max_from: V::I, other1: &impl ReadableVec<V::I, A>, other2: &impl ReadableVec<V::I, B>, other3: &impl ReadableVec<V::I, C>, other4: &impl ReadableVec<V::I, D>, t: F, exit: &Exit, ) -> Result<()>
where A: VecValue, B: VecValue, C: VecValue, D: VecValue, F: FnMut((V::I, A, B, C, D, &Self)) -> (V::I, V::T),

Source

pub fn compute_indirect_sequential<A>( &mut self, max_from: V::I, source1: &impl ReadableVec<V::I, A>, source2: &impl ReadableVec<A, V::T>, exit: &Exit, ) -> Result<()>
where A: VecValue + VecIndex,

Compute values through an indirection: for each index i, produces source2[source1[i]]. Keys from source1 must be monotonically increasing so that source2 access is sequential (cursor-friendly).

Source

pub fn compute_first_per_index( &mut self, max_from: V::T, other: &impl ReadableVec<V::T, V::I>, exit: &Exit, ) -> Result<()>
where V::I: VecValue + VecIndex, V::T: VecIndex,

Source§

impl<V> EagerVec<V>
where V: StoredVec,

Source

pub fn batch_end(&self, max_end: usize) -> usize

Max end index for one batch, capped at max_end. Ensures pushed_len * SIZE_OF_T >= MAX_CACHE_SIZE so batch_limit_reached() fires.

Source

pub fn repeat_until_complete<F>(&mut self, exit: &Exit, f: F) -> Result<()>
where F: FnMut(&mut Self) -> Result<()>,

Helper that repeatedly calls a compute function until it completes. Writes between iterations when batch limit is hit.

Source

pub fn remove(self) -> Result<()>

Removes this vector and all its associated regions from the database

Trait Implementations§

Source§

impl<V> AnyStoredVec for EagerVec<V>
where V: StoredVec,

Source§

fn db_path(&self) -> PathBuf

Source§

fn region(&self) -> &Region

Source§

fn header(&self) -> &Header

Source§

fn mut_header(&mut self) -> &mut Header

Source§

fn saved_stamped_changes(&self) -> u16

Number of stamped change files to keep for rollback support.
Source§

fn stored_len(&self) -> usize

The effective stored length (may differ from real_stored_len during truncation).
Source§

fn real_stored_len(&self) -> usize

The actual length stored on disk.
Source§

fn serialize_changes(&self) -> Result<Vec<u8>>

Source§

fn any_stamped_write_with_changes(&mut self, stamp: Stamp) -> Result<()>

Flushes with the given stamp, saving changes to enable rollback. Prefixed with any_ to avoid conflict with WritableVec::stamped_write_with_changes.
Source§

fn remove(self) -> Result<()>

Removes this vector’s region from the database.
Source§

fn any_truncate_if_needed_at(&mut self, index: usize) -> Result<()>

Truncates the vector to the given length if it is longer. Prefixed with any_ to avoid conflict with WritableVec::truncate_if_needed_at.
Source§

fn any_reset(&mut self) -> Result<()>

Resets the vector state, clearing all data.
Source§

fn flush(&mut self) -> Result<()>

Source§

fn update_stamp(&mut self, stamp: Stamp)

Source§

fn stamp(&self) -> Stamp

Source§

fn stamped_write(&mut self, stamp: Stamp) -> Result<()>

Source§

fn any_stamped_write_maybe_with_changes( &mut self, stamp: Stamp, with_changes: bool, ) -> Result<()>

Flushes with the given stamp, optionally saving changes for rollback.
Source§

impl<V> AnyVec for EagerVec<V>
where V: StoredVec,

Source§

fn version(&self) -> Version

Source§

fn name(&self) -> &str

Source§

fn len(&self) -> usize

Source§

fn index_type_to_string(&self) -> &'static str

Returns the string representation of the index type.
Source§

fn value_type_to_size_of(&self) -> usize

Returns the size in bytes of the value type.
Source§

fn value_type_to_string(&self) -> &'static str

Returns the short type name of the value type (e.g., “Sats”, “StoredF64”).
Source§

fn region_names(&self) -> Vec<String>

Returns the list of region names used by this vector.
Source§

fn is_empty(&self) -> bool

Source§

fn region_name(&self) -> String

Returns the combined name of the vector.
Source§

fn etag(&self, stamp: Stamp, to: Option<i64>) -> String

Generates an ETag for this vector based on stamp and optional end index.
Source§

fn i64_to_usize(&self, i: i64) -> usize

Converts an i64 index to usize, supporting negative indexing (Python-style).
Source§

impl<V: Debug> Debug for EagerVec<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: ImportableVec> ImportableVec for EagerVec<V>

Source§

fn import(db: &Database, name: &str, version: Version) -> Result<Self>

Import from database, creating if needed.
Source§

fn import_with(options: ImportOptions<'_>) -> Result<Self>

Import with custom options.
Source§

fn forced_import(db: &Database, name: &str, version: Version) -> Result<Self>

Import from database, resetting on version/format mismatch.
Source§

fn forced_import_with(options: ImportOptions<'_>) -> Result<Self>

Forced import with custom options.
Source§

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

Source§

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

Source§

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

Collects a single value at raw index, or None if out of bounds. Read more
Source§

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

Appends elements in [from, to) to buf. Read more
Source§

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

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

fn fold_range_at<B, F: FnMut(B, V::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. Read more
Source§

fn try_fold_range_at<B, E, F: FnMut(B, V::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. Read more
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_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. Read more
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).
Source§

impl<V> StoredVec for EagerVec<V>
where V: StoredVec,

Source§

type ReadOnly = <V as StoredVec>::ReadOnly

The concrete lean read-only type returned by read_only_clone.
Source§

fn read_only_clone(&self) -> Self::ReadOnly

Creates a lean read-only clone that only carries fields needed for disk reads.
Source§

impl<V> TypedVec for EagerVec<V>
where V: StoredVec,

Source§

type I = <V as TypedVec>::I

The index type used to address elements in this vector.
Source§

type T = <V as TypedVec>::T

The value type stored in this vector.
Source§

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

Source§

fn push(&mut self, value: V::T)

Source§

fn pushed(&self) -> &[V::T]

Returns the current pushed (uncommitted) values.
Source§

fn truncate_if_needed_at(&mut self, index: usize) -> Result<()>

Truncates the vector to the given usize index if the current length exceeds it.
Source§

fn reset(&mut self) -> Result<()>

Resets the vector state.
Source§

fn reset_unsaved(&mut self)

Resets uncommitted changes.
Source§

fn is_dirty(&self) -> bool

Returns true if there are uncommitted changes.
Source§

fn stamped_write_with_changes(&mut self, stamp: Stamp) -> Result<()>

Flushes with the given stamp, saving changes to enable rollback.
Source§

fn rollback(&mut self) -> Result<()>

Rolls back the most recent change set.
Source§

const SIZE_OF_T: usize = _

Source§

fn rollback_before(&mut self, stamp: Stamp) -> Result<Stamp>

Rolls back changes to before the given stamp.
Source§

fn pushed_len(&self) -> usize

Number of pushed (uncommitted) values in the memory buffer.
Source§

fn is_pushed_empty(&self) -> bool

Returns true if there are no pushed (uncommitted) values.
Source§

fn has(&self, index: I) -> bool

Returns true if the typed index is within bounds.
Source§

fn has_at(&self, index: usize) -> bool

Returns true if the usize index is within bounds.
Source§

fn checked_push(&mut self, index: I, value: T) -> Result<()>

Pushes a value at the given index, erroring if index != current length. Use this when you expect to always append in order.
Source§

fn checked_push_at(&mut self, index: usize, value: T) -> Result<()>

Pushes a value at the given usize index, erroring if index != current length. Use this when you expect to always append in order.
Source§

fn truncate_if_needed(&mut self, index: I) -> Result<()>

Truncates the vector to the given index if the current length exceeds it.
Source§

fn truncate_if_needed_with_stamp( &mut self, index: I, stamp: Stamp, ) -> Result<()>

Truncates the vector to the given index if needed, updating the stamp.
Source§

fn clear(&mut self) -> Result<()>

Clears all values from the vector.
Source§

fn batch_limit_reached(&self) -> bool

Returns true if the pushed cache has reached the batch limit (~1GiB). Read more
Source§

fn fill_to(&mut self, target_len: usize, value: T) -> Result<()>
where T: Copy,

Extends the vector to target_len, filling with value. Batches writes in ~1GB chunks to avoid memory explosion.
Source§

fn stamped_write_maybe_with_changes( &mut self, stamp: Stamp, with_changes: bool, ) -> Result<()>

Flushes with the given stamp, optionally saving changes for rollback.
Source§

fn validate_computed_version_or_reset( &mut self, dep_version: Version, ) -> Result<()>

Validates the computed version against the stored version, resetting if they don’t match. Automatically includes the vec’s own version - only pass dependency versions.
Source§

fn validate_and_truncate( &mut self, dep_version: Version, max_from: I, ) -> Result<()>

Validates computed version and truncates to max_from in one call. Read more

Auto Trait Implementations§

§

impl<V> Freeze for EagerVec<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for EagerVec<V>
where V: RefUnwindSafe,

§

impl<V> Send for EagerVec<V>
where V: Send,

§

impl<V> Sync for EagerVec<V>
where V: Sync,

§

impl<V> Unpin for EagerVec<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for EagerVec<V>
where V: UnsafeUnpin,

§

impl<V> UnwindSafe for EagerVec<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn range_count(&self, from: Option<i64>, to: Option<i64>) -> usize

Returns the number of items in the specified range.
Source§

fn range_weight(&self, from: Option<i64>, to: Option<i64>) -> usize

Returns the total size in bytes of items in the specified range.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<V> ReadOnlyClone for V
where V: StoredVec,

Source§

impl<V, I, T> ReadableOptionVec<I, T> for V
where V: ReadableVec<I, Option<T>>, I: VecIndex, T: VecValue + Default,

Source§

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

Collect all values, replacing None with T::default().
Source§

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

Flattens Option<Option<T>>Option<T>.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V> AnyExportableVec for V