Skip to content

Commit e816184

Browse files
authored
add: support for H5Dflush and H5Drefesh. (#69)
This commit adds a wrappers for H5D{flush,refresh} and adds two new methods `DataSet::{flush,refresh}`.
1 parent 73c07de commit e816184

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

include/highfive/H5DataSet.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ class DataSet: public Object,
7070
/// \param dims New size of the dataset
7171
void resize(const std::vector<size_t>& dims);
7272

73+
#if H5_VERSION_GE(1, 10, 0)
74+
/// \brief flush
75+
void flush();
76+
#endif
77+
78+
#if H5_VERSION_GE(1, 10, 2)
79+
/// \brief refresh
80+
void refresh();
81+
#endif
7382

7483
/// \brief Get the dimensions of the whole DataSet.
7584
/// This is a shorthand for getSpace().getDimensions()

include/highfive/bits/H5DataSet_misc.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,16 @@ inline void DataSet::resize(const std::vector<size_t>& dims) {
5959
detail::h5d_set_extent(getId(), real_dims.data());
6060
}
6161

62+
#if H5_VERSION_GE(1, 10, 0)
63+
inline void DataSet::flush() {
64+
detail::h5d_flush(_hid);
65+
}
66+
#endif
67+
68+
#if H5_VERSION_GE(1, 10, 2)
69+
inline void DataSet::refresh() {
70+
detail::h5d_refresh(_hid);
71+
}
72+
#endif
73+
6274
} // namespace HighFive

include/highfive/bits/h5d_wrapper.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,28 @@ inline herr_t h5d_write(hid_t dset_id,
7474
return err;
7575
}
7676

77+
#if H5_VERSION_GE(1, 10, 0)
78+
inline herr_t h5d_flush(hid_t dset_id) {
79+
herr_t err = H5Dflush(dset_id);
80+
if (err < 0) {
81+
HDF5ErrMapper::ToException<DataSetException>("Unable to flush the dataset.");
82+
}
83+
84+
return err;
85+
}
86+
#endif
87+
88+
#if H5_VERSION_GE(1, 10, 2)
89+
inline herr_t h5d_refresh(hid_t dset_id) {
90+
herr_t err = H5Drefresh(dset_id);
91+
if (err < 0) {
92+
HDF5ErrMapper::ToException<DataSetException>("Unable to refresh the dataset.");
93+
}
94+
95+
return err;
96+
}
97+
#endif
98+
7799
inline haddr_t h5d_get_offset(hid_t dset_id) {
78100
uint64_t addr = H5Dget_offset(dset_id);
79101
if (addr == HADDR_UNDEF) {

tests/unit/tests_high_five_base.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,9 @@ void readWriteShuffleDeflateTest() {
15881588

15891589
dataset.write(array);
15901590

1591+
#if H5_VERSION_GE(1, 10, 0)
1592+
dataset.flush();
1593+
#endif
15911594
file.flush();
15921595
}
15931596

@@ -1651,6 +1654,9 @@ void readWriteSzipTest() {
16511654

16521655
dataset.write(array);
16531656

1657+
#if H5_VERSION_GE(1, 10, 0)
1658+
dataset.flush();
1659+
#endif
16541660
file.flush();
16551661
}
16561662

tests/unit/tests_high_five_data_type.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ TEST_CASE("HighFiveCompounds") {
101101

102102
file.flush();
103103

104+
#if H5_VERSION_GE(1, 10, 2)
105+
dataset.refresh();
106+
#endif
107+
104108
std::vector<CSL1> result;
105109
dataset.select({0}, {2}).read(result);
106110

@@ -120,6 +124,11 @@ TEST_CASE("HighFiveCompounds") {
120124
dataset.write(csl);
121125

122126
file.flush();
127+
128+
#if H5_VERSION_GE(1, 10, 2)
129+
dataset.refresh();
130+
#endif
131+
123132
std::vector<CSL2> result = {{{1, 1, 1}, {2, 3, 4}}};
124133
dataset.select({0}, {2}).read(result);
125134

@@ -357,6 +366,10 @@ TEST_CASE("HighFiveEnum") {
357366

358367
file.flush();
359368

369+
#if H5_VERSION_GE(1, 10, 2)
370+
dataset.refresh();
371+
#endif
372+
360373
Position result;
361374
dataset.select(ElementSet({0})).read(result);
362375

@@ -377,6 +390,10 @@ TEST_CASE("HighFiveEnum") {
377390

378391
file.flush();
379392

393+
#if H5_VERSION_GE(1, 10, 2)
394+
dataset.refresh();
395+
#endif
396+
380397
std::vector<Direction> result;
381398
dataset.read(result);
382399

0 commit comments

Comments
 (0)