CompressibleChunkStorage

Struct CompressibleChunkStorage 

Source
pub struct CompressibleChunkStorage<N, Compr>
where Compr: Compression,
{ /* private fields */ }
Expand description

A two-tier chunk storage. The first tier is an LRU cache of uncompressed chunks. The second tier is a Slab of compressed chunks.

Implementations§

Source§

impl<N, By, Chan> CompressibleChunkStorage<N, FastArrayCompression<N, FastChannelsCompression<By, Chan>>>

Source§

impl<N, Compr> CompressibleChunkStorage<N, Compr>
where Compr: Compression,

Source

pub fn compression(&self) -> &Compr

Source§

impl<N, Compr> CompressibleChunkStorage<N, Compr>
where ChunkKey<N>: Clone + Eq + Hash, Compr: Compression,

Source

pub fn new(compression: Compr) -> CompressibleChunkStorage<N, Compr>

Source

pub fn len_cached(&self) -> usize

Source

pub fn len_compressed(&self) -> usize

Source

pub fn reader<'a>( &'a self, local_cache: &'a LocalCache<ChunkKey<N>, <Compr as Compression>::Data, RandomState>, ) -> CompressibleChunkStorageReader<'a, N, Compr>

Returns a reader that implements ChunkReadStorage.

Source

pub fn copy_without_caching( &self, key: ChunkKey<N>, ) -> Option<MaybeCompressed<<Compr as Compression>::Data, Compressed<Compr>>>
where <Compr as Compression>::Data: Clone, Compressed<Compr>: Clone,

Returns a copy of the Chunk at key.

WARNING: the cache will not be updated. This method should be used for a read-modify-write workflow where it would be inefficient to cache the chunk only for it to be overwritten by the modified version.

Source

pub fn remove( &mut self, key: ChunkKey<N>, ) -> Option<MaybeCompressed<<Compr as Compression>::Data, Compressed<Compr>>>

Remove the Chunk at key.

Source

pub fn compress_lru(&mut self)

Compress the least-recently-used, cached chunk. On access, compressed chunks will be decompressed and cached.

Source

pub fn remove_lru( &mut self, ) -> Option<(ChunkKey<N>, <Compr as Compression>::Data)>

Remove the least-recently-used, cached chunk.

This is useful for removing a batch of chunks at a time before compressing them in parallel. Then call insert_compressed.

Source

pub fn insert_compressed( &mut self, key: ChunkKey<N>, compressed_chunk: Compressed<Compr>, ) -> Option<MaybeCompressed<<Compr as Compression>::Data, Compressed<Compr>>>

Insert a compressed chunk. Returns the old chunk if one exists.

Source

pub fn flush_local_cache( &mut self, local_cache: LocalCache<ChunkKey<N>, <Compr as Compression>::Data, RandomState>, )

Consumes and flushes the chunk cache into the chunk map. This is not strictly necessary, but it will help with caching efficiency.

Source

pub fn insert_chunk( &mut self, key: ChunkKey<N>, chunk: <Compr as Compression>::Data, ) -> Option<MaybeCompressed<<Compr as Compression>::Data, Compressed<Compr>>>

Inserts chunk at key and returns the old chunk.

Trait Implementations§

Source§

impl<N, Compr> ChunkWriteStorage<N, <Compr as Compression>::Data> for CompressibleChunkStorage<N, Compr>
where ChunkKey<N>: Clone + Eq + Hash, Compr: Compression,

Source§

fn get_mut( &mut self, key: ChunkKey<N>, ) -> Option<&mut <Compr as Compression>::Data>

Mutably borrow the chunk at key.
Source§

fn get_mut_or_insert_with( &mut self, key: ChunkKey<N>, create_chunk: impl FnOnce() -> <Compr as Compression>::Data, ) -> &mut <Compr as Compression>::Data

Mutably borrow the chunk at key. If it doesn’t exist, insert the return value of create_chunk.
Source§

fn replace( &mut self, key: ChunkKey<N>, chunk: <Compr as Compression>::Data, ) -> Option<<Compr as Compression>::Data>

Replace the chunk at key with chunk, returning the old value.
Source§

fn write(&mut self, key: ChunkKey<N>, chunk: <Compr as Compression>::Data)

Overwrite the chunk at key with chunk. Drops the previous value.
Source§

fn delete(&mut self, key: ChunkKey<N>)

Removes and drops the chunk at key.
Source§

fn pop(&mut self, key: ChunkKey<N>) -> Option<<Compr as Compression>::Data>

Removes and returns the chunk at key.
Source§

impl<N, Compr> IntoIterator for CompressibleChunkStorage<N, Compr>
where N: 'static, Compr: 'static + Compression,

Source§

type IntoIter = Box<dyn Iterator<Item = <CompressibleChunkStorage<N, Compr> as IntoIterator>::Item>>

Which kind of iterator are we turning this into?
Source§

type Item = (ChunkKey<N>, <Compr as Compression>::Data)

The type of the elements being iterated over.
Source§

fn into_iter( self, ) -> <CompressibleChunkStorage<N, Compr> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, N, Compr> IterChunkKeys<'a, N> for CompressibleChunkStorage<N, Compr>
where N: 'a, ChunkKey<N>: Clone + Eq + Hash, <Compr as Compression>::Data: 'a, Compr: Compression,

Auto Trait Implementations§

§

impl<N, Compr> Freeze for CompressibleChunkStorage<N, Compr>
where Compr: Freeze,

§

impl<N, Compr> RefUnwindSafe for CompressibleChunkStorage<N, Compr>

§

impl<N, Compr> Send for CompressibleChunkStorage<N, Compr>
where Compr: Send, <Compr as Compression>::CompressedData: Send, N: Send, <Compr as Compression>::Data: Send,

§

impl<N, Compr> Sync for CompressibleChunkStorage<N, Compr>
where Compr: Sync, <Compr as Compression>::CompressedData: Sync, N: Sync, <Compr as Compression>::Data: Sync,

§

impl<N, Compr> Unpin for CompressibleChunkStorage<N, Compr>
where Compr: Unpin, <Compr as Compression>::CompressedData: Unpin, N: Unpin, <Compr as Compression>::Data: Unpin,

§

impl<N, Compr> UnwindSafe for CompressibleChunkStorage<N, Compr>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

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>,

Source§

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.