ddn.data.hdf5.dataset

HDF5 Dataset Wrapper

This module provides a D wrapper for HDF5 dataset operations with RAII semantics for automatic resource management.

License

BSD-3-Clause

Types 2

structChunkInfo

Information about a single chunk in a chunked dataset.

This struct holds metadata about a chunk including its location, size, filter status, and address in the file.

Fields
hsize_t[] offsetLogical offset of the chunk in the dataset (in element coordinates)
hsize_t sizeSize of the chunk in bytes as stored in the file
haddr_t addrAddress of the chunk in the file
uint filterMaskBitmask indicating which filters were applied (0 = all filters applied)
structDataset

RAII wrapper for HDF5 dataset handles.

This struct manages an HDF5 dataset handle and automatically closes it when the struct goes out of scope. Copy is disabled to prevent double-close issues; use move() for transferring ownership.

Example:

// Create a dataset
auto ds = Dataset.create(file.handle(), "mydata", dtype.handle(), space.handle());

// Write data
int[100] data = ...;
ds.write(data);

Fields
private hid_t _id
Methods
Dataset create(hid_t locId, string name, hid_t typeId, hid_t spaceId, hid_t lcpl = H5P_DEFAULT, hid_t dcpl = H5P_DEFAULT, hid_t dapl = H5P_DEFAULT)Creates a new dataset.
Dataset open(hid_t locId, string name, hid_t dapl = H5P_DEFAULT)Opens an existing dataset.
Dataset move(ref Dataset other)Moves ownership from another Dataset instance.
void close()Explicitly closes the dataset handle.
hid_t handle() const @nogc nothrow @safeReturns the underlying HDF5 dataset handle.
bool isValid() const @nogc nothrow @safeChecks if the dataset handle is valid.
hid_t space()Gets the dataspace of this dataset.
hid_t dtype()Gets the datatype of this dataset.
void read(void * buffer, hid_t memTypeId, hid_t memSpaceId = H5S_ALL, hid_t fileSpaceId = H5S_ALL, hid_t dxpl = H5P_DEFAULT)Reads data from the dataset.
void read(T)(T[] data, hid_t memTypeId)Reads data from the dataset into a D array.
void write(const void * buffer, hid_t memTypeId, hid_t memSpaceId = H5S_ALL, hid_t fileSpaceId = H5S_ALL, hid_t dxpl = H5P_DEFAULT)Writes data to the dataset.
void write(T)(const T[] data, hid_t memTypeId)Writes data from a D array to the dataset.
void setExtent(const hsize_t[] newSize)Changes the dimensions of a dataset.
Dataset createChunked(hid_t locId, string name, hid_t typeId, hid_t spaceId, const hsize_t[] chunkDims, hid_t lcpl = H5P_DEFAULT, hid_t dapl = H5P_DEFAULT)Creates a chunked dataset with the specified chunk dimensions.
hsize_t getStorageSize()Gets the storage size of the dataset in bytes.
hsize_t getNumChunks(hid_t fspaceId = H5S_ALL)Gets the number of chunks in a chunked dataset.
ChunkInfo getChunkInfo(hsize_t chunkIdx, int ndims, hid_t fspaceId = H5S_ALL)Gets information about a chunk by its index.
ChunkInfo getChunkInfoByCoord(const hsize_t[] offset)Gets information about a chunk by its coordinates.
hsize_t getChunkStorageSize(const hsize_t[] offset)Gets the storage size of a specific chunk.
hsize_t iterateChunks(int ndims, bool delegate(ChunkInfo, hsize_t) dg, hid_t fspaceId = H5S_ALL)Iterates over all chunks in the dataset, calling a delegate for each.
void readChunk(const hsize_t[] offset, void * buffer, uint * filters = null, hid_t dxpl = H5P_DEFAULT)Reads a chunk directly from the file without decompression.
void writeChunk(const hsize_t[] offset, const void * buffer, size_t dataSize, uint filters = 0, hid_t dxpl = H5P_DEFAULT)Writes a chunk directly to the file without compression.
void selectHyperslab(hid_t spaceId, const hsize_t[] start, const hsize_t[] count, const hsize_t[] stride = null, const hsize_t[] blockSize = null, H5S_seloper_t op = H5S_seloper_t.SELECT_SET)Selects a hyperslab region in a dataspace for partial I/O.
void readHyperslab(void * buffer, hid_t memTypeId, const hsize_t[] start, const hsize_t[] count, const hsize_t[] stride = null, const hsize_t[] blockSize = null, hid_t dxpl = H5P_DEFAULT)Reads a hyperslab (rectangular subset) from the dataset.
void writeHyperslab(const void * buffer, hid_t memTypeId, const hsize_t[] start, const hsize_t[] count, const hsize_t[] stride = null, const hsize_t[] blockSize = null, hid_t dxpl = H5P_DEFAULT)Writes a hyperslab (rectangular subset) to the dataset.
Destructors
~thisDestructor that automatically closes the dataset handle.