Struct building_blocks::prelude::CompressibleChunkStorage [−][src]
pub struct CompressibleChunkStorage<N, Compr> where
Compr: Compression, { /* fields omitted */ }
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
impl<N, By, Chan> CompressibleChunkStorage<N, FastArrayCompression<N, FastChannelsCompression<By, Chan>>> where
PointN<N>: Copy,
ChunkKey<N>: Clone,
ChunkKey<N>: Eq,
ChunkKey<N>: Hash,
FastChannelsCompression<By, Chan>: Compression,
impl<N, By, Chan> CompressibleChunkStorage<N, FastArrayCompression<N, FastChannelsCompression<By, Chan>>> where
PointN<N>: Copy,
ChunkKey<N>: Clone,
ChunkKey<N>: Eq,
ChunkKey<N>: Hash,
FastChannelsCompression<By, Chan>: Compression,
pub fn with_bytes_compression(
bytes_compression: By
) -> CompressibleChunkStorage<N, FastArrayCompression<N, FastChannelsCompression<By, Chan>>>
impl<N, Compr> CompressibleChunkStorage<N, Compr> where
Compr: Compression,
ChunkKey<N>: Clone,
ChunkKey<N>: Eq,
ChunkKey<N>: Hash,
impl<N, Compr> CompressibleChunkStorage<N, Compr> where
Compr: Compression,
ChunkKey<N>: Clone,
ChunkKey<N>: Eq,
ChunkKey<N>: Hash,
pub fn reader(
&'a self,
local_cache: &'a LocalCache<ChunkKey<N>, <Compr as Compression>::Data, RandomState>
) -> CompressibleChunkStorageReader<'a, N, Compr>
pub fn reader(
&'a self,
local_cache: &'a LocalCache<ChunkKey<N>, <Compr as Compression>::Data, RandomState>
) -> CompressibleChunkStorageReader<'a, N, Compr>
Returns a reader that implements ChunkReadStorage
.
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,
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.
pub fn remove(
&mut self,
key: ChunkKey<N>
) -> Option<MaybeCompressed<<Compr as Compression>::Data, Compressed<Compr>>>
pub fn remove(
&mut self,
key: ChunkKey<N>
) -> Option<MaybeCompressed<<Compr as Compression>::Data, Compressed<Compr>>>
Remove the Chunk
at key
.
Compress the least-recently-used, cached chunk. On access, compressed chunks will be decompressed and cached.
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
.
pub fn insert_compressed(
&mut self,
key: ChunkKey<N>,
compressed_chunk: Compressed<Compr>
) -> Option<MaybeCompressed<<Compr as Compression>::Data, Compressed<Compr>>>
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.
pub fn flush_local_cache(
&mut self,
local_cache: LocalCache<ChunkKey<N>, <Compr as Compression>::Data, RandomState>
)
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.
pub fn insert_chunk(
&mut self,
key: ChunkKey<N>,
chunk: <Compr as Compression>::Data
) -> Option<MaybeCompressed<<Compr as Compression>::Data, Compressed<Compr>>>
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
impl<N, Compr> ChunkWriteStorage<N, <Compr as Compression>::Data> for CompressibleChunkStorage<N, Compr> where
Compr: Compression,
ChunkKey<N>: Clone,
ChunkKey<N>: Eq,
ChunkKey<N>: Hash,
impl<N, Compr> ChunkWriteStorage<N, <Compr as Compression>::Data> for CompressibleChunkStorage<N, Compr> where
Compr: Compression,
ChunkKey<N>: Clone,
ChunkKey<N>: Eq,
ChunkKey<N>: Hash,
Mutably borrow the chunk at key
.
pub fn get_mut_or_insert_with(
&mut self,
key: ChunkKey<N>,
create_chunk: impl FnOnce() -> <Compr as Compression>::Data
) -> &mut <Compr as Compression>::Data
pub 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
.
pub fn replace(
&mut self,
key: ChunkKey<N>,
chunk: <Compr as Compression>::Data
) -> Option<<Compr as Compression>::Data>
pub 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.
Overwrite the chunk at key
with chunk
. Drops the previous value.
impl<N, Compr> IntoIterator for CompressibleChunkStorage<N, Compr> where
N: 'static,
Compr: 'static + Compression,
impl<N, Compr> IntoIterator for CompressibleChunkStorage<N, Compr> where
N: 'static,
Compr: 'static + Compression,
type IntoIter = Box<dyn Iterator<Item = <CompressibleChunkStorage<N, Compr> as IntoIterator>::Item> + 'static, Global>
type IntoIter = Box<dyn Iterator<Item = <CompressibleChunkStorage<N, Compr> as IntoIterator>::Item> + 'static, Global>
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
Creates an iterator from a value. Read more
impl<'a, N, Compr> IterChunkKeys<'a, N> for CompressibleChunkStorage<N, Compr> where
N: 'a,
Compr: Compression,
ChunkKey<N>: Clone,
ChunkKey<N>: Eq,
ChunkKey<N>: Hash,
<Compr as Compression>::Data: 'a,
impl<'a, N, Compr> IterChunkKeys<'a, N> for CompressibleChunkStorage<N, Compr> where
N: 'a,
Compr: Compression,
ChunkKey<N>: Clone,
ChunkKey<N>: Eq,
ChunkKey<N>: Hash,
<Compr as Compression>::Data: 'a,
type Iter = Keys<'a, ChunkKey<N>, CacheEntry<(<Compr as Compression>::Data, usize), CompressedLocation>>
pub fn chunk_keys(
&'a self
) -> <CompressibleChunkStorage<N, Compr> as IterChunkKeys<'a, N>>::Iter
Auto Trait Implementations
impl<N, Compr> RefUnwindSafe for CompressibleChunkStorage<N, Compr> where
Compr: RefUnwindSafe,
N: RefUnwindSafe,
<Compr as Compression>::CompressedData: RefUnwindSafe,
<Compr as Compression>::Data: RefUnwindSafe,
impl<N, Compr> Send for CompressibleChunkStorage<N, Compr> where
Compr: Send,
N: Send,
<Compr as Compression>::CompressedData: Send,
<Compr as Compression>::Data: Send,
impl<N, Compr> Sync for CompressibleChunkStorage<N, Compr> where
Compr: Sync,
N: Sync,
<Compr as Compression>::CompressedData: Sync,
<Compr as Compression>::Data: Sync,
impl<N, Compr> Unpin for CompressibleChunkStorage<N, Compr> where
Compr: Unpin,
N: Unpin,
<Compr as Compression>::CompressedData: Unpin,
<Compr as Compression>::Data: Unpin,
impl<N, Compr> UnwindSafe for CompressibleChunkStorage<N, Compr> where
Compr: UnwindSafe,
N: UnwindSafe,
<Compr as Compression>::CompressedData: UnwindSafe,
<Compr as Compression>::Data: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: 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
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub 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. Read more
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.