io-hdf5#

group HDF5

I/O operations backed by HDF5.

Functions

LogicalArray from_file(
const std::filesystem::path &file_path,
std::string_view dataset_name
)#

Load a HDF5 dataset into a LogicalArray.

Parameters:
  • file_path – The path to the file to load.

  • dataset_name – The name of the HDF5 dataset to load from the file.

Throws:
  • std::system_error – If file_path does not exist.

  • UnusupportedHDF5DataType – If the data type cannot be converted to a Type.

  • InvalidDataSetError – If the dataset is invalid, or is not found.

Returns:

LogicalArray The loaded array.

void to_file(
const LogicalArray &array,
std::filesystem::path file_path,
std::string_view dataset_name
)#

Write a LogicalArray to disk as a HDF5 dataset.

If file_path already exists at the time of writing, the file will be overwritten.

file_path may be absolute or relative. If it is relative, it will be written relative to the current working directory at the time of this function call.

file_path may not fully exist at the time of this function call. Any missing directories are created (with the same permissions and properties of the current process) before tasks are launched. However, no protection is provided if those directories are later deleted before the task executes — the tasks assume these directories exist when they execute.

array must not be unbound.

Parameters:
Throws:

std::invalid_argument – If file_path would not be a valid path name, for example if it is a directory name. Generally speaking this means that it must be of the form /path/to/file.h5.

class UnsupportedHDF5DataTypeError : public std::invalid_argument
#include <legate/io/hdf5/interface.h>

An exception thrown when a HDF5 datatype could not be converted to a Type.

class InvalidDataSetError : public std::invalid_argument
#include <legate/io/hdf5/interface.h>

An exception thrown when an invalid dataset is encountered in an HDF5 file.

Public Functions

InvalidDataSetError(
const std::string &what,
std::filesystem::path path,
std::string dataset_name
)

Construct an InvalidDataSetError.

Parameters:
  • what – The exception string to forward to the constructor of std::invalid_argument.

  • path – The path to the HDF5 file containing the dataset.

  • dataset_name – The name of the offending dataset.

const std::filesystem::path &path() const noexcept

Get the path to the file containing the dataset.

Returns:

The path to the file containing the dataset.

std::string_view dataset_name() const noexcept

Get the name of the dataset.

Returns:

The name of the dataset.