merge: resolve Cargo.toml conflict with upstream/main

Keep vecdb = 0.6.1 without commented path dependency.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Collins
2026-01-21 14:21:12 -05:00
65 changed files with 5671 additions and 3262 deletions

View File

@@ -70,7 +70,9 @@ where
}};
}
let index = validate_vec!(first, last, min, max, average, sum, cumulative, median, pct10, pct25, pct75, pct90);
let index = validate_vec!(
first, last, min, max, average, sum, cumulative, median, pct10, pct25, pct75, pct90
);
let needs_first = first.is_some();
let needs_last = last.is_some();
@@ -298,44 +300,9 @@ where
};
}
write_vec!(first, last, min, max, average, sum, cumulative, median, pct10, pct25, pct75, pct90);
Ok(())
}
/// Compute cumulative extension from a source vec.
///
/// Used when only cumulative needs to be extended from an existing source.
pub fn compute_cumulative_extend<I, T>(
max_from: I,
source: &impl IterableVec<I, T>,
cumulative: &mut EagerVec<PcoVec<I, T>>,
exit: &Exit,
) -> Result<()>
where
I: VecIndex,
T: ComputedVecValue + JsonSchema,
{
cumulative.validate_computed_version_or_reset(source.version())?;
let index = max_from.min(I::from(cumulative.len()));
let mut cumulative_val = index
.decremented()
.map_or(T::from(0_usize), |idx| cumulative.iter().get_unwrap(idx));
source
.iter()
.enumerate()
.skip(index.to_usize())
.try_for_each(|(i, v)| -> Result<()> {
cumulative_val += v;
cumulative.truncate_push_at(i, cumulative_val)?;
Ok(())
})?;
let _lock = exit.lock();
cumulative.write()?;
write_vec!(
first, last, min, max, average, sum, cumulative, median, pct10, pct25, pct75, pct90
);
Ok(())
}

View File

@@ -12,16 +12,16 @@ use brk_types::{
};
use derive_more::{Deref, DerefMut};
use vecdb::{
AnyStoredVec, AnyVec, Database, EagerVec, Exit, GenericStoredVec, ImportableVec,
IterableBoxedVec, IterableCloneableVec, IterableVec, LazyVecFrom3,
Database, EagerVec, Exit, ImportableVec, IterableBoxedVec, IterableCloneableVec, LazyVecFrom3,
};
use crate::{
ComputeIndexes, indexes,
indexes,
internal::{
CumulativeVec, Full, LazyBinaryTransformFull, LazyDateDerivedFull, LazyFull,
SatsTimesClosePrice, Stats,
},
ComputeIndexes,
};
/// Lazy dollars at TxIndex: `sats * price[height]`
@@ -137,7 +137,11 @@ impl ValueDollarsFromTxFull {
exit: &Exit,
) -> Result<()> {
// Compute height cumulative by summing lazy height.sum values
self.compute_height_cumulative(starting_indexes.height, exit)?;
self.height_cumulative.0.compute_cumulative(
starting_indexes.height,
&self.height.sum,
exit,
)?;
// Compute dateindex stats by aggregating lazy height stats
self.dateindex.compute(
@@ -150,30 +154,6 @@ impl ValueDollarsFromTxFull {
Ok(())
}
/// Compute cumulative USD by summing `sum_sats[h] * price[h]` for all heights.
fn compute_height_cumulative(&mut self, max_from: Height, exit: &Exit) -> Result<()> {
let starting_height = max_from.min(Height::from(self.height_cumulative.0.len()));
let mut cumulative = starting_height.decremented().map_or(Dollars::ZERO, |h| {
self.height_cumulative.0.iter().get_unwrap(h)
});
let mut sum_iter = self.height.sum.iter();
let start_idx = *starting_height as usize;
let end_idx = sum_iter.len();
for h in start_idx..end_idx {
let sum_usd = sum_iter.get_unwrap(Height::from(h));
cumulative += sum_usd;
self.height_cumulative.0.truncate_push_at(h, cumulative)?;
}
let _lock = exit.lock();
self.height_cumulative.0.write()?;
Ok(())
}
}
fn create_lazy_txindex(

View File

@@ -9,11 +9,11 @@ use schemars::JsonSchema;
use vecdb::{Database, Exit, IterableBoxedVec, IterableCloneableVec, IterableVec};
use crate::{
ComputeIndexes, indexes,
indexes,
internal::{
ComputedVecValue, CumulativeVec, LazyDateDerivedFull, Full, LazyFull, NumericValue,
compute_cumulative_extend,
ComputedVecValue, CumulativeVec, Full, LazyDateDerivedFull, LazyFull, NumericValue,
},
ComputeIndexes,
};
#[derive(Clone, Deref, DerefMut, Traversable)]
@@ -102,6 +102,9 @@ where
height_source: &impl IterableVec<Height, T>,
exit: &Exit,
) -> Result<()> {
compute_cumulative_extend(max_from, height_source, &mut self.height_cumulative.0, exit)
self.height_cumulative
.0
.compute_cumulative(max_from, height_source, exit)?;
Ok(())
}
}

View File

@@ -12,11 +12,11 @@ use vecdb::{
};
use crate::{
ComputeIndexes, indexes,
indexes,
internal::{
ComputedVecValue, CumulativeVec, LazyDateDerivedSumCum, LazySumCum, NumericValue, SumCum,
compute_cumulative_extend,
},
ComputeIndexes,
};
#[derive(Clone, Deref, DerefMut, Traversable)]
@@ -99,7 +99,10 @@ where
source: &impl IterableVec<Height, T>,
exit: &Exit,
) -> Result<()> {
compute_cumulative_extend(max_from, source, &mut self.height_cumulative.0, exit)
self.height_cumulative
.0
.compute_cumulative(max_from, source, exit)?;
Ok(())
}
fn compute_dateindex_sum_cum(

View File

@@ -1,7 +1,10 @@
use brk_error::Result;
use brk_traversable::Traversable;
use schemars::JsonSchema;
use vecdb::{AnyVec, Database, Exit, IterableBoxedVec, IterableCloneableVec, IterableVec, VecIndex, VecValue, Version};
use vecdb::{
AnyVec, Database, Exit, IterableBoxedVec, IterableCloneableVec, IterableVec, VecIndex,
VecValue, Version,
};
use crate::internal::{ComputedVecValue, CumulativeVec, SumVec};
@@ -48,7 +51,7 @@ impl<I: VecIndex, T: ComputedVecValue + JsonSchema> SumCum<I, T> {
first_indexes,
count_indexes,
exit,
0, // min_skip_count
0, // min_skip_count
None, // first
None, // last
None, // min
@@ -64,16 +67,6 @@ impl<I: VecIndex, T: ComputedVecValue + JsonSchema> SumCum<I, T> {
)
}
/// Extend cumulative from an existing source vec.
pub fn extend_cumulative(
&mut self,
max_from: I,
source: &impl IterableVec<I, T>,
exit: &Exit,
) -> Result<()> {
crate::internal::compute_cumulative_extend(max_from, source, &mut self.cumulative.0, exit)
}
pub fn len(&self) -> usize {
self.sum.0.len().min(self.cumulative.0.len())
}