1#ifndef FIRE_IO_H5_READER_H
2#define FIRE_IO_H5_READER_H
5#include <highfive/H5File.hpp>
7#include "fire/io/Reader.h"
10namespace fire::io::h5 {
160 virtual bool canCopy() const final
override {
return true; }
175 Writer& output)
final override;
194 template <
typename AtomicType>
197 is_atomic_v<AtomicType>,
198 "Type not supported by HighFive atomic made its way to Reader::load");
262 template <
typename AtomicType>
332 virtual void load() final
override {
338 assert(request_len >= 0);
341 if constexpr (std::is_same_v<AtomicType,bool>) {
349 this->
set_.select({i_file_}, {request_len})
352 for (
const auto& v : buff)
buffer_.push_back(v == Bool::TRUE);
394 void copy(
unsigned long int i_entry,
unsigned long int n,
Writer& output);
Empty data base allowing recursion.
Definition: AbstractData.h:30
Prototype for reading files within fire.
Definition: Reader.h:29
Write the fire DataSets into a deterministic structure in the output HDF5 data file.
Definition: Writer.h:19
Type-less handle to the Buffer.
Definition: Reader.h:230
HighFive::DataSet set_
the HDF5 dataset we are reading from
Definition: Reader.h:235
virtual ~BufferHandle()=default
virtual destructor to pass on to derived types
BufferHandle(std::size_t max, HighFive::DataSet s)
Define the size of the in-memory buffer and the set we are reading from.
Definition: Reader.h:243
std::size_t max_len_
the maximum length of the buffer
Definition: Reader.h:233
virtual void load()=0
pure virtual load function to be defined when we know the type
Read buffer allowing individual element access from a dataset.
Definition: Reader.h:263
void read(AtomicType &out)
Read the next entry from the dataset into the input variable.
Definition: Reader.h:303
std::vector< AtomicType > buffer_
the actual buffer of in-memory elements
Definition: Reader.h:265
virtual void load() final override
Load the next chunk of data into memory.
Definition: Reader.h:332
virtual ~Buffer()=default
nothing fancy, just clearing in-memory objects
std::size_t i_file_
the current index of data-set elements in the file
Definition: Reader.h:267
std::size_t i_memory_
the current index of data-set elements in-memory
Definition: Reader.h:269
Buffer(std::size_t max, HighFive::DataSet s)
Define the size of the buffer and provide the dataset to read from.
Definition: Reader.h:284
std::size_t entries_
the number of entries in the entire dataset
Definition: Reader.h:271
A mirror event object.
Definition: Reader.h:373
std::unique_ptr< BaseData > data_
handle to the atomic data type once we get down to that point
Definition: Reader.h:377
MirrorObject(const std::string &path, Reader &reader)
Construct this mirror object and any of its (data or object) children.
Definition: Reader.cxx:108
unsigned long int last_entry_
the last entry that was copied
Definition: Reader.h:383
Reader & reader_
handle to the reader we are reading from
Definition: Reader.h:375
std::vector< std::unique_ptr< MirrorObject > > obj_members_
list of sub-objects within this object
Definition: Reader.h:381
void copy(unsigned long int i_entry, unsigned long int n, Writer &output)
Copy the n entries starting from i_entry.
Definition: Reader.cxx:155
std::unique_ptr< BaseData > size_member_
handle to the size member of this object (if it exists)
Definition: Reader.h:379
Reading a file generated by fire.
Definition: Reader.h:22
void operator=(const Reader &)=delete
never want to copy a reader
HighFive::DataType getDataSetType(const std::string &dataset) const
Deduce the type of the dataset requested.
Definition: Reader.cxx:32
virtual std::vector< std::pair< std::string, std::string > > availableObjects() final override
Get the event objects available in the file.
Definition: Reader.cxx:41
std::size_t entries() const final override
Get the number of entries in the file.
Definition: Reader.h:145
std::unordered_map< std::string, std::unique_ptr< MirrorObject > > mirror_objects_
our in-memory mirror objects for data being copied to the output file without processing
Definition: Reader.h:409
std::unordered_map< std::string, std::unique_ptr< BufferHandle > > buffers_
our in-memory buffers for the data to be read in from disk
Definition: Reader.h:407
std::string getTypeName(const std::string &obj_name) const
Get the 'type' attribute from the input group name.
virtual void load_into(BaseData &d) final override
Load the next event into the passed data.
Definition: Reader.cxx:20
const std::size_t entries_
the number of entries in this file, set in constructor
Definition: Reader.h:401
void load(const std::string &path, AtomicType &val)
Try to load a single value of an atomic type into the input handle.
Definition: Reader.h:195
std::size_t rows_per_chunk_
the number of rows to keep in each chunk, read from DataSet?
Definition: Reader.h:405
virtual std::string name() const final override
Get the name of this file.
Definition: Reader.cxx:24
const std::size_t runs_
the number of runs in this file, set in constructor
Definition: Reader.h:403
virtual void copy(unsigned long int i_entry, const std::string &path, Writer &output) final override
Copy the input data set to the output file.
std::size_t runs() const final override
Get the number of runs in the file.
Definition: Reader.h:154
HighFive::File file_
our highfive file
Definition: Reader.h:399
Reader(const std::string &name)
Open the file in read mode.
Definition: Reader.cxx:8
std::vector< std::string > list(const std::string &group_path) const
List the entries inside of a group.
Definition: Reader.cxx:26
HighFive::ObjectType getH5ObjectType(const std::string &path) const
Get the H5 type of object at the input path.
Definition: Reader.cxx:37
virtual std::pair< std::string, int > type(const std::string &path) final override
Get the type of the input object.
Definition: Reader.cxx:56
void mirror(const std::string &path, Writer &output)
Mirror the structure of the passed path from us into the output file.
Definition: Reader.cxx:74
Reader(const Reader &)=delete
never want to copy a reader
virtual bool canCopy() const final override
We can copy.
Definition: Reader.h:160
HighFive::EnumType< Bool > create_enum_bool()
HighFive method for creating the enum data type.
Definition: Atomic.cxx:5