1#ifndef TAKANE_STRING_FACTOR_HPP
2#define TAKANE_STRING_FACTOR_HPP
8#include "ritsuko/hdf5/hdf5.hpp"
11#include "utils_string.hpp"
12#include "utils_factor.hpp"
25namespace string_factor {
33 const std::string type_name =
"string_factor";
34 const auto& vstring = internal_json::extract_version_for_type(metadata.
other, type_name);
35 auto version = ritsuko::parse_version_string(vstring.c_str(), vstring.size(),
true);
36 if (version.major != 1) {
37 throw std::runtime_error(
"unsupported version string '" + vstring +
"'");
40 auto handle = ritsuko::hdf5::open_file(path /
"contents.h5");
41 auto ghandle = ritsuko::hdf5::open_group(handle, type_name.c_str());
42 internal_factor::check_ordered_attribute(ghandle);
44 size_t num_levels = internal_factor::validate_factor_levels(ghandle,
"levels", options.
hdf5_buffer_size);
45 size_t num_codes = internal_factor::validate_factor_codes(ghandle,
"codes", num_levels, options.
hdf5_buffer_size);
47 internal_string::validate_names(ghandle,
"names", num_codes, options.
hdf5_buffer_size);
57 auto handle = ritsuko::hdf5::open_file(path /
"contents.h5");
58 auto ghandle = handle.openGroup(
"string_factor");
59 auto dhandle = ghandle.openDataSet(
"codes");
60 return ritsuko::hdf5::get_1d_length(dhandle.getSpace(),
false);
size_t height(const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options)
Definition string_factor.hpp:56
void validate(const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options)
Definition string_factor.hpp:32
takane validation functions.
Definition _derived_from.hpp:15
Validation options.
Definition utils_public.hpp:94
hsize_t hdf5_buffer_size
Definition utils_public.hpp:103