Iterate through an high-dimensional dataspace by chunk.
More...
#include <IterateChunks.hpp>
Iterate through an high-dimensional dataspace by chunk.
This class iterates through an N-dimensional dataspace in a chunk-by-chunk manner. It optimizes access to the HDF5 file given that the HDF5 library will always read/write an entire chunk. It is typically used to stream a chunked HDF5 dataset into memory, where we can reduce memory usage by reading only one chunk at a time.
◆ IterateChunks()
| ritsuko::hdf5::IterateChunks::IterateChunks |
( |
std::vector< hsize_t > | data_dimensions, |
|
|
std::vector< hsize_t > | chunk_dimensions ) |
|
inline |
- Parameters
-
| data_dimensions | Dataset dimension extents. |
| chunk_dimensions | Chunk dimensions. Each entry may be less than, equal to, or greater than the corresponding entry of data_dimensions; the only requirement is that, if data_dimensions[i] is positive, so is chunk_dimensions[i]. |
◆ advance()
| bool ritsuko::hdf5::IterateChunks::advance |
( |
| ) |
|
|
inline |
Advance to the next chunk. On return, this is now the "current" chunk.
- Returns
- Whether the advance was successful. If false, the iteration has finished.
◆ chunk_dimensions()
| const std::vector< hsize_t > & ritsuko::hdf5::IterateChunks::chunk_dimensions |
( |
| ) |
const |
|
inline |
- Returns
- Dimensions of the chunks. Each entry will be no greater than the corresponding entry of the
chunk_dimensions in the constructor. Each entry will be no smaller than the corresponding entry of counts() at any time.
◆ counts()
| const std::vector< hsize_t > & ritsuko::hdf5::IterateChunks::counts |
( |
| ) |
const |
|
inline |
This should only be called after a call to advance() returns true.
- Returns
- Dimensions of the current chunk. This is usually equal to the chunk dimensions used in the constructor, except at the edges of the dataset where the current chunk may be truncated.
◆ data_dimensions()
| const std::vector< hsize_t > & ritsuko::hdf5::IterateChunks::data_dimensions |
( |
| ) |
const |
|
inline |
- Returns
- Dimensions of the dataset, as provided in the constructor.
◆ starts()
| const std::vector< hsize_t > & ritsuko::hdf5::IterateChunks::starts |
( |
| ) |
const |
|
inline |
This should only be called after a call to advance() returns true.
- Returns
- Starting coordinates of the current chunk.
The documentation for this struct was generated from the following file: