1#ifndef RITSUKO_HDF5_STREAM_1D_NUMERIC_DATASET_HPP
2#define RITSUKO_HDF5_STREAM_1D_NUMERIC_DATASET_HPP
30template<
typename Type_>
43 mspace(1, &block_size),
44 dspace(1, &full_length),
63 while (consumed >= available) {
64 consumed -= available;
67 return buffer[consumed];
76 while (consumed >= available) {
77 consumed -= available;
80 return std::make_pair(buffer.data() + consumed, available - consumed);
88 void next(
size_t jump = 1) {
103 return consumed + last_loaded;
107 const H5::DataSet* ptr;
108 hsize_t full_length, block_size;
109 H5::DataSpace mspace;
110 H5::DataSpace dspace;
111 std::vector<Type_> buffer;
113 hsize_t last_loaded = 0;
114 hsize_t consumed = 0;
115 hsize_t available = 0;
118 if (last_loaded >= full_length) {
119 throw std::runtime_error(
"requesting data beyond the end of the dataset at '" +
get_name(*ptr) +
"'");
121 available = std::min(full_length - last_loaded, block_size);
122 constexpr hsize_t zero = 0;
123 mspace.selectHyperslab(H5S_SELECT_SET, &available, &zero);
124 dspace.selectHyperslab(H5S_SELECT_SET, &available, &last_loaded);
126 last_loaded += available;
Stream a numeric 1-dimensional HDF5 dataset into memory.
Definition Stream1dNumericDataset.hpp:31
Stream1dNumericDataset(const H5::DataSet *ptr, hsize_t buffer_size)
Definition Stream1dNumericDataset.hpp:54
hsize_t length() const
Definition Stream1dNumericDataset.hpp:95
std::pair< const Type_ *, size_t > get_many()
Definition Stream1dNumericDataset.hpp:75
Type_ get()
Definition Stream1dNumericDataset.hpp:62
hsize_t position() const
Definition Stream1dNumericDataset.hpp:102
void next(size_t jump=1)
Definition Stream1dNumericDataset.hpp:88
Stream1dNumericDataset(const H5::DataSet *ptr, hsize_t length, hsize_t buffer_size)
Definition Stream1dNumericDataset.hpp:39
Get the length of a 1-dimensional HDF5 dataset.
Get the name of a HDF5 object.
std::string get_name(const Handle_ &handle)
Definition get_name.hpp:24
hsize_t pick_1d_block_size(const H5::DSetCreatPropList &cplist, hsize_t full_length, hsize_t buffer_size=10000)
Definition pick_1d_block_size.hpp:26
const H5::PredType & as_numeric_datatype()
Definition as_numeric_datatype.hpp:26
hsize_t get_1d_length(const H5::DataSpace &space, bool allow_scalar)
Definition get_1d_length.hpp:25
Assorted helper functions for parsing and validation.
Definition choose_missing_placeholder.hpp:15
Pick a block size for a 1-dimensional HDF5 dataset.