15 bool requireSameFormat,
16 std::size_t bufferSize,
28 const H5::Group& source)
31 bool isEmpty = target.getNumObjs() == 0;
34 for (hsize_t ii = 0; ii < source.getNumObjs(); ++ii) {
35 H5G_obj_t childType = source.getObjTypeByIdx(ii);
36 std::string childName = source.getObjnameByIdx(ii);
38 hsize_t targetIdx = 0;
39 for (; targetIdx < target.getNumObjs(); ++targetIdx)
40 if (target.getObjnameByIdx(targetIdx) == childName)
42 bool found = targetIdx != target.getNumObjs();
45 if (target.getObjTypeByIdx(targetIdx) != childType)
46 throw std::invalid_argument(
47 "Both target and source contain " + childName +
48 " but they have different types!");
51 throw std::invalid_argument(
52 "Target and source have different formats!");
57 H5::Group sg = source.openGroup(childName);
58 H5::Group tg = found ?
59 target.openGroup(childName) :
65 std::cerr <<
"Encountered an error merging child " << childName << std::endl;
72 H5::DataSet sd = source.openDataSet(childName);
73 if (sd.getSpace().getSimpleExtentNdims() == 0) {
74 std::cerr <<
"WARNING: skipping scalar '"
75 << childName <<
"'" << std::endl;
78 H5::DataSet td = found ?
79 target.openDataSet(childName) :
85 std::cerr <<
"Encountered an error merging child " << childName << std::endl;
100 const H5::DataSet& source)
107 std::overflow_error(
"Requested buffer would overflow the register!");
114 H5::H5Location& targetLocation,
115 const H5::DataSet& source)
hsize_t m_mergeAxis
The axis to merge along.
H5::DataSet createFrom(H5::H5Location &targetLocation, const H5::DataSet &source) override
Make a new dataset from information in a source dataset.
int m_chunkSize
The chunk size to apply.
DefaultMerger(hsize_t mergeAxis=0, int chunkSize=-1, bool requireSameFormat=true, std::size_t bufferSize=-1, bool bufferInRows=false)
Create the merger.
std::size_t m_bufferSize
The size of the buffer.
bool m_measureBufferInRows
Whether to measure the buffer in bytes or rows.
void merge(H5::Group &target, const H5::Group &source) override
Merge a source group into a target group.
bool m_requireSameFormat
Whether to require the same group structure.
std::size_t getRowSize(const H5::DataSet &ds, hsize_t axis)
Calculate the size of a row of a dataset in bytes.
H5::DataSet createDataSet(H5::H5Location &targetLocation, const H5::DataSet &source, hsize_t mergeAxis, int chunkSize=-1, int mergeExtent=-1)
Make a new dataset using the properties of another.
void mergeDatasets(H5::DataSet &target, const H5::DataSet &source, hsize_t mergeAxis, std::size_t bufferSize=-1)
Merge two datasets.