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::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::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 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 316 of file Writer.h.

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

◆ 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 265 of file Writer.h.

265 {
266 if (consumers.size() < 1) {
267 throw std::logic_error(
268 "you must specify at least one consumer when initializing the HDF5"
269 "writer");
270 }
271
272 H5::CompType type(consumers.size() * sizeof(data_buffer_t));
273 size_t dt_offset = 0;
274 for (const SharedConsumer<I>& filler: consumers) {
275 type.insertMember(filler->name(), dt_offset, filler->getType());
276 dt_offset += sizeof(data_buffer_t);
277 }
278 return type;
279 }
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 281 of file Writer.h.

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

◆ 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 WriterCommon.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 WriterCommon.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 WriterCommon.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 WriterCommon.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 WriterCommon.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 332 of file Writer.h.

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

◆ vec()

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

Definition at line 326 of file Writer.h.

326 {
327 return std::vector<hsize_t>(a.begin(),a.end());
328 }
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.