tatami_chunked
Helpers to create custom chunked tatami matrices
|
Least-recently-used cache for slabs. More...
#include <LruSlabCache.hpp>
Public Member Functions | |
LruSlabCache (size_t max_slabs) | |
LruSlabCache (const LruSlabCache &)=delete | |
LruSlabCache & | operator= (const LruSlabCache &)=delete |
template<class Cfunction_ , class Pfunction_ > | |
const Slab_ & | find (Id_ id, Cfunction_ create, Pfunction_ populate) |
size_t | get_max_slabs () const |
size_t | get_num_slabs () const |
Least-recently-used cache for slabs.
Id_ | Type of cache identifier, typically integer. |
Slab_ | Class for a single slab. |
Implements a least-recently-used (LRU) cache, typically containing one or more "slabs" from a chunked matrix representation. Each slab is defined as the set of chunks required to read an element of the target dimension (or a contiguous block/indexed subset thereof) from a tatami::Matrix
. The LRU cache can be used for chunked tatami::Matrix
representations where the data is costly to load (e.g., from file) and no oracle is provided to predict future accesses on the target dimension. In such cases, chunks of data can be loaded and cached such that any possible future request for an already-loaded slab will just fetch it from cache.
|
inline |
max_slabs | Maximum number of slabs to store in the cache. |
|
delete |
Deleted as the cache holds persistent iterators.
|
delete |
Deleted as the cache holds persistent iterators.
|
inline |
This method should only be called if m > 0
in the constructor.
Cfunction_ | Function to create a new Slab_ object. |
Pfunction_ | Function to populate a Slab_ object with the contents of a slab. |
id | Identifier for the cached slab. This is typically defined as the index of the slab on the target dimension. For example, if each chunk takes up 10 rows, attempting to access row 21 would require retrieval of slab 2. |
create | Function that accepts no arguments and returns a Slab_ object. |
populate | Function that accepts a slab ID and a reference to a Slab_ object, and populates the latter with the contents of the former. |
id
. If the slab does not exist and there is no space in the cache, the least recently used slab is evicted and its Slab_
is populated with the contents of slab id
.
|
inline |
|
inline |