global: snapshot

This commit is contained in:
nym21
2025-10-31 21:37:02 +01:00
parent 82e59d409e
commit cf08e470ef
127 changed files with 1059 additions and 450 deletions

View File

@@ -222,7 +222,7 @@ where
cumulative_vec.iter().unwrap_get_inner(index)
});
source.iter_at(index).try_for_each(|(i, v)| -> Result<()> {
cumulative += v.into_owned();
cumulative += v;
cumulative_vec.forced_push_at(i, cumulative, exit)?;
Ok(())
})?;
@@ -263,8 +263,6 @@ where
first_indexes
.iter_at(index)
.try_for_each(|(index, first_index)| -> Result<()> {
let first_index = first_index.into_owned();
let count_index = count_indexes_iter.unwrap_get_inner(index);
if let Some(first) = self.first.as_mut() {
@@ -286,7 +284,7 @@ where
// dbg!(first_index, count_index, last_index);
// })
// .unwrap()
// .into_owned();
// ;
last.forced_push_at(index, v, exit)?;
}
@@ -306,7 +304,7 @@ where
source_iter.set(first_index);
let mut values = (&mut source_iter)
.take(*count_index as usize)
.map(|(_, v)| v.into_owned())
.map(|(_, v)| v)
.collect::<Vec<_>>();
if needs_sorted {
@@ -436,8 +434,6 @@ where
first_indexes
.iter_at(index)
.try_for_each(|(index, first_index, ..)| -> Result<()> {
let first_index = first_index.into_owned();
let count_index = count_indexes_iter.unwrap_get_inner(index);
if let Some(first) = self.first.as_mut() {
@@ -474,7 +470,7 @@ where
source_max_iter.set(first_index);
let mut values = source_max_iter
.take(*count_index as usize)
.map(|(_, v)| v.into_owned())
.map(|(_, v)| v)
.collect::<Vec<_>>();
values.sort_unstable();
max.forced_push_at(index, *values.last().unwrap(), exit)?;
@@ -485,7 +481,7 @@ where
source_min_iter.set(first_index);
let mut values = source_min_iter
.take(*count_index as usize)
.map(|(_, v)| v.into_owned())
.map(|(_, v)| v)
.collect::<Vec<_>>();
values.sort_unstable();
min.forced_push_at(index, *values.first().unwrap(), exit)?;
@@ -498,7 +494,7 @@ where
source_average_iter.set(first_index);
let values = source_average_iter
.take(*count_index as usize)
.map(|(_, v)| v.into_owned())
.map(|(_, v)| v)
.collect::<Vec<_>>();
let len = values.len();
@@ -514,7 +510,7 @@ where
source_sum_iter.set(first_index);
let values = source_sum_iter
.take(*count_index as usize)
.map(|(_, v)| v.into_owned())
.map(|(_, v)| v)
.collect::<Vec<_>>();
let sum = values.into_iter().fold(T::from(0), |a, b| a + b);

View File

@@ -71,9 +71,7 @@ where
if i.to_usize() >= len_source.len() {
return None;
}
source
.next_at(S1I::min_from(i))
.map(|(_, cow)| cow.into_owned())
source.next_at(S1I::min_from(i)).map(|(_, v)| v)
},
))
}),
@@ -100,7 +98,7 @@ where
}
source
.next_at(S1I::max_from(i, source.len()))
.map(|(_, cow)| cow.into_owned())
.map(|(_, v)| v)
},
))
}),
@@ -118,7 +116,7 @@ where
return None;
}
S1I::inclusive_range_from(i, source.len())
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
.flat_map(|i| source.next_at(i).map(|(_, v)| v))
.min()
},
))
@@ -137,7 +135,7 @@ where
return None;
}
S1I::inclusive_range_from(i, source.len())
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
.flat_map(|i| source.next_at(i).map(|(_, v)| v))
.max()
},
))
@@ -156,7 +154,7 @@ where
return None;
}
let vec = S1I::inclusive_range_from(i, source.len())
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
.flat_map(|i| source.next_at(i).map(|(_, v)| v))
.collect::<Vec<_>>();
if vec.is_empty() {
return None;
@@ -186,7 +184,7 @@ where
return None;
}
let vec = S1I::inclusive_range_from(i, source.len())
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
.flat_map(|i| source.next_at(i).map(|(_, v)| v))
.collect::<Vec<_>>();
if vec.is_empty() {
return None;
@@ -209,7 +207,7 @@ where
}
source
.next_at(S1I::max_from(i, source.len()))
.map(|(_, cow)| cow.into_owned())
.map(|(_, v)| v)
},
))
}),
@@ -259,6 +257,7 @@ pub struct LazyVecBuilderOptions {
}
impl From<VecBuilderOptions> for LazyVecBuilderOptions {
#[inline]
fn from(value: VecBuilderOptions) -> Self {
Self {
average: value.average(),

View File

@@ -440,7 +440,6 @@ impl ComputedRatioVecsFromDateIndex {
.unwrap()
.forced_push_at(index, StoredF32::NAN, exit)?;
} else {
let ratio = ratio.into_owned();
let pos = sorted.binary_search(&ratio).unwrap_or_else(|pos| pos);
sorted.insert(pos, ratio);

View File

@@ -545,7 +545,6 @@ impl ComputedStandardDeviationVecsFromDateIndex {
v.forced_push_at(index, StoredF32::NAN, exit)?
}
} else {
let ratio = ratio.into_owned();
let pos = sorted.binary_search(&ratio).unwrap_or_else(|pos| pos);
sorted.insert(pos, ratio);

View File

@@ -29,18 +29,21 @@ impl<I, T> Source<I, T> {
}
impl<I, T> From<bool> for Source<I, T> {
#[inline]
fn from(value: bool) -> Self {
if value { Self::Compute } else { Self::None }
}
}
impl<I, T> From<AnyBoxedIterableVec<I, T>> for Source<I, T> {
#[inline]
fn from(value: AnyBoxedIterableVec<I, T>) -> Self {
Self::Vec(value)
}
}
impl<I, T> From<Option<AnyBoxedIterableVec<I, T>>> for Source<I, T> {
#[inline]
fn from(value: Option<AnyBoxedIterableVec<I, T>>) -> Self {
if let Some(v) = value {
Self::Vec(v)

View File

@@ -59,10 +59,8 @@ impl ComputedValueVecsFromTxindex {
version + VERSION,
source_vec.map_or_else(|| sats.txindex.as_ref().unwrap().boxed_clone(), |s| s),
|txindex: TxIndex, iter| {
iter.next_at(txindex.to_usize()).map(|(_, value)| {
let sats = value.into_owned();
Bitcoin::from(sats)
})
iter.next_at(txindex.to_usize())
.map(|(_, sats)| Bitcoin::from(sats))
},
);
@@ -87,15 +85,13 @@ impl ComputedValueVecsFromTxindex {
txindex_to_height_iter,
height_to_price_close_iter| {
let txindex = txindex.to_usize();
txindex_to_btc_iter.next_at(txindex).and_then(|(_, value)| {
let btc = value.into_owned();
txindex_to_btc_iter.next_at(txindex).and_then(|(_, btc)| {
txindex_to_height_iter
.next_at(txindex)
.and_then(|(_, value)| {
let height = value.into_owned();
.and_then(|(_, height)| {
height_to_price_close_iter
.next_at(height.to_usize())
.map(|(_, close)| *close.into_owned() * btc)
.map(|(_, close)| *close * btc)
})
})
},