global: snapshot

This commit is contained in:
nym21
2025-02-02 23:55:05 +01:00
parent 1e37d75e49
commit 42c996e16e
15 changed files with 55 additions and 28 deletions

View File

@@ -0,0 +1,5 @@
mod error;
mod value;
pub use error::*;
pub use value::*;

View File

@@ -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(),

View File

@@ -0,0 +1,3 @@
mod version;
pub use version::*;

View File

@@ -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;

View File

@@ -0,0 +1,8 @@
mod any;
// mod bytes;
mod index;
mod type_;
pub use any::*;
pub use index::*;
pub use type_::*;