CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cms::h5::DataSet Class Reference

#include <h5_DataSet.h>

Public Member Functions

 DataSet (hid_t iParentID, std::string const &iName)
 
 DataSet (hid_t iParentID, const void *iRef)
 
 DataSet (const DataSet &)=delete
 
 DataSet (DataSet &&)=delete
 
uint64_t fileOffset () const
 
std::shared_ptr< AttributefindAttribute (std::string const &iName) const
 
uint32_t layout () const
 
std::size_t memorySize () const
 
DataSetoperator= (const DataSet &)=delete
 
DataSetoperator= (DataSet &&)=delete
 
std::vector< char > readBytes () const
 
std::vector< hobj_ref_t > readRefs () const
 
std::vector< cond::hdf5::IOVSyncValuereadSyncValues () const
 
std::size_t storageSize () const
 
 ~DataSet ()
 

Private Member Functions

std::size_t size () const
 

Private Attributes

hid_t id_
 

Detailed Description

Definition at line 38 of file h5_DataSet.h.

Constructor & Destructor Documentation

◆ DataSet() [1/4]

DataSet::DataSet ( hid_t  iParentID,
std::string const &  iName 
)

Definition at line 48 of file h5_DataSet.cc.

References Exception, and id_.

48  : id_(H5Dopen2(iParentID, iName.c_str(), H5P_DEFAULT)) {
49  if (id_ < 0) {
50  throw cms::Exception("UnknownH5DataSet") << "unable to find dataset " << iName;
51  }
52  }

◆ DataSet() [2/4]

DataSet::DataSet ( hid_t  iParentID,
const void *  iRef 
)

Definition at line 54 of file h5_DataSet.cc.

References Exception, and id_.

54  : id_(H5Rdereference2(iParentID, H5P_DEFAULT, H5R_OBJECT, iRef)) {
55  if (id_ < 0) {
56  throw cms::Exception("BadH5DataSetRef") << "unable to derenfence dataset from parent " << iParentID;
57  }
58  }

◆ ~DataSet()

DataSet::~DataSet ( )

Definition at line 65 of file h5_DataSet.cc.

References id_.

65 { H5Dclose(id_); }

◆ DataSet() [3/4]

cms::h5::DataSet::DataSet ( const DataSet )
delete

◆ DataSet() [4/4]

cms::h5::DataSet::DataSet ( DataSet &&  )
delete

Member Function Documentation

◆ fileOffset()

uint64_t DataSet::fileOffset ( ) const

Definition at line 101 of file h5_DataSet.cc.

References id_.

101 { return H5Dget_offset(id_); }

◆ findAttribute()

std::shared_ptr< Attribute > DataSet::findAttribute ( std::string const &  iName) const

Definition at line 86 of file h5_DataSet.cc.

References id_.

86  {
87  return std::make_shared<Attribute>(id_, iName);
88  }

◆ layout()

uint32_t DataSet::layout ( ) const

Definition at line 103 of file h5_DataSet.cc.

References id_, and runTheMatrix::ret.

103  {
104  auto pl = H5Dget_create_plist(id_);
105  auto ret = H5Pget_layout(pl);
106  H5Pclose(pl);
107  return ret;
108  }
ret
prodAgent to be discontinued

◆ memorySize()

std::size_t DataSet::memorySize ( ) const

Definition at line 100 of file h5_DataSet.cc.

References size().

100 { return size(); }
std::size_t size() const
Definition: h5_DataSet.cc:90

◆ operator=() [1/2]

DataSet& cms::h5::DataSet::operator= ( const DataSet )
delete

◆ operator=() [2/2]

DataSet& cms::h5::DataSet::operator= ( DataSet &&  )
delete

◆ readBytes()

std::vector< char > DataSet::readBytes ( ) const

Definition at line 127 of file h5_DataSet.cc.

References Exception, id_, and size().

127  {
128  Type type_id{H5Dget_type(id_)};
129  auto class_type = H5Tget_class(type_id.id_);
130  if (class_type != H5T_INTEGER) {
131  throw cms::Exception("BadDataSetType") << "asked to read dataset as a byte, but it is a " << class_type;
132  }
133 
134  std::vector<char> bytes;
135  bytes.resize(size());
136 
137  auto ret_value = H5Dread(id_, H5T_STD_I8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, bytes.data());
138  if (ret_value < 0) {
139  throw cms::Exception("BadH5Read") << "unable to read bytes dataset " << id_;
140  }
141  return bytes;
142  }
std::size_t size() const
Definition: h5_DataSet.cc:90

◆ readRefs()

std::vector< hobj_ref_t > DataSet::readRefs ( ) const

Definition at line 110 of file h5_DataSet.cc.

References Exception, id_, and size().

110  {
111  Type type_id{H5Dget_type(id_)};
112  auto class_type = H5Tget_class(type_id.id_);
113  if (class_type != H5T_REFERENCE) {
114  throw cms::Exception("BadDataSetType") << "asked to read dataset as a ref, but it is a " << class_type;
115  }
116 
117  std::vector<hobj_ref_t> refs;
118  refs.resize(size());
119 
120  auto ret_value = H5Dread(id_, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, refs.data());
121  if (ret_value < 0) {
122  throw cms::Exception("BadH5Read") << "unable to read ref dataset " << id_;
123  }
124  return refs;
125  }
std::size_t size() const
Definition: h5_DataSet.cc:90

◆ readSyncValues()

std::vector< cond::hdf5::IOVSyncValue > DataSet::readSyncValues ( ) const

Definition at line 144 of file h5_DataSet.cc.

References Exception, id_, and size().

144  {
145  Type sv_type_id{H5Tcreate(H5T_COMPOUND, sizeof(cond::hdf5::IOVSyncValue))};
146  sv_type_id.insertMember("high", HOFFSET(cond::hdf5::IOVSyncValue, high_), H5T_NATIVE_UINT32);
147  sv_type_id.insertMember("low", HOFFSET(cond::hdf5::IOVSyncValue, low_), H5T_NATIVE_UINT32);
148 
149  {
150  const Type type_id{H5Dget_type(id_)};
151  if (not H5Tequal(sv_type_id.id_, type_id.id_)) {
152  throw cms::Exception("BadDataSetType")
153  << "asked to read dataset as a IOVSyncValue, but it is a " << type_id.id_;
154  }
155  }
156 
157  std::vector<cond::hdf5::IOVSyncValue> syncValues;
158  syncValues.resize(size());
159 
160  auto ret_value = H5Dread(id_, sv_type_id.id_, H5S_ALL, H5S_ALL, H5P_DEFAULT, syncValues.data());
161  if (ret_value < 0) {
162  throw cms::Exception("BadH5Read") << "unable to read IOVSyncValue dataset " << id_;
163  }
164  return syncValues;
165  }
std::size_t size() const
Definition: h5_DataSet.cc:90

◆ size()

std::size_t DataSet::size ( void  ) const
private

Definition at line 90 of file h5_DataSet.cc.

References cms::cuda::assert(), and id_.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), memorySize(), readBytes(), readRefs(), and readSyncValues().

90  {
91  DataSpace space_id{H5Dget_space(id_)};
92 
93  hssize_t num_elements = H5Sget_simple_extent_npoints(space_id.id_);
94  assert(num_elements >= 0);
95 
96  return num_elements;
97  }
assert(be >=bs)

◆ storageSize()

std::size_t DataSet::storageSize ( ) const

Definition at line 99 of file h5_DataSet.cc.

References id_.

99 { return H5Dget_storage_size(id_); }

Member Data Documentation

◆ id_

hid_t cms::h5::DataSet::id_
private