yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.1.0
YODA::H5DataSetWriter< T > Class Template Reference

A helper class to deal with chunking of H5 datasets. More...

#include <H5Utils.h>

Public Member Functions

 H5DataSetWriter (YODA_H5::File &h5file, const string &label, size_t datalen, size_t chunksize, bool compress)
 
void writeSlice (vector< T > &&data) noexcept
 Method to write a slice that may span multiple rows/columns.
 
template<typename U >
void createAttribute (const string &label, vector< U > &&data) noexcept
 Method to decorate dataset with an attribute.
 
size_t colPos () const noexcept
 
size_t rowPos () const noexcept
 

Detailed Description

template<typename T>
class YODA::H5DataSetWriter< T >

A helper class to deal with chunking of H5 datasets.

Definition at line 158 of file H5Utils.h.

Constructor & Destructor Documentation

◆ H5DataSetWriter()

template<typename T >
YODA::H5DataSetWriter< T >::H5DataSetWriter ( YODA_H5::File &  h5file,
const string &  label,
size_t  datalen,
size_t  chunksize,
bool  compress 
)
inline

Definition at line 162 of file H5Utils.h.

164 : _ncols(chunksize), _thiscol(0), _nrows(1+(datalen-1)/chunksize), _thisrow(0),
165 _ds(H5DataSet<T>(h5file, label, _nrows, chunksize, compress)) { }

Member Function Documentation

◆ colPos()

template<typename T >
size_t YODA::H5DataSetWriter< T >::colPos ( ) const
inlinenoexcept

Definition at line 197 of file H5Utils.h.

197{ return _thiscol; }

◆ createAttribute()

template<typename T >
template<typename U >
void YODA::H5DataSetWriter< T >::createAttribute ( const string &  label,
vector< U > &&  data 
)
inlinenoexcept

Method to decorate dataset with an attribute.

Definition at line 193 of file H5Utils.h.

193 {
194 _ds.createAttribute(label, std::forward<vector<U>>(data));
195 }

◆ rowPos()

template<typename T >
size_t YODA::H5DataSetWriter< T >::rowPos ( ) const
inlinenoexcept

Definition at line 199 of file H5Utils.h.

199{ return _thisrow; }

◆ writeSlice()

template<typename T >
void YODA::H5DataSetWriter< T >::writeSlice ( vector< T > &&  data)
inlinenoexcept

Method to write a slice that may span multiple rows/columns.

Definition at line 168 of file H5Utils.h.

168 {
169
170 if (data.empty()) return;
171
172 size_t offset = 0, len = data.size();
173 const auto itr = data.cbegin();
174 while (len) {
175 vector<T> tmp;
176 size_t ncols = std::min(len, _ncols - _thiscol);
177 auto first = itr + offset;
178 auto last = first + ncols;
179 _ds.select({_thisrow,_thiscol},
180 {1,ncols}).write(vector<vector<T>>{{std::make_move_iterator(first),
181 std::make_move_iterator(last)}});
182 offset += ncols;
183 _thiscol += ncols;
184 if (_thiscol == _ncols) {
185 _thiscol = 0; ++_thisrow;
186 }
187 len -= ncols;
188 }
189 }
void write(const std::string &filename, const AnalysisObject &ao, int precision=-1)
Write out object ao to file filename.
Definition IO.h:19

References YODA::write().

Referenced by YODA::WriterH5::writeAOS().


The documentation for this class was generated from the following file: