icedb  version 0.5.1
Snow particle scattering database API
Namespaces | Typedefs | Enumerations | Functions
icedb::fs::hdf5 Namespace Reference

Namespaces

 zlib
 

Typedefs

typedef std::unique_ptr< H5::Group > HDFgroup_t
 
typedef std::unique_ptr< H5::AtomType > MatchAttributeTypeType
 
typedef std::unique_ptr< H5::DataSet > HDFdataset_t
 

Enumerations

enum  DataContainerType {
  DataContainerType::BASIC, DataContainerType::ARRAY, DataContainerType::COMPOUND, DataContainerType::ENUM,
  DataContainerType::OPAQUE, DataContainerType::VLEN, DataContainerType::STRING, DataContainerType::UNKNOWN
}
 

Functions

int useZLIB ()
 
void useZLIB (int val)
 
template<>
MatchAttributeTypeType MatchAttributeType< std::string > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< const char * > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< char > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< uint8_t > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< uint16_t > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< uint32_t > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< uint64_t > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< int8_t > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< int16_t > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< int32_t > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< int64_t > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< float > ()
 
template<>
MatchAttributeTypeType MatchAttributeType< double > ()
 
template<>
bool isStrType< std::string > ()
 
template<>
bool isStrType< const char * > ()
 
template<>
void insertAttr< std::string > (const H5::Attribute &attr, gsl::not_null< H5::AtomType *> vls_type, const std::string &value)
 
template<>
void loadAttr< std::string > (const H5::Attribute &attr, gsl::not_null< H5::AtomType *> vls_type, std::string &value)
 
HDFgroup_t openOrCreateGroup (gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR > base, gsl::not_null< const char *> name)
 
HDFgroup_t openGroup (gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR > base, gsl::not_null< const char *> name)
 
bool attrExists (gsl::not_null< H5::H5Object *> base, gsl::not_null< const char *> name)
 
bool groupExists (gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR > base, gsl::not_null< const char *> name)
 
std::pair< bool, bool > symLinkExists (gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR > base, gsl::not_null< const char *> name)
 
bool datasetExists (gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR > base, gsl::not_null< const char * > name)
 Convenience function to check if a given dataset exists. More...
 
std::shared_ptr< H5::DSetCreatPropList > make_plist (size_t rows, size_t cols, bool compress=true)
 Creates a property list with the compression + chunking as specified. More...
 
std::set< std::string > getGroupMembers (const ICEDB_H5_GETNUMOBJS_OWNER &base)
 
std::map< std::string, H5G_obj_t > getGroupMembersTypes (const ICEDB_H5_GETNUMOBJS_OWNER &base)
 
std::vector< std::string > explode (std::string const &s, char delim)
 
std::vector< std::string > explodeHDF5groupPath (const std::string &s)
 
H5::Group createGroupStructure (const std::string &groupName, ICEDB_H5_GROUP_OWNER &base)
 
H5::Group createGroupStructure (const std::vector< std::string > &groups, ICEDB_H5_GROUP_OWNER &base)
 
unsigned int getHDF5IOflags (fs::IOopenFlags flags)
 
template<>
bool isType< uint64_t > (hid_t type_id)
 
template<>
bool isType< int64_t > (hid_t type_id)
 
template<>
bool isType< uint32_t > (hid_t type_id)
 
template<>
bool isType< int32_t > (hid_t type_id)
 
template<>
bool isType< uint16_t > (hid_t type_id)
 
template<>
bool isType< int16_t > (hid_t type_id)
 
template<>
bool isType< uint8_t > (hid_t type_id)
 
template<>
bool isType< int8_t > (hid_t type_id)
 
template<>
bool isType< float > (hid_t type_id)
 
template<>
bool isType< double > (hid_t type_id)
 
template<>
bool isType< char > (hid_t type_id)
 
template<>
bool isType< std::string > (hid_t type_id)
 
void readDatasetDimensions (gsl::not_null< H5::DataSet *> dataset, std::vector< size_t > &dims)
 
size_t readDatasetNumDimensions (gsl::not_null< H5::DataSet *> dataset)
 
template<class DataType >
MatchAttributeTypeType MatchAttributeType ()
 
template<>
MatchAttributeTypeType MatchAttributeType< const char * > ()
 
template<class DataType >
bool isStrType ()
 Check to see if output type is for a string. More...
 
template<>
bool isStrType< const char * > ()
 
template<class DataType >
void insertAttr (const H5::Attribute &attr, gsl::not_null< H5::AtomType *> vls_type, const DataType &value)
 Handles proper insertion of strings versus other data types. More...
 
template<class DataType , class Container >
void addAttr (gsl::not_null< Container *> obj, gsl::not_null< const char *> attname, const DataType &value)
 Convenient template to add an attribute of a variable type to a group or dataset. More...
 
template<class DataType , class Container >
void addAttrArray (gsl::not_null< Container *> obj, gsl::not_null< const char *> attname, const std::vector< size_t > &dimensionality, const std::vector< DataType > &value)
 Writes an array of objects. More...
 
template<class DataType , class Container >
void addAttrVector (gsl::not_null< Container *> obj, gsl::not_null< const char *> attname, const std::vector< DataType > &data)
 Writes a vector of objects. More...
 
template<class DataType >
void loadAttr (const H5::Attribute &attr, gsl::not_null< H5::AtomType *> vls_type, DataType &value)
 Handles proper insertion of strings versus other data types. More...
 
template<class DataType , class Container >
void readAttr (gsl::not_null< Container *> obj, gsl::not_null< const char *> attname, DataType &value)
 Convenient template to read an attribute of a variable. More...
 
template<class DataType , class Container >
void readAttrArray (gsl::not_null< Container *> obj, gsl::not_null< const char *> attname, std::vector< size_t > &dims, std::vector< DataType > &value)
 Reads an array (or vector) of objects. More...
 
template<class DataType , class Container >
void readAttrVector (gsl::not_null< Container *> obj, gsl::not_null< const char *> attname, std::vector< DataType > &value)
 Reads an array (or vector) of objects. More...
 
template<class Container >
DataContainerType getAttributeGroupingType (gsl::not_null< Container *> obj, gsl::not_null< const char *> attname)
 
template<class Container >
std::vector< hsize_t > getAttrArrayDimensionality (gsl::not_null< Container *> obj, gsl::not_null< const char *> attname)
 
template<class DataType , class Container >
HDFdataset_t addDatasetArray (gsl::not_null< Container *> obj, gsl::not_null< const char *> name, size_t rows, size_t cols, gsl::not_null< const DataType *> values, std::shared_ptr< H5::DSetCreatPropList > iplist=nullptr)
 
template<class DataType , class Container >
HDFdataset_t addDatasetArray (gsl::not_null< Container *> obj, gsl::not_null< const char *> name, size_t rows, gsl::not_null< const DataType *> values, std::shared_ptr< H5::DSetCreatPropList > iplist=nullptr)
 
template<class DataType , class Container >
gsl::not_null< H5::DataSet * > writeDatasetArray (const std::vector< size_t > &dimensions, gsl::not_null< H5::DataSet *> dset, gsl::not_null< const DataType *> values)
 
template<class DataType , class Container >
HDFdataset_t createDatasetRaw (gsl::not_null< Container *> parent, gsl::not_null< const char *> name, const std::vector< size_t > &dims, std::shared_ptr< H5::DSetCreatPropList > iplist=nullptr)
 
template<class Container >
HDFdataset_t readDatasetDimensions (gsl::not_null< Container *> obj, gsl::not_null< const char *> name, std::vector< size_t > &out)
 
template<class DataType , class Container >
HDFdataset_t readDatasetArray (gsl::not_null< Container *> obj, gsl::not_null< const char *> name, gsl::not_null< DataType *> values)
 
template<class DataType , class Container >
gsl::not_null< Container * > readDatasetArray (gsl::not_null< Container *> dataset, gsl::not_null< DataType *> values)
 
template<class Container >
void addNames (gsl::not_null< Container *> obj, const std::string &prefix, size_t num, const std::function< std::string(int)> &s, size_t stride=0, size_t mCols=0)
 Add column names to table. More...
 
template<class Container >
void addColNames (gsl::not_null< Container *> obj, size_t num, const std::function< std::string(int)> &s, size_t stride=0, size_t mCols=0)
 Add column names to table. More...
 
template<class DataType >
bool isType (hid_t)
 Functions to detect the type of data. More...
 
template<class DataType , class Container >
bool isType (gsl::not_null< const Container *> obj, const std::string &attributeName)
 
template<class DataType , class Container >
bool isType (gsl::not_null< const Container *> obj)
 

Typedef Documentation

◆ HDFdataset_t

typedef std::unique_ptr<H5::DataSet > icedb::fs::hdf5::HDFdataset_t

Definition at line 268 of file hdf5_supplemental.hpp.

◆ HDFgroup_t

typedef std::unique_ptr<H5::Group > icedb::fs::hdf5::HDFgroup_t

Definition at line 44 of file hdf5_supplemental.hpp.

◆ MatchAttributeTypeType

typedef std::unique_ptr<H5::AtomType> icedb::fs::hdf5::MatchAttributeTypeType
Parameters
std::shared_ptr<H5::AtomType>is a pointer to a newly-constructed matching type
Returns
A pair of (the matching type, a flag indicating passing by pointer or reference)

Definition at line 53 of file hdf5_supplemental.hpp.

Enumeration Type Documentation

◆ DataContainerType

Function Documentation

◆ addAttr()

template<class DataType , class Container >
void icedb::fs::hdf5::addAttr ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  attname,
const DataType &  value 
)

Convenient template to add an attribute of a variable type to a group or dataset.

Definition at line 89 of file hdf5_supplemental.hpp.

90  {
91  auto vls_type = MatchAttributeType<DataType>();
92  //H5::DataSpace att_space(H5S_SCALAR); // Will not work with older NetCDF versions
93  //H5::DataSpace att_space(H5S_SIMPLE);
94  hsize_t dsize = 1; //static_cast<hsize_t>(data.size());
95  H5::DataSpace att_space(1, &dsize);
96  H5::Attribute attr = obj->createAttribute(attname, *vls_type, att_space);
97  insertAttr<DataType>(attr, vls_type.get(), value);
98  }

◆ addAttrArray()

template<class DataType , class Container >
void icedb::fs::hdf5::addAttrArray ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  attname,
const std::vector< size_t > &  dimensionality,
const std::vector< DataType > &  value 
)

Writes an array of objects.

Definition at line 102 of file hdf5_supplemental.hpp.

107  {
108  auto ftype = MatchAttributeType<DataType>();
109  std::vector<hsize_t> hdims;
110  for (const auto &d : dimensionality)
111  hdims.push_back(static_cast<hsize_t>(d));
112 
113  // This newer form can be read by old NetCDF versions (like 4.1.1, 01/2014)
114  // The older form could only be read by newer NetCDF versions
115  // Of course, NC can only ever read singular-dimension attributes.
116  H5::DataSpace att_space(static_cast<int>(dimensionality.size()), hdims.data());
117  H5::Attribute attr = obj->createAttribute(attname, *(ftype.get()), att_space);
118  attr.write(*ftype, value.data());
119 
120  // Older form cannot be read by older versions of NetCDF.
121  //H5::ArrayType vls_type(*ftype, static_cast<int>(dimensionality.size()), (hdims.data()));
122  //H5::DataSpace att_space(H5S_SCALAR); // Will not work with older NetCDF versions.
123  //H5::Attribute attr = obj->createAttribute(attname, vls_type, att_space);
124  //attr.write(vls_type, value.data());
125  }

◆ addAttrVector()

template<class DataType , class Container >
void icedb::fs::hdf5::addAttrVector ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  attname,
const std::vector< DataType > &  data 
)

Writes a vector of objects.

Definition at line 129 of file hdf5_supplemental.hpp.

133  {
134  auto ftype = MatchAttributeType<DataType>();
135  hsize_t dsize = static_cast<hsize_t>(data.size());
136  H5::DataSpace att_space(1, &dsize);
137  H5::Attribute attr = obj->createAttribute(attname, *(ftype.get()), att_space);
138  attr.write(*ftype, data.data());
139  }

◆ addColNames()

template<class Container >
void icedb::fs::hdf5::addColNames ( gsl::not_null< Container *>  obj,
size_t  num,
const std::function< std::string(int)> &  s,
size_t  stride = 0,
size_t  mCols = 0 
)

Add column names to table.

Parameters
numis the number of columns
strideallows name duplication (for vectors)

Definition at line 456 of file hdf5_supplemental.hpp.

References createGroupStructure(), explode(), explodeHDF5groupPath(), getHDF5IOflags(), and make_plist().

457  {
458  size_t nstride = stride;
459  if (!nstride) nstride = 1;
460  for (size_t i = 0; i < num; ++i)
461  {
462  size_t j = i / nstride;
463  std::string lbl = s((int)j);
464  std::ostringstream fldname;
465  fldname << "COLUMN_";
466  fldname.width(2);
467  fldname.fill('0');
468  fldname << std::right << i << "_NAME";
469  std::string sfldname = fldname.str();
470  if (stride)
471  {
472  size_t k = i % nstride;
473  if (!mCols) {
474  if (k == 0) lbl.append("_X");
475  if (k == 1) lbl.append("_Y");
476  if (k == 2) lbl.append("_Z");
477  if (k == 3) lbl.append("_R");
478  }
479  else {
480  size_t row = k / mCols;
481  size_t col = k % mCols;
482  std::ostringstream iappend;
483  iappend << "_" << row << "_" << col;
484  lbl.append(iappend.str());
485  }
486  }
487  addAttr<std::string, Container>(obj, sfldname.c_str(), lbl);
488  }
489  }
Here is the call graph for this function:

◆ addDatasetArray() [1/2]

template<class DataType , class Container >
HDFdataset_t icedb::fs::hdf5::addDatasetArray ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  name,
size_t  rows,
size_t  cols,
gsl::not_null< const DataType *>  values,
std::shared_ptr< H5::DSetCreatPropList >  iplist = nullptr 
)

Definition at line 272 of file hdf5_supplemental.hpp.

References useZLIB().

Referenced by addDatasetArray().

275  {
276  using namespace H5;
277  std::vector<hsize_t> sz{ (hsize_t)rows, (hsize_t)cols };
278  int dimensionality = 2;
279  if (cols == 1) dimensionality = 1;
280  H5::DataSpace fspace(dimensionality, sz.data());
281  auto ftype = MatchAttributeType<DataType>();
282  std::shared_ptr<DSetCreatPropList> plist;
283  if (iplist) plist = iplist;
284  else
285  {
286  plist = std::shared_ptr<DSetCreatPropList>(new DSetCreatPropList);
287  if (!isStrType<DataType>())
288  {
289  int fillvalue = -1;
290  plist->setFillValue(PredType::NATIVE_INT, &fillvalue);
291  if (useZLIB()) {
292  plist->setChunk(static_cast<int>(sz.size()), sz.data());
293  plist->setDeflate(useZLIB());
294  }
295  }
296  }
297 
298  HDFdataset_t dataset(new DataSet(obj->createDataSet(name, *(ftype.get()),
299  fspace, *(plist.get()))));
300  dataset->write(values, *(ftype.get()));
301  return dataset;
302  }
Definition: Data_Types.hpp:9
std::unique_ptr< H5::DataSet > HDFdataset_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addDatasetArray() [2/2]

template<class DataType , class Container >
HDFdataset_t icedb::fs::hdf5::addDatasetArray ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  name,
size_t  rows,
gsl::not_null< const DataType *>  values,
std::shared_ptr< H5::DSetCreatPropList >  iplist = nullptr 
)

Definition at line 305 of file hdf5_supplemental.hpp.

References addDatasetArray().

308  {
309  return std::move(addDatasetArray(obj, name, rows, 1, values, iplist));
310  }
HDFdataset_t addDatasetArray(gsl::not_null< Container *> obj, gsl::not_null< const char *> name, size_t rows, gsl::not_null< const DataType *> values, std::shared_ptr< H5::DSetCreatPropList > iplist=nullptr)
Here is the call graph for this function:

◆ addNames()

template<class Container >
void icedb::fs::hdf5::addNames ( gsl::not_null< Container *>  obj,
const std::string &  prefix,
size_t  num,
const std::function< std::string(int)> &  s,
size_t  stride = 0,
size_t  mCols = 0 
)

Add column names to table.

Parameters
numis the number of columns
strideallows name duplication (for vectors)

Definition at line 429 of file hdf5_supplemental.hpp.

434  {
435  size_t nstride = stride;
436  if (!nstride) nstride = 1;
437  for (size_t i = 0; i < num; ++i)
438  {
439  size_t j = i / nstride;
440  std::string lbl = s((int)j);
441  std::ostringstream fldname;
442  fldname << std::string(prefix);
443  fldname.width(2);
444  fldname.fill('0');
445  fldname << std::right << i << "_NAME";
446  std::string sfldname = fldname.str();
447  addAttr<std::string, Container>(obj, sfldname.c_str(), lbl);
448  }
449  }

◆ attrExists()

bool icedb::fs::hdf5::attrExists ( gsl::not_null< H5::H5Object *>  base,
gsl::not_null< const char *>  name 
)

Definition at line 88 of file export-hdf5.cpp.

Referenced by getAttrArrayDimensionality().

89  {
90  try {
91  H5::Attribute(base->openAttribute(name));
92  return true;
93  }
94  catch (H5::AttributeIException not_found_error) {
95  return false;
96  }
97  catch (H5::FileIException not_found_error) {
98  return false;
99  }
100  catch (H5::GroupIException not_found_error) {
101  return false;
102  }
103  }
Here is the caller graph for this function:

◆ createDatasetRaw()

template<class DataType , class Container >
HDFdataset_t icedb::fs::hdf5::createDatasetRaw ( gsl::not_null< Container *>  parent,
gsl::not_null< const char *>  name,
const std::vector< size_t > &  dims,
std::shared_ptr< H5::DSetCreatPropList >  iplist = nullptr 
)

Definition at line 330 of file hdf5_supplemental.hpp.

References useZLIB().

335  {
336  using namespace H5;
337  std::vector<hsize_t> sz(dims.size());
338  for (size_t i = 0; i < sz.size(); ++i)
339  sz[i] = static_cast<hsize_t>(dims[i]);
340 
341  DataSpace fspace(static_cast<int>(sz.size()), sz.data());
342  auto ftype = MatchAttributeType<DataType>();
343  std::shared_ptr<DSetCreatPropList> plist;
344  if (iplist) plist = iplist;
345  else
346  {
347  plist = std::shared_ptr<DSetCreatPropList>(new DSetCreatPropList);
348  if (!isStrType<DataType>())
349  {
350  int fillvalue = -1;
351  plist->setFillValue(PredType::NATIVE_INT, &fillvalue);
352  if (useZLIB()) {
353  plist->setChunk(static_cast<int>(sz.size()), sz.data());
354  plist->setDeflate(useZLIB());
355  }
356  }
357  }
358 
359  HDFdataset_t dataset(new DataSet(parent->createDataSet(name, *(ftype.get()),
360  fspace, *(plist.get()))));
361  return dataset;
362  }
Definition: Data_Types.hpp:9
std::unique_ptr< H5::DataSet > HDFdataset_t
Here is the call graph for this function:

◆ createGroupStructure() [1/2]

H5::Group icedb::fs::hdf5::createGroupStructure ( const std::string &  groupName,
ICEDB_H5_GROUP_OWNER &  base 
)

Definition at line 205 of file export-hdf5.cpp.

References explode().

Referenced by addColNames(), icedb::Databases::Database_impl::createGroupStructure(), icedb::Databases::Database::indexDatabase(), and icedb::Databases::Database::openDatabase().

205  {
206  // Using the '/' specifier, pop off the group names and
207  // create groups if necessary in the tree. Return the final group.
208  Expects(groupName.size() > 0);
209  std::string mountStr = groupName;
210  std::replace(mountStr.begin(), mountStr.end(), '\\', '/');
211  std::vector<std::string> groups = explode(mountStr, '/');
212 
213  return std::move(createGroupStructure(groups, base));
214  }
H5::Group createGroupStructure(const std::vector< std::string > &groups, ICEDB_H5_GROUP_OWNER &base)
std::vector< std::string > explode(std::string const &s, char delim)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createGroupStructure() [2/2]

H5::Group icedb::fs::hdf5::createGroupStructure ( const std::vector< std::string > &  groups,
ICEDB_H5_GROUP_OWNER &  base 
)
Note
This is really awkwardly stated because of an MSVC2017 bug. The HDF5 group copy constructor fails to update its id field, even though the hid_t is a uint64 and the copy is trivial. These 'relocatable references' allow me to avoid these copies through liberal use of std::move.

Definition at line 216 of file export-hdf5.cpp.

References getGroupMembers().

216  {
217 
222  std::shared_ptr<ICEDB_H5_GROUP_OWNER> current(&base, [](ICEDB_H5_GROUP_OWNER*) {});
223  std::vector<H5::Group> vgrps;
224  //vgrps.push_back(current);
225 
226  //H5::Group current(base);
227  for (const auto &grpname : groups) {
228  if (!grpname.size()) continue; // Skip any empty entries
229  std::set<std::string> members = getGroupMembers(*(current.get()));
230  if (!members.count(grpname)) {
231  vgrps.push_back(std::move(current->createGroup(grpname)));
232  current = std::shared_ptr<H5::Group>(&(*(vgrps.rbegin())), [](H5::Group*) {});
233  }
234  else {
235  //H5::Group newcur = current->openGroup(grpname);
236  //current = newcur;
237  vgrps.push_back(std::move(current->openGroup(grpname)));
238  current = std::shared_ptr<H5::Group>(&(*(vgrps.rbegin())), [](H5::Group*) {});
239  }
240  }
241  return std::move((*(vgrps.rbegin())));
242  }
std::set< std::string > getGroupMembers(const ICEDB_H5_GETNUMOBJS_OWNER &base)
Here is the call graph for this function:

◆ datasetExists()

bool icedb::fs::hdf5::datasetExists ( gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR >  base,
gsl::not_null< const char *>  name 
)

Convenience function to check if a given dataset exists.

Definition at line 137 of file export-hdf5.cpp.

Referenced by getAttrArrayDimensionality().

138  {
139  try {
140  H5::DataSet(base->openDataSet(name));
141  return true;
142  }
143  catch (H5::GroupIException not_found_error) {
144  return false;
145  }
146  catch (H5::FileIException not_found_error) {
147  return false;
148  }
149  }
Here is the caller graph for this function:

◆ explode()

std::vector< std::string > icedb::fs::hdf5::explode ( std::string const &  s,
char  delim 
)

Definition at line 185 of file export-hdf5.cpp.

Referenced by addColNames(), createGroupStructure(), and explodeHDF5groupPath().

186  {
187  std::vector<std::string> result;
188  std::istringstream iss(s);
189 
190  for (std::string token; std::getline(iss, token, delim); )
191  {
192  if (token.size())
193  result.push_back(std::move(token));
194  }
195 
196  return result;
197  }
Here is the caller graph for this function:

◆ explodeHDF5groupPath()

std::vector< std::string > icedb::fs::hdf5::explodeHDF5groupPath ( const std::string &  s)

Definition at line 199 of file export-hdf5.cpp.

References explode().

Referenced by addColNames(), and icedb::Databases::Database::indexDatabase().

199  {
200  std::string mountStr = s;
201  std::replace(mountStr.begin(), mountStr.end(), '\\', '/');
202  return explode(mountStr, '/');
203  }
std::vector< std::string > explode(std::string const &s, char delim)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAttrArrayDimensionality()

template<class Container >
std::vector<hsize_t> icedb::fs::hdf5::getAttrArrayDimensionality ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  attname 
)

Definition at line 241 of file hdf5_supplemental.hpp.

References attrExists(), datasetExists(), and symLinkExists().

243  {
244  std::vector<hsize_t> dims;
245  H5::Attribute attr = obj->openAttribute(attname);
246  int dimensionality = attr.getArrayType().getArrayNDims();
247  dims.resize(dimensionality);
248  attr.getArrayType().getArrayDims(dims.data());
249  return dims;
250  }
Here is the call graph for this function:

◆ getAttributeGroupingType()

template<class Container >
DataContainerType icedb::fs::hdf5::getAttributeGroupingType ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  attname 
)

Definition at line 219 of file hdf5_supplemental.hpp.

References ARRAY, BASIC, COMPOUND, ENUM, OPAQUE, STRING, UNKNOWN, and VLEN.

Referenced by icedb::Attributes::pullData().

220  {
221  H5::Attribute attr = obj->openAttribute(attname);
222  //const hid_t attrid = attr.getId();
223  H5::DataType dtype = attr.getDataType();
224  //const hid_t dtypeid = dtype.getId();
225  //const H5T_class_t class_type = H5Tget_class(dtypeid);
226  H5T_class_t class_type = dtype.getClass();
227  // I could also use the H5::DataType::detectClass method here...
228  if (class_type == H5T_class_t::H5T_ARRAY) return DataContainerType::ARRAY;
229  else if (class_type == H5T_class_t::H5T_COMPOUND) return DataContainerType::COMPOUND;
230  else if (class_type == H5T_class_t::H5T_ENUM) return DataContainerType::ENUM;
231  else if (class_type == H5T_class_t::H5T_OPAQUE) return DataContainerType::OPAQUE;
232  else if (class_type == H5T_class_t::H5T_INTEGER) return DataContainerType::BASIC;
233  else if (class_type == H5T_class_t::H5T_FLOAT) return DataContainerType::BASIC;
234  else if (class_type == H5T_class_t::H5T_VLEN) return DataContainerType::VLEN;
235  else if (class_type == H5T_class_t::H5T_STRING) return DataContainerType::STRING;
236 
237  return DataContainerType::UNKNOWN;
238  }
Here is the caller graph for this function:

◆ getGroupMembers()

std::set< std::string > icedb::fs::hdf5::getGroupMembers ( const ICEDB_H5_GETNUMOBJS_OWNER &  base)

Definition at line 162 of file export-hdf5.cpp.

Referenced by createGroupStructure().

162  {
163  std::set<std::string> res;
164  const hsize_t numObjs = base.getNumObjs();
165  for (hsize_t i = 0; i < numObjs; ++i)
166  {
167  std::string name = base.getObjnameByIdx(i);
168  res.insert(name);
169  }
170  return res;
171  }
Here is the caller graph for this function:

◆ getGroupMembersTypes()

std::map< std::string, H5G_obj_t > icedb::fs::hdf5::getGroupMembersTypes ( const ICEDB_H5_GETNUMOBJS_OWNER &  base)

Definition at line 173 of file export-hdf5.cpp.

Referenced by icedb::Groups::Group_impl::getGroupNames(), and icedb::Tables::CanHaveTables::getTableNames().

173  {
174  std::map<std::string, H5G_obj_t> res;
175  const hsize_t numObjs = base.getNumObjs();
176  for (hsize_t i = 0; i < numObjs; ++i)
177  {
178  std::string name = base.getObjnameByIdx(i);
179  H5G_obj_t gtype = base.getObjTypeByIdx(i);
180  res[name] = gtype;
181  }
182  return res;
183  }
Here is the caller graph for this function:

◆ getHDF5IOflags()

unsigned int icedb::fs::hdf5::getHDF5IOflags ( fs::IOopenFlags  flags)
Todo:
Candidate for constexpr inlining

Definition at line 246 of file export-hdf5.cpp.

References icedb::fs::CREATE, icedb::fs::READ_ONLY, icedb::fs::READ_WRITE, and icedb::fs::TRUNCATE.

Referenced by addColNames(), icedb::Databases::Database::createSampleDatabase(), icedb::Databases::Database::createSingleFileDatabase(), icedb::Databases::Database_impl::makeDatabaseFileStandard(), and icedb::Databases::Database::openDatabase().

246  {
247  unsigned int Hflags = 0; // HDF5 flags
248  if (flags == fs::IOopenFlags::READ_ONLY) Hflags = H5F_ACC_RDONLY;
249  else if (flags == fs::IOopenFlags::READ_WRITE) Hflags = H5F_ACC_RDWR;
250  else if (flags == fs::IOopenFlags::TRUNCATE) Hflags = H5F_ACC_TRUNC;
251  else if (flags == fs::IOopenFlags::CREATE) Hflags = H5F_ACC_CREAT;
252  return Hflags;
253  }
Here is the caller graph for this function:

◆ groupExists()

bool icedb::fs::hdf5::groupExists ( gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR >  base,
gsl::not_null< const char *>  name 
)

Definition at line 105 of file export-hdf5.cpp.

106  {
107  try {
108  H5::Group( base->openGroup( name ));
109  return true;
110  } catch( H5::GroupIException not_found_error ) {
111  return false;
112  }
113  catch (H5::FileIException not_found_error) {
114  return false;
115  }
116  }

◆ insertAttr()

template<class DataType >
void icedb::fs::hdf5::insertAttr ( const H5::Attribute &  attr,
gsl::not_null< H5::AtomType *>  vls_type,
const DataType &  value 
)

Handles proper insertion of strings versus other data types.

Definition at line 81 of file hdf5_supplemental.hpp.

82  {
83  attr.write(*vls_type, &value);
84  }

◆ insertAttr< std::string >()

template<>
void icedb::fs::hdf5::insertAttr< std::string > ( const H5::Attribute &  attr,
gsl::not_null< H5::AtomType *>  vls_type,
const std::string &  value 
)

Definition at line 44 of file export-hdf5.cpp.

45  {
46  attr.write(*vls_type, value);
47  }

◆ isStrType()

template<class DataType >
bool icedb::fs::hdf5::isStrType ( )

Check to see if output type is for a string.

Definition at line 75 of file hdf5_supplemental.hpp.

75 { return false; }

◆ isStrType< const char * >() [1/2]

template<>
bool icedb::fs::hdf5::isStrType< const char *> ( )

Definition at line 42 of file export-hdf5.cpp.

42 { return true; }

◆ isStrType< const char * >() [2/2]

template<>
bool icedb::fs::hdf5::isStrType< const char *> ( )

Definition at line 42 of file export-hdf5.cpp.

42 { return true; }

◆ isStrType< std::string >()

template<>
bool icedb::fs::hdf5::isStrType< std::string > ( )

Definition at line 41 of file export-hdf5.cpp.

41 { return true; }

◆ isType() [1/3]

template<class DataType >
bool icedb::fs::hdf5::isType ( hid_t  )

Functions to detect the type of data.

Definition at line 506 of file hdf5_supplemental.hpp.

506 { throw(std::invalid_argument("Unsupported type. (icedb::fs::hdf5::isType(hid_t))")); return false; }

◆ isType() [2/3]

template<class DataType , class Container >
bool icedb::fs::hdf5::isType ( gsl::not_null< const Container *>  obj,
const std::string &  attributeName 
)

Definition at line 509 of file hdf5_supplemental.hpp.

509  {
510  H5::Attribute attr = obj->openAttribute(attributeName);
511  return isType<DataType>(attr.getDataType().getId());
512  }

◆ isType() [3/3]

template<class DataType , class Container >
bool icedb::fs::hdf5::isType ( gsl::not_null< const Container *>  obj)

Definition at line 514 of file hdf5_supplemental.hpp.

References isType< char >(), isType< double >(), isType< float >(), isType< int16_t >(), isType< int32_t >(), isType< int64_t >(), isType< int8_t >(), isType< uint16_t >(), isType< uint32_t >(), isType< uint64_t >(), and isType< uint8_t >().

514  {
515  return isType<DataType>(obj->getDataType().getId());
516  }
Here is the call graph for this function:

◆ isType< char >()

template<>
bool icedb::fs::hdf5::isType< char > ( hid_t  type_id)

Definition at line 266 of file export-hdf5.cpp.

Referenced by isType().

266 { return (H5Tequal(type_id, H5T_NATIVE_CHAR) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< double >()

template<>
bool icedb::fs::hdf5::isType< double > ( hid_t  type_id)

Definition at line 265 of file export-hdf5.cpp.

Referenced by isType().

265 { return (H5Tequal(type_id, H5T_NATIVE_DOUBLE) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< float >()

template<>
bool icedb::fs::hdf5::isType< float > ( hid_t  type_id)

Definition at line 264 of file export-hdf5.cpp.

Referenced by isType().

264 { return (H5Tequal(type_id, H5T_NATIVE_FLOAT) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< int16_t >()

template<>
bool icedb::fs::hdf5::isType< int16_t > ( hid_t  type_id)

Definition at line 261 of file export-hdf5.cpp.

Referenced by isType().

261 { return (H5Tequal(type_id, H5T_NATIVE_INT16) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< int32_t >()

template<>
bool icedb::fs::hdf5::isType< int32_t > ( hid_t  type_id)

Definition at line 259 of file export-hdf5.cpp.

Referenced by isType().

259 { return (H5Tequal(type_id, H5T_NATIVE_INT32) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< int64_t >()

template<>
bool icedb::fs::hdf5::isType< int64_t > ( hid_t  type_id)

Definition at line 257 of file export-hdf5.cpp.

Referenced by isType().

257 { return (H5Tequal(type_id, H5T_NATIVE_INT64) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< int8_t >()

template<>
bool icedb::fs::hdf5::isType< int8_t > ( hid_t  type_id)

Definition at line 263 of file export-hdf5.cpp.

Referenced by isType().

263 { return (H5Tequal(type_id, H5T_NATIVE_INT8) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< std::string >()

template<>
bool icedb::fs::hdf5::isType< std::string > ( hid_t  type_id)

Definition at line 267 of file export-hdf5.cpp.

267  {
268  std::shared_ptr<H5::AtomType> a = std::make_shared<H5::StrType>(0, H5T_VARIABLE);
269  return (H5Tequal(type_id, a->getId()) > 0) ? true : false;
270  }

◆ isType< uint16_t >()

template<>
bool icedb::fs::hdf5::isType< uint16_t > ( hid_t  type_id)

Definition at line 260 of file export-hdf5.cpp.

Referenced by isType().

260 { return (H5Tequal(type_id, H5T_NATIVE_UINT16) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< uint32_t >()

template<>
bool icedb::fs::hdf5::isType< uint32_t > ( hid_t  type_id)

Definition at line 258 of file export-hdf5.cpp.

Referenced by isType().

258 { return (H5Tequal(type_id, H5T_NATIVE_UINT32) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< uint64_t >()

template<>
bool icedb::fs::hdf5::isType< uint64_t > ( hid_t  type_id)

Definition at line 256 of file export-hdf5.cpp.

Referenced by isType().

256 { return (H5Tequal(type_id, H5T_NATIVE_UINT64) > 0) ? true : false; }
Here is the caller graph for this function:

◆ isType< uint8_t >()

template<>
bool icedb::fs::hdf5::isType< uint8_t > ( hid_t  type_id)

Definition at line 262 of file export-hdf5.cpp.

Referenced by isType().

262 { return (H5Tequal(type_id, H5T_NATIVE_UINT8) > 0) ? true : false; }
Here is the caller graph for this function:

◆ loadAttr()

template<class DataType >
void icedb::fs::hdf5::loadAttr ( const H5::Attribute &  attr,
gsl::not_null< H5::AtomType *>  vls_type,
DataType &  value 
)

Handles proper insertion of strings versus other data types.

Definition at line 143 of file hdf5_supplemental.hpp.

144  {
145  attr.read(*vls_type, &value);
146  }

◆ loadAttr< std::string >()

template<>
void icedb::fs::hdf5::loadAttr< std::string > ( const H5::Attribute &  attr,
gsl::not_null< H5::AtomType *>  vls_type,
std::string &  value 
)

Definition at line 48 of file export-hdf5.cpp.

49  {
50  attr.read(*vls_type, value);
51  //attr.write(*vls_type, value);
52  }

◆ make_plist()

std::shared_ptr< H5::DSetCreatPropList > icedb::fs::hdf5::make_plist ( size_t  rows,
size_t  cols,
bool  compress 
)

Creates a property list with the compression + chunking as specified.

Definition at line 151 of file export-hdf5.cpp.

Referenced by addColNames().

152  {
153  using namespace H5;
154  const hsize_t chunk[2] = { static_cast<hsize_t>(rows), static_cast<hsize_t>(cols) };
155  auto plist = std::make_shared<H5::DSetCreatPropList>();
156  plist->setChunk(2, chunk);
157  if (compress)
158  plist->setDeflate(6);
159  return plist;
160  }
Definition: Data_Types.hpp:9
Here is the caller graph for this function:

◆ MatchAttributeType()

template<class DataType >
MatchAttributeTypeType icedb::fs::hdf5::MatchAttributeType ( )

Definition at line 55 of file hdf5_supplemental.hpp.

References MatchAttributeType< char >(), MatchAttributeType< double >(), MatchAttributeType< float >(), MatchAttributeType< int16_t >(), MatchAttributeType< int32_t >(), MatchAttributeType< int64_t >(), MatchAttributeType< int8_t >(), MatchAttributeType< uint16_t >(), MatchAttributeType< uint32_t >(), MatchAttributeType< uint64_t >(), and MatchAttributeType< uint8_t >().

56  {
57  throw(std::invalid_argument("Unsupported type during attribute conversion in rtmath::plugins::hdf5::MatchAttributeType."));
58  }
Here is the call graph for this function:

◆ MatchAttributeType< char >()

Definition at line 24 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

24 { return std::make_unique<H5::StrType>(0, 1); }
Here is the caller graph for this function:

◆ MatchAttributeType< const char * >() [1/2]

Definition at line 23 of file export-hdf5.cpp.

23 { return std::make_unique<H5::StrType>(0, H5T_VARIABLE); }

◆ MatchAttributeType< const char * >() [2/2]

Definition at line 23 of file export-hdf5.cpp.

23 { return std::make_unique<H5::StrType>(0, H5T_VARIABLE); }

◆ MatchAttributeType< double >()

Definition at line 37 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

37 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_DOUBLE); }
Here is the caller graph for this function:

◆ MatchAttributeType< float >()

Definition at line 36 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

36 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_FLOAT); }
Here is the caller graph for this function:

◆ MatchAttributeType< int16_t >()

Definition at line 31 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

31 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_INT16); }
Here is the caller graph for this function:

◆ MatchAttributeType< int32_t >()

Definition at line 32 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

32 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_INT32); }
Here is the caller graph for this function:

◆ MatchAttributeType< int64_t >()

Definition at line 33 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

33 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_INT64); }
Here is the caller graph for this function:

◆ MatchAttributeType< int8_t >()

Definition at line 30 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

30 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_INT8); }
Here is the caller graph for this function:

◆ MatchAttributeType< std::string >()

Definition at line 22 of file export-hdf5.cpp.

22 { return std::make_unique<H5::StrType>(0, H5T_VARIABLE); }

◆ MatchAttributeType< uint16_t >()

Definition at line 27 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

27 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_UINT16); }
Here is the caller graph for this function:

◆ MatchAttributeType< uint32_t >()

Definition at line 28 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

28 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_UINT32); }
Here is the caller graph for this function:

◆ MatchAttributeType< uint64_t >()

Definition at line 29 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

29 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_UINT64); }
Here is the caller graph for this function:

