mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-30 04:08:11 -07:00
global: wip
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_core::{Bitcoin, DateIndex, Dollars, Sats, Version};
|
||||
use brk_core::{Bitcoin, DateIndex, Dollars, Result, Sats, Version};
|
||||
use brk_exit::Exit;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vec::{AnyCollectableVec, CollectableVec, Format, StoredVec};
|
||||
use brk_vec::{AnyCollectableVec, CollectableVec, EagerVec, Format, StoredVec};
|
||||
|
||||
use crate::vecs::{Indexes, fetched, grouped::ComputedVecsFromDateIndex, indexes};
|
||||
|
||||
@@ -59,37 +59,37 @@ impl ComputedValueVecsFromDateIndex {
|
||||
})
|
||||
}
|
||||
|
||||
// pub fn compute_all<F>(
|
||||
// &mut self,
|
||||
// indexer: &Indexer,
|
||||
// indexes: &indexes::Vecs,
|
||||
// fetched: Option<&fetched::Vecs>,
|
||||
// starting_indexes: &Indexes,
|
||||
// exit: &Exit,
|
||||
// mut compute: F,
|
||||
// ) -> color_eyre::Result<()>
|
||||
// where
|
||||
// F: FnMut(
|
||||
// &mut EagerVec<DateIndex, Sats>,
|
||||
// &Indexer,
|
||||
// &indexes::Vecs,
|
||||
// &Indexes,
|
||||
// &Exit,
|
||||
// ) -> Result<()>,
|
||||
// {
|
||||
// compute(
|
||||
// self.sats.dateindex.as_mut().unwrap(),
|
||||
// indexer,
|
||||
// indexes,
|
||||
// starting_indexes,
|
||||
// exit,
|
||||
// )?;
|
||||
pub fn compute_all<F>(
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
fetched: Option<&fetched::Vecs>,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut compute: F,
|
||||
) -> color_eyre::Result<()>
|
||||
where
|
||||
F: FnMut(
|
||||
&mut EagerVec<DateIndex, Sats>,
|
||||
&Indexer,
|
||||
&indexes::Vecs,
|
||||
&Indexes,
|
||||
&Exit,
|
||||
) -> Result<()>,
|
||||
{
|
||||
compute(
|
||||
self.sats.dateindex.as_mut().unwrap(),
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// let dateindex: Option<&StoredVec<DateIndex, Sats>> = None;
|
||||
// self.compute_rest(indexer, indexes, fetched, starting_indexes, exit, dateindex)?;
|
||||
let dateindex: Option<&StoredVec<DateIndex, Sats>> = None;
|
||||
self.compute_rest(indexer, indexes, fetched, starting_indexes, exit, dateindex)?;
|
||||
|
||||
// Ok(())
|
||||
// }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn compute_rest(
|
||||
&mut self,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_core::{Bitcoin, Dollars, Height, Sats, Version};
|
||||
use brk_core::{Bitcoin, Dollars, Height, Result, Sats, Version};
|
||||
use brk_exit::Exit;
|
||||
use brk_vec::{AnyCollectableVec, CollectableVec, EagerVec, Format};
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vec::{AnyCollectableVec, CollectableVec, EagerVec, Format, StoredVec};
|
||||
|
||||
use crate::vecs::{Indexes, fetched};
|
||||
use crate::vecs::{Indexes, fetched, indexes};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ComputedHeightValueVecs {
|
||||
@@ -47,37 +48,37 @@ impl ComputedHeightValueVecs {
|
||||
})
|
||||
}
|
||||
|
||||
// pub fn compute_all<F>(
|
||||
// &mut self,
|
||||
// indexer: &Indexer,
|
||||
// indexes: &indexes::Vecs,
|
||||
// fetched: Option<&fetched::Vecs>,
|
||||
// starting_indexes: &Indexes,
|
||||
// exit: &Exit,
|
||||
// mut compute: F,
|
||||
// ) -> color_eyre::Result<()>
|
||||
// where
|
||||
// F: FnMut(
|
||||
// &mut EagerVec<Height, Sats>,
|
||||
// &Indexer,
|
||||
// &indexes::Vecs,
|
||||
// &Indexes,
|
||||
// &Exit,
|
||||
// ) -> Result<()>,
|
||||
// {
|
||||
// compute(
|
||||
// self.sats.as_mut().unwrap(),
|
||||
// indexer,
|
||||
// indexes,
|
||||
// starting_indexes,
|
||||
// exit,
|
||||
// )?;
|
||||
pub fn compute_all<F>(
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
fetched: Option<&fetched::Vecs>,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut compute: F,
|
||||
) -> color_eyre::Result<()>
|
||||
where
|
||||
F: FnMut(
|
||||
&mut EagerVec<Height, Sats>,
|
||||
&Indexer,
|
||||
&indexes::Vecs,
|
||||
&Indexes,
|
||||
&Exit,
|
||||
) -> Result<()>,
|
||||
{
|
||||
compute(
|
||||
self.sats.as_mut().unwrap(),
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// let height: Option<&StoredVec<Height, Sats>> = None;
|
||||
// self.compute_rest(fetched, starting_indexes, exit, height)?;
|
||||
let height: Option<&StoredVec<Height, Sats>> = None;
|
||||
self.compute_rest(fetched, starting_indexes, exit, height)?;
|
||||
|
||||
// Ok(())
|
||||
// }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn compute_rest(
|
||||
&mut self,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use core::panic;
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use brk_core::{
|
||||
DateIndex, Dollars, Height, Result, Sats, StoredF32, StoredF64, StoredUsize, Version,
|
||||
Bitcoin, DateIndex, Dollars, Height, Result, Sats, StoredF32, StoredF64, StoredUsize, Version,
|
||||
};
|
||||
use brk_exit::Exit;
|
||||
use brk_indexer::Indexer;
|
||||
@@ -16,8 +17,7 @@ use crate::vecs::{
|
||||
Indexes, fetched,
|
||||
grouped::{
|
||||
ComputedHeightValueVecs, ComputedRatioVecsFromDateIndex, ComputedValueVecsFromDateIndex,
|
||||
ComputedValueVecsFromHeight, ComputedVecsFromDateIndex, ComputedVecsFromHeight,
|
||||
StorableVecGeneatorOptions,
|
||||
ComputedVecsFromDateIndex, ComputedVecsFromHeight, StorableVecGeneatorOptions,
|
||||
},
|
||||
indexes, market,
|
||||
};
|
||||
@@ -52,7 +52,11 @@ pub struct Vecs {
|
||||
pub height_to_unrealized_profit: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_value_created: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_value_destroyed: Option<EagerVec<Height, Dollars>>,
|
||||
pub height_to_satblocks_destroyed: EagerVec<Height, Sats>,
|
||||
pub height_to_satdays_destroyed: EagerVec<Height, Sats>,
|
||||
|
||||
pub indexes_to_coinblocks_destroyed: ComputedVecsFromHeight<Bitcoin>,
|
||||
pub indexes_to_coindays_destroyed: ComputedVecsFromHeight<Bitcoin>,
|
||||
pub dateindex_to_adjusted_spent_output_profit_ratio: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
pub dateindex_to_realized_cap_30d_change: Option<EagerVec<DateIndex, Dollars>>,
|
||||
pub dateindex_to_sell_side_risk_ratio: Option<EagerVec<DateIndex, StoredF32>>,
|
||||
@@ -67,7 +71,8 @@ pub struct Vecs {
|
||||
pub indexes_to_realized_price_extra: Option<ComputedRatioVecsFromDateIndex>,
|
||||
pub indexes_to_realized_profit: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_realized_value: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_supply: ComputedValueVecsFromHeight,
|
||||
pub height_to_supply_value: ComputedHeightValueVecs,
|
||||
pub indexes_to_supply: ComputedValueVecsFromDateIndex,
|
||||
pub indexes_to_utxo_count: ComputedVecsFromHeight<StoredUsize>,
|
||||
pub indexes_to_value_created: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_value_destroyed: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
@@ -75,7 +80,8 @@ pub struct Vecs {
|
||||
pub indexes_to_unrealized_loss: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub indexes_to_min_price_paid: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_max_price_paid: Option<ComputedVecsFromHeight<Dollars>>,
|
||||
pub indexes_to_halved_supply: ComputedValueVecsFromHeight,
|
||||
pub height_to_halved_supply_value: ComputedHeightValueVecs,
|
||||
pub indexes_to_halved_supply: ComputedValueVecsFromDateIndex,
|
||||
pub height_to_negative_unrealized_loss: Option<EagerVec<Height, Dollars>>,
|
||||
pub indexes_to_negative_unrealized_loss: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub height_to_net_unrealized_profit_and_loss: Option<EagerVec<Height, Dollars>>,
|
||||
@@ -139,7 +145,7 @@ impl Vecs {
|
||||
keyspace,
|
||||
stores_path,
|
||||
cohort_name.unwrap_or_default(),
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
compute_dollars,
|
||||
)?;
|
||||
|
||||
@@ -361,12 +367,20 @@ impl Vecs {
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
indexes_to_supply: ComputedValueVecsFromHeight::forced_import(
|
||||
height_to_supply_value: ComputedHeightValueVecs::forced_import(
|
||||
path,
|
||||
&suffix("supply"),
|
||||
false,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
compute_dollars,
|
||||
)?,
|
||||
indexes_to_supply: ComputedValueVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&suffix("supply"),
|
||||
true,
|
||||
version + VERSION + Version::ONE,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
compute_dollars,
|
||||
)?,
|
||||
@@ -595,7 +609,15 @@ impl Vecs {
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_halved_supply: ComputedValueVecsFromHeight::forced_import(
|
||||
height_to_halved_supply_value: ComputedHeightValueVecs::forced_import(
|
||||
path,
|
||||
&suffix("halved_supply"),
|
||||
true,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
compute_dollars,
|
||||
)?,
|
||||
indexes_to_halved_supply: ComputedValueVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&suffix("halved_supply"),
|
||||
true,
|
||||
@@ -604,7 +626,6 @@ impl Vecs {
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
compute_dollars,
|
||||
)?,
|
||||
|
||||
height_to_negative_unrealized_loss: compute_dollars.then(|| {
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
@@ -687,7 +708,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_even"),
|
||||
false,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
compute_dollars,
|
||||
)
|
||||
@@ -698,7 +719,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_in_loss"),
|
||||
false,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
compute_dollars,
|
||||
)
|
||||
@@ -709,7 +730,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_in_profit"),
|
||||
false,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
compute_dollars,
|
||||
)
|
||||
@@ -719,7 +740,7 @@ impl Vecs {
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("supply_even_relative_to_own_supply"),
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -728,7 +749,7 @@ impl Vecs {
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("supply_in_loss_relative_to_own_supply"),
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -737,7 +758,7 @@ impl Vecs {
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("supply_in_profit_relative_to_own_supply"),
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -747,7 +768,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_even_relative_to_own_supply"),
|
||||
true,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
@@ -758,7 +779,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_in_loss_relative_to_own_supply"),
|
||||
true,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
@@ -769,7 +790,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_in_profit_relative_to_own_supply"),
|
||||
true,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
@@ -780,7 +801,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_relative_to_circulating_supply"),
|
||||
true,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
@@ -792,7 +813,7 @@ impl Vecs {
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("supply_even_relative_to_circulating_supply"),
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -803,7 +824,7 @@ impl Vecs {
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("supply_in_loss_relative_to_circulating_supply"),
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -814,7 +835,7 @@ impl Vecs {
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("supply_in_profit_relative_to_circulating_supply"),
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -826,7 +847,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_even_relative_to_circulating_supply"),
|
||||
true,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
@@ -839,7 +860,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_in_loss_relative_to_circulating_supply"),
|
||||
true,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
@@ -852,12 +873,44 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("supply_in_profit_relative_to_circulating_supply"),
|
||||
true,
|
||||
version,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
height_to_satblocks_destroyed: EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("satblocks_destroyed"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
height_to_satdays_destroyed: EagerVec::forced_import(
|
||||
path,
|
||||
&suffix("satdays_destroyed"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
indexes_to_coinblocks_destroyed: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
&suffix("coinblocks_destroyed"),
|
||||
true,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default()
|
||||
.add_sum()
|
||||
.add_cumulative(),
|
||||
)?,
|
||||
indexes_to_coindays_destroyed: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
&suffix("coindays_destroyed"),
|
||||
true,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default()
|
||||
.add_sum()
|
||||
.add_cumulative(),
|
||||
)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -911,6 +964,8 @@ impl Vecs {
|
||||
self.height_to_max_price_paid
|
||||
.as_ref()
|
||||
.map_or(usize::MAX, |v| v.len()),
|
||||
self.height_to_satdays_destroyed.len(),
|
||||
self.height_to_satblocks_destroyed.len(),
|
||||
]
|
||||
.into_iter()
|
||||
.map(Height::from)
|
||||
@@ -956,6 +1011,16 @@ impl Vecs {
|
||||
base_version + self.height_to_utxo_count.inner_version(),
|
||||
)?;
|
||||
|
||||
self.height_to_satblocks_destroyed
|
||||
.validate_computed_version_or_reset_file(
|
||||
base_version + self.height_to_satblocks_destroyed.inner_version(),
|
||||
)?;
|
||||
|
||||
self.height_to_satdays_destroyed
|
||||
.validate_computed_version_or_reset_file(
|
||||
base_version + self.height_to_satdays_destroyed.inner_version(),
|
||||
)?;
|
||||
|
||||
if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut().as_mut() {
|
||||
height_to_realized_cap.validate_computed_version_or_reset_file(
|
||||
base_version + height_to_realized_cap.inner_version(),
|
||||
@@ -1175,6 +1240,18 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.height_to_satblocks_destroyed.forced_push_at(
|
||||
height,
|
||||
self.state.satblocks_destroyed,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.height_to_satdays_destroyed.forced_push_at(
|
||||
height,
|
||||
self.state.satdays_destroyed,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut() {
|
||||
let realized = self.state.realized.as_ref().unwrap_or_else(|| {
|
||||
dbg!((&self.state.realized, &self.state.supply));
|
||||
@@ -1301,8 +1378,9 @@ impl Vecs {
|
||||
|
||||
pub fn safe_flush_stateful_vecs(&mut self, height: Height, exit: &Exit) -> Result<()> {
|
||||
self.height_to_supply.safe_flush(exit)?;
|
||||
|
||||
self.height_to_utxo_count.safe_flush(exit)?;
|
||||
self.height_to_satdays_destroyed.safe_flush(exit)?;
|
||||
self.height_to_satblocks_destroyed.safe_flush(exit)?;
|
||||
|
||||
if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut() {
|
||||
height_to_realized_cap.safe_flush(exit)?;
|
||||
@@ -1409,6 +1487,24 @@ impl Vecs {
|
||||
.as_slice(),
|
||||
exit,
|
||||
)?;
|
||||
self.height_to_satblocks_destroyed.compute_sum_of_others(
|
||||
starting_indexes.height,
|
||||
others
|
||||
.iter()
|
||||
.map(|v| &v.height_to_satblocks_destroyed)
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
exit,
|
||||
)?;
|
||||
self.height_to_satdays_destroyed.compute_sum_of_others(
|
||||
starting_indexes.height,
|
||||
others
|
||||
.iter()
|
||||
.map(|v| &v.height_to_satdays_destroyed)
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
if let Some(height_to_realized_cap) = &mut self.height_to_realized_cap {
|
||||
height_to_realized_cap.compute_sum_of_others(
|
||||
@@ -1675,13 +1771,37 @@ impl Vecs {
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> color_eyre::Result<()> {
|
||||
self.indexes_to_supply.compute_rest(
|
||||
self.height_to_supply_value.compute_rest(
|
||||
fetched,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(&self.height_to_supply),
|
||||
)?;
|
||||
|
||||
self.indexes_to_supply.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
fetched,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(&self.height_to_supply),
|
||||
|v, _, indexes, starting_indexes, exit| {
|
||||
let mut dateindex_to_height_count_iter =
|
||||
indexes.dateindex_to_height_count.into_iter();
|
||||
let mut height_to_supply_iter = self.height_to_supply.into_iter();
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
&indexes.dateindex_to_first_height,
|
||||
|(i, height, ..)| {
|
||||
let count = dateindex_to_height_count_iter.unwrap_get_inner(i);
|
||||
if count == StoredUsize::default() {
|
||||
unreachable!()
|
||||
}
|
||||
let supply = height_to_supply_iter.unwrap_get_inner(height + (*count - 1));
|
||||
(i, supply)
|
||||
},
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
self.indexes_to_utxo_count.compute_rest(
|
||||
@@ -1691,6 +1811,22 @@ impl Vecs {
|
||||
Some(&self.height_to_utxo_count),
|
||||
)?;
|
||||
|
||||
self.height_to_halved_supply_value.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
fetched,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.height_to_supply,
|
||||
|(h, v, ..)| (h, v / 2),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
self.indexes_to_halved_supply.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
@@ -1699,9 +1835,37 @@ impl Vecs {
|
||||
exit,
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.indexes_to_supply.sats.dateindex.as_ref().unwrap(),
|
||||
|(i, sats, ..)| (i, sats / 2),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
self.indexes_to_coinblocks_destroyed.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_from_sats(
|
||||
starting_indexes.height,
|
||||
&self.height_to_supply,
|
||||
|(h, sats, ..)| (h, sats / 2),
|
||||
&self.height_to_satblocks_destroyed,
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
self.indexes_to_coindays_destroyed.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_from_sats(
|
||||
starting_indexes.height,
|
||||
&self.height_to_satdays_destroyed,
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -1718,8 +1882,8 @@ impl Vecs {
|
||||
fetched: Option<&fetched::Vecs>,
|
||||
starting_indexes: &Indexes,
|
||||
market: &market::Vecs,
|
||||
height_to_supply: &impl AnyIterableVec<Height, Sats>,
|
||||
dateindex_to_supply: &impl AnyIterableVec<DateIndex, Sats>,
|
||||
height_to_supply: &impl AnyIterableVec<Height, Bitcoin>,
|
||||
dateindex_to_supply: &impl AnyIterableVec<DateIndex, Bitcoin>,
|
||||
height_to_realized_cap: Option<&impl AnyIterableVec<Height, Dollars>>,
|
||||
exit: &Exit,
|
||||
) -> color_eyre::Result<()> {
|
||||
@@ -1735,7 +1899,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_percentage(
|
||||
starting_indexes.height,
|
||||
&self.height_to_supply,
|
||||
&self.height_to_supply_value.bitcoin,
|
||||
height_to_supply,
|
||||
exit,
|
||||
)
|
||||
@@ -1763,7 +1927,7 @@ impl Vecs {
|
||||
vec.compute_divide(
|
||||
starting_indexes.height,
|
||||
self.height_to_realized_cap.as_ref().unwrap(),
|
||||
self.indexes_to_supply.bitcoin.height.as_ref().unwrap(),
|
||||
&self.height_to_supply_value.bitcoin,
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -2213,7 +2377,7 @@ impl Vecs {
|
||||
v.compute_percentage(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_supply_even.as_ref().unwrap(),
|
||||
self.indexes_to_supply.sats.dateindex.unwrap_last(),
|
||||
self.indexes_to_supply.sats.dateindex.as_ref().unwrap(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -2230,7 +2394,7 @@ impl Vecs {
|
||||
v.compute_percentage(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_supply_even.as_ref().unwrap(),
|
||||
self.indexes_to_supply.sats.dateindex.unwrap_last(),
|
||||
self.indexes_to_supply.sats.dateindex.as_ref().unwrap(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -2247,7 +2411,7 @@ impl Vecs {
|
||||
v.compute_percentage(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_supply_even.as_ref().unwrap(),
|
||||
self.indexes_to_supply.sats.dateindex.unwrap_last(),
|
||||
self.indexes_to_supply.sats.dateindex.as_ref().unwrap(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -2259,7 +2423,7 @@ impl Vecs {
|
||||
{
|
||||
height_to_supply_even_relative_to_circulating_supply.compute_percentage(
|
||||
starting_indexes.height,
|
||||
self.height_to_supply_even.as_ref().unwrap(),
|
||||
&self.height_to_supply_even_value.as_ref().unwrap().bitcoin,
|
||||
height_to_supply,
|
||||
exit,
|
||||
)?;
|
||||
@@ -2268,7 +2432,11 @@ impl Vecs {
|
||||
.unwrap()
|
||||
.compute_percentage(
|
||||
starting_indexes.height,
|
||||
self.height_to_supply_in_loss.as_ref().unwrap(),
|
||||
&self
|
||||
.height_to_supply_in_loss_value
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.bitcoin,
|
||||
height_to_supply,
|
||||
exit,
|
||||
)?;
|
||||
@@ -2277,7 +2445,11 @@ impl Vecs {
|
||||
.unwrap()
|
||||
.compute_percentage(
|
||||
starting_indexes.height,
|
||||
self.height_to_supply_in_profit.as_ref().unwrap(),
|
||||
&self
|
||||
.height_to_supply_in_profit_value
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.bitcoin,
|
||||
height_to_supply,
|
||||
exit,
|
||||
)?;
|
||||
@@ -2292,7 +2464,13 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_percentage(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_supply_even.as_ref().unwrap(),
|
||||
self.indexes_to_supply_even
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.bitcoin
|
||||
.dateindex
|
||||
.as_ref()
|
||||
.unwrap(),
|
||||
dateindex_to_supply,
|
||||
exit,
|
||||
)
|
||||
@@ -2309,7 +2487,13 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_percentage(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_supply_in_loss.as_ref().unwrap(),
|
||||
self.indexes_to_supply_in_loss
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.bitcoin
|
||||
.dateindex
|
||||
.as_ref()
|
||||
.unwrap(),
|
||||
dateindex_to_supply,
|
||||
exit,
|
||||
)
|
||||
@@ -2326,7 +2510,13 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_percentage(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_supply_in_profit.as_ref().unwrap(),
|
||||
self.indexes_to_supply_in_profit
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.bitcoin
|
||||
.dateindex
|
||||
.as_ref()
|
||||
.unwrap(),
|
||||
dateindex_to_supply,
|
||||
exit,
|
||||
)
|
||||
@@ -2343,10 +2533,14 @@ impl Vecs {
|
||||
vec![
|
||||
&self.height_to_supply as &dyn AnyCollectableVec,
|
||||
&self.height_to_utxo_count,
|
||||
&self.height_to_satblocks_destroyed,
|
||||
&self.height_to_satdays_destroyed,
|
||||
],
|
||||
self.height_to_realized_cap
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| vec![v as &dyn AnyCollectableVec]),
|
||||
self.height_to_supply_value.vecs(),
|
||||
self.height_to_halved_supply_value.vecs(),
|
||||
self.indexes_to_supply.vecs(),
|
||||
self.indexes_to_utxo_count.vecs(),
|
||||
self.indexes_to_realized_cap
|
||||
@@ -2542,6 +2736,8 @@ impl Vecs {
|
||||
self.indexes_to_supply_in_profit_relative_to_circulating_supply
|
||||
.as_ref()
|
||||
.map_or(vec![], |v| v.vecs()),
|
||||
self.indexes_to_coinblocks_destroyed.vecs(),
|
||||
self.indexes_to_coindays_destroyed.vecs(),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
|
||||
@@ -29,7 +29,7 @@ use super::{
|
||||
pub mod cohort;
|
||||
mod outputs;
|
||||
|
||||
const VERSION: Version = Version::new(9);
|
||||
const VERSION: Version = Version::new(5);
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Vecs {
|
||||
@@ -40,10 +40,6 @@ pub struct Vecs {
|
||||
pub indexes_to_unspendable_supply: ComputedValueVecsFromHeight,
|
||||
pub height_to_opreturn_supply: EagerVec<Height, Sats>,
|
||||
pub indexes_to_opreturn_supply: ComputedValueVecsFromHeight,
|
||||
// pub height_to_satdays_destroyed: EagerVec<Height, Sats>,
|
||||
// pub indexes_to_satdays_destroyed: ComputedValueVecsFromHeight,
|
||||
// pub height_to_satblocks_destroyed: EagerVec<Height, Sats>,
|
||||
// pub indexes_to_satblocks_destroyed: ComputedValueVecsFromHeight,
|
||||
utxos_vecs: Outputs<(OutputFilter, cohort::Vecs)>,
|
||||
}
|
||||
|
||||
@@ -102,36 +98,6 @@ impl Vecs {
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
compute_dollars,
|
||||
)?,
|
||||
// height_to_satdays_destroyed: EagerVec::forced_import(
|
||||
// path,
|
||||
// "satdays_destroyed",
|
||||
// version,
|
||||
// format,
|
||||
// )?,
|
||||
// indexes_to_satdays_destroyed: ComputedValueVecsFromHeight::forced_import(
|
||||
// path,
|
||||
// "satdays_destroyed",
|
||||
// false,
|
||||
// version + VERSION + Version::ZERO,
|
||||
// format,
|
||||
// StorableVecGeneatorOptions::default().add_last(),
|
||||
// compute_dollars,
|
||||
// )?,
|
||||
// height_to_satblocks_destroyed: EagerVec::forced_import(
|
||||
// path,
|
||||
// "satblocks_destroyed",
|
||||
// version,
|
||||
// format,
|
||||
// )?,
|
||||
// indexes_to_satblocks_destroyed: ComputedValueVecsFromHeight::forced_import(
|
||||
// path,
|
||||
// "satblocks_destroyed",
|
||||
// false,
|
||||
// version + VERSION + Version::ZERO,
|
||||
// format,
|
||||
// StorableVecGeneatorOptions::default().add_last(),
|
||||
// compute_dollars,
|
||||
// )?,
|
||||
utxos_vecs: {
|
||||
Outputs::<(OutputFilter, cohort::Vecs)>::from(Outputs {
|
||||
all: cohort::Vecs::forced_import(
|
||||
@@ -603,9 +569,9 @@ impl Vecs {
|
||||
&stores_path,
|
||||
true,
|
||||
)?,
|
||||
_1m_to_3m: cohort::Vecs::forced_import(
|
||||
_1m_to_2m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("from_1m_to_3m"),
|
||||
Some("from_1m_to_2m"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -614,9 +580,42 @@ impl Vecs {
|
||||
&stores_path,
|
||||
true,
|
||||
)?,
|
||||
_3m_to_6m: cohort::Vecs::forced_import(
|
||||
_2m_to_3m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("from_3m_to_6m"),
|
||||
Some("from_2m_to_3m"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
fetched,
|
||||
keyspace,
|
||||
&stores_path,
|
||||
true,
|
||||
)?,
|
||||
_3m_to_4m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("from_3m_to_4m"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
fetched,
|
||||
keyspace,
|
||||
&stores_path,
|
||||
true,
|
||||
)?,
|
||||
_4m_to_5m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("from_4m_to_5m"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
fetched,
|
||||
keyspace,
|
||||
&stores_path,
|
||||
true,
|
||||
)?,
|
||||
_5m_to_6m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("from_5m_to_6m"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -680,9 +679,9 @@ impl Vecs {
|
||||
&stores_path,
|
||||
true,
|
||||
)?,
|
||||
_5y_to_7y: cohort::Vecs::forced_import(
|
||||
_5y_to_6y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("from_5y_to_7y"),
|
||||
Some("from_5y_to_6y"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -691,9 +690,31 @@ impl Vecs {
|
||||
&stores_path,
|
||||
true,
|
||||
)?,
|
||||
_7y_to_10y: cohort::Vecs::forced_import(
|
||||
_6y_to_7y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("from_7y_to_10y"),
|
||||
Some("from_6y_to_7y"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
fetched,
|
||||
keyspace,
|
||||
&stores_path,
|
||||
true,
|
||||
)?,
|
||||
_7y_to_8y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("from_7y_to_8y"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
fetched,
|
||||
keyspace,
|
||||
&stores_path,
|
||||
true,
|
||||
)?,
|
||||
_8y_to_10y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("from_8y_to_10y"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -1377,14 +1398,6 @@ impl Vecs {
|
||||
.validate_computed_version_or_reset_file(
|
||||
base_version + self.height_to_opreturn_supply.inner_version(),
|
||||
)?;
|
||||
// self.height_to_satblocks_destroyed
|
||||
// .validate_computed_version_or_reset_file(
|
||||
// base_version + self.height_to_satblocks_destroyed.inner_version(),
|
||||
// )?;
|
||||
// self.height_to_satdays_destroyed
|
||||
// .validate_computed_version_or_reset_file(
|
||||
// base_version + self.height_to_satdays_destroyed.inner_version(),
|
||||
// )?;
|
||||
|
||||
let mut chain_state: Vec<BlockState>;
|
||||
let mut chain_state_starting_height = Height::from(self.chain_state.len());
|
||||
@@ -1437,8 +1450,6 @@ impl Vecs {
|
||||
.min(stateful_starting_height)
|
||||
.min(Height::from(self.height_to_unspendable_supply.len()))
|
||||
.min(Height::from(self.height_to_opreturn_supply.len()));
|
||||
// .min(Height::from(self.height_to_satblocks_destroyed.len()));
|
||||
// .min(Height::from(self.height_to_satdays_destroyed.len()));
|
||||
|
||||
// ---
|
||||
// INIT
|
||||
@@ -1462,20 +1473,6 @@ impl Vecs {
|
||||
} else {
|
||||
Sats::ZERO
|
||||
};
|
||||
// let mut satblocks_destroyed = if let Some(prev_height) = starting_height.decremented() {
|
||||
// self.height_to_satblocks_destroyed
|
||||
// .into_iter()
|
||||
// .unwrap_get_inner(prev_height)
|
||||
// } else {
|
||||
// Sats::ZERO
|
||||
// };
|
||||
// let mut satdays_destroyed = if let Some(prev_height) = starting_height.decremented() {
|
||||
// self.height_to_satdays_destroyed
|
||||
// .into_iter()
|
||||
// .unwrap_get_inner(prev_height)
|
||||
// } else {
|
||||
// Sats::ZERO
|
||||
// };
|
||||
|
||||
let mut height = starting_height;
|
||||
starting_indexes.update_from_height(height, indexes);
|
||||
@@ -1717,18 +1714,16 @@ impl Vecs {
|
||||
.try_for_each(|(_, v)| {
|
||||
v.compute_rest_part1(indexer, indexes, fetched, &starting_indexes, exit)
|
||||
})?;
|
||||
let height_to_supply = self.utxos_vecs.all.1.height_to_supply.clone();
|
||||
let height_to_supply = self.utxos_vecs.all.1.height_to_supply_value.bitcoin.clone();
|
||||
let dateindex_to_supply = self
|
||||
.utxos_vecs
|
||||
.all
|
||||
.1
|
||||
.indexes_to_supply
|
||||
.sats
|
||||
.bitcoin
|
||||
.dateindex
|
||||
.unwrap_last()
|
||||
.clone();
|
||||
let height_to_realized_cap = self.utxos_vecs.all.1.height_to_realized_cap.clone();
|
||||
let height_to_realized_cap = height_to_realized_cap.as_ref();
|
||||
self.utxos_vecs
|
||||
.as_mut_vecs()
|
||||
.par_iter_mut()
|
||||
@@ -1740,8 +1735,8 @@ impl Vecs {
|
||||
&starting_indexes,
|
||||
market,
|
||||
&height_to_supply,
|
||||
&dateindex_to_supply,
|
||||
height_to_realized_cap,
|
||||
dateindex_to_supply.as_ref().unwrap(),
|
||||
height_to_realized_cap.as_ref(),
|
||||
exit,
|
||||
)
|
||||
})?;
|
||||
@@ -1761,22 +1756,6 @@ impl Vecs {
|
||||
exit,
|
||||
Some(&self.height_to_opreturn_supply),
|
||||
)?;
|
||||
// self.indexes_to_satblocks_destroyed.compute_rest(
|
||||
// indexer,
|
||||
// indexes,
|
||||
// fetched,
|
||||
// &starting_indexes,
|
||||
// exit,
|
||||
// Some(&self.height_to_satblocks_destroyed),
|
||||
// )?;
|
||||
// self.indexes_to_satdays_destroyed.compute_rest(
|
||||
// indexer,
|
||||
// indexes,
|
||||
// fetched,
|
||||
// &starting_indexes,
|
||||
// exit,
|
||||
// Some(&self.height_to_satdays_destroyed),
|
||||
// )?;
|
||||
|
||||
exit.release();
|
||||
|
||||
@@ -1795,8 +1774,6 @@ impl Vecs {
|
||||
.try_for_each(|(_, v)| v.safe_flush_stateful_vecs(height, exit))?;
|
||||
self.height_to_unspendable_supply.safe_flush(exit)?;
|
||||
self.height_to_opreturn_supply.safe_flush(exit)?;
|
||||
// self.height_to_satblocks_destroyed.safe_flush(exit)?;
|
||||
// self.height_to_satdays_destroyed.safe_flush(exit)?;
|
||||
|
||||
self.chain_state.truncate_if_needed(Height::ZERO)?;
|
||||
chain_state.iter().for_each(|block_state| {
|
||||
@@ -1820,16 +1797,6 @@ impl Vecs {
|
||||
&self.height_to_unspendable_supply,
|
||||
&self.height_to_opreturn_supply,
|
||||
],
|
||||
// self.indexes_to_satblocks_destroyed.vecs(),
|
||||
// vec![
|
||||
// &self.height_to_unspendable_supply,
|
||||
// &self.height_to_satblocks_destroyed,
|
||||
// ],
|
||||
// self.indexes_to_satdays_destroyed.vecs(),
|
||||
// vec![
|
||||
// &self.height_to_unspendable_supply,
|
||||
// &self.height_to_satdays_destroyed,
|
||||
// ],
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
|
||||
@@ -72,10 +72,16 @@ impl OutputCohorts for Outputs<(OutputFilter, cohort::Vecs)> {
|
||||
let block_state = chain_state.get(height.unwrap_to_usize()).unwrap();
|
||||
let prev_price = block_state.price;
|
||||
|
||||
let blocks_old = chain_state.len() - 1 - height.unwrap_to_usize();
|
||||
|
||||
let days_old = block_state
|
||||
.timestamp
|
||||
.difference_in_days_between(last_timestamp);
|
||||
|
||||
let days_old_foat = block_state
|
||||
.timestamp
|
||||
.difference_in_days_between_float(last_timestamp);
|
||||
|
||||
let older_than_hour =
|
||||
jiff::Timestamp::from(last_timestamp.checked_sub(block_state.timestamp).unwrap())
|
||||
.as_second()
|
||||
@@ -95,6 +101,8 @@ impl OutputCohorts for Outputs<(OutputFilter, cohort::Vecs)> {
|
||||
&sent.spendable_supply,
|
||||
current_price,
|
||||
prev_price,
|
||||
blocks_old,
|
||||
days_old_foat,
|
||||
older_than_hour,
|
||||
);
|
||||
});
|
||||
@@ -105,6 +113,8 @@ impl OutputCohorts for Outputs<(OutputFilter, cohort::Vecs)> {
|
||||
supply_state,
|
||||
current_price,
|
||||
prev_price,
|
||||
blocks_old,
|
||||
days_old_foat,
|
||||
older_than_hour,
|
||||
)
|
||||
},
|
||||
@@ -117,6 +127,8 @@ impl OutputCohorts for Outputs<(OutputFilter, cohort::Vecs)> {
|
||||
&supply_state,
|
||||
current_price,
|
||||
prev_price,
|
||||
blocks_old,
|
||||
days_old_foat,
|
||||
older_than_hour,
|
||||
);
|
||||
});
|
||||
@@ -159,93 +171,86 @@ impl OutputCohorts for Outputs<(OutputFilter, cohort::Vecs)> {
|
||||
}
|
||||
|
||||
fn compute_overlaping_vecs(&mut self, starting_indexes: &Indexes, exit: &Exit) -> Result<()> {
|
||||
self.all
|
||||
.1
|
||||
.compute_from_stateful(starting_indexes, &self.by_epoch.vecs(), exit)?;
|
||||
let by_date_range = self.by_date_range.as_vec();
|
||||
let by_size_range = self.by_size_range.as_vec();
|
||||
|
||||
self.by_from_date
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.try_for_each(|(filter, vecs)| {
|
||||
vecs.compute_from_stateful(
|
||||
starting_indexes,
|
||||
self.by_date_range
|
||||
.as_vec()
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
exit,
|
||||
)
|
||||
})?;
|
||||
|
||||
self.by_up_to_date
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.try_for_each(|(filter, vecs)| {
|
||||
vecs.compute_from_stateful(
|
||||
starting_indexes,
|
||||
self.by_date_range
|
||||
.as_vec()
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
exit,
|
||||
)
|
||||
})?;
|
||||
|
||||
self.by_term
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.try_for_each(|(filter, vecs)| {
|
||||
vecs.compute_from_stateful(
|
||||
starting_indexes,
|
||||
self.by_date_range
|
||||
.as_vec()
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
exit,
|
||||
)
|
||||
})?;
|
||||
|
||||
self.by_up_to_size
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.try_for_each(|(filter, vecs)| {
|
||||
vecs.compute_from_stateful(
|
||||
starting_indexes,
|
||||
self.by_date_range
|
||||
.as_vec()
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
exit,
|
||||
)
|
||||
})?;
|
||||
|
||||
self.by_from_size
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.try_for_each(|(filter, vecs)| {
|
||||
vecs.compute_from_stateful(
|
||||
starting_indexes,
|
||||
self.by_size_range
|
||||
.as_vec()
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
exit,
|
||||
)
|
||||
})
|
||||
[
|
||||
vec![(&mut self.all.1, self.by_epoch.vecs().to_vec())],
|
||||
self.by_from_date
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.map(|(filter, vecs)| {
|
||||
(
|
||||
vecs,
|
||||
by_date_range
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
self.by_up_to_date
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.map(|(filter, vecs)| {
|
||||
(
|
||||
vecs,
|
||||
by_date_range
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
self.by_term
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.map(|(filter, vecs)| {
|
||||
(
|
||||
vecs,
|
||||
by_date_range
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
self.by_from_size
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.map(|(filter, vecs)| {
|
||||
(
|
||||
vecs,
|
||||
by_size_range
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
self.by_up_to_size
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.map(|(filter, vecs)| {
|
||||
(
|
||||
vecs,
|
||||
by_size_range
|
||||
.into_iter()
|
||||
.filter(|(other, _)| filter.includes(other))
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
]
|
||||
.into_par_iter()
|
||||
.flatten()
|
||||
.try_for_each(|(vecs, stateful)| {
|
||||
vecs.compute_from_stateful(starting_indexes, &stateful, exit)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user