Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Typedefs | Functions
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. More...
 
template<typename I >
H5::CompType buildType (const std::vector< SharedConsumer< I > > &consumers)
 Adapter to translate configuration info into the objects needed by the writer. More...
 
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 ()
 

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  }

◆ 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  }

◆ 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  }

◆ 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) {
26  case Compression::STANDARD: return H5Traits<T>::type;
27  case Compression::HALF_PRECISION: return halfPrecisionFloat();
28  case Compression::HALF_PRECISION_LARGE: return halfPrecisionFloat(5);
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  }

◆ 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  }

◆ 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  return ar;
335  }

◆ 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  }
plotting.yearwise_luminosity_vs_mu.comp
comp
Definition: yearwise_luminosity_vs_mu.py:23
H5Utils::SharedConsumer
std::shared_ptr< internal::IDataConsumer< I > > SharedConsumer
Consumer Class.
Definition: Writer.h:126
jet::ExtendedBool::TRUE
@ TRUE
Definition: UncertaintyEnum.h:234
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
athena.value
value
Definition: athena.py:124
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
H5Utils::internal::halfPrecisionFloat
H5::DataType halfPrecisionFloat(int ebias=15)
Definition: CompressedTypes.cxx:14
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
EL::Detail::ManagerStep::initial
@ initial
this is just the initial step we do, nothing really happens here
hist_file_dump.f
f
Definition: hist_file_dump.py:141
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
a
TList * a
Definition: liststreamerinfos.cxx:10
ref
const boost::regex ref(r_ef)
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
jet::ExtendedBool::FALSE
@ FALSE
Definition: UncertaintyEnum.h:233
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7