Commit 1b49696f authored by gbalduzz's avatar gbalduzz
Browse files

Merge branch 'hdf5_cleanup' into write_checkpoints

parents f0a0fa97 eef2eb33
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -159,6 +159,8 @@ private:
  bool verbose_;

  std::mutex mutex_;

  std::vector<hsize_t> size_check_;
};

template <typename arbitrary_struct_t>
+6 −5
Original line number Diff line number Diff line
@@ -114,11 +114,12 @@ void HDF5Writer::write(const std::string& name, const std::vector<hsize_t>& dims
    H5::DataSet dataset = file_->openDataSet(name.c_str());
    H5::DataSpace dataspace = dataset.getSpace();

#ifndef NDEBUG  // Check for a size match.
    std::vector<hsize_t> size_check(dims.size());
    dataspace.getSimpleExtentDims(size_check.data(), nullptr);
    assert(dims == size_check);
#endif
    size_check_.resize(dims.size());
    dataspace.getSimpleExtentDims(size_check_.data(), nullptr);

    if (size_check_ != dims) {
      throw(std::out_of_range("Object size different than HDF5 dataset."));
    }

    dataset.write(data, type, dataspace, H5P_DEFAULT);
  }
+1 −1
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ TEST(HDF5ReaderWriterTest, Overwrite) {
  writer.execute("a", 2);

  // Try to write with different size.
  EXPECT_DEBUG_DEATH(writer.execute("a", std::pair<int, int>(1, 1)), "");
  EXPECT_THROW(writer.execute("a", std::pair<int, int>(1, 1)), std::out_of_range);

  writer.close_file();