◆ MatchAttributeType< uint8_t >()

Definition at line 26 of file export-hdf5.cpp.

Referenced by MatchAttributeType().

26 { return std::make_unique<H5::IntType>(H5::PredType::NATIVE_UINT8); }
Here is the caller graph for this function:

◆ openGroup()

HDFgroup_t icedb::fs::hdf5::openGroup ( gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR >  base,
gsl::not_null< const char *>  name 
)

Definition at line 75 of file export-hdf5.cpp.

Referenced by icedb::Groups::Group_impl::Group_impl().

76  {
77  HDFgroup_t res;
78  try {
79  res=(std::make_unique<H5::Group>(base->openGroup( name )));
80  } catch( H5::GroupIException not_found_error ) {
81  return nullptr;
82  } catch( H5::FileIException not_found_error ) {
83  return nullptr;
84  }
85  return res;
86  }
std::unique_ptr< H5::Group > HDFgroup_t
Here is the caller graph for this function:

◆ openOrCreateGroup()

HDFgroup_t icedb::fs::hdf5::openOrCreateGroup ( gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR >  base,
gsl::not_null< const char *>  name 
)

Definition at line 62 of file export-hdf5.cpp.

63  {
64  HDFgroup_t res;
65  try {
66  res=std::make_unique<H5::Group>( base->openGroup( name ));
67  } catch( H5::GroupIException not_found_error ) {
68  res=std::make_unique<H5::Group>(base->createGroup( name ));
69  } catch( H5::FileIException not_found_error ) {
70  res=std::make_unique<H5::Group>(base->createGroup( name ));
71  }
72  return res;
73  }
std::unique_ptr< H5::Group > HDFgroup_t

◆ readAttr()

template<class DataType , class Container >
void icedb::fs::hdf5::readAttr ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  attname,
DataType &  value 
)

Convenient template to read an attribute of a variable.

Definition at line 151 of file hdf5_supplemental.hpp.

Referenced by icedb::Attributes::pullData().

152  {
153  auto vls_type = MatchAttributeType<DataType>();
154  H5::DataSpace att_space(H5S_SCALAR);
155  H5::Attribute attr = obj->openAttribute(attname); //, *vls_type, att_space);
156  loadAttr<DataType>(attr, vls_type.get(), value);
157  }
Here is the caller graph for this function:

◆ readAttrArray()

template<class DataType , class Container >
void icedb::fs::hdf5::readAttrArray ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  attname,
std::vector< size_t > &  dims,
std::vector< DataType > &  value 
)

Reads an array (or vector) of objects.

Definition at line 161 of file hdf5_supplemental.hpp.

Referenced by icedb::Attributes::pullData().

164  {
165  H5::Attribute attr = obj->openAttribute(attname);
166  int dimensionality = attr.getArrayType().getArrayNDims();
167  Expects(dimensionality > 0);
168  std::vector<hsize_t> sz(static_cast<size_t>(dimensionality));
169  attr.getArrayType().getArrayDims(sz.data());
170 
171  dims.resize(static_cast<size_t>(dimensionality));
172  size_t numElems = 1;
173  for (size_t i = 0; i < dimensionality; ++i) {
174  dims[i] = static_cast<size_t>(sz[i]);
175  numElems *= dims[i];
176  }
177  value.resize(numElems);
178 
179  auto ftype = MatchAttributeType<DataType>();
180  //H5::IntType ftype(H5::PredType::NATIVE_FLOAT);
181  H5::ArrayType vls_type(*ftype, dimensionality, sz.data());
182 
183  //H5::DataSpace att_space(H5S_SCALAR);
184  //H5::Attribute attr = obj->createAttribute(attname, vls_type, att_space);
185  attr.read(vls_type, value.data());
186  }
Here is the caller graph for this function:

◆ readAttrVector()

template<class DataType , class Container >
void icedb::fs::hdf5::readAttrVector ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  attname,
std::vector< DataType > &  value 
)

Reads an array (or vector) of objects.

Definition at line 190 of file hdf5_supplemental.hpp.

Referenced by icedb::Attributes::pullData().

192  {
193  /*
194  std::shared_ptr<H5::AtomType> ftype = MatchAttributeType<DataType>();
195  hsize_t dsize = (hsize_t) data.size();
196  H5::DataSpace att_space(1, &dsize);
197  H5::Attribute attr = obj->createAttribute(attname, *(ftype.get()), att_space);
198  attr.write(*ftype, data.data());
199  */
200  H5::Attribute attr = obj->openAttribute(attname);
201  auto ftype = MatchAttributeType<DataType>();
202  H5::DataSpace dspace = attr.getSpace();
203  value.resize(dspace.getSimpleExtentNdims());
204  attr.read(*(ftype.get()), value.data());
205  }
Here is the caller graph for this function:

◆ readDatasetArray() [1/2]

template<class DataType , class Container >
HDFdataset_t icedb::fs::hdf5::readDatasetArray ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  name,
gsl::not_null< DataType *>  values 
)

Definition at line 391 of file hdf5_supplemental.hpp.

