tatami_chunked
Helpers to create custom chunked tatami matrices
|
Oracular-aware cache for slabs. More...
#include <OracularSlabCache.hpp>
Public Member Functions | |
OracularSlabCache (std::shared_ptr< const tatami::Oracle< Index_ > > oracle, size_t max_slabs) | |
OracularSlabCache (const OracularSlabCache &)=delete | |
OracularSlabCache & | operator= (const OracularSlabCache &)=delete |
Index_ | next () |
template<class Ifunction_ , class Cfunction_ , class Pfunction_ > | |
std::pair< const Slab_ *, Index_ > | next (Ifunction_ identify, Cfunction_ create, Pfunction_ populate) |
size_t | get_max_slabs () const |
size_t | get_num_slabs () const |
Oracular-aware cache for slabs.
Id_ | Type of slab identifier, typically integer. |
Index_ | Type of row/column index produced by the oracle. |
Slab_ | Class for a single slab. |
track_reuse_ | Whether to track slabs in the cache that are re-used. |
Implement an oracle-aware cache for slabs. 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
. This cache can be used for Matrix
representations where the data is costly to load (e.g., from file) and a tatami::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.
It is assumed that each slab has the same size such that Slab_
instances can be effectively reused between slabs without requiring any reallocation of memory. For variable-sized slabs, consider using OracularVariableSlabCache
instead.
|
inline |
oracle | Pointer to an tatami::Oracle to be used for predictions. |
max_slabs | Maximum number of slabs to store in the cache. |
|
delete |
Deleted as the cache holds persistent pointers.
|
delete |
Deleted as the cache holds persistent pointers.
|
inline |
This method is intended to be called when num_slabs = 0
, to provide callers with the oracle predictions for non-cached extraction of data. Calls to this method should not be intermingled with calls to its overload below; the latter should only be called when num_slabs > 0
.
|
inline |
Fetch the next slab according to the stream of predictions provided by the tatami::Oracle
. This method should only be called if num_slabs > 0
in the constructor; otherwise, no slabs are actually available and cannot be returned.
Ifunction_ | Function to identify the slab containing each predicted row/column. |
Cfunction_ | Function to create a new slab. |
Pfunction_ | Function to populate zero, one or more slabs with their contents. |
identify | Function that accepts i , an Index_ containing the predicted index of a single element on the target dimension. This should return a pair containing:
|
create | Function that accepts no arguments and returns a Slab_ object with sufficient memory to hold a slab's contents when used in populate() . This may also return a default-constructed Slab_ object if the allocation is done dynamically per slab in populate() . |
populate | Function where the arguments depend on track_reuse_ . The return value is ignored.
|
|
inline |
|
inline |