mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-05 03:39:10 -07:00
global: snapshot
This commit is contained in:
5
storable_vec/src/enums/mod.rs
Normal file
5
storable_vec/src/enums/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
mod error;
|
||||
mod value;
|
||||
|
||||
pub use error::*;
|
||||
pub use value::*;
|
||||
@@ -13,21 +13,28 @@ use std::{
|
||||
use memmap2::{Mmap, MmapOptions};
|
||||
use unsafe_slice_serde::UnsafeSliceSerde;
|
||||
|
||||
mod any;
|
||||
// mod bytes;
|
||||
mod error;
|
||||
mod index;
|
||||
mod type_;
|
||||
mod value;
|
||||
mod version;
|
||||
mod enums;
|
||||
mod structs;
|
||||
mod traits;
|
||||
|
||||
pub use any::*;
|
||||
// pub use bytes::*;
|
||||
pub use error::*;
|
||||
pub use index::*;
|
||||
pub use type_::*;
|
||||
pub use value::*;
|
||||
pub use version::*;
|
||||
pub use enums::*;
|
||||
pub use structs::*;
|
||||
pub use traits::*;
|
||||
|
||||
/// Uses `Mmap` instead of `File`
|
||||
///
|
||||
/// Used in `/indexer`
|
||||
const CACHED: u8 = 0;
|
||||
|
||||
/// Will use the same `File` for every read, so not thread safe
|
||||
///
|
||||
/// Used in `/computer`
|
||||
const RAW_SYNC: u8 = 1;
|
||||
|
||||
/// Will spin up a new `File` for every read
|
||||
///
|
||||
/// Used in `/server`
|
||||
const RAW_ASYNC: u8 = 2;
|
||||
|
||||
///
|
||||
/// A very small, fast, efficient and simple storable Vec
|
||||
@@ -45,6 +52,7 @@ pub struct StorableVec<I, T> {
|
||||
pathbuf: PathBuf,
|
||||
unsafe_file: File,
|
||||
cache: Vec<OnceLock<Box<Mmap>>>, // Boxed Mmap to reduce the size of the Lock (from 24 to 16)
|
||||
buf: Vec<u8>,
|
||||
disk_len: usize,
|
||||
pushed: Vec<T>,
|
||||
// updated: BTreeMap<usize, T>,
|
||||
@@ -89,6 +97,7 @@ where
|
||||
pathbuf: path.to_owned(),
|
||||
disk_len: Self::disk_len(&unsafe_file)?,
|
||||
unsafe_file,
|
||||
buf: vec![0; Self::SIZE_OF_T],
|
||||
cache: vec![],
|
||||
pushed: vec![],
|
||||
// updated: BTreeMap::new(),
|
||||
|
||||
3
storable_vec/src/structs/mod.rs
Normal file
3
storable_vec/src/structs/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
mod version;
|
||||
|
||||
pub use version::*;
|
||||
@@ -1,6 +1,8 @@
|
||||
use std::io;
|
||||
|
||||
use crate::{StorableVec, StorableVecIndex, StorableVecType};
|
||||
use crate::StorableVec;
|
||||
|
||||
use super::{StorableVecIndex, StorableVecType};
|
||||
|
||||
pub trait AnyStorableVec {
|
||||
fn len(&self) -> usize;
|
||||
8
storable_vec/src/traits/mod.rs
Normal file
8
storable_vec/src/traits/mod.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
mod any;
|
||||
// mod bytes;
|
||||
mod index;
|
||||
mod type_;
|
||||
|
||||
pub use any::*;
|
||||
pub use index::*;
|
||||
pub use type_::*;
|
||||
Reference in New Issue
Block a user