1#ifndef RITSUKO_HDF5_STREAM_1D_NUMERIC_DATASET_HPP
2#define RITSUKO_HDF5_STREAM_1D_NUMERIC_DATASET_HPP
14#include "../utils.hpp"
46template<
typename Type_,
class DataSetPo
inter_ = const H5::DataSet*>
58 my_data_ptr(std::move(data_ptr)),
59 my_full_length(length),
61 assert(my_data_ptr->getSpace().getSimpleExtentNdims() == 1);
63 const auto& plist = my_data_ptr->getCreatePlist();
64 if (plist.getLayout() == H5D_CHUNKED) {
65 plist.getChunk(1, &output);
71 my_mspace(1, &my_block_size),
72 my_fspace(1, &my_full_length)
75 const auto cls = my_data_ptr->getDataType().getClass();
76 return cls == H5T_INTEGER || cls == H5T_FLOAT;
98 hsize_t
load(Type_* buffer) {
99 static_assert(std::is_arithmetic<Type_>::value);
101 my_last_loaded += my_available;
102 my_available = std::min(my_full_length - my_last_loaded, my_block_size);
103 if (my_available == 0) {
107 constexpr hsize_t zero = 0;
108 my_mspace.selectHyperslab(H5S_SELECT_SET, &my_available, &zero);
109 my_fspace.selectHyperslab(H5S_SELECT_SET, &my_available, &my_last_loaded);
122 return my_last_loaded;
126 DataSetPointer_ my_data_ptr;
127 hsize_t my_full_length, my_block_size;
128 H5::DataSpace my_mspace;
129 H5::DataSpace my_fspace;
130 hsize_t my_last_loaded = 0;
131 hsize_t my_available = 0;
133 static_assert(std::is_base_of<H5::DataSet, I<
decltype(*my_data_ptr)> >::value);
Stream a 1-dimensional HDF5 numeric dataset into memory.
Definition Stream1dNumericDataset.hpp:47
Stream1dNumericDataset(DataSetPointer_ data_ptr, hsize_t length, const Stream1dNumericDatasetOptions &options)
Definition Stream1dNumericDataset.hpp:57
hsize_t start() const
Definition Stream1dNumericDataset.hpp:121
hsize_t chunk_size() const
Definition Stream1dNumericDataset.hpp:84
hsize_t load(Type_ *buffer)
Definition Stream1dNumericDataset.hpp:98
const H5::PredType & as_numeric_datatype()
Definition as_numeric_datatype.hpp:27
Helper functions for ArtifactDB parsing and validation.
Definition Pointer.hpp:22
constexpr Dest_ cap(Value_ x)
Options for Stream1dNumericDataset.
Definition Stream1dNumericDataset.hpp:29
hsize_t contiguous_chunk_size
Definition Stream1dNumericDataset.hpp:34