Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Conversation

@1uc
Copy link
Collaborator

@1uc 1uc commented Mar 15, 2023

The integration tests show that we have issues when dealing with empty datasets, both when reading and writing them. This commit adds testing to cover reading and writing empty datasets using std::vector, Eigen::* and boost::multi_array for datasets and attributes. Furthermore, it fixes the discovered bugs.

@1uc
Copy link
Collaborator Author

1uc commented Mar 15, 2023

These are the result for the integration tests (green):
https://github.com/BlueBrain/HighFive-testing/actions/runs/4427635111/jobs/7765526499#step:6:35

@1uc
Copy link
Collaborator Author

1uc commented Mar 15, 2023

The issues to consider are:

  • Even when loading an empty dataset, since we perform allocation, we need to ensure that the returned object is appropriately empty.
  • For multi-dimensional arrays, there's a difference between (n, m, 0) and (0, m, l), e.g. for nested std::vectors the former is a vector with n vectors, each containing m empty vectors. The latter is just an empty vector.
  • We might need to consider that the shape of std::vector<std::array<T, 2>> is always (n, 2). Therefore, even if n == 0 the next dimension should be deduced as 2. Currently, we unable to get the shape of compile-time constant dimensions correct, in general. We return 1 instead.
  • We currently don't check that in write_raw the buffer isn't the nullptr, nor do we turn it into a no-op. Instead we rely on HDF5 doing the appropriate checks, e.g. if a positive number of elements are to be read into the nullptr.

@1uc 1uc marked this pull request as ready for review March 15, 2023 15:36
@ferdonline
Copy link
Contributor

ferdonline commented Mar 15, 2023

I have checked around and LGTM. It's a pity we have some duplication in Attribute::read/write and Slice::read/write, but improving that is another story.

@1uc 1uc merged commit 70d7b6c into master Mar 17, 2023
@1uc 1uc deleted the 1uc/fix-empty branch March 17, 2023 10:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants