ATLAS Offline Software
Loading...
Searching...
No Matches
H5Utils::internal Namespace Reference

clssses to add type traits for H5 More...

Classes

struct  CheckType
struct  CheckType< 0, T, I, decltype(*begin(std::declval< T & >()), void())>
struct  CheckType< N, T, I, decltype(*begin(std::declval< T & >()), void())>
union  data_buffer_t
 data_buffer_t More...
class  DataConsumer
 implementation for variable filler More...
struct  DataFlattener
 Data flattener class: this is used by the writer to read in the elements one by one and put them in an internal buffer. More...
struct  DataFlattener< 0, F, T, M >
struct  DSParameters
 Constant parameters for the writer. More...
struct  H5Traits
 We have lots of code to get around HDF5's rather weak typing. More...
struct  H5Traits< bool >
struct  H5Traits< char >
struct  H5Traits< double >
struct  H5Traits< float >
struct  H5Traits< int >
struct  H5Traits< long >
struct  H5Traits< long long >
struct  H5Traits< short >
struct  H5Traits< unsigned char >
struct  H5Traits< unsigned int >
struct  H5Traits< unsigned long >
struct  H5Traits< unsigned long long >
struct  H5Traits< unsigned short >
class  IDataConsumer
 DataConsumer classes. More...
class  IVariableFiller
 Variable fillers. More...
class  VariableFiller
 implementation for variable filler More...

Typedefs

typedef H5::PredType PT

Functions

H5::CompType packed (H5::CompType in)
H5::DataSpace getUnlimitedSpace (const std::vector< hsize_t > &max_length)
template<size_t N>
H5::DSetCreatPropList getChunckedDatasetParams (const WriterConfiguration< N > &)
std::vector< hsize_t > getStriding (std::vector< hsize_t > max_length)
void throwIfExists (const std::string &name, const H5::Group &in_group)
void printDestructorError (const std::string &msg)
H5::DataType halfPrecisionFloat (int ebias=15)
template<typename T>
H5::DataType getCompressedType (Compression comp)
template<typename T>
data_buffer_t get_buffer_from_func (const std::function< T()> &func)
 Buffer element harvester.
template<typename I>
H5::CompType buildType (const std::vector< SharedConsumer< I > > &consumers)
 Adapter to translate configuration info into the objects needed by the writer.
template<typename I>
H5::CompType buildWriteType (const std::vector< SharedConsumer< I > > &con)
template<typename I>
std::vector< data_buffer_tbuildDefault (const std::vector< SharedConsumer< I > > &f)
template<size_t N>
std::vector< hsize_t > vec (std::array< hsize_t, N > a)
template<hsize_t N>
std::array< hsize_t, N > uniform (size_t val)
H5::DataType get_bool_type ()

Variables

const H5::DataType H5Traits< int >::type = PT::NATIVE_INT
const H5::DataType H5Traits< long >::type = PT::NATIVE_LONG
const H5::DataType H5Traits< longlong >::type = PT::NATIVE_LLONG
const H5::DataType H5Traits< unsignedlong >::type = PT::NATIVE_ULONG
const H5::DataType H5Traits< unsignedlonglong >::type = PT::NATIVE_ULLONG
const H5::DataType H5Traits< unsignedint >::type = PT::NATIVE_UINT
const H5::DataType H5Traits< unsignedchar >::type = PT::NATIVE_UCHAR
const H5::DataType H5Traits< char >::type = PT::NATIVE_CHAR
const H5::DataType H5Traits< float >::type = PT::NATIVE_FLOAT
const H5::DataType H5Traits< double >::type = PT::NATIVE_DOUBLE
const H5::DataType H5Traits< bool >::type = get_bool_type()
const H5::DataType H5Traits< short >::type = PT::NATIVE_SHORT
const H5::DataType H5Traits< unsignedshort >::type = PT::NATIVE_USHORT

Detailed Description

clssses to add type traits for H5

internal code for the Writer class

internal classes and code

Internal clssses and code.

Typedef Documentation

◆ PT

typedef H5::PredType H5Utils::internal::PT

Definition at line 15 of file H5Traits.cxx.

Function Documentation

◆ buildDefault()

template<typename I>
std::vector< data_buffer_t > H5Utils::internal::buildDefault ( const std::vector< SharedConsumer< I > > & f)

Definition at line 315 of file Writer.h.

315 {
316 std::vector<data_buffer_t> def;
317 for (const SharedConsumer<I>& filler: f) {
318 def.push_back(filler->getDefault());
319 }
320 return def;
321 }
std::shared_ptr< internal::IDataConsumer< I > > SharedConsumer
Consumer Class.
Definition Writer.h:126

◆ buildType()

template<typename I>
H5::CompType H5Utils::internal::buildType ( const std::vector< SharedConsumer< I > > & consumers)

Adapter to translate configuration info into the objects needed by the writer.

Definition at line 264 of file Writer.h.

264 {
265 if (consumers.size() < 1) {
266 throw std::logic_error(
267 "you must specify at least one consumer when initializing the HDF5"
268 "writer");
269 }
270
271 H5::CompType type(consumers.size() * sizeof(data_buffer_t));
272 size_t dt_offset = 0;
273 for (const SharedConsumer<I>& filler: consumers) {
274 type.insertMember(filler->name(), dt_offset, filler->getType());
275 dt_offset += sizeof(data_buffer_t);
276 }
277 return type;
278 }
const H5::DataType H5Traits< int >::type
Definition H5Traits.cxx:16

◆ buildWriteType()

template<typename I>
H5::CompType H5Utils::internal::buildWriteType ( const std::vector< SharedConsumer< I > > & con)

Definition at line 280 of file Writer.h.

280 {
281 H5::CompType type(con.size() * sizeof(data_buffer_t));
282 size_t dt_offset = 0;
283 for (const SharedConsumer<I>& filler: con) {
284 type.insertMember(filler->name(), dt_offset, filler->getWriteType());
285 dt_offset += sizeof(data_buffer_t);
286 }
287 type.pack();
288 return type;
289 }

◆ get_bool_type()

H5::DataType H5Utils::internal::get_bool_type ( )

Definition at line 31 of file H5Traits.cxx.

31 {
32 bool TRUE = true;
33 bool FALSE = false;
34 H5::EnumType btype(sizeof(bool));
35 btype.insert("TRUE", &TRUE);
36 btype.insert("FALSE", &FALSE);
37 return btype;
38 }

◆ get_buffer_from_func()

template<typename T>
data_buffer_t H5Utils::internal::get_buffer_from_func ( const std::function< T()> & func)

Buffer element harvester.

This is used to buld the unions we use to build the hdf5 memory buffer. Together with the get_type templates it gives us a strongly typed HDF5 writer.

Definition at line 42 of file HdfTuple.h.

42 {
43 data_buffer_t buffer;
44 H5Traits<T>::ref(buffer) = func();
45 return buffer;
46 }
We have lots of code to get around HDF5's rather weak typing.
Definition H5Traits.h:54

◆ getChunckedDatasetParams()

template<size_t N>
H5::DSetCreatPropList H5Utils::internal::getChunckedDatasetParams ( const WriterConfiguration< N > & )

◆ getCompressedType()

template<typename T>
H5::DataType H5Utils::internal::getCompressedType ( Compression comp)

Definition at line 23 of file CompressedTypes.h.

23 {
24 if constexpr (std::is_floating_point<T>::value) {
25 switch (comp) {
29 default: throw std::logic_error("unknown float compression");
30 }
31 }
32 if (comp != Compression::STANDARD) {
33 throw std::logic_error("compression not supported for this type");
34 }
35 return H5Traits<T>::type;
36 }
H5::DataType halfPrecisionFloat(int ebias=15)

◆ getStriding()

std::vector< hsize_t > H5Utils::internal::getStriding ( std::vector< hsize_t > max_length)

Definition at line 38 of file common.cxx.

38 {
39 // calculate striding
40 extent.push_back(1);
41 for (size_t iii = extent.size(); iii - 1 != 0; iii--) {
42 extent.at(iii-2) = extent.at(iii-2) * extent.at(iii-1);
43 }
44 return extent;
45 }

◆ getUnlimitedSpace()

H5::DataSpace H5Utils::internal::getUnlimitedSpace ( const std::vector< hsize_t > & max_length)

Definition at line 31 of file common.cxx.

31 {
32 std::vector<hsize_t> initial{0};
33 initial.insert(initial.end(), extent.begin(), extent.end());
34 std::vector<hsize_t> eventual{H5S_UNLIMITED};
35 eventual.insert(eventual.end(), extent.begin(), extent.end());
36 return H5::DataSpace(eventual.size(), initial.data(), eventual.data());
37 }

◆ halfPrecisionFloat()

H5::DataType H5Utils::internal::halfPrecisionFloat ( int ebias = 15)

Definition at line 14 of file CompressedTypes.cxx.

14 {
15 // start with native float
16 H5::FloatType type(H5Tcopy(H5::PredType::NATIVE_FLOAT.getId()));
17
18 // These definitions are copied from h5py, see:
19 //
20 // https://github.com/h5py/h5py/blob/596748d52c351258c851bb56c8df1c25d3673110/h5py/h5t.pyx#L212-L217
21 //
22 type.setFields(15, 10, 5, 0, 10);
23 type.setSize(2);
24 type.setEbias(ebias);
25 return type;
26 }