394  {
395  using namespace H5;
396 
397  HDFdataset_t dataset(new H5::DataSet(obj->openDataSet(name)));
398  H5T_class_t type_class = dataset->getTypeClass();
399  DataSpace fspace = dataset->getSpace();
400 
401  //DataSpace fspace(dimensionality, sz);
402  auto ftype = MatchAttributeType<DataType>();
403 
404  dataset->read(values, *(ftype.get()));
405  return std::move(dataset);
406  }
Definition: Data_Types.hpp:9
std::unique_ptr< H5::DataSet > HDFdataset_t

◆ readDatasetArray() [2/2]

template<class DataType , class Container >
gsl::not_null<Container*> icedb::fs::hdf5::readDatasetArray ( gsl::not_null< Container *>  dataset,
gsl::not_null< DataType *>  values 
)

Definition at line 409 of file hdf5_supplemental.hpp.

412  {
413  using namespace H5;
414 
415  H5T_class_t type_class = dataset->getTypeClass();
416  DataSpace fspace = dataset->getSpace();
417 
418  //DataSpace fspace(dimensionality, sz);
419  auto ftype = MatchAttributeType<DataType>();
420 
421  dataset->read(values, *(ftype.get()));
422  return dataset;
423  }
Definition: Data_Types.hpp:9

◆ readDatasetDimensions() [1/2]

void icedb::fs::hdf5::readDatasetDimensions ( gsl::not_null< H5::DataSet *>  dataset,
std::vector< size_t > &  dims 
)

Definition at line 273 of file export-hdf5.cpp.

Referenced by icedb::Tables::Table::getDimensions(), icedb::Tables::Table::readAll(), and readDatasetDimensions().

273  {
274  using namespace H5;
275  const H5T_class_t type_class = dataset->getTypeClass();
276  DataSpace fspace = dataset->getSpace();
277  int rank = fspace.getSimpleExtentNdims();
278  assert(rank >= 0);
279  std::vector<hsize_t> sz(rank);
280  const int dimensionality = fspace.getSimpleExtentDims(sz.data(), NULL);
281  for (size_t i = 0; i < rank; ++i)
282  dims.push_back((size_t)sz[i]);
283  }
Definition: Data_Types.hpp:9
Here is the caller graph for this function:

◆ readDatasetDimensions() [2/2]

template<class Container >
HDFdataset_t icedb::fs::hdf5::readDatasetDimensions ( gsl::not_null< Container *>  obj,
gsl::not_null< const char *>  name,
std::vector< size_t > &  out 
)

Definition at line 366 of file hdf5_supplemental.hpp.

References readDatasetDimensions(), and readDatasetNumDimensions().

370  {
371  using namespace H5;
372 
373  HDFdataset_t dataset(new H5::DataSet(obj->openDataSet(name)));
374  H5T_class_t type_class = dataset->getTypeClass();
375  DataSpace fspace = dataset->getSpace();
376  int rank = fspace.getSimpleExtentNdims();
377 
378  std::vector<hsize_t> sz(rank);
379  int dimensionality = fspace.getSimpleExtentDims( sz.data(), NULL);
380  for (size_t i = 0; i < rank; ++i)
381  out.push_back(sz[i]);
382 
383  return dataset;
384  }
Definition: Data_Types.hpp:9
std::unique_ptr< H5::DataSet > HDFdataset_t
Here is the call graph for this function:

◆ readDatasetNumDimensions()

size_t icedb::fs::hdf5::readDatasetNumDimensions ( gsl::not_null< H5::DataSet *>  dataset)

Definition at line 285 of file export-hdf5.cpp.

Referenced by icedb::Tables::Table::getNumDimensions(), and readDatasetDimensions().

285  {
286  using namespace H5;
287  const H5T_class_t type_class = dataset->getTypeClass();
288  DataSpace fspace = dataset->getSpace();
289  int rank = fspace.getSimpleExtentNdims();
290  assert(rank >= 0);
291  return (size_t)rank;
292  }
Definition: Data_Types.hpp:9
Here is the caller graph for this function:

◆ symLinkExists()

std::pair< bool, bool > icedb::fs::hdf5::symLinkExists ( gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR >  base,
gsl::not_null< const char * >  name 
)

Convenience function to check if a symbolic link exists, and if the object being pointed to also exists.

Returns
std::pair<bool,bool> refers to, respectively, if a symbolic link is found and if the symbolic link is good.

Definition at line 118 of file export-hdf5.cpp.

Referenced by getAttrArrayDimensionality().

119  {
120  bool linkexists = false;
121  bool linkgood = false;
122  std::string lloc;
123  try {
124  H5G_stat_t stats;
125  base->getObjinfo(name, false, stats);
126  linkexists = true;
127 
128  //lloc = base->getLinkval(name);
129  base->getObjinfo(name, true, stats);
130  linkgood = true;
131  } catch( H5::GroupIException not_found_error ) {
132  } catch( H5::FileIException not_found_error) {
133  }
134  return std::pair<bool,bool>(linkexists,linkgood);
135  }
Here is the caller graph for this function:

◆ useZLIB() [1/2]

int icedb::fs::hdf5::useZLIB ( )

Definition at line 17 of file export-hdf5.cpp.

References icedb::fs::hdf5::zlib::cval.

Referenced by icedb::Tables::CanHaveTables::_createTable(), addDatasetArray(), createDatasetRaw(), and main().

17 { return zlib::cval; }
Here is the caller graph for this function:

◆ useZLIB() [2/2]

void icedb::fs::hdf5::useZLIB ( int  val)

Definition at line 18 of file export-hdf5.cpp.

References icedb::fs::hdf5::zlib::cval.

18 { zlib::cval = val; }

◆ writeDatasetArray()

template<class DataType , class Container >
gsl::not_null<H5::DataSet*> icedb::fs::hdf5::writeDatasetArray ( const std::vector< size_t > &  dimensions,
gsl::not_null< H5::DataSet *>  dset,
gsl::not_null< const DataType *>  values 
)

Definition at line 313 of file hdf5_supplemental.hpp.

317  {
318  using namespace H5;
319  std::vector<hsize_t> sz(dimensions.size());
320  for (size_t i = 0; i < sz.size(); ++i)
321  sz[i] = static_cast<hsize_t>(dimensions[i]);
322  //DataSpace fspace(static_cast<int>(sz.size()), sz);
323  auto ftype = MatchAttributeType<DataType>();
324 
325  dset->write(values, *(ftype.get()));
326  return dset;
327  }
Definition: Data_Types.hpp:9