70 auto vstring = internal_json::extract_version_for_type(metadata.
other,
"delayed_array");
71 auto version = ritsuko::parse_version_string(vstring.c_str(), vstring.size(),
true);
72 if (version.major != 1) {
73 throw std::runtime_error(
"unsupported version '" + vstring +
"'");
78 std::string custom_name =
"custom takane seed array";
80 bool custom_found = (custom_options.array_validate_registry.find(custom_name) != custom_options.array_validate_registry.end());
96 struct ValidateResetter {
97 ValidateResetter(chihaya::Options& o,
const std::string& n,
bool f) : options(o), name(n), found(f) {}
100 options.array_validate_registry.erase(name);
104 chihaya::Options& options;
105 const std::string& name;
108 [[maybe_unused]] ValidateResetter v(custom_options, custom_name, custom_found);
111 custom_options.array_validate_registry[custom_name] = [&](
const H5::Group& handle,
const ritsuko::Version& version, chihaya::Options& ch_options) -> chihaya::ArrayDetails {
112 auto details = chihaya::custom_array::validate(handle, version, ch_options);
114 auto dhandle = ritsuko::hdf5::open_dataset(handle,
"index");
115 if (ritsuko::hdf5::exceeds_integer_limit(dhandle, 64,
false)) {
116 throw std::runtime_error(
"'index' should have a datatype that fits into a 64-bit unsigned integer");
119 auto index = ritsuko::hdf5::load_scalar_numeric_dataset<uint64_t>(dhandle);
120 auto seed_path = path /
"seeds" / std::to_string(index);
125 if (seed_dims.size() != details.dimensions.size()) {
126 throw std::runtime_error(
"dimensionality of 'seeds/" + std::to_string(index) +
"' is not consistent with 'dimensions'");
129 for (
size_t d = 0, ndims = seed_dims.size(); d < ndims; ++d) {
130 if (seed_dims[d] != details.dimensions[d]) {
131 throw std::runtime_error(
"dimension extents of 'seeds/" + std::to_string(index) +
"' is not consistent with 'dimensions'");
142 auto apath = path /
"array.h5";
143 auto fhandle = ritsuko::hdf5::open_file(apath);
144 auto ghandle = ritsuko::hdf5::open_group(fhandle,
"delayed_array");
145 ritsuko::Version chihaya_version = chihaya::extract_version(ghandle);
146 if (chihaya_version.lt(1, 1, 0)) {
147 throw std::runtime_error(
"version of the chihaya specification should be no less than 1.1");
152 [[maybe_unused]] internal::DetailsOnlyResetter o(custom_options);
153 custom_options.details_only =
false;
155 chihaya::validate(ghandle, chihaya_version, custom_options);
159 auto seed_path = path /
"seeds";
160 if (std::filesystem::exists(seed_path)) {
161 found = internal_other::count_directory_entries(seed_path);
164 throw std::runtime_error(
"number of objects in 'seeds' is not consistent with the number of 'index' references in 'array.h5'");
176 [[maybe_unused]] internal::DetailsOnlyResetter o(chihaya_options);
177 chihaya_options.details_only =
true;
179 auto apath = path /
"array.h5";
180 auto fhandle = ritsuko::hdf5::open_file(apath);
181 auto ghandle = ritsuko::hdf5::open_group(fhandle,
"delayed_array");
182 auto output = chihaya::validate(ghandle, chihaya_options);
183 return output.dimensions[0];
194 [[maybe_unused]] internal::DetailsOnlyResetter o(chihaya_options);
195 chihaya_options.details_only =
true;
197 auto apath = path /
"array.h5";
198 auto fhandle = ritsuko::hdf5::open_file(apath);
199 auto ghandle = ritsuko::hdf5::open_group(fhandle,
"delayed_array");
200 auto output = chihaya::validate(ghandle, chihaya_options);
201 return std::vector<size_t>(output.dimensions.begin(), output.dimensions.end());