◆ packed()

H5::CompType H5Utils::internal::packed ( H5::CompType in)

Definition at line 16 of file common.cxx.

16 {
17 // TODO: Figure out why a normal copy constructor doesn't work here.
18 // The normal one seems to create shallow copies.
19 H5::CompType out(H5Tcopy(in.getId()));
20 out.pack();
21 return out;
22 }

◆ printDestructorError()

void H5Utils::internal::printDestructorError ( const std::string & msg)

Definition at line 24 of file common.cxx.

24 {
25 std::cerr << "ERROR: an exception was thrown in the destructor of an "
26 "HDF5 file, the output buffer may be corrupted";
27 std::cerr << " (error message: " << msg << ")" << std::endl;
28 }
MsgStream & msg
Definition testRead.cxx:32

◆ throwIfExists()

void H5Utils::internal::throwIfExists ( const std::string & name,
const H5::Group & in_group )

Definition at line 46 of file common.cxx.

46 {
47 if (H5Lexists(in_group.getLocId(), name.c_str(), H5P_DEFAULT)) {
48 throw std::logic_error("tried to overwrite '" + name + "'");
49 }
50 }

◆ uniform()

template<hsize_t N>
std::array< hsize_t, N > H5Utils::internal::uniform ( size_t val)

Definition at line 331 of file Writer.h.

331 {
332 std::array<hsize_t, N> ar;
333 ar.fill(val);
334 //coverity[UNINIT:FALSE]
335 return ar;
336 }

◆ vec()

template<size_t N>
std::vector< hsize_t > H5Utils::internal::vec ( std::array< hsize_t, N > a)

Definition at line 325 of file Writer.h.

325 {
326 return std::vector<hsize_t>(a.begin(),a.end());
327 }
static Double_t a

Variable Documentation

◆ H5Traits< bool >::type

const H5::DataType H5Utils::internal::H5Traits< bool >::type = get_bool_type()

Definition at line 26 of file H5Traits.cxx.

◆ H5Traits< char >::type

const H5::DataType H5Utils::internal::H5Traits< char >::type = PT::NATIVE_CHAR

Definition at line 23 of file H5Traits.cxx.

◆ H5Traits< double >::type

const H5::DataType H5Utils::internal::H5Traits< double >::type = PT::NATIVE_DOUBLE

Definition at line 25 of file H5Traits.cxx.

◆ H5Traits< float >::type

const H5::DataType H5Utils::internal::H5Traits< float >::type = PT::NATIVE_FLOAT

Definition at line 24 of file H5Traits.cxx.

◆ H5Traits< int >::type

const H5::DataType H5Utils::internal::H5Traits< int >::type = PT::NATIVE_INT

Definition at line 16 of file H5Traits.cxx.

◆ H5Traits< long >::type

const H5::DataType H5Utils::internal::H5Traits< long >::type = PT::NATIVE_LONG

Definition at line 17 of file H5Traits.cxx.

◆ H5Traits< longlong >::type

const H5::DataType H5Utils::internal::H5Traits< longlong >::type = PT::NATIVE_LLONG

Definition at line 18 of file H5Traits.cxx.

◆ H5Traits< short >::type

const H5::DataType H5Utils::internal::H5Traits< short >::type = PT::NATIVE_SHORT

Definition at line 27 of file H5Traits.cxx.

◆ H5Traits< unsignedchar >::type

const H5::DataType H5Utils::internal::H5Traits< unsignedchar >::type = PT::NATIVE_UCHAR

Definition at line 22 of file H5Traits.cxx.

◆ H5Traits< unsignedint >::type

const H5::DataType H5Utils::internal::H5Traits< unsignedint >::type = PT::NATIVE_UINT

Definition at line 21 of file H5Traits.cxx.

◆ H5Traits< unsignedlong >::type

const H5::DataType H5Utils::internal::H5Traits< unsignedlong >::type = PT::NATIVE_ULONG

Definition at line 19 of file H5Traits.cxx.

◆ H5Traits< unsignedlonglong >::type

const H5::DataType H5Utils::internal::H5Traits< unsignedlonglong >::type = PT::NATIVE_ULLONG

Definition at line 20 of file H5Traits.cxx.

◆ H5Traits< unsignedshort >::type

const H5::DataType H5Utils::internal::H5Traits< unsignedshort >::type = PT::NATIVE_USHORT

Definition at line 28 of file H5Traits.cxx.