pub struct ChunkCache { /* private fields */ }Expand description
Implementations§
Source§impl ChunkCache
impl ChunkCache
Sourcepub fn with_capacity(max_bytes: usize, max_slots: usize) -> Self
pub fn with_capacity(max_bytes: usize, max_slots: usize) -> Self
Create a new chunk cache with custom byte budget and slot count.
Sourcepub fn populate_index(&self, chunks: &[ChunkInfo], rank: usize)
pub fn populate_index(&self, chunks: &[ChunkInfo], rank: usize)
Build the chunk index from a pre-collected list of ChunkInfo.
The rank parameter is used to truncate offsets to spatial dims only
(B-tree v1 stores rank+1 offsets).
Sourcepub fn lookup_index(&self, coord: &[u64]) -> Option<ChunkInfo>
pub fn lookup_index(&self, coord: &[u64]) -> Option<ChunkInfo>
Look up a chunk by its spatial coordinate in the index.
Sourcepub fn all_indexed_chunks(&self) -> Option<Vec<ChunkInfo>>
pub fn all_indexed_chunks(&self) -> Option<Vec<ChunkInfo>>
Return all indexed chunks as a Vec<ChunkInfo> (order unspecified).
Sourcepub fn get_decompressed(&self, coord: &[u64]) -> Option<Vec<u8>>
pub fn get_decompressed(&self, coord: &[u64]) -> Option<Vec<u8>>
Try to get cached decompressed data for a chunk coordinate.
Returns a clone of the cache-line-aligned buffer.
Sourcepub fn get_decompressed_aligned(
&self,
coord: &[u64],
) -> Option<CacheAlignedBuffer>
pub fn get_decompressed_aligned( &self, coord: &[u64], ) -> Option<CacheAlignedBuffer>
Try to get a reference-counted clone of the aligned buffer for a chunk.
Sourcepub fn put_decompressed(&self, coord: ChunkCoord, data: Vec<u8>)
pub fn put_decompressed(&self, coord: ChunkCoord, data: Vec<u8>)
Insert decompressed chunk data into the LRU cache.
The data is stored in a CacheAlignedBuffer so subsequent reads
return cache-line-aligned memory.
Sourcepub fn put_decompressed_aligned(
&self,
coord: ChunkCoord,
data: CacheAlignedBuffer,
)
pub fn put_decompressed_aligned( &self, coord: ChunkCoord, data: CacheAlignedBuffer, )
Insert an already-aligned buffer into the LRU cache.
Sourcepub fn prefetch_hint(&self, next_coords: &[ChunkCoord])
pub fn prefetch_hint(&self, next_coords: &[ChunkCoord])
Hint that the given chunk coordinates will be accessed soon.
Pre-populates the chunk index for these coordinates so that subsequent lookups are O(1). This does NOT pre-decompress the chunks — it only ensures the index entries exist.
Sourcepub fn access_stats(&self) -> AccessStats
pub fn access_stats(&self) -> AccessStats
Return the current access pattern statistics.
Sourcepub fn set_sweep_direction(&self, direction: &'static str)
pub fn set_sweep_direction(&self, direction: &'static str)
Update the sweep direction label in the access stats.
Sourcepub fn cached_chunk_count(&self) -> usize
pub fn cached_chunk_count(&self) -> usize
Number of decompressed chunks currently cached.
Sourcepub fn cached_bytes(&self) -> usize
pub fn cached_bytes(&self) -> usize
Total bytes of decompressed data currently cached.