mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-09 05:39:09 -07:00
global: adding semester + making coarser intervals computed instead of eager
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use brk_core::Version;
|
||||
use brk_core::{Height, Version};
|
||||
|
||||
use super::{BoxedVecIterator, StoredIndex, StoredType};
|
||||
|
||||
@@ -20,10 +20,10 @@ pub trait AnyVec: Send + Sync {
|
||||
}
|
||||
fn index_type_to_string(&self) -> &'static str;
|
||||
fn value_type_to_size_of(&self) -> usize;
|
||||
fn etag(&self, to: Option<i64>) -> String {
|
||||
fn etag(&self, height: Height, to: Option<i64>) -> String {
|
||||
let len = self.len();
|
||||
format!(
|
||||
"{}-{:?}",
|
||||
"{}-{}-{}",
|
||||
to.map_or(len, |to| {
|
||||
if to.is_negative() {
|
||||
len.checked_sub(to.unsigned_abs() as usize)
|
||||
@@ -32,7 +32,8 @@ pub trait AnyVec: Send + Sync {
|
||||
to as usize
|
||||
}
|
||||
}),
|
||||
self.version()
|
||||
u64::from(self.version()),
|
||||
u32::from(height),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -122,13 +122,14 @@ where
|
||||
|
||||
fn file_write_all(&mut self, file: &mut File, buf: &[u8]) -> Result<()> {
|
||||
file.write_all(buf)?;
|
||||
// file.flush()?;
|
||||
// file.sync_data()?;
|
||||
self.update_mmap(file)
|
||||
}
|
||||
|
||||
fn file_truncate_and_write_all(&mut self, file: &mut File, len: u64, buf: &[u8]) -> Result<()> {
|
||||
Self::file_set_len_(file, len)?;
|
||||
file.write_all(buf)?;
|
||||
self.update_mmap(file)
|
||||
self.file_write_all(file, buf)
|
||||
}
|
||||
|
||||
fn reset(&mut self) -> Result<()>;
|
||||
|
||||
@@ -92,7 +92,7 @@ where
|
||||
S3T: StoredType,
|
||||
{
|
||||
pub fn forced_import_or_init_from_1(
|
||||
mode: Computation,
|
||||
computation: Computation,
|
||||
path: &Path,
|
||||
name: &str,
|
||||
version: Version,
|
||||
@@ -100,7 +100,7 @@ where
|
||||
source: BoxedAnyIterableVec<S1I, S1T>,
|
||||
compute: ComputeFrom1<I, T, S1I, S1T>,
|
||||
) -> Result<Self> {
|
||||
Ok(match mode {
|
||||
Ok(match computation {
|
||||
Computation::Eager => Self::Eager {
|
||||
vec: EagerVec::forced_import(path, name, version, format)?,
|
||||
deps: Dependencies::From1(source, compute),
|
||||
@@ -114,7 +114,7 @@ where
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn forced_import_or_init_from_2(
|
||||
mode: Computation,
|
||||
computation: Computation,
|
||||
path: &Path,
|
||||
name: &str,
|
||||
version: Version,
|
||||
@@ -123,7 +123,7 @@ where
|
||||
source2: BoxedAnyIterableVec<S2I, S2T>,
|
||||
compute: ComputeFrom2<I, T, S1I, S1T, S2I, S2T>,
|
||||
) -> Result<Self> {
|
||||
Ok(match mode {
|
||||
Ok(match computation {
|
||||
Computation::Eager => Self::Eager {
|
||||
vec: EagerVec::forced_import(path, name, version, format)?,
|
||||
deps: Dependencies::From2((source1, source2), compute),
|
||||
@@ -137,7 +137,7 @@ where
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn forced_import_or_init_from_3(
|
||||
mode: Computation,
|
||||
computation: Computation,
|
||||
path: &Path,
|
||||
name: &str,
|
||||
version: Version,
|
||||
@@ -147,7 +147,7 @@ where
|
||||
source3: BoxedAnyIterableVec<S3I, S3T>,
|
||||
compute: ComputeFrom3<I, T, S1I, S1T, S2I, S2T, S3I, S3T>,
|
||||
) -> Result<Self> {
|
||||
Ok(match mode {
|
||||
Ok(match computation {
|
||||
Computation::Eager => Self::Eager {
|
||||
vec: EagerVec::forced_import(path, name, version, format)?,
|
||||
deps: Dependencies::From3((source1, source2, source3), compute),
|
||||
|
||||
@@ -35,10 +35,6 @@ where
|
||||
source: BoxedAnyIterableVec<S1I, S1T>,
|
||||
compute: ComputeFrom1<I, T, S1I, S1T>,
|
||||
) -> Self {
|
||||
if source.index_type_to_string() != I::to_string() {
|
||||
panic!("Should have same index");
|
||||
}
|
||||
|
||||
Self {
|
||||
name: name.to_string(),
|
||||
version,
|
||||
|
||||
Reference in New Issue
Block a user