1#ifndef CHIHAYA_DENSE_ARRAY_HPP
2#define CHIHAYA_DENSE_ARRAY_HPP
5#include "ritsuko/ritsuko.hpp"
6#include "ritsuko/hdf5/hdf5.hpp"
12#include "utils_type.hpp"
13#include "utils_dimnames.hpp"
26namespace dense_array {
40 auto dhandle = ritsuko::hdf5::open_dataset(handle,
"data");
41 auto dspace = dhandle.getSpace();
42 auto ndims = dspace.getSimpleExtentNdims();
44 throw std::runtime_error(
"'data' should have non-zero dimensions for a dense array");
47 std::vector<hsize_t> dims(ndims);
48 dspace.getSimpleExtentDims(dims.data());
52 if (version.lt(1, 1, 0)) {
53 output.
type = internal_type::translate_type_0_0(dhandle.getTypeClass());
54 if (internal_type::is_boolean(dhandle)) {
55 output.
type = BOOLEAN;
58 auto type = ritsuko::hdf5::open_and_load_scalar_string_attribute(dhandle,
"type");
59 output.
type = internal_type::translate_type_1_1(type);
60 internal_type::check_type_1_1(dhandle, output.
type);
63 if (!options.details_only) {
64 internal_misc::validate_missing_placeholder(dhandle, version);
67 if (dhandle.getTypeClass() == H5T_STRING) {
68 ritsuko::hdf5::validate_nd_string_dataset(dhandle, dims, 1000000);
71 }
catch (std::exception& e) {
72 throw std::runtime_error(
"failed to validate 'data'; " + std::string(e.what()));
78 auto nhandle = ritsuko::hdf5::open_dataset(handle,
"native");
79 if (!ritsuko::hdf5::is_scalar(nhandle)) {
80 throw std::runtime_error(
"'native' should be a scalar");
83 if (version.lt(1, 1, 0)) {
84 if (nhandle.getTypeClass() != H5T_INTEGER) {
85 throw std::runtime_error(
"'native' should have an integer datatype");
87 native = ritsuko::hdf5::load_scalar_numeric_dataset<int>(nhandle);
89 if (ritsuko::hdf5::exceeds_integer_limit(nhandle, 8,
true)) {
90 throw std::runtime_error(
"'native' should have a datatype that fits into an 8-bit signed integer");
92 native = ritsuko::hdf5::load_scalar_numeric_dataset<int8_t>(nhandle);
97 if (!options.details_only) {
98 if (handle.exists(
"dimnames")) {
99 internal_dimnames::validate(handle, output.
dimensions, version);
ArrayDetails validate(const H5::Group &handle, const ritsuko::Version &version, Options &options)
Definition: dense_array.hpp:36
Namespace for all chihaya functions.
Definition: binary_arithmetic.hpp:22
Details about an array.
Definition: utils_public.hpp:36
std::vector< size_t > dimensions
Definition: utils_public.hpp:56
ArrayType type
Definition: utils_public.hpp:50
Validation options.
Definition: utils_public.hpp:66
Various public utilities.