mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
compression: added everywhere
This commit is contained in:
@@ -12,6 +12,7 @@ pub use brk_parser::rpc;
|
||||
|
||||
mod storage;
|
||||
|
||||
use brk_vec::Compressed;
|
||||
use log::info;
|
||||
use storage::{Stores, Vecs};
|
||||
|
||||
@@ -21,15 +22,17 @@ pub struct Computer {
|
||||
fetcher: Option<Fetcher>,
|
||||
vecs: Option<Vecs>,
|
||||
stores: Option<Stores>,
|
||||
compressed: Compressed,
|
||||
}
|
||||
|
||||
impl Computer {
|
||||
pub fn new(computed_dir: PathBuf, fetcher: Option<Fetcher>) -> Self {
|
||||
pub fn new(computed_dir: PathBuf, fetcher: Option<Fetcher>, compressed: bool) -> Self {
|
||||
Self {
|
||||
path: computed_dir,
|
||||
fetcher,
|
||||
vecs: None,
|
||||
stores: None,
|
||||
compressed: Compressed::from(compressed),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +40,7 @@ impl Computer {
|
||||
self.vecs = Some(Vecs::import(
|
||||
&self.path.join("vecs"),
|
||||
self.fetcher.is_some(),
|
||||
self.compressed,
|
||||
)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ where
|
||||
I: StoredIndex,
|
||||
T: StoredType,
|
||||
{
|
||||
pub fn import(path: &Path, version: Version) -> brk_vec::Result<Self> {
|
||||
let vec = brk_vec::StorableVec::forced_import(path, version, Compressed::YES)?;
|
||||
pub fn import(path: &Path, version: Version, compressed: Compressed) -> brk_vec::Result<Self> {
|
||||
let vec = brk_vec::StorableVec::forced_import(path, version, compressed)?;
|
||||
|
||||
Ok(Self {
|
||||
computed_version: None,
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{fs, ops::Deref, path::Path};
|
||||
use brk_core::{Date, Dateindex, Height, Txindex, Txinindex, Txoutindex};
|
||||
use brk_exit::Exit;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vec::{AnyStorableVec, Value, Version};
|
||||
use brk_vec::{AnyStorableVec, Compressed, Value, Version};
|
||||
|
||||
use super::StorableVec;
|
||||
|
||||
@@ -25,54 +25,65 @@ pub struct Vecs {
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
pub fn import(path: &Path) -> color_eyre::Result<Self> {
|
||||
pub fn import(path: &Path, compressed: Compressed) -> color_eyre::Result<Self> {
|
||||
fs::create_dir_all(path)?;
|
||||
|
||||
Ok(Self {
|
||||
dateindex_to_date: StorableVec::import(
|
||||
&path.join("dateindex_to_date"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_dateindex: StorableVec::import(
|
||||
&path.join("dateindex_to_dateindex"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_first_height: StorableVec::import(
|
||||
&path.join("dateindex_to_first_height"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_last_height: StorableVec::import(
|
||||
&path.join("dateindex_to_last_height"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_real_date: StorableVec::import(
|
||||
&path.join("height_to_real_date"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_fixed_date: StorableVec::import(
|
||||
&path.join("height_to_fixed_date"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_dateindex: StorableVec::import(
|
||||
&path.join("height_to_dateindex"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_height: StorableVec::import(
|
||||
&path.join("height_to_height"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_last_txindex: StorableVec::import(
|
||||
&path.join("height_to_last_txindex"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
|
||||
txindex_to_last_txinindex: StorableVec::import(
|
||||
&path.join("txindex_to_last_txinindex"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
txindex_to_last_txoutindex: StorableVec::import(
|
||||
&path.join("txindex_to_last_txoutindex"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use brk_core::{
|
||||
use brk_exit::Exit;
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vec::{AnyStorableVec, Value, Version};
|
||||
use brk_vec::{AnyStorableVec, Compressed, Value, Version};
|
||||
|
||||
use super::{Indexes, StorableVec, indexes};
|
||||
|
||||
@@ -37,82 +37,119 @@ pub struct Vecs {
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
pub fn import(path: &Path) -> color_eyre::Result<Self> {
|
||||
pub fn import(path: &Path, compressed: Compressed) -> color_eyre::Result<Self> {
|
||||
fs::create_dir_all(path)?;
|
||||
|
||||
Ok(Self {
|
||||
dateindex_to_ohlc_in_cents: StorableVec::import(
|
||||
&path.join("dateindex_to_ohlc_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_ohlc: StorableVec::import(
|
||||
&path.join("dateindex_to_ohlc"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_close_in_cents: StorableVec::import(
|
||||
&path.join("dateindex_to_close_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_close: StorableVec::import(
|
||||
&path.join("dateindex_to_close"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_high_in_cents: StorableVec::import(
|
||||
&path.join("dateindex_to_high_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_high: StorableVec::import(
|
||||
&path.join("dateindex_to_high"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_low_in_cents: StorableVec::import(
|
||||
&path.join("dateindex_to_low_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_low: StorableVec::import(
|
||||
&path.join("dateindex_to_low"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_open_in_cents: StorableVec::import(
|
||||
&path.join("dateindex_to_open_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_open: StorableVec::import(
|
||||
&path.join("dateindex_to_open"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
dateindex_to_sats_per_dollar: StorableVec::import(
|
||||
&path.join("dateindex_to_sats_per_dollar"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_ohlc_in_cents: StorableVec::import(
|
||||
&path.join("height_to_ohlc_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_ohlc: StorableVec::import(
|
||||
&path.join("height_to_ohlc"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_ohlc: StorableVec::import(&path.join("height_to_ohlc"), Version::from(1))?,
|
||||
height_to_close_in_cents: StorableVec::import(
|
||||
&path.join("height_to_close_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_close: StorableVec::import(
|
||||
&path.join("height_to_close"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_close: StorableVec::import(&path.join("height_to_close"), Version::from(1))?,
|
||||
height_to_high_in_cents: StorableVec::import(
|
||||
&path.join("height_to_high_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_high: StorableVec::import(
|
||||
&path.join("height_to_high"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_high: StorableVec::import(&path.join("height_to_high"), Version::from(1))?,
|
||||
height_to_low_in_cents: StorableVec::import(
|
||||
&path.join("height_to_low_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_low: StorableVec::import(
|
||||
&path.join("height_to_low"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_low: StorableVec::import(&path.join("height_to_low"), Version::from(1))?,
|
||||
height_to_open_in_cents: StorableVec::import(
|
||||
&path.join("height_to_open_in_cents"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_open: StorableVec::import(
|
||||
&path.join("height_to_open"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
height_to_open: StorableVec::import(&path.join("height_to_open"), Version::from(1))?,
|
||||
height_to_sats_per_dollar: StorableVec::import(
|
||||
&path.join("height_to_sats_per_dollar"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{fs, path::Path};
|
||||
use brk_exit::Exit;
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vec::AnyStorableVec;
|
||||
use brk_vec::{AnyStorableVec, Compressed};
|
||||
|
||||
mod base;
|
||||
mod indexes;
|
||||
@@ -21,13 +21,13 @@ pub struct Vecs {
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
pub fn import(path: &Path, fetch: bool) -> color_eyre::Result<Self> {
|
||||
pub fn import(path: &Path, fetch: bool, compressed: Compressed) -> color_eyre::Result<Self> {
|
||||
fs::create_dir_all(path)?;
|
||||
|
||||
Ok(Self {
|
||||
indexes: indexes::Vecs::import(path)?,
|
||||
transactions: transactions::Vecs::import(path)?,
|
||||
marketprice: fetch.then(|| marketprice::Vecs::import(path).unwrap()),
|
||||
indexes: indexes::Vecs::import(path, compressed)?,
|
||||
transactions: transactions::Vecs::import(path, compressed)?,
|
||||
marketprice: fetch.then(|| marketprice::Vecs::import(path, compressed).unwrap()),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{fs, path::Path};
|
||||
use brk_core::Txindex;
|
||||
use brk_exit::Exit;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vec::{AnyStorableVec, Version};
|
||||
use brk_vec::{AnyStorableVec, Compressed, Version};
|
||||
|
||||
use super::{Indexes, StorableVec, indexes};
|
||||
|
||||
@@ -29,7 +29,7 @@ pub struct Vecs {
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
pub fn import(path: &Path) -> color_eyre::Result<Self> {
|
||||
pub fn import(path: &Path, compressed: Compressed) -> color_eyre::Result<Self> {
|
||||
fs::create_dir_all(path)?;
|
||||
|
||||
Ok(Self {
|
||||
@@ -50,6 +50,7 @@ impl Vecs {
|
||||
txindex_to_is_coinbase: StorableVec::import(
|
||||
&path.join("txindex_to_is_coinbase"),
|
||||
Version::from(1),
|
||||
compressed,
|
||||
)?,
|
||||
// txindex_to_feerate: StorableVec::forced_import(&path.join("txindex_to_feerate"), Version::from(1))?,
|
||||
// txindex_to_inputs_count: StorableVec::forced_import(
|
||||
|
||||
Reference in New Issue
Block a user