global: adding semester + making coarser intervals computed instead of eager

This commit is contained in:
nym21
2025-07-10 17:44:19 +02:00
parent a66f4ad4bd
commit c229e218f6
65 changed files with 2490 additions and 1003 deletions

View File

@@ -8,9 +8,11 @@ use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, AnyIterableVec, Computation, EagerVec, Format};
use crate::vecs::grouped::Source;
use super::{
Indexes,
grouped::{ComputedVecsFromDateIndex, ComputedVecsFromHeight, StorableVecGeneatorOptions},
grouped::{ComputedVecsFromDateIndex, ComputedVecsFromHeight, EagerVecBuilderOptions},
indexes,
};
@@ -34,7 +36,7 @@ impl Vecs {
pub fn forced_import(
path: &Path,
version: Version,
_computation: Computation,
computation: Computation,
format: Format,
) -> color_eyre::Result<Self> {
Ok(Self {
@@ -47,18 +49,20 @@ impl Vecs {
timeindexes_to_timestamp: ComputedVecsFromDateIndex::forced_import(
path,
"timestamp",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_first(),
computation,
EagerVecBuilderOptions::default().add_first(),
)?,
indexes_to_block_interval: ComputedVecsFromHeight::forced_import(
path,
"block_interval",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_percentiles()
.add_minmax()
.add_average(),
@@ -66,32 +70,29 @@ impl Vecs {
indexes_to_block_count: ComputedVecsFromHeight::forced_import(
path,
"block_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_block_weight: ComputedVecsFromHeight::forced_import(
path,
"block_weight",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_block_size: ComputedVecsFromHeight::forced_import(
path,
"block_size",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
height_to_vbytes: EagerVec::forced_import(
path,
@@ -102,12 +103,11 @@ impl Vecs {
indexes_to_block_vbytes: ComputedVecsFromHeight::forced_import(
path,
"block_vbytes",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
difficultyepoch_to_timestamp: EagerVec::forced_import(
path,

View File

@@ -7,13 +7,13 @@ use brk_vec::{AnyCollectableVec, Computation, Format, VecIterator};
use crate::vecs::{
fetched,
grouped::{ComputedRatioVecsFromDateIndex, ComputedValueVecsFromHeight},
grouped::{ComputedRatioVecsFromDateIndex, ComputedValueVecsFromHeight, Source},
stateful, transactions,
};
use super::{
Indexes,
grouped::{ComputedVecsFromHeight, StorableVecGeneatorOptions},
grouped::{ComputedVecsFromHeight, EagerVecBuilderOptions},
indexes,
};
@@ -51,7 +51,7 @@ impl Vecs {
pub fn forced_import(
path: &Path,
version: Version,
_computation: Computation,
computation: Computation,
format: Format,
fetched: Option<&fetched::Vecs>,
) -> color_eyre::Result<Self> {
@@ -61,194 +61,207 @@ impl Vecs {
indexes_to_coinblocks_created: ComputedVecsFromHeight::forced_import(
path,
"coinblocks_created",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_coinblocks_stored: ComputedVecsFromHeight::forced_import(
path,
"coinblocks_stored",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_liveliness: ComputedVecsFromHeight::forced_import(
path,
"liveliness",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_vaultedness: ComputedVecsFromHeight::forced_import(
path,
"vaultedness",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_activity_to_vaultedness_ratio: ComputedVecsFromHeight::forced_import(
path,
"activity_to_vaultedness_ratio",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_vaulted_supply: ComputedValueVecsFromHeight::forced_import(
path,
"vaulted_supply",
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
compute_dollars,
)?,
indexes_to_active_supply: ComputedValueVecsFromHeight::forced_import(
path,
"active_supply",
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
compute_dollars,
)?,
indexes_to_thermo_cap: ComputedVecsFromHeight::forced_import(
path,
"thermo_cap",
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_investor_cap: ComputedVecsFromHeight::forced_import(
path,
"investor_cap",
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_vaulted_cap: ComputedVecsFromHeight::forced_import(
path,
"vaulted_cap",
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_active_cap: ComputedVecsFromHeight::forced_import(
path,
"active_cap",
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_vaulted_price: ComputedVecsFromHeight::forced_import(
path,
"vaulted_price",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_vaulted_price_ratio: ComputedRatioVecsFromDateIndex::forced_import(
path,
"vaulted_price",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
computation,
)?,
indexes_to_active_price: ComputedVecsFromHeight::forced_import(
path,
"active_price",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_active_price_ratio: ComputedRatioVecsFromDateIndex::forced_import(
path,
"active_price",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
computation,
)?,
indexes_to_true_market_mean: ComputedVecsFromHeight::forced_import(
path,
"true_market_mean",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_true_market_mean_ratio: ComputedRatioVecsFromDateIndex::forced_import(
path,
"true_market_mean",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
computation,
)?,
indexes_to_cointime_value_destroyed: ComputedVecsFromHeight::forced_import(
path,
"cointime_value_destroyed",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_cointime_value_created: ComputedVecsFromHeight::forced_import(
path,
"cointime_value_created",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_cointime_value_stored: ComputedVecsFromHeight::forced_import(
path,
"cointime_value_stored",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_cointime_price: ComputedVecsFromHeight::forced_import(
path,
"cointime_price",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_cointime_cap: ComputedVecsFromHeight::forced_import(
path,
"cointime_cap",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_cointime_price_ratio: ComputedRatioVecsFromDateIndex::forced_import(
path,
"cointime_price",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
computation,
)?,
})
}

View File

@@ -5,9 +5,11 @@ use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, AnyVec, Computation, Format};
use crate::vecs::grouped::Source;
use super::{
Indexes,
grouped::{ComputedVecsFromHeight, StorableVecGeneatorOptions},
grouped::{ComputedVecsFromHeight, EagerVecBuilderOptions},
indexes,
};
@@ -25,41 +27,45 @@ impl Vecs {
pub fn forced_import(
path: &Path,
version: Version,
_computation: Computation,
computation: Computation,
format: Format,
) -> color_eyre::Result<Self> {
Ok(Self {
constant_0: ComputedVecsFromHeight::forced_import(
path,
"constant_0",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
constant_1: ComputedVecsFromHeight::forced_import(
path,
"constant_1",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
constant_50: ComputedVecsFromHeight::forced_import(
path,
"constant_50",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
constant_100: ComputedVecsFromHeight::forced_import(
path,
"constant_100",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
})
}

View File

@@ -2,18 +2,19 @@ use std::path::Path;
use brk_core::{
Cents, Close, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, Height, High, Low, MonthIndex,
OHLCCents, OHLCDollars, OHLCSats, Open, QuarterIndex, Sats, Version, WeekIndex, YearIndex,
OHLCCents, OHLCDollars, OHLCSats, Open, QuarterIndex, Sats, SemesterIndex, Version, WeekIndex,
YearIndex,
};
use brk_exit::Exit;
use brk_fetcher::Fetcher;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, AnyIterableVec, Computation, EagerVec, Format, StoredIndex};
use crate::vecs::grouped::Source;
use super::{
Indexes,
grouped::{
ComputedVecsFromDateIndex, ComputedVecsFromHeightStrict, StorableVecGeneatorOptions,
},
grouped::{ComputedVecsFromDateIndex, ComputedVecsFromHeightStrict, EagerVecBuilderOptions},
indexes,
};
@@ -57,6 +58,8 @@ pub struct Vecs {
pub monthindex_to_ohlc_in_sats: EagerVec<MonthIndex, OHLCSats>,
pub quarterindex_to_ohlc: EagerVec<QuarterIndex, OHLCDollars>,
pub quarterindex_to_ohlc_in_sats: EagerVec<QuarterIndex, OHLCSats>,
pub semesterindex_to_ohlc: EagerVec<SemesterIndex, OHLCDollars>,
pub semesterindex_to_ohlc_in_sats: EagerVec<SemesterIndex, OHLCSats>,
pub yearindex_to_ohlc: EagerVec<YearIndex, OHLCDollars>,
pub yearindex_to_ohlc_in_sats: EagerVec<YearIndex, OHLCSats>,
// pub halvingepoch_to_ohlc: StorableVec<Halvingepoch, OHLCDollars>,
@@ -72,7 +75,7 @@ impl Vecs {
pub fn forced_import(
path: &Path,
version: Version,
_computation: Computation,
computation: Computation,
format: Format,
) -> color_eyre::Result<Self> {
let mut fetched_path = path.to_owned();
@@ -167,122 +170,130 @@ impl Vecs {
timeindexes_to_open: ComputedVecsFromDateIndex::forced_import(
path,
"open",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_first(),
computation,
EagerVecBuilderOptions::default().add_first(),
)?,
timeindexes_to_high: ComputedVecsFromDateIndex::forced_import(
path,
"high",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_max(),
computation,
EagerVecBuilderOptions::default().add_max(),
)?,
timeindexes_to_low: ComputedVecsFromDateIndex::forced_import(
path,
"low",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_min(),
computation,
EagerVecBuilderOptions::default().add_min(),
)?,
timeindexes_to_close: ComputedVecsFromDateIndex::forced_import(
path,
"close",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
timeindexes_to_open_in_sats: ComputedVecsFromDateIndex::forced_import(
path,
"open_in_sats",
true,
Source::Compute,
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_first(),
computation,
EagerVecBuilderOptions::default().add_first(),
)?,
timeindexes_to_high_in_sats: ComputedVecsFromDateIndex::forced_import(
path,
"high_in_sats",
true,
Source::Compute,
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_max(),
computation,
EagerVecBuilderOptions::default().add_max(),
)?,
timeindexes_to_low_in_sats: ComputedVecsFromDateIndex::forced_import(
path,
"low_in_sats",
true,
Source::Compute,
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_min(),
computation,
EagerVecBuilderOptions::default().add_min(),
)?,
timeindexes_to_close_in_sats: ComputedVecsFromDateIndex::forced_import(
path,
"close_in_sats",
true,
Source::Compute,
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
chainindexes_to_open: ComputedVecsFromHeightStrict::forced_import(
path,
"open",
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_first(),
EagerVecBuilderOptions::default().add_first(),
)?,
chainindexes_to_high: ComputedVecsFromHeightStrict::forced_import(
path,
"high",
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_max(),
EagerVecBuilderOptions::default().add_max(),
)?,
chainindexes_to_low: ComputedVecsFromHeightStrict::forced_import(
path,
"low",
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_min(),
EagerVecBuilderOptions::default().add_min(),
)?,
chainindexes_to_close: ComputedVecsFromHeightStrict::forced_import(
path,
"close",
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
EagerVecBuilderOptions::default().add_last(),
)?,
chainindexes_to_open_in_sats: ComputedVecsFromHeightStrict::forced_import(
path,
"open_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_first(),
EagerVecBuilderOptions::default().add_first(),
)?,
chainindexes_to_high_in_sats: ComputedVecsFromHeightStrict::forced_import(
path,
"high_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_max(),
EagerVecBuilderOptions::default().add_max(),
)?,
chainindexes_to_low_in_sats: ComputedVecsFromHeightStrict::forced_import(
path,
"low_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_min(),
EagerVecBuilderOptions::default().add_min(),
)?,
chainindexes_to_close_in_sats: ComputedVecsFromHeightStrict::forced_import(
path,
"close_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
EagerVecBuilderOptions::default().add_last(),
)?,
weekindex_to_ohlc: EagerVec::forced_import(
path,
@@ -332,6 +343,18 @@ impl Vecs {
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
)?,
semesterindex_to_ohlc: EagerVec::forced_import(
path,
"ohlc",
version + VERSION + Version::ZERO,
format,
)?,
semesterindex_to_ohlc_in_sats: EagerVec::forced_import(
path,
"ohlc_in_sats",
version + VERSION + VERSION_IN_SATS + Version::ZERO,
format,
)?,
yearindex_to_ohlc: EagerVec::forced_import(
path,
"ohlc",
@@ -693,6 +716,27 @@ impl Vecs {
exit,
)?;
let mut semesterindex_first_iter =
self.timeindexes_to_open.semesterindex.unwrap_first().iter();
let mut semesterindex_max_iter = self.timeindexes_to_high.semesterindex.unwrap_max().iter();
let mut semesterindex_min_iter = self.timeindexes_to_low.semesterindex.unwrap_min().iter();
self.semesterindex_to_ohlc.compute_transform(
starting_indexes.semesterindex,
self.timeindexes_to_close.semesterindex.unwrap_last(),
|(i, close, ..)| {
(
i,
OHLCDollars {
open: semesterindex_first_iter.unwrap_get_inner(i),
high: semesterindex_max_iter.unwrap_get_inner(i),
low: semesterindex_min_iter.unwrap_get_inner(i),
close,
},
)
},
exit,
)?;
let mut yearindex_first_iter = self.timeindexes_to_open.yearindex.unwrap_first().iter();
let mut yearindex_max_iter = self.timeindexes_to_high.yearindex.unwrap_max().iter();
let mut yearindex_min_iter = self.timeindexes_to_low.yearindex.unwrap_min().iter();
@@ -1044,6 +1088,40 @@ impl Vecs {
exit,
)?;
let mut semesterindex_first_iter = self
.timeindexes_to_open_in_sats
.semesterindex
.unwrap_first()
.iter();
let mut semesterindex_max_iter = self
.timeindexes_to_high_in_sats
.semesterindex
.unwrap_max()
.iter();
let mut semesterindex_min_iter = self
.timeindexes_to_low_in_sats
.semesterindex
.unwrap_min()
.iter();
self.semesterindex_to_ohlc_in_sats.compute_transform(
starting_indexes.semesterindex,
self.timeindexes_to_close_in_sats
.semesterindex
.unwrap_last(),
|(i, close, ..)| {
(
i,
OHLCSats {
open: semesterindex_first_iter.unwrap_get_inner(i),
high: semesterindex_max_iter.unwrap_get_inner(i),
low: semesterindex_min_iter.unwrap_get_inner(i),
close,
},
)
},
exit,
)?;
let mut yearindex_first_iter = self
.timeindexes_to_open_in_sats
.yearindex
@@ -1133,6 +1211,7 @@ impl Vecs {
&self.difficultyepoch_to_ohlc,
&self.monthindex_to_ohlc,
&self.quarterindex_to_ohlc,
&self.semesterindex_to_ohlc,
&self.yearindex_to_ohlc,
// &self.halvingepoch_to_ohlc,
&self.decadeindex_to_ohlc,
@@ -1142,6 +1221,7 @@ impl Vecs {
&self.difficultyepoch_to_ohlc_in_sats,
&self.monthindex_to_ohlc_in_sats,
&self.quarterindex_to_ohlc_in_sats,
&self.semesterindex_to_ohlc_in_sats,
&self.yearindex_to_ohlc_in_sats,
// &self.halvingepoch_to_ohlc_in_sats,
&self.decadeindex_to_ohlc_in_sats,

View File

@@ -0,0 +1,442 @@
use std::path::Path;
use brk_core::{FromCoarserIndex, Result, Version};
use brk_exit::Exit;
use brk_vec::{
AnyCollectableVec, AnyIterableVec, BoxedAnyIterableVec, CloneableAnyIterableVec, Computation,
ComputedVec, ComputedVecFrom1, Format, StoredIndex,
};
use crate::vecs::grouped::{EagerVecBuilder, EagerVecBuilderOptions};
use super::ComputedType;
#[derive(Clone)]
pub struct ComputedVecBuilder<I, T, S1I>
where
I: StoredIndex,
T: ComputedType,
{
pub first: Option<Box<ComputedVecFrom1<I, T, S1I, T>>>,
pub average: Option<Box<ComputedVecFrom1<I, T, S1I, T>>>,
pub sum: Option<Box<ComputedVecFrom1<I, T, S1I, T>>>,
pub max: Option<Box<ComputedVecFrom1<I, T, S1I, T>>>,
pub min: Option<Box<ComputedVecFrom1<I, T, S1I, T>>>,
pub last: Option<Box<ComputedVecFrom1<I, T, S1I, T>>>,
pub cumulative: Option<Box<ComputedVecFrom1<I, T, S1I, T>>>,
}
const VERSION: Version = Version::ZERO;
impl<I, T, S1I> ComputedVecBuilder<I, T, S1I>
where
I: StoredIndex,
T: ComputedType + 'static,
S1I: StoredIndex + 'static + FromCoarserIndex<I>,
{
#[allow(clippy::too_many_arguments)]
pub fn forced_import(
path: &Path,
name: &str,
version: Version,
format: Format,
computation: Computation,
source: Option<BoxedAnyIterableVec<S1I, T>>,
source_extra: &EagerVecBuilder<S1I, T>,
options: ComputedVecBuilderOptions,
) -> color_eyre::Result<Self> {
let only_one_active = options.is_only_one_active();
let suffix = |s: &str| format!("{name}_{s}");
let maybe_suffix = |s: &str| {
if only_one_active {
name.to_string()
} else {
suffix(s)
}
};
Ok(Self {
first: options.first.then(|| {
Box::new(
ComputedVec::forced_import_or_init_from_1(
computation,
path,
&maybe_suffix("first"),
version + VERSION + Version::ZERO,
format,
source_extra
.first
.as_ref()
.map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()),
|i, source| {
source
.next_at(S1I::min_from(i))
.map(|(_, cow)| cow.into_owned())
},
)
.unwrap(),
)
}),
last: options.last.then(|| {
Box::new(
ComputedVec::forced_import_or_init_from_1(
computation,
path,
name,
version + VERSION + Version::ZERO,
format,
source_extra.last.as_ref().map_or_else(
|| {
source
.as_ref()
.unwrap_or_else(|| {
dbg!(path, name, I::to_string());
panic!()
})
.clone()
},
|v| v.clone(),
),
|i, source| {
source
.next_at(S1I::max_from(i))
.map(|(_, cow)| cow.into_owned())
},
)
.unwrap(),
)
}),
min: options.min.then(|| {
Box::new(
ComputedVec::forced_import_or_init_from_1(
computation,
path,
&maybe_suffix("min"),
version + VERSION + Version::ZERO,
format,
source_extra
.min
.as_ref()
.map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()),
|i, source| {
S1I::inclusive_range_from(i)
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
.min()
},
)
.unwrap(),
)
}),
max: options.max.then(|| {
Box::new(
ComputedVec::forced_import_or_init_from_1(
computation,
path,
&maybe_suffix("max"),
version + VERSION + Version::ZERO,
format,
source_extra
.max
.as_ref()
.map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()),
|i, source| {
S1I::inclusive_range_from(i)
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
.max()
},
)
.unwrap(),
)
}),
average: options.average.then(|| {
Box::new(
ComputedVec::forced_import_or_init_from_1(
computation,
path,
&maybe_suffix("average"),
version + VERSION + Version::ZERO,
format,
source_extra
.average
.as_ref()
.map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()),
|i, source| {
let vec = S1I::inclusive_range_from(i)
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
.collect::<Vec<_>>();
if vec.is_empty() {
return None;
}
let mut sum = T::from(0);
let len = vec.len();
vec.into_iter().for_each(|v| sum += v);
Some(sum / len)
},
)
.unwrap(),
)
}),
sum: options.sum.then(|| {
Box::new(
ComputedVec::forced_import_or_init_from_1(
computation,
path,
&(if !options.last && !options.average && !options.min && !options.max {
name.to_string()
} else {
maybe_suffix("sum")
}),
version + VERSION + Version::ZERO,
format,
source_extra
.sum
.as_ref()
.map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()),
|i, source| {
let vec = S1I::inclusive_range_from(i)
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
.collect::<Vec<_>>();
if vec.is_empty() {
return None;
}
let mut sum = T::from(0);
vec.into_iter().for_each(|v| sum += v);
Some(sum)
},
)
.unwrap(),
)
}),
cumulative: options.cumulative.then(|| {
Box::new(
ComputedVec::forced_import_or_init_from_1(
computation,
path,
&suffix("cumulative"),
version + VERSION + Version::ZERO,
format,
source_extra.cumulative.as_ref().unwrap().boxed_clone(),
|i, source| {
source
.next_at(S1I::max_from(i))
.map(|(_, cow)| cow.into_owned())
},
)
.unwrap(),
)
}),
})
}
pub fn compute_if_necessary<T2>(
&mut self,
max_from: I,
len_source: &impl AnyIterableVec<I, T2>,
exit: &Exit,
) -> Result<()> {
if let Some(first) = self.first.as_mut() {
first.compute_if_necessary(max_from, len_source, exit)?;
}
if let Some(last) = self.last.as_mut() {
last.compute_if_necessary(max_from, len_source, exit)?;
}
if let Some(min) = self.min.as_mut() {
min.compute_if_necessary(max_from, len_source, exit)?;
}
if let Some(max) = self.max.as_mut() {
max.compute_if_necessary(max_from, len_source, exit)?;
}
if let Some(average) = self.average.as_mut() {
average.compute_if_necessary(max_from, len_source, exit)?;
}
if let Some(sum) = self.sum.as_mut() {
sum.compute_if_necessary(max_from, len_source, exit)?;
}
if let Some(cumulative) = self.cumulative.as_mut() {
cumulative.compute_if_necessary(max_from, len_source, exit)?;
}
Ok(())
}
pub fn starting_index(&self, max_from: I) -> I {
max_from.min(I::from(
self.vecs().into_iter().map(|v| v.len()).min().unwrap(),
))
}
pub fn unwrap_first(&self) -> &ComputedVecFrom1<I, T, S1I, T> {
self.first.as_ref().unwrap()
}
#[allow(unused)]
pub fn unwrap_average(&self) -> &ComputedVecFrom1<I, T, S1I, T> {
self.average.as_ref().unwrap()
}
pub fn unwrap_sum(&self) -> &ComputedVecFrom1<I, T, S1I, T> {
self.sum.as_ref().unwrap()
}
pub fn unwrap_max(&self) -> &ComputedVecFrom1<I, T, S1I, T> {
self.max.as_ref().unwrap()
}
pub fn unwrap_min(&self) -> &ComputedVecFrom1<I, T, S1I, T> {
self.min.as_ref().unwrap()
}
pub fn unwrap_last(&self) -> &ComputedVecFrom1<I, T, S1I, T> {
self.last.as_ref().unwrap()
}
#[allow(unused)]
pub fn unwrap_cumulative(&self) -> &ComputedVecFrom1<I, T, S1I, T> {
self.cumulative.as_ref().unwrap()
}
pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
let mut v: Vec<&dyn AnyCollectableVec> = vec![];
if let Some(first) = self.first.as_ref() {
v.push(first.as_ref());
}
if let Some(last) = self.last.as_ref() {
v.push(last.as_ref());
}
if let Some(min) = self.min.as_ref() {
v.push(min.as_ref());
}
if let Some(max) = self.max.as_ref() {
v.push(max.as_ref());
}
if let Some(average) = self.average.as_ref() {
v.push(average.as_ref());
}
if let Some(sum) = self.sum.as_ref() {
v.push(sum.as_ref());
}
if let Some(cumulative) = self.cumulative.as_ref() {
v.push(cumulative.as_ref());
}
v
}
}
#[derive(Default, Clone, Copy)]
pub struct ComputedVecBuilderOptions {
average: bool,
sum: bool,
max: bool,
min: bool,
first: bool,
last: bool,
cumulative: bool,
}
impl From<EagerVecBuilderOptions> for ComputedVecBuilderOptions {
fn from(value: EagerVecBuilderOptions) -> Self {
Self {
average: value.average(),
sum: value.sum(),
max: value.max(),
min: value.min(),
first: value.first(),
last: value.last(),
cumulative: value.cumulative(),
}
}
}
impl ComputedVecBuilderOptions {
pub fn add_first(mut self) -> Self {
self.first = true;
self
}
pub fn add_last(mut self) -> Self {
self.last = true;
self
}
pub fn add_min(mut self) -> Self {
self.min = true;
self
}
pub fn add_max(mut self) -> Self {
self.max = true;
self
}
pub fn add_average(mut self) -> Self {
self.average = true;
self
}
pub fn add_sum(mut self) -> Self {
self.sum = true;
self
}
pub fn add_cumulative(mut self) -> Self {
self.cumulative = true;
self
}
#[allow(unused)]
pub fn rm_min(mut self) -> Self {
self.min = false;
self
}
#[allow(unused)]
pub fn rm_max(mut self) -> Self {
self.max = false;
self
}
#[allow(unused)]
pub fn rm_average(mut self) -> Self {
self.average = false;
self
}
#[allow(unused)]
pub fn rm_sum(mut self) -> Self {
self.sum = false;
self
}
#[allow(unused)]
pub fn rm_cumulative(mut self) -> Self {
self.cumulative = false;
self
}
pub fn add_minmax(mut self) -> Self {
self.min = true;
self.max = true;
self
}
pub fn is_only_one_active(&self) -> bool {
[
self.average,
self.sum,
self.max,
self.min,
self.first,
self.last,
self.cumulative,
]
.iter()
.filter(|b| **b)
.count()
== 1
}
pub fn copy_self_extra(&self) -> Self {
Self {
cumulative: self.cumulative,
..Self::default()
}
}
}

View File

@@ -10,7 +10,7 @@ use crate::utils::get_percentile;
use super::ComputedType;
#[derive(Clone, Debug)]
pub struct ComputedVecBuilder<I, T>
pub struct EagerVecBuilder<I, T>
where
I: StoredIndex,
T: ComputedType,
@@ -31,7 +31,7 @@ where
const VERSION: Version = Version::ZERO;
impl<I, T> ComputedVecBuilder<I, T>
impl<I, T> EagerVecBuilder<I, T>
where
I: StoredIndex,
T: ComputedType,
@@ -41,7 +41,7 @@ where
name: &str,
version: Version,
format: Format,
options: StorableVecGeneatorOptions,
options: EagerVecBuilderOptions,
) -> color_eyre::Result<Self> {
let only_one_active = options.is_only_one_active();
@@ -384,7 +384,7 @@ where
pub fn from_aligned<I2>(
&mut self,
max_from: I,
source: &ComputedVecBuilder<I2, T>,
source: &EagerVecBuilder<I2, T>,
first_indexes: &impl AnyIterableVec<I, I2>,
count_indexes: &impl AnyIterableVec<I, StoredUsize>,
exit: &Exit,
@@ -706,7 +706,7 @@ where
}
#[derive(Default, Clone, Copy)]
pub struct StorableVecGeneatorOptions {
pub struct EagerVecBuilderOptions {
average: bool,
sum: bool,
max: bool,
@@ -721,7 +721,55 @@ pub struct StorableVecGeneatorOptions {
cumulative: bool,
}
impl StorableVecGeneatorOptions {
impl EagerVecBuilderOptions {
pub fn average(&self) -> bool {
self.average
}
pub fn sum(&self) -> bool {
self.sum
}
pub fn max(&self) -> bool {
self.max
}
pub fn _90p(&self) -> bool {
self._90p
}
pub fn _75p(&self) -> bool {
self._75p
}
pub fn median(&self) -> bool {
self.median
}
pub fn _25p(&self) -> bool {
self._25p
}
pub fn _10p(&self) -> bool {
self._10p
}
pub fn min(&self) -> bool {
self.min
}
pub fn first(&self) -> bool {
self.first
}
pub fn last(&self) -> bool {
self.last
}
pub fn cumulative(&self) -> bool {
self.cumulative
}
pub fn add_first(mut self) -> Self {
self.first = true;
self

View File

@@ -1,15 +1,18 @@
use std::path::Path;
use brk_core::{
DateIndex, DecadeIndex, MonthIndex, QuarterIndex, Result, Version, WeekIndex, YearIndex,
DateIndex, DecadeIndex, MonthIndex, QuarterIndex, Result, SemesterIndex, Version, WeekIndex,
YearIndex,
};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, AnyIterableVec, EagerVec, Format};
use brk_vec::{
AnyCollectableVec, AnyIterableVec, CloneableAnyIterableVec, Computation, EagerVec, Format,
};
use crate::vecs::{Indexes, indexes};
use crate::vecs::{Indexes, grouped::ComputedVecBuilder, indexes};
use super::{ComputedType, ComputedVecBuilder, StorableVecGeneatorOptions};
use super::{ComputedType, EagerVecBuilder, EagerVecBuilderOptions, Source};
#[derive(Clone)]
pub struct ComputedVecsFromDateIndex<T>
@@ -17,33 +20,35 @@ where
T: ComputedType + PartialOrd,
{
pub dateindex: Option<EagerVec<DateIndex, T>>,
pub dateindex_extra: ComputedVecBuilder<DateIndex, T>,
pub weekindex: ComputedVecBuilder<WeekIndex, T>,
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
pub yearindex: ComputedVecBuilder<YearIndex, T>,
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
pub dateindex_extra: EagerVecBuilder<DateIndex, T>,
pub weekindex: ComputedVecBuilder<WeekIndex, T, DateIndex>,
pub monthindex: ComputedVecBuilder<MonthIndex, T, DateIndex>,
pub quarterindex: ComputedVecBuilder<QuarterIndex, T, DateIndex>,
pub semesterindex: ComputedVecBuilder<SemesterIndex, T, DateIndex>,
pub yearindex: ComputedVecBuilder<YearIndex, T, DateIndex>,
pub decadeindex: ComputedVecBuilder<DecadeIndex, T, DateIndex>,
}
const VERSION: Version = Version::ZERO;
impl<T> ComputedVecsFromDateIndex<T>
where
T: ComputedType,
T: ComputedType + 'static,
{
pub fn forced_import(
path: &Path,
name: &str,
compute_source: bool,
source: Source<DateIndex, T>,
version: Version,
format: Format,
options: StorableVecGeneatorOptions,
computation: Computation,
options: EagerVecBuilderOptions,
) -> color_eyre::Result<Self> {
let dateindex = compute_source.then(|| {
let dateindex = source.is_compute().then(|| {
EagerVec::forced_import(path, name, version + VERSION + Version::ZERO, format).unwrap()
});
let dateindex_extra = ComputedVecBuilder::forced_import(
let dateindex_extra = EagerVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
@@ -53,44 +58,71 @@ where
let options = options.remove_percentiles();
let dateindex_source = source.vec().or(dateindex.as_ref().map(|v| v.boxed_clone()));
Ok(Self {
dateindex,
dateindex_extra,
weekindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
dateindex_source.clone(),
&dateindex_extra,
options.into(),
)?,
monthindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
dateindex_source.clone(),
&dateindex_extra,
options.into(),
)?,
quarterindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
dateindex_source.clone(),
&dateindex_extra,
options.into(),
)?,
semesterindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
computation,
dateindex_source.clone(),
&dateindex_extra,
options.into(),
)?,
yearindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
dateindex_source.clone(),
&dateindex_extra,
options.into(),
)?,
decadeindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
dateindex_source.clone(),
&dateindex_extra,
options.into(),
)?,
dateindex,
dateindex_extra,
})
}
@@ -133,65 +165,45 @@ where
if let Some(dateindex) = dateindex {
self.dateindex_extra
.extend(starting_indexes.dateindex, dateindex, exit)?;
self.weekindex.compute(
starting_indexes.weekindex,
dateindex,
&indexes.weekindex_to_first_dateindex,
&indexes.weekindex_to_dateindex_count,
exit,
)?;
self.monthindex.compute(
starting_indexes.monthindex,
dateindex,
&indexes.monthindex_to_first_dateindex,
&indexes.monthindex_to_dateindex_count,
exit,
)?;
} else {
let dateindex = self.dateindex.as_ref().unwrap();
self.dateindex_extra
.extend(starting_indexes.dateindex, dateindex, exit)?;
self.weekindex.compute(
starting_indexes.weekindex,
dateindex,
&indexes.weekindex_to_first_dateindex,
&indexes.weekindex_to_dateindex_count,
exit,
)?;
self.monthindex.compute(
starting_indexes.monthindex,
dateindex,
&indexes.monthindex_to_first_dateindex,
&indexes.monthindex_to_dateindex_count,
exit,
)?;
}
self.quarterindex.from_aligned(
self.weekindex.compute_if_necessary(
starting_indexes.weekindex,
&indexes.weekindex_to_dateindex_count,
exit,
)?;
self.monthindex.compute_if_necessary(
starting_indexes.monthindex,
&indexes.monthindex_to_dateindex_count,
exit,
)?;
self.quarterindex.compute_if_necessary(
starting_indexes.quarterindex,
&self.monthindex,
&indexes.quarterindex_to_first_monthindex,
&indexes.quarterindex_to_monthindex_count,
exit,
)?;
self.yearindex.from_aligned(
self.semesterindex.compute_if_necessary(
starting_indexes.semesterindex,
&indexes.semesterindex_to_monthindex_count,
exit,
)?;
self.yearindex.compute_if_necessary(
starting_indexes.yearindex,
&self.monthindex,
&indexes.yearindex_to_first_monthindex,
&indexes.yearindex_to_monthindex_count,
exit,
)?;
self.decadeindex.from_aligned(
self.decadeindex.compute_if_necessary(
starting_indexes.decadeindex,
&self.yearindex,
&indexes.decadeindex_to_first_yearindex,
&indexes.decadeindex_to_yearindex_count,
exit,
)?;
@@ -208,6 +220,7 @@ where
self.weekindex.vecs(),
self.monthindex.vecs(),
self.quarterindex.vecs(),
self.semesterindex.vecs(),
self.yearindex.vecs(),
self.decadeindex.vecs(),
]

View File

@@ -1,16 +1,20 @@
use std::path::Path;
use brk_core::{
DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, Result, Version,
WeekIndex, YearIndex,
DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, Result,
SemesterIndex, Version, WeekIndex, YearIndex,
};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, AnyIterableVec, EagerVec, Format};
use brk_vec::{AnyCollectableVec, AnyIterableVec, Computation, EagerVec, Format};
use crate::vecs::{Indexes, indexes};
use crate::vecs::{
Indexes,
grouped::{ComputedVecBuilder, Source},
indexes,
};
use super::{ComputedType, ComputedVecBuilder, StorableVecGeneatorOptions};
use super::{ComputedType, EagerVecBuilder, EagerVecBuilderOptions};
#[derive(Clone)]
pub struct ComputedVecsFromHeight<T>
@@ -18,38 +22,39 @@ where
T: ComputedType + PartialOrd,
{
pub height: Option<EagerVec<Height, T>>,
pub height_extra: ComputedVecBuilder<Height, T>,
pub dateindex: ComputedVecBuilder<DateIndex, T>,
pub weekindex: ComputedVecBuilder<WeekIndex, T>,
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
// 6 months
pub yearindex: ComputedVecBuilder<YearIndex, T>,
pub height_extra: EagerVecBuilder<Height, T>,
pub dateindex: EagerVecBuilder<DateIndex, T>,
pub weekindex: ComputedVecBuilder<WeekIndex, T, DateIndex>,
pub difficultyepoch: EagerVecBuilder<DifficultyEpoch, T>,
pub monthindex: ComputedVecBuilder<MonthIndex, T, DateIndex>,
pub quarterindex: ComputedVecBuilder<QuarterIndex, T, DateIndex>,
pub semesterindex: ComputedVecBuilder<SemesterIndex, T, DateIndex>,
pub yearindex: ComputedVecBuilder<YearIndex, T, DateIndex>,
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
pub decadeindex: ComputedVecBuilder<DecadeIndex, T, DateIndex>,
}
const VERSION: Version = Version::ZERO;
impl<T> ComputedVecsFromHeight<T>
where
T: ComputedType + Ord + From<f64>,
T: ComputedType + Ord + From<f64> + 'static,
f64: From<T>,
{
pub fn forced_import(
path: &Path,
name: &str,
compute_source: bool,
source: Source<Height, T>,
version: Version,
format: Format,
options: StorableVecGeneatorOptions,
computation: Computation,
options: EagerVecBuilderOptions,
) -> color_eyre::Result<Self> {
let height = compute_source.then(|| {
let height = source.is_compute().then(|| {
EagerVec::forced_import(path, name, version + VERSION + Version::ZERO, format).unwrap()
});
let height_extra = ComputedVecBuilder::forced_import(
let height_extra = EagerVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
@@ -57,7 +62,7 @@ where
options.copy_self_extra(),
)?;
let dateindex = ComputedVecBuilder::forced_import(
let dateindex = EagerVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
@@ -68,46 +73,71 @@ where
let options = options.remove_percentiles();
Ok(Self {
height,
height_extra,
dateindex,
weekindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
)?,
difficultyepoch: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
None,
&dateindex,
options.into(),
)?,
monthindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
None,
&dateindex,
options.into(),
)?,
quarterindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
None,
&dateindex,
options.into(),
)?,
semesterindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
computation,
None,
&dateindex,
options.into(),
)?,
yearindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
None,
&dateindex,
options.into(),
)?,
decadeindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
computation,
None,
&dateindex,
options.into(),
)?,
// halvingepoch: StorableVecGeneator::forced_import(path, name, version + VERSION + Version::ZERO, format, options)?,
decadeindex: ComputedVecBuilder::forced_import(
height,
height_extra,
dateindex,
difficultyepoch: EagerVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
@@ -189,42 +219,38 @@ where
)?;
}
self.weekindex.from_aligned(
self.weekindex.compute_if_necessary(
starting_indexes.weekindex,
&self.dateindex,
&indexes.weekindex_to_first_dateindex,
&indexes.weekindex_to_dateindex_count,
exit,
)?;
self.monthindex.from_aligned(
self.monthindex.compute_if_necessary(
starting_indexes.monthindex,
&self.dateindex,
&indexes.monthindex_to_first_dateindex,
&indexes.monthindex_to_dateindex_count,
exit,
)?;
self.quarterindex.from_aligned(
self.quarterindex.compute_if_necessary(
starting_indexes.quarterindex,
&self.monthindex,
&indexes.quarterindex_to_first_monthindex,
&indexes.quarterindex_to_monthindex_count,
exit,
)?;
self.yearindex.from_aligned(
self.semesterindex.compute_if_necessary(
starting_indexes.semesterindex,
&indexes.semesterindex_to_monthindex_count,
exit,
)?;
self.yearindex.compute_if_necessary(
starting_indexes.yearindex,
&self.monthindex,
&indexes.yearindex_to_first_monthindex,
&indexes.yearindex_to_monthindex_count,
exit,
)?;
self.decadeindex.from_aligned(
self.decadeindex.compute_if_necessary(
starting_indexes.decadeindex,
&self.yearindex,
&indexes.decadeindex_to_first_yearindex,
&indexes.decadeindex_to_yearindex_count,
exit,
)?;
@@ -243,6 +269,7 @@ where
self.difficultyepoch.vecs(),
self.monthindex.vecs(),
self.quarterindex.vecs(),
self.semesterindex.vecs(),
self.yearindex.vecs(),
// self.halvingepoch.vecs(),
self.decadeindex.vecs(),

View File

@@ -5,9 +5,9 @@ use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, EagerVec, Format};
use crate::vecs::{indexes, Indexes};
use crate::vecs::{Indexes, indexes};
use super::{ComputedType, ComputedVecBuilder, StorableVecGeneatorOptions};
use super::{ComputedType, EagerVecBuilder, EagerVecBuilderOptions};
#[derive(Clone)]
pub struct ComputedVecsFromHeightStrict<T>
@@ -15,8 +15,8 @@ where
T: ComputedType + PartialOrd,
{
pub height: EagerVec<Height, T>,
pub height_extra: ComputedVecBuilder<Height, T>,
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
pub height_extra: EagerVecBuilder<Height, T>,
pub difficultyepoch: EagerVecBuilder<DifficultyEpoch, T>,
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
}
@@ -32,12 +32,12 @@ where
name: &str,
version: Version,
format: Format,
options: StorableVecGeneatorOptions,
options: EagerVecBuilderOptions,
) -> color_eyre::Result<Self> {
let height =
EagerVec::forced_import(path, name, version + VERSION + Version::ZERO, format)?;
let height_extra = ComputedVecBuilder::forced_import(
let height_extra = EagerVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
@@ -50,7 +50,7 @@ where
Ok(Self {
height,
height_extra,
difficultyepoch: ComputedVecBuilder::forced_import(
difficultyepoch: EagerVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,

View File

@@ -2,17 +2,22 @@ use std::path::Path;
use brk_core::{
Bitcoin, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, Height, MonthIndex, QuarterIndex,
Result, Sats, TxIndex, Version, WeekIndex, YearIndex,
Result, Sats, SemesterIndex, TxIndex, Version, WeekIndex, YearIndex,
};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{
AnyCollectableVec, AnyVec, CollectableVec, EagerVec, Format, StoredIndex, VecIterator,
AnyCollectableVec, AnyVec, CollectableVec, Computation, EagerVec, Format, StoredIndex,
VecIterator,
};
use crate::vecs::{Indexes, fetched, indexes};
use crate::vecs::{
Indexes, fetched,
grouped::{ComputedVecBuilder, Source},
indexes,
};
use super::{ComputedType, ComputedVecBuilder, StorableVecGeneatorOptions};
use super::{ComputedType, EagerVecBuilder, EagerVecBuilderOptions};
#[derive(Clone)]
pub struct ComputedVecsFromTxindex<T>
@@ -20,40 +25,42 @@ where
T: ComputedType + PartialOrd,
{
pub txindex: Option<Box<EagerVec<TxIndex, T>>>,
pub height: ComputedVecBuilder<Height, T>,
pub dateindex: ComputedVecBuilder<DateIndex, T>,
pub weekindex: ComputedVecBuilder<WeekIndex, T>,
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
pub yearindex: ComputedVecBuilder<YearIndex, T>,
pub height: EagerVecBuilder<Height, T>,
pub dateindex: EagerVecBuilder<DateIndex, T>,
pub weekindex: ComputedVecBuilder<WeekIndex, T, DateIndex>,
pub difficultyepoch: EagerVecBuilder<DifficultyEpoch, T>,
pub monthindex: ComputedVecBuilder<MonthIndex, T, DateIndex>,
pub quarterindex: ComputedVecBuilder<QuarterIndex, T, DateIndex>,
pub semesterindex: ComputedVecBuilder<SemesterIndex, T, DateIndex>,
pub yearindex: ComputedVecBuilder<YearIndex, T, DateIndex>,
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
pub decadeindex: ComputedVecBuilder<DecadeIndex, T, DateIndex>,
}
const VERSION: Version = Version::ZERO;
impl<T> ComputedVecsFromTxindex<T>
where
T: ComputedType + Ord + From<f64>,
T: ComputedType + Ord + From<f64> + 'static,
f64: From<T>,
{
pub fn forced_import(
path: &Path,
name: &str,
compute_source: bool,
source: Source<TxIndex, T>,
version: Version,
format: Format,
options: StorableVecGeneatorOptions,
computation: Computation,
options: EagerVecBuilderOptions,
) -> color_eyre::Result<Self> {
let txindex = compute_source.then(|| {
let txindex = source.is_compute().then(|| {
Box::new(
EagerVec::forced_import(path, name, version + VERSION + Version::ZERO, format)
.unwrap(),
)
});
let height = ComputedVecBuilder::forced_import(
let height = EagerVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
@@ -63,45 +70,80 @@ where
let options = options.remove_percentiles();
let dateindex = EagerVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
)?;
Ok(Self {
txindex,
height,
dateindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
)?,
weekindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
)?,
difficultyepoch: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
None,
&dateindex,
options.into(),
)?,
monthindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
None,
&dateindex,
options.into(),
)?,
quarterindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
computation,
None,
&dateindex,
options.into(),
)?,
semesterindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
computation,
None,
&dateindex,
options.into(),
)?,
yearindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
computation,
None,
&dateindex,
options.into(),
)?,
decadeindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
computation,
None,
&dateindex,
options.into(),
)?,
txindex,
height,
dateindex,
difficultyepoch: EagerVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
@@ -109,13 +151,6 @@ where
options,
)?,
// halvingepoch: StorableVecGeneator::forced_import(path, name, version + VERSION + Version::ZERO, format, options)?,
decadeindex: ComputedVecBuilder::forced_import(
path,
name,
version + VERSION + Version::ZERO,
format,
options,
)?,
})
}
@@ -196,42 +231,38 @@ where
exit,
)?;
self.weekindex.from_aligned(
self.weekindex.compute_if_necessary(
starting_indexes.weekindex,
&self.dateindex,
&indexes.weekindex_to_first_dateindex,
&indexes.weekindex_to_dateindex_count,
exit,
)?;
self.monthindex.from_aligned(
self.monthindex.compute_if_necessary(
starting_indexes.monthindex,
&self.dateindex,
&indexes.monthindex_to_first_dateindex,
&indexes.monthindex_to_dateindex_count,
exit,
)?;
self.quarterindex.from_aligned(
self.quarterindex.compute_if_necessary(
starting_indexes.quarterindex,
&self.monthindex,
&indexes.quarterindex_to_first_monthindex,
&indexes.quarterindex_to_monthindex_count,
exit,
)?;
self.yearindex.from_aligned(
self.semesterindex.compute_if_necessary(
starting_indexes.semesterindex,
&indexes.semesterindex_to_monthindex_count,
exit,
)?;
self.yearindex.compute_if_necessary(
starting_indexes.yearindex,
&self.monthindex,
&indexes.yearindex_to_first_monthindex,
&indexes.yearindex_to_monthindex_count,
exit,
)?;
self.decadeindex.from_aligned(
self.decadeindex.compute_if_necessary(
starting_indexes.decadeindex,
&self.yearindex,
&indexes.decadeindex_to_first_yearindex,
&indexes.decadeindex_to_yearindex_count,
exit,
)?;
@@ -258,6 +289,7 @@ where
self.difficultyepoch.vecs(),
self.monthindex.vecs(),
self.quarterindex.vecs(),
self.semesterindex.vecs(),
self.yearindex.vecs(),
// self.halvingepoch.vecs(),
self.decadeindex.vecs(),

View File

@@ -1,21 +1,25 @@
mod builder;
mod builder_computed;
mod builder_eager;
mod from_dateindex;
mod from_height;
mod from_height_strict;
mod from_txindex;
mod ratio_from_dateindex;
mod source;
mod r#type;
mod value_from_dateindex;
mod value_from_height;
mod value_from_txindex;
mod value_height;
pub use builder::*;
pub use builder_computed::*;
pub use builder_eager::*;
pub use from_dateindex::*;
pub use from_height::*;
pub use from_height_strict::*;
pub use from_txindex::*;
pub use ratio_from_dateindex::*;
pub use source::*;
use r#type::*;
pub use value_from_dateindex::*;
pub use value_from_height::*;

View File

@@ -4,16 +4,16 @@ use brk_core::{Date, DateIndex, Dollars, Result, StoredF32, Version};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{
AnyCollectableVec, AnyIterableVec, AnyVec, CollectableVec, EagerVec, Format, StoredIndex,
VecIterator,
AnyCollectableVec, AnyIterableVec, AnyVec, CollectableVec, Computation, EagerVec, Format,
StoredIndex, VecIterator,
};
use crate::{
utils::get_percentile,
vecs::{Indexes, fetched, indexes},
vecs::{Indexes, fetched, grouped::source::Source, indexes},
};
use super::{ComputedVecsFromDateIndex, StorableVecGeneatorOptions};
use super::{ComputedVecsFromDateIndex, EagerVecBuilderOptions};
#[derive(Clone)]
pub struct ComputedRatioVecsFromDateIndex {
@@ -64,20 +64,22 @@ impl ComputedRatioVecsFromDateIndex {
pub fn forced_import(
path: &Path,
name: &str,
compute_source: bool,
source: Source<DateIndex, Dollars>,
version: Version,
format: Format,
computation: Computation,
) -> color_eyre::Result<Self> {
let options = StorableVecGeneatorOptions::default().add_last();
let options = EagerVecBuilderOptions::default().add_last();
Ok(Self {
price: compute_source.then(|| {
price: source.is_compute().then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
name,
true,
Source::Compute,
version + VERSION,
format,
computation,
options,
)
.unwrap()
@@ -85,297 +87,334 @@ impl ComputedRatioVecsFromDateIndex {
ratio: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_sma: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_sma"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_1w_sma: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_1w_sma"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_1m_sma: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_1m_sma"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_1y_sma: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_1y_sma"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_4y_sma: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_4y_sma"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_1y_sma_momentum_oscillator: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_1y_sma_momentum_oscillator"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_sd: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_sd"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_4y_sd: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_4y_sd"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_1y_sd: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_1y_sd"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p99_9: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p99_9"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p99_5: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p99_5"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p99: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p99"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p1: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p1"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p0_5: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p0_5"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p0_1: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p0_1"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p1sd: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p1sd"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p2sd: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p2sd"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p3sd: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p3sd"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_m1sd: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_m1sd"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_m2sd: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_m2sd"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_m3sd: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_m3sd"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p99_9_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p99_9_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p99_5_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p99_5_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p99_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p99_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p1_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p1_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p0_5_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p0_5_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p0_1_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p0_1_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p1sd_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p1sd_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p2sd_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p2sd_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_p3sd_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_p3sd_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_m1sd_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_m1sd_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_m2sd_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_m2sd_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_m3sd_as_price: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_m3sd_as_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_zscore: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_zscore"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_4y_zscore: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_4y_zscore"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
ratio_1y_zscore: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_ratio_1y_zscore"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
computation,
options,
)?,
})

View File

@@ -0,0 +1,51 @@
use brk_vec::BoxedAnyIterableVec;
#[derive(Clone)]
pub enum Source<I, T> {
Compute,
None,
Vec(BoxedAnyIterableVec<I, T>),
}
impl<I, T> Source<I, T> {
pub fn is_compute(&self) -> bool {
matches!(self, Self::Compute)
}
pub fn is_none(&self) -> bool {
matches!(self, Self::None)
}
pub fn is_vec(&self) -> bool {
matches!(self, Self::Vec(_))
}
pub fn vec(self) -> Option<BoxedAnyIterableVec<I, T>> {
match self {
Self::Vec(v) => Some(v),
_ => None,
}
}
}
impl<I, T> From<bool> for Source<I, T> {
fn from(value: bool) -> Self {
if value { Self::Compute } else { Self::None }
}
}
impl<I, T> From<BoxedAnyIterableVec<I, T>> for Source<I, T> {
fn from(value: BoxedAnyIterableVec<I, T>) -> Self {
Self::Vec(value)
}
}
impl<I, T> From<Option<BoxedAnyIterableVec<I, T>>> for Source<I, T> {
fn from(value: Option<BoxedAnyIterableVec<I, T>>) -> Self {
if let Some(v) = value {
Self::Vec(v)
} else {
Self::None
}
}
}

View File

@@ -1,13 +1,14 @@
use std::ops::{Add, Div};
use std::ops::{Add, AddAssign, Div};
use brk_vec::StoredType;
pub trait ComputedType
where
Self: StoredType + From<usize> + Div<usize, Output = Self> + Add<Output = Self> + Ord,
Self:
StoredType + From<usize> + Div<usize, Output = Self> + Add<Output = Self> + AddAssign + Ord,
{
}
impl<T> ComputedType for T where
T: StoredType + From<usize> + Div<usize, Output = Self> + Add<Output = Self> + Ord
T: StoredType + From<usize> + Div<usize, Output = Self> + Add<Output = Self> + AddAssign + Ord
{
}

View File

@@ -3,11 +3,11 @@ use std::path::Path;
use brk_core::{Bitcoin, DateIndex, Dollars, Result, Sats, Version};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, CollectableVec, EagerVec, Format, StoredVec};
use brk_vec::{AnyCollectableVec, CollectableVec, Computation, EagerVec, Format, StoredVec};
use crate::vecs::{Indexes, fetched, grouped::ComputedVecsFromDateIndex, indexes};
use super::StorableVecGeneatorOptions;
use super::{EagerVecBuilderOptions, Source};
#[derive(Clone)]
pub struct ComputedValueVecsFromDateIndex {
@@ -19,39 +19,44 @@ pub struct ComputedValueVecsFromDateIndex {
const VERSION: Version = Version::ZERO;
impl ComputedValueVecsFromDateIndex {
#[allow(clippy::too_many_arguments)]
pub fn forced_import(
path: &Path,
name: &str,
compute_source: bool,
source: Source<DateIndex, Sats>,
version: Version,
format: Format,
options: StorableVecGeneatorOptions,
computation: Computation,
options: EagerVecBuilderOptions,
compute_dollars: bool,
) -> color_eyre::Result<Self> {
Ok(Self {
sats: ComputedVecsFromDateIndex::forced_import(
path,
name,
compute_source,
source,
version + VERSION,
format,
computation,
options,
)?,
bitcoin: ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_in_btc"),
true,
Source::Compute,
version + VERSION,
format,
computation,
options,
)?,
dollars: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&format!("{name}_in_usd"),
true,
Source::Compute,
version + VERSION,
format,
computation,
options,
)
.unwrap()

View File

@@ -3,11 +3,11 @@ use std::path::Path;
use brk_core::{Bitcoin, Dollars, Height, Result, Sats, Version};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, CollectableVec, EagerVec, Format, StoredVec};
use brk_vec::{AnyCollectableVec, CollectableVec, Computation, EagerVec, Format, StoredVec};
use crate::vecs::{Indexes, fetched, indexes};
use crate::vecs::{Indexes, fetched, grouped::Source, indexes};
use super::{ComputedVecsFromHeight, StorableVecGeneatorOptions};
use super::{ComputedVecsFromHeight, EagerVecBuilderOptions};
#[derive(Clone)]
pub struct ComputedValueVecsFromHeight {
@@ -19,39 +19,44 @@ pub struct ComputedValueVecsFromHeight {
const VERSION: Version = Version::ZERO;
impl ComputedValueVecsFromHeight {
#[allow(clippy::too_many_arguments)]
pub fn forced_import(
path: &Path,
name: &str,
compute_source: bool,
source: Source<Height, Sats>,
version: Version,
format: Format,
options: StorableVecGeneatorOptions,
computation: Computation,
options: EagerVecBuilderOptions,
compute_dollars: bool,
) -> color_eyre::Result<Self> {
Ok(Self {
sats: ComputedVecsFromHeight::forced_import(
path,
name,
compute_source,
source,
version + VERSION,
format,
computation,
options,
)?,
bitcoin: ComputedVecsFromHeight::forced_import(
path,
&format!("{name}_in_btc"),
true,
Source::Compute,
version + VERSION,
format,
computation,
options,
)?,
dollars: compute_dollars.then(|| {
ComputedVecsFromHeight::forced_import(
path,
&format!("{name}_in_usd"),
true,
Source::Compute,
version + VERSION,
format,
computation,
options,
)
.unwrap()

View File

@@ -4,13 +4,13 @@ use brk_core::{Bitcoin, Close, Dollars, Height, Sats, TxIndex, Version};
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{
AnyCollectableVec, BoxedAnyIterableVec, CloneableAnyIterableVec, CollectableVec, Computation,
ComputedVecFrom3, Format, LazyVecFrom1, StoredIndex, StoredVec,
AnyCollectableVec, CloneableAnyIterableVec, CollectableVec, Computation, ComputedVecFrom3,
Format, LazyVecFrom1, StoredIndex, StoredVec,
};
use crate::vecs::{Indexes, fetched, indexes};
use crate::vecs::{Indexes, fetched, grouped::Source, indexes};
use super::{ComputedVecsFromTxindex, StorableVecGeneatorOptions};
use super::{ComputedVecsFromTxindex, EagerVecBuilderOptions};
#[derive(Clone)]
pub struct ComputedValueVecsFromTxindex {
@@ -41,14 +41,13 @@ impl ComputedValueVecsFromTxindex {
path: &Path,
name: &str,
indexes: &indexes::Vecs,
source: Option<BoxedAnyIterableVec<TxIndex, Sats>>,
source: Source<TxIndex, Sats>,
version: Version,
computation: Computation,
format: Format,
fetched: Option<&fetched::Vecs>,
options: StorableVecGeneatorOptions,
options: EagerVecBuilderOptions,
) -> color_eyre::Result<Self> {
let compute_source = source.is_none();
let compute_dollars = fetched.is_some();
let name_in_btc = format!("{name}_in_btc");
@@ -57,16 +56,19 @@ impl ComputedValueVecsFromTxindex {
let sats = ComputedVecsFromTxindex::forced_import(
path,
name,
compute_source,
source.clone(),
version + VERSION,
format,
computation,
options,
)?;
let source_vec = source.vec();
let bitcoin_txindex = LazyVecFrom1::init(
&name_in_btc,
version + VERSION,
source.map_or_else(|| sats.txindex.as_ref().unwrap().boxed_clone(), |s| s),
source_vec.map_or_else(|| sats.txindex.as_ref().unwrap().boxed_clone(), |s| s),
|txindex: TxIndex, iter| {
iter.next_at(txindex.unwrap_to_usize()).map(|(_, value)| {
let sats = value.into_owned();
@@ -78,9 +80,10 @@ impl ComputedValueVecsFromTxindex {
let bitcoin = ComputedVecsFromTxindex::forced_import(
path,
&name_in_btc,
false,
Source::None,
version + VERSION,
format,
computation,
options,
)?;
@@ -124,9 +127,10 @@ impl ComputedValueVecsFromTxindex {
ComputedVecsFromTxindex::forced_import(
path,
&name_in_usd,
false,
Source::None,
version + VERSION,
format,
computation,
options,
)
.unwrap()

View File

@@ -5,7 +5,7 @@ use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, CollectableVec, EagerVec, Format, StoredVec};
use crate::vecs::{Indexes, fetched, indexes};
use crate::vecs::{Indexes, fetched, grouped::Source, indexes};
#[derive(Clone)]
pub struct ComputedHeightValueVecs {
@@ -20,13 +20,13 @@ impl ComputedHeightValueVecs {
pub fn forced_import(
path: &Path,
name: &str,
compute_source: bool,
source: Source<Height, Sats>,
version: Version,
format: Format,
compute_dollars: bool,
) -> color_eyre::Result<Self> {
Ok(Self {
sats: compute_source.then(|| {
sats: source.is_compute().then(|| {
EagerVec::forced_import(path, name, version + VERSION + Version::ZERO, format)
.unwrap()
}),

View File

@@ -5,8 +5,8 @@ use brk_core::{
InputIndex, MonthIndex, OpReturnIndex, OutputIndex, P2AAddressIndex, P2ABytes, P2MSOutputIndex,
P2PK33AddressIndex, P2PK33Bytes, P2PK65AddressIndex, P2PK65Bytes, P2PKHAddressIndex,
P2PKHBytes, P2SHAddressIndex, P2SHBytes, P2TRAddressIndex, P2TRBytes, P2WPKHAddressIndex,
P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes, QuarterIndex, Sats, StoredUsize, Timestamp,
TxIndex, Txid, UnknownOutputIndex, Version, WeekIndex, YearIndex,
P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes, QuarterIndex, Sats, SemesterIndex, StoredUsize,
Timestamp, TxIndex, Txid, UnknownOutputIndex, Version, WeekIndex, YearIndex,
};
use brk_exit::Exit;
use brk_indexer::Indexer;
@@ -50,6 +50,7 @@ pub struct Vecs {
pub monthindex_to_first_dateindex: EagerVec<MonthIndex, DateIndex>,
pub monthindex_to_monthindex: EagerVec<MonthIndex, MonthIndex>,
pub monthindex_to_quarterindex: EagerVec<MonthIndex, QuarterIndex>,
pub monthindex_to_semesterindex: EagerVec<MonthIndex, SemesterIndex>,
pub monthindex_to_yearindex: EagerVec<MonthIndex, YearIndex>,
pub opreturnindex_to_opreturnindex:
ComputedVecFrom1<OpReturnIndex, OpReturnIndex, OpReturnIndex, TxIndex>,
@@ -76,6 +77,9 @@ pub struct Vecs {
pub quarterindex_to_first_monthindex: EagerVec<QuarterIndex, MonthIndex>,
pub quarterindex_to_monthindex_count: EagerVec<QuarterIndex, StoredUsize>,
pub quarterindex_to_quarterindex: EagerVec<QuarterIndex, QuarterIndex>,
pub semesterindex_to_first_monthindex: EagerVec<SemesterIndex, MonthIndex>,
pub semesterindex_to_monthindex_count: EagerVec<SemesterIndex, StoredUsize>,
pub semesterindex_to_semesterindex: EagerVec<SemesterIndex, SemesterIndex>,
pub txindex_to_height: EagerVec<TxIndex, Height>,
pub txindex_to_input_count:
ComputedVecFrom2<TxIndex, StoredUsize, TxIndex, InputIndex, InputIndex, OutputIndex>,
@@ -413,6 +417,12 @@ impl Vecs {
version + VERSION + Version::ZERO,
format,
)?,
monthindex_to_semesterindex: EagerVec::forced_import(
path,
"semesterindex",
version + VERSION + Version::ZERO,
format,
)?,
monthindex_to_yearindex: EagerVec::forced_import(
path,
"yearindex",
@@ -425,6 +435,12 @@ impl Vecs {
version + VERSION + Version::ZERO,
format,
)?,
semesterindex_to_first_monthindex: EagerVec::forced_import(
path,
"first_monthindex",
version + VERSION + Version::ZERO,
format,
)?,
weekindex_to_first_dateindex: EagerVec::forced_import(
path,
"first_dateindex",
@@ -443,6 +459,12 @@ impl Vecs {
version + VERSION + Version::ZERO,
format,
)?,
semesterindex_to_semesterindex: EagerVec::forced_import(
path,
"semesterindex",
version + VERSION + Version::ZERO,
format,
)?,
weekindex_to_weekindex: EagerVec::forced_import(
path,
"weekindex",
@@ -521,6 +543,12 @@ impl Vecs {
version + VERSION + Version::ZERO,
format,
)?,
semesterindex_to_monthindex_count: EagerVec::forced_import(
path,
"monthindex_count",
version + VERSION + Version::ZERO,
format,
)?,
yearindex_to_monthindex_count: EagerVec::forced_import(
path,
"monthindex_count",
@@ -943,6 +971,45 @@ impl Vecs {
exit,
)?;
// ---
// SemesterIndex
// ---
let starting_semesterindex = self
.monthindex_to_semesterindex
.into_iter()
.get_inner(starting_monthindex)
.unwrap_or_default();
self.monthindex_to_semesterindex.compute_from_index(
starting_monthindex,
&self.monthindex_to_first_dateindex,
exit,
)?;
self.semesterindex_to_first_monthindex
.compute_inverse_more_to_less(
starting_monthindex,
&self.monthindex_to_semesterindex,
exit,
)?;
// let semester_count = self.semesterindex_to_first_monthindex.len();
self.semesterindex_to_semesterindex.compute_from_index(
starting_semesterindex,
&self.semesterindex_to_first_monthindex,
exit,
)?;
self.semesterindex_to_monthindex_count
.compute_count_from_indexes(
starting_semesterindex,
&self.semesterindex_to_first_monthindex,
&self.monthindex_to_monthindex,
exit,
)?;
// ---
// YearIndex
// ---
@@ -1051,6 +1118,7 @@ impl Vecs {
weekindex: starting_weekindex,
monthindex: starting_monthindex,
quarterindex: starting_quarterindex,
semesterindex: starting_semesterindex,
yearindex: starting_yearindex,
decadeindex: starting_decadeindex,
difficultyepoch: starting_difficultyepoch,
@@ -1088,6 +1156,7 @@ impl Vecs {
&self.monthindex_to_first_dateindex,
&self.monthindex_to_monthindex,
&self.monthindex_to_quarterindex,
&self.monthindex_to_semesterindex,
&self.monthindex_to_yearindex,
&self.opreturnindex_to_opreturnindex,
&self.outputindex_to_outputindex,
@@ -1103,6 +1172,9 @@ impl Vecs {
&self.quarterindex_to_first_monthindex,
&self.quarterindex_to_monthindex_count,
&self.quarterindex_to_quarterindex,
&self.semesterindex_to_first_monthindex,
&self.semesterindex_to_monthindex_count,
&self.semesterindex_to_semesterindex,
&self.txindex_to_height,
&self.txindex_to_txindex,
&self.txindex_to_input_count,
@@ -1126,6 +1198,7 @@ pub struct Indexes {
pub weekindex: WeekIndex,
pub monthindex: MonthIndex,
pub quarterindex: QuarterIndex,
pub semesterindex: SemesterIndex,
pub yearindex: YearIndex,
pub decadeindex: DecadeIndex,
pub difficultyepoch: DifficultyEpoch,
@@ -1145,6 +1218,7 @@ impl Indexes {
self.weekindex = WeekIndex::from(self.dateindex);
self.monthindex = MonthIndex::from(self.dateindex);
self.quarterindex = QuarterIndex::from(self.monthindex);
self.semesterindex = SemesterIndex::from(self.monthindex);
self.yearindex = YearIndex::from(self.monthindex);
self.decadeindex = DecadeIndex::from(self.dateindex);
self.difficultyepoch = DifficultyEpoch::from(self.height);

File diff suppressed because it is too large Load Diff

View File

@@ -5,9 +5,11 @@ use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, Computation, Format, VecIterator};
use crate::vecs::grouped::Source;
use super::{
Indexes,
grouped::{ComputedVecsFromDateIndex, ComputedVecsFromHeight, StorableVecGeneatorOptions},
grouped::{ComputedVecsFromDateIndex, ComputedVecsFromHeight, EagerVecBuilderOptions},
indexes,
};
@@ -24,33 +26,36 @@ impl Vecs {
pub fn forced_import(
path: &Path,
version: Version,
_computation: Computation,
computation: Computation,
format: Format,
) -> color_eyre::Result<Self> {
Ok(Self {
indexes_to_difficulty: ComputedVecsFromHeight::forced_import(
path,
"difficulty",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_difficultyepoch: ComputedVecsFromDateIndex::forced_import(
path,
"difficultyepoch",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_halvingepoch: ComputedVecsFromDateIndex::forced_import(
path,
"halvingepoch",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
})
}

View File

@@ -11,7 +11,7 @@ use crate::{
states::AddressCohortState,
vecs::{
Indexes, fetched,
grouped::{ComputedVecsFromHeight, StorableVecGeneatorOptions},
grouped::{ComputedVecsFromHeight, EagerVecBuilderOptions, Source},
indexes, market,
stateful::{
common,
@@ -66,10 +66,11 @@ impl Vecs {
indexes_to_address_count: ComputedVecsFromHeight::forced_import(
path,
&suffix("address_count"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
inner: common::Vecs::forced_import(
path,

View File

@@ -6,7 +6,8 @@ use brk_core::{
use brk_exit::Exit;
use brk_indexer::Indexer;
use brk_vec::{
AnyCollectableVec, AnyIterableVec, AnyVec, Computation, EagerVec, Format, VecIterator,
AnyCollectableVec, AnyIterableVec, AnyVec, CloneableAnyIterableVec, Computation, EagerVec,
Format, VecIterator,
};
use crate::{
@@ -16,7 +17,7 @@ use crate::{
grouped::{
ComputedHeightValueVecs, ComputedRatioVecsFromDateIndex,
ComputedValueVecsFromDateIndex, ComputedVecsFromDateIndex, ComputedVecsFromHeight,
StorableVecGeneatorOptions,
EagerVecBuilderOptions, Source,
},
indexes, market,
},
@@ -132,7 +133,7 @@ impl Vecs {
pub fn forced_import(
path: &Path,
cohort_name: Option<&str>,
_computation: Computation,
computation: Computation,
format: Format,
version: Version,
fetched: Option<&fetched::Vecs>,
@@ -144,8 +145,57 @@ impl Vecs {
let suffix = |s: &str| cohort_name.map_or(s.to_string(), |name| format!("{name}_{s}"));
Ok(Self {
let dateindex_to_supply_in_profit = compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_in_profit"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
});
let dateindex_to_supply_even = compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_even"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
});
let dateindex_to_supply_in_loss = compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_in_loss"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
});
let dateindex_to_unrealized_profit = compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("unrealized_profit"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
});
let dateindex_to_unrealized_loss = compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("unrealized_loss"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
});
Ok(Self {
height_to_supply_in_profit: compute_dollars.then(|| {
EagerVec::forced_import(
path,
@@ -155,27 +205,20 @@ impl Vecs {
)
.unwrap()
}),
dateindex_to_supply_in_profit: compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_in_profit"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
}),
indexes_to_supply_in_profit: compute_dollars.then(|| {
ComputedValueVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_profit"),
false,
dateindex_to_supply_in_profit.as_ref().map(|v | v.boxed_clone()).into(),
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
compute_dollars,
)
.unwrap()
}),
dateindex_to_supply_in_profit,
height_to_supply_even: compute_dollars.then(|| {
EagerVec::forced_import(
path,
@@ -185,27 +228,20 @@ impl Vecs {
)
.unwrap()
}),
dateindex_to_supply_even: compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_even"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
}),
indexes_to_supply_even: compute_dollars.then(|| {
ComputedValueVecsFromDateIndex::forced_import(
path,
&suffix("supply_even"),
false,
dateindex_to_supply_even.as_ref().map(|v | v.boxed_clone()).into(),
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
compute_dollars,
)
.unwrap()
}),
dateindex_to_supply_even,
height_to_supply_in_loss: compute_dollars.then(|| {
EagerVec::forced_import(
path,
@@ -215,27 +251,20 @@ impl Vecs {
)
.unwrap()
}),
dateindex_to_supply_in_loss: compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("supply_in_loss"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
}),
indexes_to_supply_in_loss: compute_dollars.then(|| {
ComputedValueVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_loss"),
false,
dateindex_to_supply_in_loss.as_ref().map(|v | v.boxed_clone()).into(),
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
compute_dollars,
)
.unwrap()
}),
dateindex_to_supply_in_loss,
height_to_unrealized_profit: compute_dollars.then(|| {
EagerVec::forced_import(
path,
@@ -245,26 +274,19 @@ impl Vecs {
)
.unwrap()
}),
dateindex_to_unrealized_profit: compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("unrealized_profit"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
}),
indexes_to_unrealized_profit: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("unrealized_profit"),
false,
dateindex_to_unrealized_profit.as_ref().map(|v | v.boxed_clone()).into(),
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
dateindex_to_unrealized_profit,
height_to_unrealized_loss: compute_dollars.then(|| {
EagerVec::forced_import(
path,
@@ -292,26 +314,19 @@ impl Vecs {
)
.unwrap()
}),
dateindex_to_unrealized_loss: compute_dollars.then(|| {
EagerVec::forced_import(
path,
&suffix("unrealized_loss"),
version + VERSION + Version::ZERO,
format,
)
.unwrap()
}),
indexes_to_unrealized_loss: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("unrealized_loss"),
false,
dateindex_to_unrealized_loss.as_ref().map(|v | v.boxed_clone()).into(),
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
dateindex_to_unrealized_loss,
height_to_realized_cap: compute_dollars.then(|| {
EagerVec::forced_import(
path,
@@ -325,10 +340,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("realized_cap"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -336,10 +352,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("min_price_paid"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -347,10 +364,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("max_price_paid"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -363,7 +381,7 @@ impl Vecs {
height_to_supply_value: ComputedHeightValueVecs::forced_import(
path,
&suffix("supply"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
compute_dollars,
@@ -371,10 +389,11 @@ impl Vecs {
indexes_to_supply: ComputedValueVecsFromDateIndex::forced_import(
path,
&suffix("supply"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
compute_dollars,
)?,
height_to_utxo_count: EagerVec::forced_import(
@@ -386,19 +405,21 @@ impl Vecs {
indexes_to_utxo_count: ComputedVecsFromHeight::forced_import(
path,
&suffix("utxo_count"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_realized_price: compute_dollars.then(|| {
ComputedVecsFromHeight::forced_import(
path,
&suffix("realized_price"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -406,9 +427,10 @@ impl Vecs {
ComputedRatioVecsFromDateIndex::forced_import(
path,
&suffix("realized_price"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
computation,
)
.unwrap()
}),
@@ -425,10 +447,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("realized_profit"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_sum()
.add_cumulative(),
)
@@ -447,10 +470,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("realized_loss"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_sum()
.add_cumulative(),
)
@@ -460,10 +484,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("negative_realized_loss"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_sum().add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)
.unwrap()
}),
@@ -480,10 +505,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("value_created"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_sum(),
computation,
EagerVecBuilderOptions::default().add_sum(),
)
.unwrap()
}),
@@ -491,10 +517,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("realized_value"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_sum(),
computation,
EagerVecBuilderOptions::default().add_sum(),
)
.unwrap()
}),
@@ -511,10 +538,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("adjusted_value_created"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_sum(),
computation,
EagerVecBuilderOptions::default().add_sum(),
)
.unwrap()
}),
@@ -531,10 +559,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("value_destroyed"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_sum(),
computation,
EagerVecBuilderOptions::default().add_sum(),
)
.unwrap()
}),
@@ -551,10 +580,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("adjusted_value_destroyed"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_sum(),
computation,
EagerVecBuilderOptions::default().add_sum(),
)
.unwrap()
}),
@@ -562,10 +592,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("realized_cap_30d_change"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -573,10 +604,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("net_realized_profit_and_loss"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_sum()
.add_cumulative(),
)
@@ -612,7 +644,7 @@ impl Vecs {
height_to_halved_supply_value: ComputedHeightValueVecs::forced_import(
path,
&suffix("halved_supply"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
compute_dollars,
@@ -620,10 +652,11 @@ impl Vecs {
indexes_to_halved_supply: ComputedValueVecsFromDateIndex::forced_import(
path,
&suffix("halved_supply"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
compute_dollars,
)?,
height_to_negative_unrealized_loss: compute_dollars.then(|| {
@@ -639,10 +672,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("negative_unrealized_loss"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -659,10 +693,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("net_unrealized_profit_and_loss"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -682,10 +717,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("net_unrealized_profit_and_loss_relative_to_market_cap"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
},
@@ -694,10 +730,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("realized_profit_relative_to_realized_cap"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_sum(),
computation,
EagerVecBuilderOptions::default().add_sum(),
)
.unwrap()
}),
@@ -705,10 +742,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("realized_loss_relative_to_realized_cap"),
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_sum(),
computation,
EagerVecBuilderOptions::default().add_sum(),
)
.unwrap()
}),
@@ -717,10 +755,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("net_realized_profit_and_loss_relative_to_realized_cap"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_sum(),
computation,
EagerVecBuilderOptions::default().add_sum(),
)
.unwrap()
},
@@ -729,7 +768,7 @@ impl Vecs {
ComputedHeightValueVecs::forced_import(
path,
&suffix("supply_even"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
compute_dollars,
@@ -740,7 +779,7 @@ impl Vecs {
ComputedHeightValueVecs::forced_import(
path,
&suffix("supply_in_loss"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
compute_dollars,
@@ -751,7 +790,7 @@ impl Vecs {
ComputedHeightValueVecs::forced_import(
path,
&suffix("supply_in_profit"),
false,
Source::None,
version + VERSION + Version::ZERO,
format,
compute_dollars,
@@ -789,10 +828,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_even_relative_to_own_supply"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -800,10 +840,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_loss_relative_to_own_supply"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -811,10 +852,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_profit_relative_to_own_supply"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -822,10 +864,11 @@ impl Vecs {
ComputedVecsFromHeight::forced_import(
path,
&suffix("supply_relative_to_circulating_supply"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -868,10 +911,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_even_relative_to_circulating_supply"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -881,10 +925,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_loss_relative_to_circulating_supply"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -894,10 +939,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("supply_in_profit_relative_to_circulating_supply"),
true,
Source::Compute,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)
.unwrap()
}),
@@ -916,27 +962,30 @@ impl Vecs {
indexes_to_coinblocks_destroyed: ComputedVecsFromHeight::forced_import(
path,
&suffix("coinblocks_destroyed"),
true,
Source::Compute,
version + VERSION + Version::TWO,
format,
StorableVecGeneatorOptions::default().add_sum().add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_coindays_destroyed: ComputedVecsFromHeight::forced_import(
path,
&suffix("coindays_destroyed"),
true,
Source::Compute,
version + VERSION + Version::TWO,
format,
StorableVecGeneatorOptions::default().add_sum().add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_net_realized_profit_and_loss_cumulative_30d_change: compute_dollars.then(|| {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("net_realized_profit_and_loss_cumulative_30d_change"),
true,
Source::Compute,
version + VERSION + Version::new(3),
format,
StorableVecGeneatorOptions::default().add_last()
computation,
EagerVecBuilderOptions::default().add_last()
)
.unwrap()
}),
@@ -944,10 +993,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap"),
true,
Source::Compute,
version + VERSION + Version::new(3),
format,
StorableVecGeneatorOptions::default().add_last()
computation,
EagerVecBuilderOptions::default().add_last()
)
.unwrap()
}),
@@ -955,10 +1005,11 @@ impl Vecs {
ComputedVecsFromDateIndex::forced_import(
path,
&suffix("net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap"),
true,
Source::Compute,
version + VERSION + Version::new(3),
format,
StorableVecGeneatorOptions::default().add_last()
computation,
EagerVecBuilderOptions::default().add_last()
)
.unwrap()
}),

View File

@@ -18,7 +18,7 @@ use crate::{
BlockState, SupplyState, Transacted,
stores::Stores,
vecs::{
grouped::ComputedVecsFromHeight,
grouped::{ComputedVecsFromHeight, Source},
market,
stateful::{
addresstype_to_addresscount::AddressTypeToAddressCount,
@@ -31,7 +31,7 @@ use crate::{
use super::{
Indexes, fetched,
grouped::{ComputedValueVecsFromHeight, StorableVecGeneatorOptions},
grouped::{ComputedValueVecsFromHeight, EagerVecBuilderOptions},
indexes, transactions,
};
@@ -78,7 +78,7 @@ impl Vecs {
pub fn forced_import(
path: &Path,
version: Version,
_computation: Computation,
computation: Computation,
format: Format,
fetched: Option<&fetched::Vecs>,
) -> color_eyre::Result<Self> {
@@ -106,10 +106,11 @@ impl Vecs {
indexes_to_unspendable_supply: ComputedValueVecsFromHeight::forced_import(
path,
"unspendable_supply",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
compute_dollars,
)?,
height_to_opreturn_supply: EagerVec::forced_import(
@@ -121,27 +122,30 @@ impl Vecs {
indexes_to_opreturn_supply: ComputedValueVecsFromHeight::forced_import(
path,
"opreturn_supply",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
compute_dollars,
)?,
indexes_to_address_count: ComputedVecsFromHeight::forced_import(
path,
"address_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
indexes_to_empty_address_count: ComputedVecsFromHeight::forced_import(
path,
"empty_address_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
addresstype_to_height_to_address_count: AddressTypeToHeightToAddressCount::from(
ByAddressType {
@@ -252,66 +256,74 @@ impl Vecs {
p2pk65: ComputedVecsFromHeight::forced_import(
path,
"p2pk65_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2pk33: ComputedVecsFromHeight::forced_import(
path,
"p2pk33_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2pkh: ComputedVecsFromHeight::forced_import(
path,
"p2pkh_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2sh: ComputedVecsFromHeight::forced_import(
path,
"p2sh_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2wpkh: ComputedVecsFromHeight::forced_import(
path,
"p2wpkh_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2wsh: ComputedVecsFromHeight::forced_import(
path,
"p2wsh_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2tr: ComputedVecsFromHeight::forced_import(
path,
"p2tr_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2a: ComputedVecsFromHeight::forced_import(
path,
"p2a_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
},
),
@@ -320,73 +332,81 @@ impl Vecs {
p2pk65: ComputedVecsFromHeight::forced_import(
path,
"p2pk65_empty_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2pk33: ComputedVecsFromHeight::forced_import(
path,
"p2pk33_empty_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2pkh: ComputedVecsFromHeight::forced_import(
path,
"p2pkh_empty_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2sh: ComputedVecsFromHeight::forced_import(
path,
"p2sh_empty_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2wpkh: ComputedVecsFromHeight::forced_import(
path,
"p2wpkh_empty_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2wsh: ComputedVecsFromHeight::forced_import(
path,
"p2wsh_empty_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2tr: ComputedVecsFromHeight::forced_import(
path,
"p2tr_empty_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
p2a: ComputedVecsFromHeight::forced_import(
path,
"p2a_empty_address_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
},
),
utxo_vecs: utxo_cohorts::Vecs::forced_import(
path,
version,
_computation,
computation,
format,
fetched,
&states_path,
@@ -394,7 +414,7 @@ impl Vecs {
address_vecs: address_cohorts::Vecs::forced_import(
path,
version,
_computation,
computation,
format,
fetched,
&states_path,
@@ -1302,34 +1322,37 @@ impl Vecs {
// Capped as external drives (even thunderbolt 4 SSDs) can be overwhelmed
let chunk_size = (vecs.len() as f64 / 3.0).ceil() as usize;
vecs.into_par_iter().chunks(chunk_size).try_for_each(|v| {
v.into_iter().try_for_each(|either| match either {
Either::Left(v) => v.compute_rest_part2(
indexer,
indexes,
fetched,
starting_indexes,
market,
&height_to_supply,
dateindex_to_supply_ref,
height_to_realized_cap_ref,
dateindex_to_realized_cap_ref,
exit,
),
Either::Right(v) => v.compute_rest_part2(
indexer,
indexes,
fetched,
starting_indexes,
market,
&height_to_supply,
dateindex_to_supply_ref,
height_to_realized_cap_ref,
dateindex_to_realized_cap_ref,
exit,
),
})
})?;
vecs.into_par_iter()
// .into_iter()
.chunks(chunk_size)
.try_for_each(|v| {
v.into_iter().try_for_each(|either| match either {
Either::Left(v) => v.compute_rest_part2(
indexer,
indexes,
fetched,
starting_indexes,
market,
&height_to_supply,
dateindex_to_supply_ref,
height_to_realized_cap_ref,
dateindex_to_realized_cap_ref,
exit,
),
Either::Right(v) => v.compute_rest_part2(
indexer,
indexes,
fetched,
starting_indexes,
market,
&height_to_supply,
dateindex_to_supply_ref,
height_to_realized_cap_ref,
dateindex_to_realized_cap_ref,
exit,
),
})
})?;
self.indexes_to_unspendable_supply.compute_rest(
indexer,

View File

@@ -11,11 +11,13 @@ use brk_vec::{
ComputedVecFrom1, ComputedVecFrom2, ComputedVecFrom3, Format, StoredIndex, VecIterator,
};
use crate::vecs::grouped::Source;
use super::{
Indexes, fetched,
grouped::{
ComputedValueVecsFromHeight, ComputedValueVecsFromTxindex, ComputedVecsFromHeight,
ComputedVecsFromTxindex, StorableVecGeneatorOptions,
ComputedVecsFromTxindex, EagerVecBuilderOptions,
},
indexes,
};
@@ -237,7 +239,8 @@ impl Vecs {
// true,
// version + VERSION + Version::ZERO,
// format,
// StorableVecGeneatorOptions::default()
// computation,
// StorableVecGeneatorOptions::default()
// .add_average()
// .add_sum()
// .add_cumulative(),
@@ -286,7 +289,8 @@ impl Vecs {
// true,
// version + VERSION + Version::ZERO,
// format,
// StorableVecGeneatorOptions::default()
// computation,
// StorableVecGeneatorOptions::default()
// .add_average()
// .add_sum()
// .add_cumulative(),
@@ -339,10 +343,11 @@ impl Vecs {
indexes_to_tx_count: ComputedVecsFromHeight::forced_import(
path,
"tx_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -352,10 +357,11 @@ impl Vecs {
indexes_to_input_count: ComputedVecsFromTxindex::forced_import(
path,
"input_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -365,10 +371,11 @@ impl Vecs {
indexes_to_output_count: ComputedVecsFromTxindex::forced_import(
path,
"output_count",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -378,43 +385,40 @@ impl Vecs {
indexes_to_tx_v1: ComputedVecsFromHeight::forced_import(
path,
"tx_v1",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_tx_v2: ComputedVecsFromHeight::forced_import(
path,
"tx_v2",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_tx_v3: ComputedVecsFromHeight::forced_import(
path,
"tx_v3",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_fee: ComputedValueVecsFromTxindex::forced_import(
path,
"fee",
indexes,
Some(txindex_to_fee.boxed_clone()),
Source::Vec(txindex_to_fee.boxed_clone()),
version + VERSION + Version::ZERO,
computation,
format,
fetched,
StorableVecGeneatorOptions::default()
EagerVecBuilderOptions::default()
.add_sum()
.add_cumulative()
.add_percentiles()
@@ -424,10 +428,11 @@ impl Vecs {
indexes_to_feerate: ComputedVecsFromTxindex::forced_import(
path,
"feerate",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_percentiles()
.add_minmax()
.add_average(),
@@ -435,10 +440,11 @@ impl Vecs {
indexes_to_tx_vsize: ComputedVecsFromTxindex::forced_import(
path,
"tx_vsize",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_percentiles()
.add_minmax()
.add_average(),
@@ -446,10 +452,11 @@ impl Vecs {
indexes_to_tx_weight: ComputedVecsFromTxindex::forced_import(
path,
"tx_weight",
false,
Source::None,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_percentiles()
.add_minmax()
.add_average(),
@@ -457,10 +464,11 @@ impl Vecs {
indexes_to_subsidy: ComputedValueVecsFromHeight::forced_import(
path,
"subsidy",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_percentiles()
.add_sum()
.add_cumulative()
@@ -471,10 +479,11 @@ impl Vecs {
indexes_to_coinbase: ComputedValueVecsFromHeight::forced_import(
path,
"coinbase",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_sum()
.add_cumulative()
.add_percentiles()
@@ -485,21 +494,21 @@ impl Vecs {
indexes_to_unclaimed_rewards: ComputedValueVecsFromHeight::forced_import(
path,
"unclaimed_rewards",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
.add_sum()
.add_cumulative(),
computation,
EagerVecBuilderOptions::default().add_sum().add_cumulative(),
compute_dollars,
)?,
indexes_to_p2a_count: ComputedVecsFromHeight::forced_import(
path,
"p2a_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -509,10 +518,11 @@ impl Vecs {
indexes_to_p2ms_count: ComputedVecsFromHeight::forced_import(
path,
"p2ms_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -522,10 +532,11 @@ impl Vecs {
indexes_to_p2pk33_count: ComputedVecsFromHeight::forced_import(
path,
"p2pk33_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -535,10 +546,11 @@ impl Vecs {
indexes_to_p2pk65_count: ComputedVecsFromHeight::forced_import(
path,
"p2pk65_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -548,10 +560,11 @@ impl Vecs {
indexes_to_p2pkh_count: ComputedVecsFromHeight::forced_import(
path,
"p2pkh_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -561,10 +574,11 @@ impl Vecs {
indexes_to_p2sh_count: ComputedVecsFromHeight::forced_import(
path,
"p2sh_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -574,10 +588,11 @@ impl Vecs {
indexes_to_p2tr_count: ComputedVecsFromHeight::forced_import(
path,
"p2tr_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -587,10 +602,11 @@ impl Vecs {
indexes_to_p2wpkh_count: ComputedVecsFromHeight::forced_import(
path,
"p2wpkh_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -600,10 +616,11 @@ impl Vecs {
indexes_to_p2wsh_count: ComputedVecsFromHeight::forced_import(
path,
"p2wsh_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -613,10 +630,11 @@ impl Vecs {
indexes_to_opreturn_count: ComputedVecsFromHeight::forced_import(
path,
"opreturn_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -626,10 +644,11 @@ impl Vecs {
indexes_to_unknownoutput_count: ComputedVecsFromHeight::forced_import(
path,
"unknownoutput_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -639,10 +658,11 @@ impl Vecs {
indexes_to_emptyoutput_count: ComputedVecsFromHeight::forced_import(
path,
"emptyoutput_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default()
computation,
EagerVecBuilderOptions::default()
.add_average()
.add_minmax()
.add_percentiles()
@@ -652,10 +672,11 @@ impl Vecs {
indexes_to_exact_utxo_count: ComputedVecsFromHeight::forced_import(
path,
"exact_utxo_count",
true,
Source::Compute,
version + VERSION + Version::ZERO,
format,
StorableVecGeneatorOptions::default().add_last(),
computation,
EagerVecBuilderOptions::default().add_last(),
)?,
txindex_to_is_coinbase,
inputindex_to_value,