fire v0.19.0
Framework for sImulation and Reconstruction of Events
|
Write the fire DataSets into a deterministic structure in the output HDF5 data file. More...
#include <Writer.h>
Classes | |
class | Buffer |
Buffer atomic data types in-memory for efficient disk operations. More... | |
class | BufferHandle |
Type-less handle to buffers. More... | |
Public Member Functions | |
Writer (const int &event_limit, const config::Parameters &ps) | |
Open the file in write mode. More... | |
~Writer () | |
Close up our file, making sure to flush contents to disk. | |
void | flush () |
Flush the data to disk. More... | |
const std::string & | name () const |
Get the name of this file. | |
void | structure (const std::string &path, const std::pair< std::string, int > &type) |
Persist the structure of the event object at the input path. More... | |
std::size_t | entries () const |
Get the number of entries in the file. | |
template<typename AtomicType > | |
void | save (const std::string &path, const AtomicType &val) |
Save an atomic type into the dataset at the passed path. More... | |
Writer (const Writer &)=delete | |
don't allow copies of the Writer | |
void | operator= (const Writer &)=delete |
don't allow copies of the Writer | |
Private Attributes | |
std::unique_ptr< HighFive::File > | file_ |
our highfive file More... | |
HighFive::DataSetCreateProps | create_props_ |
the creation properties to be used on datasets we are writing | |
HighFive::DataSpace | space_ |
the dataspace shared amongst all of our datasets | |
std::size_t | entries_ |
the expected number of entries in this file | |
std::size_t | rows_per_chunk_ |
number of rows to keep in each chunk | |
std::unordered_map< std::string, std::unique_ptr< BufferHandle > > | buffers_ |
our in-memory buffers for data to be written to disk | |
Friends | |
std::ostream & | operator<< (std::ostream &s, const Writer &w) |
Stream this writer. More... | |
Write the fire DataSets into a deterministic structure in the output HDF5 data file.
fire::io::Writer::Writer | ( | const int & | event_limit, |
const config::Parameters & | ps | ||
) |
Open the file in write mode.
Our write mode is the HDF5 TRUNC (overwrite) mode.
[in] | event_limit | Maximum number of events that could end up here |
[in] | ps | Parameters used to configure the writing of the output file |
void fire::io::Writer::flush | ( | ) |
Flush the data to disk.
We flush all buffers and then flush the file.
|
inline |
Save an atomic type into the dataset at the passed path.
If the path does not have a Buffer created for it yet, we create a new one. Creating this new buffer is when HDF5 creates the DataSet in the file and so it may throw an exception at this time if it is unable to create the DataSet for some reason.
If the path already has a Buffer, we simply pass the new value to be saved into the Buffer.
std::bad_cast | if mismatched type is passed to buffer |
HighFive::DataSetException | if unable to create data set |
void fire::io::Writer::structure | ( | const std::string & | path, |
const std::pair< std::string, int > & | type | ||
) |
Persist the structure of the event object at the input path.
The "structure" is simply the type and the type's version at the correct location within the EVENT_GROUP.
[in] | path | full path to the group |
[in] | {type,version} | pair demangled type name of object and its version number |
[in] | version | version number of type |
|
friend |
Stream this writer.
We stream 'Writer' and the name of the file we are writing to
[in] | s | ostream to stream into |
[in] | w | writer to stream |
|
private |
our highfive file
we need it to be a smart pointer because we want to do some parameter validation before creating the file in the constructor