ritsuko
Helper utilities for ArtifactDB C++ code
Loading...
Searching...
No Matches
pick_1d_block_size.hpp
Go to the documentation of this file.
1#ifndef RITSUKO_PICK_1D_BLOCK_SIZE_HPP
2#define RITSUKO_PICK_1D_BLOCK_SIZE_HPP
3
4#include "H5Cpp.h"
5
11namespace ritsuko {
12
13namespace hdf5 {
14
26inline hsize_t pick_1d_block_size(const H5::DSetCreatPropList& cplist, hsize_t full_length, hsize_t buffer_size = 10000) {
27 if (full_length < buffer_size) {
28 return full_length;
29 }
30
31 if (cplist.getLayout() != H5D_CHUNKED) {
32 return buffer_size;
33 }
34
35 hsize_t chunk_size;
36 cplist.getChunk(1, &chunk_size);
37
38 // Finding the number of chunks to load per iteration; this is either
39 // the largest multiple below 'buffer_size' or the chunk size.
40 int num_chunks = (buffer_size / chunk_size);
41 if (num_chunks == 0) {
42 num_chunks = 1;
43 }
44
45 // This is already guaranteed to be less than 'full_length', as
46 // 'chunk_size <= full_length' from HDF5.
47 return num_chunks * chunk_size;
48}
49
50}
51
52}
53
54#endif
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
Assorted helper functions for parsing and validation.
Definition choose_missing_placeholder.hpp:15