fire v0.19.0
Framework for sImulation and Reconstruction of Events
|
Read buffer allowing individual element access from a dataset. More...
Public Member Functions | |
Buffer (std::size_t max, HighFive::DataSet s) | |
Define the size of the buffer and provide the dataset to read from. More... | |
virtual | ~Buffer ()=default |
nothing fancy, just clearing in-memory objects | |
void | read (AtomicType &out) |
Read the next entry from the dataset into the input variable. More... | |
virtual void | load () final override |
Load the next chunk of data into memory. More... | |
Public Member Functions inherited from fire::io::h5::Reader::BufferHandle | |
BufferHandle (std::size_t max, HighFive::DataSet s) | |
Define the size of the in-memory buffer and the set we are reading from. More... | |
virtual | ~BufferHandle ()=default |
virtual destructor to pass on to derived types | |
Private Attributes | |
std::vector< AtomicType > | buffer_ |
the actual buffer of in-memory elements | |
std::size_t | i_file_ |
the current index of data-set elements in the file | |
std::size_t | i_memory_ |
the current index of data-set elements in-memory | |
std::size_t | entries_ |
the number of entries in the entire dataset | |
Additional Inherited Members | |
Protected Attributes inherited from fire::io::h5::Reader::BufferHandle | |
std::size_t | max_len_ |
the maximum length of the buffer | |
HighFive::DataSet | set_ |
the HDF5 dataset we are reading from | |
Read buffer allowing individual element access from a dataset.
AtomicType | type of elements in dataset |
|
inlineexplicit |
Define the size of the buffer and provide the dataset to read from.
We initialize ourselves with the indices set to 0, the entries read from the size of the dataset passed, and the buffer empty. Then we call our own Buffer::load method to get the first chunk of data into memory.
[in] | max | size of the buffer |
[in] | s | dataset to read from |
|
inlinefinaloverridevirtual |
Load the next chunk of data into memory.
We determine the size of the next chunk from our own maximum and the number of entries in the data set. We shrink the size of the next chunk depending on how many entries are left if we can't grab a whole maximum sized chunk.
We have a compile-time split in order to patch a bug in HighFive that doesn't allow writing of std::vector<bool> due to the specialization of it and to translate our custom enum fire::io::Bool into bools.
After reading the next chunk into memory, we update our indicies by resetting the in-memory index to 0 and moving the file index by the size of the buffer.
compile-time split for bools which
Implements fire::io::h5::Reader::BufferHandle.
|
inline |
Read the next entry from the dataset into the input variable.
If we have reached the end of the in-memory buffer, then we call Buffer::load to retrieve the next chunk of data into memory.
[out] | out | variable to read entry into |