Struct merkletree::store::LevelCacheStore

source ·
pub struct LevelCacheStore<E: Element, R: Read + Send + Sync> { /* private fields */ }
Expand description

The LevelCacheStore is used to reduce the on-disk footprint even further to the minimum at the cost of build time performance. Each LevelCacheStore is created with a StoreConfig object which contains the number of binary tree levels above the base that are ‘cached’. This implementation has hard requirements about the on disk file size based on that number of levels, so on-disk files are tied, structurally to the configuration they were built with and can only be accessed with the same number of levels.

Implementations§

source§

impl<E: Element, R: Read + Send + Sync> LevelCacheStore<E, R>

source

pub fn new_from_disk_with_reader( store_range: usize, branches: usize, config: &StoreConfig, reader: ExternalReader<R>, ) -> Result<Self>

Used for opening v2 compacted DiskStores.

source

pub fn set_external_reader(&mut self, reader: ExternalReader<R>) -> Result<()>

source§

impl<E: Element, R: Read + Send + Sync> LevelCacheStore<E, R>

source

pub fn set_len(&mut self, len: usize)

source

pub fn front_truncate(&mut self, config: &StoreConfig, len: usize) -> Result<()>

source

pub fn store_size(&self) -> usize

source

pub fn is_consistent_v1( store_range: usize, branches: usize, config: &StoreConfig, ) -> Result<bool>

source

pub fn is_consistent( store_range: usize, branches: usize, config: &StoreConfig, ) -> Result<bool>

source

pub fn store_read_range(&self, start: usize, end: usize) -> Result<Vec<u8>>

source

pub fn store_read_into( &self, start: usize, end: usize, buf: &mut [u8], ) -> Result<()>

source

pub fn store_copy_from_slice( &mut self, start: usize, slice: &[u8], ) -> Result<()>

Trait Implementations§

source§

impl<E: Element, R: Read + Send + Sync> Debug for LevelCacheStore<E, R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<E: Element, R: Read + Send + Sync> Store<E> for LevelCacheStore<E, R>

source§

fn new_with_config( size: usize, branches: usize, config: StoreConfig, ) -> Result<Self>

Creates a new store which can store up to size elements.
source§

fn new(size: usize) -> Result<Self>

source§

fn new_from_slice_with_config( size: usize, branches: usize, data: &[u8], config: StoreConfig, ) -> Result<Self>

source§

fn new_from_slice(size: usize, data: &[u8]) -> Result<Self>

source§

fn new_from_disk( store_range: usize, branches: usize, config: &StoreConfig, ) -> Result<Self>

This constructor is used for instantiating stores ONLY from existing (potentially read-only) files
source§

fn write_at(&mut self, el: E, index: usize) -> Result<()>

source§

fn copy_from_slice(&mut self, buf: &[u8], start: usize) -> Result<()>

source§

fn read_at(&self, index: usize) -> Result<E>

source§

fn read_into(&self, index: usize, buf: &mut [u8]) -> Result<()>

source§

fn read_range_into( &self, start: usize, end: usize, buf: &mut [u8], ) -> Result<()>

source§

fn read_range(&self, r: Range<usize>) -> Result<Vec<E>>

source§

fn len(&self) -> usize

source§

fn loaded_from_disk(&self) -> bool

source§

fn compact( &mut self, _branches: usize, _config: StoreConfig, _store_version: u32, ) -> Result<bool>

source§

fn delete(config: StoreConfig) -> Result<()>

source§

fn is_empty(&self) -> bool

source§

fn push(&mut self, el: E) -> Result<()>

source§

fn sync(&self) -> Result<()>

source§

fn process_layer<A: Algorithm<E>, U: Unsigned>( &mut self, width: usize, level: usize, read_start: usize, write_start: usize, ) -> Result<()>

source§

fn build<A: Algorithm<E>, U: Unsigned>( &mut self, leafs: usize, row_count: usize, config: Option<StoreConfig>, ) -> Result<E>

source§

fn reinit(&mut self) -> Result<()>

source§

fn last(&self) -> Result<E>

source§

fn build_small_tree<A: Algorithm<E>, U: Unsigned>( &mut self, leafs: usize, row_count: usize, ) -> Result<E>

Auto Trait Implementations§

§

impl<E, R> Freeze for LevelCacheStore<E, R>
where R: Freeze,

§

impl<E, R> RefUnwindSafe for LevelCacheStore<E, R>

§

impl<E, R> Send for LevelCacheStore<E, R>

§

impl<E, R> Sync for LevelCacheStore<E, R>

§

impl<E, R> Unpin for LevelCacheStore<E, R>
where E: Unpin, R: Unpin,

§

impl<E, R> UnwindSafe for LevelCacheStore<E, R>
where E: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.