ritsuko
Helper utilities for ArtifactDB C++ code
Loading...
Searching...
No Matches
mock_contiguous_chunks.hpp
Go to the documentation of this file.
1#ifndef RITSUKO_HDF5_MOCK_CONTIGUOUS_CHUNKS_HPP
2#define RITSUKO_HDF5_MOCK_CONTIGUOUS_CHUNKS_HPP
3
4#include <vector>
5
6#include "H5Cpp.h"
7#include "sanisizer/sanisizer.hpp"
8
14namespace ritsuko {
15
16namespace hdf5 {
17
30inline std::vector<hsize_t> mock_contiguous_chunks(const std::vector<hsize_t>& dimensions, hsize_t chunk_size) {
31 const auto ndims = dimensions.size();
32 auto output = sanisizer::create<std::vector<hsize_t> >(ndims, 1);
33 // Starting from the end, as this is the fastest-changing.
34 for (auto i = ndims; i > 0; --i) {
35 const auto d = i - 1;
36 if (dimensions[d] == 0) {
37 continue;
38 }
39 if (chunk_size <= dimensions[d]) {
40 output[d] = chunk_size;
41 break;
42 }
43 output[d] = dimensions[d];
44 chunk_size /= dimensions[d];
45 }
46 return output;
47}
48
49}
50
51}
52
53#endif
std::vector< hsize_t > mock_contiguous_chunks(const std::vector< hsize_t > &dimensions, hsize_t chunk_size)
Definition mock_contiguous_chunks.hpp:30
Helper functions for ArtifactDB parsing and validation.
Definition Pointer.hpp:21