global: snapshot

This commit is contained in:
nym21
2025-11-25 18:37:14 +01:00
parent dc86514329
commit 9e41d51702
49 changed files with 858 additions and 1013 deletions
@@ -2,8 +2,8 @@ use brk_error::{Error, Result};
use brk_traversable::Traversable;
use brk_types::{CheckedSub, StoredU64, Version};
use vecdb::{
AnyStoredVec, AnyVec, Database, EagerVec, Exit, Format, GenericStoredVec, IterableVec,
VecIndex, VecValue,
AnyStoredVec, AnyVec, Database, EagerVec, Exit, GenericStoredVec, Importable, IterableVec,
PcoVec, VecIndex, VecValue,
};
use crate::utils::get_percentile;
@@ -16,18 +16,18 @@ where
I: VecIndex,
T: ComputedVecValue,
{
pub first: Option<Box<EagerVec<I, T>>>,
pub average: Option<Box<EagerVec<I, T>>>,
pub sum: Option<Box<EagerVec<I, T>>>,
pub max: Option<Box<EagerVec<I, T>>>,
pub pct90: Option<Box<EagerVec<I, T>>>,
pub pct75: Option<Box<EagerVec<I, T>>>,
pub median: Option<Box<EagerVec<I, T>>>,
pub pct25: Option<Box<EagerVec<I, T>>>,
pub pct10: Option<Box<EagerVec<I, T>>>,
pub min: Option<Box<EagerVec<I, T>>>,
pub last: Option<Box<EagerVec<I, T>>>,
pub cumulative: Option<Box<EagerVec<I, T>>>,
pub first: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub average: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub sum: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub max: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub pct90: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub pct75: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub median: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub pct25: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub pct10: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub min: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub last: Option<Box<EagerVec<PcoVec<I, T>>>>,
pub cumulative: Option<Box<EagerVec<PcoVec<I, T>>>>,
}
const VERSION: Version = Version::ZERO;
@@ -37,20 +37,10 @@ where
I: VecIndex,
T: ComputedVecValue,
{
pub fn forced_import_compressed(
db: &Database,
name: &str,
version: Version,
options: VecBuilderOptions,
) -> Result<Self> {
Self::forced_import(db, name, version, Format::Compressed, options)
}
pub fn forced_import(
db: &Database,
name: &str,
version: Version,
format: Format,
options: VecBuilderOptions,
) -> Result<Self> {
let only_one_active = options.is_only_one_active();
@@ -72,15 +62,12 @@ where
db,
&maybe_suffix("first"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
}),
last: options.last.then(|| {
Box::new(
EagerVec::forced_import(db, name, version + Version::ZERO, format).unwrap(),
)
Box::new(EagerVec::forced_import(db, name, version + Version::ZERO).unwrap())
}),
min: options.min.then(|| {
Box::new(
@@ -88,7 +75,6 @@ where
db,
&maybe_suffix("min"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -99,7 +85,6 @@ where
db,
&maybe_suffix("max"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -110,7 +95,6 @@ where
db,
&maybe_suffix("median"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -121,7 +105,6 @@ where
db,
&maybe_suffix("avg"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -136,7 +119,6 @@ where
maybe_suffix("sum")
}),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -147,7 +129,6 @@ where
db,
&suffix("cumulative"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -158,7 +139,6 @@ where
db,
&maybe_suffix("pct90"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -169,7 +149,6 @@ where
db,
&maybe_suffix("pct75"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -180,7 +159,6 @@ where
db,
&maybe_suffix("pct25"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -191,7 +169,6 @@ where
db,
&maybe_suffix("pct10"),
version + VERSION + Version::ZERO,
format,
)
.unwrap(),
)
@@ -535,51 +512,51 @@ where
pub fn starting_index(&self, max_from: I) -> I {
max_from.min(I::from(
self.iter_any_writable().map(|v| v.len()).min().unwrap(),
self.iter_any_exportable().map(|v| v.len()).min().unwrap(),
))
}
pub fn unwrap_first(&self) -> &EagerVec<I, T> {
pub fn unwrap_first(&self) -> &EagerVec<PcoVec<I, T>> {
self.first.as_ref().unwrap()
}
#[allow(unused)]
pub fn unwrap_average(&self) -> &EagerVec<I, T> {
pub fn unwrap_average(&self) -> &EagerVec<PcoVec<I, T>> {
self.average.as_ref().unwrap()
}
pub fn unwrap_sum(&self) -> &EagerVec<I, T> {
pub fn unwrap_sum(&self) -> &EagerVec<PcoVec<I, T>> {
self.sum.as_ref().unwrap()
}
pub fn unwrap_max(&self) -> &EagerVec<I, T> {
pub fn unwrap_max(&self) -> &EagerVec<PcoVec<I, T>> {
self.max.as_ref().unwrap()
}
#[allow(unused)]
pub fn unwrap_pct90(&self) -> &EagerVec<I, T> {
pub fn unwrap_pct90(&self) -> &EagerVec<PcoVec<I, T>> {
self.pct90.as_ref().unwrap()
}
#[allow(unused)]
pub fn unwrap_pct75(&self) -> &EagerVec<I, T> {
pub fn unwrap_pct75(&self) -> &EagerVec<PcoVec<I, T>> {
self.pct75.as_ref().unwrap()
}
#[allow(unused)]
pub fn unwrap_median(&self) -> &EagerVec<I, T> {
pub fn unwrap_median(&self) -> &EagerVec<PcoVec<I, T>> {
self.median.as_ref().unwrap()
}
#[allow(unused)]
pub fn unwrap_pct25(&self) -> &EagerVec<I, T> {
pub fn unwrap_pct25(&self) -> &EagerVec<PcoVec<I, T>> {
self.pct25.as_ref().unwrap()
}
#[allow(unused)]
pub fn unwrap_pct10(&self) -> &EagerVec<I, T> {
pub fn unwrap_pct10(&self) -> &EagerVec<PcoVec<I, T>> {
self.pct10.as_ref().unwrap()
}
pub fn unwrap_min(&self) -> &EagerVec<I, T> {
pub fn unwrap_min(&self) -> &EagerVec<PcoVec<I, T>> {
self.min.as_ref().unwrap()
}
pub fn unwrap_last(&self) -> &EagerVec<I, T> {
pub fn unwrap_last(&self) -> &EagerVec<PcoVec<I, T>> {
self.last.as_ref().unwrap()
}
#[allow(unused)]
pub fn unwrap_cumulative(&self) -> &EagerVec<I, T> {
pub fn unwrap_cumulative(&self) -> &EagerVec<PcoVec<I, T>> {
self.cumulative.as_ref().unwrap()
}
@@ -209,7 +209,7 @@ where
pub fn starting_index(&self, max_from: I) -> I {
max_from.min(I::from(
self.iter_any_writable().map(|v| v.len()).min().unwrap(),
self.iter_any_exportable().map(|v| v.len()).min().unwrap(),
))
}
+4 -1
View File
@@ -1,5 +1,6 @@
use std::ops::{Add, AddAssign, Div};
use serde::Serialize;
use vecdb::{Formattable, PcoVecValue};
pub trait ComputedVecValue
@@ -10,7 +11,8 @@ where
+ Add<Output = Self>
+ AddAssign
+ Ord
+ Formattable,
+ Formattable
+ Serialize,
{
}
impl<T> ComputedVecValue for T where
@@ -21,5 +23,6 @@ impl<T> ComputedVecValue for T where
+ AddAssign
+ Ord
+ Formattable
+ Serialize
{
}
@@ -4,7 +4,10 @@ use brk_traversable::Traversable;
use brk_types::{
DateIndex, DecadeIndex, MonthIndex, QuarterIndex, SemesterIndex, Version, WeekIndex, YearIndex,
};
use vecdb::{AnyWritableVec, Database, EagerVec, Exit, IterableCloneableVec, IterableVec};
use vecdb::{
AnyExportableVec, Database, EagerVec, Exit, Importable, IterableCloneableVec, IterableVec,
PcoVec,
};
use crate::{Indexes, grouped::LazyVecsBuilder, indexes};
@@ -15,7 +18,7 @@ pub struct ComputedVecsFromDateIndex<T>
where
T: ComputedVecValue + PartialOrd,
{
pub dateindex: Option<EagerVec<DateIndex, T>>,
pub dateindex: Option<EagerVec<PcoVec<DateIndex, T>>>,
pub dateindex_extra: EagerVecsBuilder<DateIndex, T>,
pub weekindex: LazyVecsBuilder<WeekIndex, T, DateIndex, WeekIndex>,
pub monthindex: LazyVecsBuilder<MonthIndex, T, DateIndex, MonthIndex>,
@@ -40,11 +43,11 @@ where
indexes: &indexes::Vecs,
options: VecBuilderOptions,
) -> Result<Self> {
let dateindex = source.is_compute().then(|| {
EagerVec::forced_import_compressed(db, name, version + VERSION + Version::ZERO).unwrap()
});
let dateindex = source
.is_compute()
.then(|| EagerVec::forced_import(db, name, version + VERSION + Version::ZERO).unwrap());
let dateindex_extra = EagerVecsBuilder::forced_import_compressed(
let dateindex_extra = EagerVecsBuilder::forced_import(
db,
name,
version + VERSION + Version::ZERO,
@@ -116,11 +119,11 @@ where
mut compute: F,
) -> Result<()>
where
F: FnMut(&mut EagerVec<DateIndex, T>) -> Result<()>,
F: FnMut(&mut EagerVec<PcoVec<DateIndex, T>>) -> Result<()>,
{
compute(self.dateindex.as_mut().unwrap())?;
let dateindex: Option<&EagerVec<DateIndex, T>> = None;
let dateindex: Option<&EagerVec<PcoVec<DateIndex, T>>> = None;
self.compute_rest(starting_indexes, exit, dateindex)
}
@@ -178,17 +181,17 @@ where
.unwrap()
}
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyWritableVec>> =
Box::new(self.dateindex_extra.iter_any_writable());
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_writable()));
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> {
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyExportableVec>> =
Box::new(self.dateindex_extra.iter_any_exportable());
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_exportable()));
if let Some(ref x) = self.dateindex {
regular_iter = Box::new(regular_iter.chain(x.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(x.iter_any_exportable()));
}
regular_iter
}
+26 -27
View File
@@ -5,7 +5,10 @@ use brk_types::{
DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, SemesterIndex,
Version, WeekIndex, YearIndex,
};
use vecdb::{AnyWritableVec, Database, EagerVec, Exit, IterableCloneableVec, IterableVec};
use vecdb::{
AnyExportableVec, Database, EagerVec, Exit, Importable, IterableCloneableVec, IterableVec,
PcoVec,
};
use crate::{
Indexes,
@@ -20,7 +23,7 @@ pub struct ComputedVecsFromHeight<T>
where
T: ComputedVecValue + PartialOrd,
{
pub height: Option<EagerVec<Height, T>>,
pub height: Option<EagerVec<PcoVec<Height, T>>>,
pub height_extra: EagerVecsBuilder<Height, T>,
pub dateindex: EagerVecsBuilder<DateIndex, T>,
pub weekindex: LazyVecsBuilder<WeekIndex, T, DateIndex, WeekIndex>,
@@ -49,23 +52,19 @@ where
indexes: &indexes::Vecs,
options: VecBuilderOptions,
) -> Result<Self> {
let height = source.is_compute().then(|| {
EagerVec::forced_import_compressed(db, name, version + VERSION + Version::ZERO).unwrap()
});
let height = source
.is_compute()
.then(|| EagerVec::forced_import(db, name, version + VERSION + Version::ZERO).unwrap());
let height_extra = EagerVecsBuilder::forced_import_compressed(
let height_extra = EagerVecsBuilder::forced_import(
db,
name,
version + VERSION + Version::ZERO,
options.copy_self_extra(),
)?;
let dateindex = EagerVecsBuilder::forced_import_compressed(
db,
name,
version + VERSION + Version::ZERO,
options,
)?;
let dateindex =
EagerVecsBuilder::forced_import(db, name, version + VERSION + Version::ZERO, options)?;
let options = options.remove_percentiles();
@@ -122,7 +121,7 @@ where
height,
height_extra,
dateindex,
difficultyepoch: EagerVecsBuilder::forced_import_compressed(
difficultyepoch: EagerVecsBuilder::forced_import(
db,
name,
version + VERSION + Version::ZERO,
@@ -139,11 +138,11 @@ where
mut compute: F,
) -> Result<()>
where
F: FnMut(&mut EagerVec<Height, T>) -> Result<()>,
F: FnMut(&mut EagerVec<PcoVec<Height, T>>) -> Result<()>,
{
compute(self.height.as_mut().unwrap())?;
let height: Option<&EagerVec<Height, T>> = None;
let height: Option<&EagerVec<PcoVec<Height, T>>> = None;
self.compute_rest(indexes, starting_indexes, exit, height)
}
@@ -239,19 +238,19 @@ where
.unwrap()
}
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyWritableVec>> =
Box::new(self.height_extra.iter_any_writable());
regular_iter = Box::new(regular_iter.chain(self.dateindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_writable()));
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> {
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyExportableVec>> =
Box::new(self.height_extra.iter_any_exportable());
regular_iter = Box::new(regular_iter.chain(self.dateindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_exportable()));
if let Some(ref x) = self.height {
regular_iter = Box::new(regular_iter.chain(x.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(x.iter_any_exportable()));
}
regular_iter
}
@@ -2,7 +2,7 @@ use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{DifficultyEpoch, Height, Version};
use vecdb::{AnyWritableVec, Database, EagerVec, Exit};
use vecdb::{AnyExportableVec, Database, EagerVec, Exit, Importable, PcoVec};
use crate::{Indexes, indexes};
@@ -13,7 +13,7 @@ pub struct ComputedVecsFromHeightStrict<T>
where
T: ComputedVecValue + PartialOrd,
{
pub height: EagerVec<Height, T>,
pub height: EagerVec<PcoVec<Height, T>>,
pub height_extra: EagerVecsBuilder<Height, T>,
pub difficultyepoch: EagerVecsBuilder<DifficultyEpoch, T>,
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
@@ -32,10 +32,9 @@ where
version: Version,
options: VecBuilderOptions,
) -> Result<Self> {
let height =
EagerVec::forced_import_compressed(db, name, version + VERSION + Version::ZERO)?;
let height = EagerVec::forced_import(db, name, version + VERSION + Version::ZERO)?;
let height_extra = EagerVecsBuilder::forced_import_compressed(
let height_extra = EagerVecsBuilder::forced_import(
db,
name,
version + VERSION + Version::ZERO,
@@ -47,7 +46,7 @@ where
Ok(Self {
height,
height_extra,
difficultyepoch: EagerVecsBuilder::forced_import_compressed(
difficultyepoch: EagerVecsBuilder::forced_import(
db,
name,
version + VERSION + Version::ZERO,
@@ -65,7 +64,7 @@ where
mut compute: F,
) -> Result<()>
where
F: FnMut(&mut EagerVec<Height, T>) -> Result<()>,
F: FnMut(&mut EagerVec<PcoVec<Height, T>>) -> Result<()>,
{
compute(&mut self.height)?;
@@ -111,11 +110,11 @@ where
.unwrap()
}
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyWritableVec>> =
Box::new(self.height.iter_any_writable());
regular_iter = Box::new(regular_iter.chain(self.height_extra.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_writable()));
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> {
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyExportableVec>> =
Box::new(self.height.iter_any_exportable());
regular_iter = Box::new(regular_iter.chain(self.height_extra.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_exportable()));
regular_iter
}
}
+22 -33
View File
@@ -6,8 +6,8 @@ use brk_types::{
Sats, SemesterIndex, TxIndex, Version, WeekIndex, YearIndex,
};
use vecdb::{
AnyVec, AnyWritableVec, CollectableVec, Database, EagerVec, Exit, GenericStoredVec,
IterableCloneableVec, TypedVecIterator, VecIndex,
AnyExportableVec, AnyVec, CollectableVec, Database, EagerVec, Exit, GenericStoredVec,
Importable, IterableCloneableVec, PcoVec, TypedVecIterator, VecIndex,
};
use crate::{
@@ -23,7 +23,7 @@ pub struct ComputedVecsFromTxindex<T>
where
T: ComputedVecValue + PartialOrd,
{
pub txindex: Option<Box<EagerVec<TxIndex, T>>>,
pub txindex: Option<Box<EagerVec<PcoVec<TxIndex, T>>>>,
pub height: EagerVecsBuilder<Height, T>,
pub dateindex: EagerVecsBuilder<DateIndex, T>,
pub weekindex: LazyVecsBuilder<WeekIndex, T, DateIndex, WeekIndex>,
@@ -53,27 +53,16 @@ where
options: VecBuilderOptions,
) -> Result<Self> {
let txindex = source.is_compute().then(|| {
Box::new(
EagerVec::forced_import_compressed(db, name, version + VERSION + Version::ZERO)
.unwrap(),
)
Box::new(EagerVec::forced_import(db, name, version + VERSION + Version::ZERO).unwrap())
});
let height = EagerVecsBuilder::forced_import_compressed(
db,
name,
version + VERSION + Version::ZERO,
options,
)?;
let height =
EagerVecsBuilder::forced_import(db, name, version + VERSION + Version::ZERO, options)?;
let options = options.remove_percentiles();
let dateindex = EagerVecsBuilder::forced_import_compressed(
db,
name,
version + VERSION + Version::ZERO,
options,
)?;
let dateindex =
EagerVecsBuilder::forced_import(db, name, version + VERSION + Version::ZERO, options)?;
Ok(Self {
weekindex: LazyVecsBuilder::forced_import(
@@ -128,7 +117,7 @@ where
txindex,
height,
dateindex,
difficultyepoch: EagerVecsBuilder::forced_import_compressed(
difficultyepoch: EagerVecsBuilder::forced_import(
db,
name,
version + VERSION + Version::ZERO,
@@ -149,7 +138,7 @@ where
// ) -> Result<()>
// where
// F: FnMut(
// &mut EagerVec<TxIndex, T>,
// &mut EagerVec<PcoVec<TxIndex, T>>,
// &Indexer,
// &indexes::Vecs,
// &Indexes,
@@ -497,19 +486,19 @@ where
.unwrap()
}
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyWritableVec>> =
Box::new(self.height.iter_any_writable());
regular_iter = Box::new(regular_iter.chain(self.dateindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_writable()));
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec> {
let mut regular_iter: Box<dyn Iterator<Item = &dyn AnyExportableVec>> =
Box::new(self.height.iter_any_exportable());
regular_iter = Box::new(regular_iter.chain(self.dateindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.weekindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.difficultyepoch.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.monthindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.quarterindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.semesterindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.yearindex.iter_any_exportable()));
regular_iter = Box::new(regular_iter.chain(self.decadeindex.iter_any_exportable()));
if let Some(ref x) = self.txindex {
regular_iter = Box::new(regular_iter.chain(x.iter_any_writable()));
regular_iter = Box::new(regular_iter.chain(x.iter_any_exportable()));
}
regular_iter
}
@@ -1,7 +1,7 @@
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Date, DateIndex, Dollars, StoredF32, Version};
use vecdb::{
use vecdb::{PcoVec,
AnyStoredVec, AnyVec, CollectableVec, Database, EagerVec, Exit, GenericStoredVec, IterableVec,
TypedVecIterator, VecIndex,
};
@@ -290,14 +290,14 @@ impl ComputedRatioVecsFromDateIndex {
compute: F,
) -> Result<()>
where
F: FnMut(&mut EagerVec<DateIndex, Dollars>) -> Result<()>,
F: FnMut(&mut EagerVec<PcoVec<DateIndex, Dollars>>) -> Result<()>,
{
self.price
.as_mut()
.unwrap()
.compute_all(starting_indexes, exit, compute)?;
let date_to_price_opt: Option<&EagerVec<DateIndex, Dollars>> = None;
let date_to_price_opt: Option<&EagerVec<PcoVec<DateIndex, Dollars>>> = None;
self.compute_rest(price, starting_indexes, exit, date_to_price_opt)
}
@@ -501,32 +501,32 @@ impl ComputedRatioVecsFromDateIndex {
self.ratio_pct1.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
None as Option<&EagerVec<PcoVec<_, _>>>,
)?;
self.ratio_pct2.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
None as Option<&EagerVec<PcoVec<_, _>>>,
)?;
self.ratio_pct5.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
None as Option<&EagerVec<PcoVec<_, _>>>,
)?;
self.ratio_pct95.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
None as Option<&EagerVec<PcoVec<_, _>>>,
)?;
self.ratio_pct98.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
None as Option<&EagerVec<PcoVec<_, _>>>,
)?;
self.ratio_pct99.as_mut().unwrap().compute_rest(
starting_indexes,
exit,
None as Option<&EagerVec<_, _>>,
None as Option<&EagerVec<PcoVec<_, _>>>,
)?;
let date_to_price = price_opt.unwrap_or_else(|| unsafe {
@@ -610,7 +610,7 @@ impl ComputedRatioVecsFromDateIndex {
Ok(())
}
fn mut_ratio_vecs(&mut self) -> Vec<&mut EagerVec<DateIndex, StoredF32>> {
fn mut_ratio_vecs(&mut self) -> Vec<&mut EagerVec<PcoVec<DateIndex, StoredF32>>> {
let mut vecs = Vec::with_capacity(6);
if let Some(v) = self.ratio_pct1.as_mut() {
vecs.push(v.dateindex.as_mut().unwrap());
@@ -1,7 +1,7 @@
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Date, DateIndex, Dollars, StoredF32, Version};
use vecdb::{
use vecdb::{PcoVec,
AnyStoredVec, AnyVec, BoxedVecIterator, CollectableVec, Database, EagerVec, Exit,
GenericStoredVec, IterableVec, VecIndex,
};
@@ -440,7 +440,7 @@ impl ComputedStandardDeviationVecsFromDateIndex {
Ok(())
})?;
let sma_opt: Option<&EagerVec<DateIndex, StoredF32>> = None;
let sma_opt: Option<&EagerVec<PcoVec<DateIndex, StoredF32>>> = None;
self.compute_rest(starting_indexes, exit, sma_opt, source, price_opt)
}
@@ -615,7 +615,7 @@ impl ComputedStandardDeviationVecsFromDateIndex {
.try_for_each(|v| v.safe_flush(exit))?;
self.mut_stateful_computed().try_for_each(|v| {
v.compute_rest(starting_indexes, exit, None as Option<&EagerVec<_, _>>)
v.compute_rest(starting_indexes, exit, None as Option<&EagerVec<PcoVec<_, _>>>)
})?;
if let Some(zscore) = self.zscore.as_mut() {
@@ -805,7 +805,7 @@ impl ComputedStandardDeviationVecsFromDateIndex {
fn mut_stateful_date_vecs(
&mut self,
) -> impl Iterator<Item = &mut EagerVec<DateIndex, StoredF32>> {
) -> impl Iterator<Item = &mut EagerVec<PcoVec<DateIndex, StoredF32>>> {
self.mut_stateful_computed()
.map(|c| c.dateindex.as_mut().unwrap())
}
@@ -1,7 +1,7 @@
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Bitcoin, DateIndex, Dollars, Sats, Version};
use vecdb::{CollectableVec, Database, EagerVec, Exit, StoredVec};
use vecdb::{CollectableVec, Database, EagerVec, Exit, PcoVec};
use crate::{
Indexes,
@@ -71,11 +71,11 @@ impl ComputedValueVecsFromDateIndex {
mut compute: F,
) -> Result<()>
where
F: FnMut(&mut EagerVec<DateIndex, Sats>) -> Result<()>,
F: FnMut(&mut EagerVec<PcoVec<DateIndex, Sats>>) -> Result<()>,
{
compute(self.sats.dateindex.as_mut().unwrap())?;
let dateindex: Option<&StoredVec<DateIndex, Sats>> = None;
let dateindex: Option<&PcoVec<DateIndex, Sats>> = None;
self.compute_rest(price, starting_indexes, exit, dateindex)?;
Ok(())
@@ -96,7 +96,7 @@ impl ComputedValueVecsFromDateIndex {
v.compute_from_sats(starting_indexes.dateindex, dateindex, exit)
})?;
} else {
let dateindex: Option<&StoredVec<DateIndex, Sats>> = None;
let dateindex: Option<&PcoVec<DateIndex, Sats>> = None;
self.sats.compute_rest(starting_indexes, exit, dateindex)?;
@@ -1,7 +1,7 @@
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Bitcoin, Dollars, Height, Sats, Version};
use vecdb::{CollectableVec, Database, EagerVec, Exit, StoredVec};
use vecdb::{CollectableVec, Database, EagerVec, Exit, PcoVec};
use crate::{
Indexes,
@@ -72,11 +72,11 @@ impl ComputedValueVecsFromHeight {
mut compute: F,
) -> Result<()>
where
F: FnMut(&mut EagerVec<Height, Sats>) -> Result<()>,
F: FnMut(&mut EagerVec<PcoVec<Height, Sats>>) -> Result<()>,
{
compute(self.sats.height.as_mut().unwrap())?;
let height: Option<&StoredVec<Height, Sats>> = None;
let height: Option<&PcoVec<Height, Sats>> = None;
self.compute_rest(indexes, price, starting_indexes, exit, height)?;
Ok(())
@@ -99,7 +99,7 @@ impl ComputedValueVecsFromHeight {
v.compute_from_sats(starting_indexes.height, height, exit)
})?;
} else {
let height: Option<&StoredVec<Height, Sats>> = None;
let height: Option<&PcoVec<Height, Sats>> = None;
self.sats
.compute_rest(indexes, starting_indexes, exit, height)?;
@@ -3,7 +3,7 @@ use brk_indexer::Indexer;
use brk_traversable::Traversable;
use brk_types::{Bitcoin, Close, Dollars, Height, Sats, TxIndex, Version};
use vecdb::{
CollectableVec, Database, Exit, IterableCloneableVec, LazyVecFrom1, LazyVecFrom3, StoredVec,
CollectableVec, Database, Exit, IterableCloneableVec, LazyVecFrom1, LazyVecFrom3, PcoVec,
VecIndex,
};
@@ -122,7 +122,7 @@ impl ComputedValueVecsFromTxindex {
// ) -> Result<()>
// where
// F: FnMut(
// &mut EagerVec<TxIndex, Sats>,
// &mut EagerVec<PcoVec<TxIndex, Sats>>,
// &Indexer,
// &indexes::Vecs,
// &Indexes,
@@ -137,7 +137,7 @@ impl ComputedValueVecsFromTxindex {
// exit,
// )?;
// let txindex: Option<&StoredVec<TxIndex, Sats>> = None;
// let txindex: Option<&PcoVec<TxIndex, Sats>> = None;
// self.compute_rest(
// indexer,
// indexes,
@@ -163,7 +163,7 @@ impl ComputedValueVecsFromTxindex {
self.sats
.compute_rest(indexer, indexes, starting_indexes, exit, Some(txindex))?;
} else {
let txindex: Option<&StoredVec<TxIndex, Sats>> = None;
let txindex: Option<&PcoVec<TxIndex, Sats>> = None;
self.sats
.compute_rest(indexer, indexes, starting_indexes, exit, txindex)?;
}
@@ -1,7 +1,7 @@
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Bitcoin, Dollars, Height, Sats, Version};
use vecdb::{CollectableVec, Database, EagerVec, Exit, Format, StoredVec};
use vecdb::{CollectableVec, Database, EagerVec, Exit, Importable, PcoVec};
use crate::{
Indexes,
@@ -12,9 +12,9 @@ use crate::{
#[derive(Clone, Traversable)]
pub struct ComputedHeightValueVecs {
pub sats: Option<EagerVec<Height, Sats>>,
pub bitcoin: EagerVec<Height, Bitcoin>,
pub dollars: Option<EagerVec<Height, Dollars>>,
pub sats: Option<EagerVec<PcoVec<Height, Sats>>>,
pub bitcoin: EagerVec<PcoVec<Height, Bitcoin>>,
pub dollars: Option<EagerVec<PcoVec<Height, Dollars>>>,
}
const VERSION: Version = Version::ZERO;
@@ -25,26 +25,22 @@ impl ComputedHeightValueVecs {
name: &str,
source: Source<Height, Sats>,
version: Version,
format: Format,
compute_dollars: bool,
) -> Result<Self> {
Ok(Self {
sats: source.is_compute().then(|| {
EagerVec::forced_import(db, name, version + VERSION + Version::ZERO, format)
.unwrap()
EagerVec::forced_import(db, name, version + VERSION + Version::ZERO).unwrap()
}),
bitcoin: EagerVec::forced_import(
db,
&format!("{name}_btc"),
version + VERSION + Version::ZERO,
format,
)?,
dollars: compute_dollars.then(|| {
EagerVec::forced_import(
db,
&format!("{name}_usd"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
}),
@@ -59,11 +55,11 @@ impl ComputedHeightValueVecs {
mut compute: F,
) -> Result<()>
where
F: FnMut(&mut EagerVec<Height, Sats>) -> Result<()>,
F: FnMut(&mut EagerVec<PcoVec<Height, Sats>>) -> Result<()>,
{
compute(self.sats.as_mut().unwrap())?;
let height: Option<&StoredVec<Height, Sats>> = None;
let height: Option<&PcoVec<Height, Sats>> = None;
self.compute_rest(price, starting_indexes, exit, height)?;
Ok(())