-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File size utilities #764
File size utilities #764
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -426,6 +426,56 @@ TEST_CASE("Test groups and datasets") { | |
} | ||
} | ||
|
||
#if H5_VERSION_GE(1, 10, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason it's needed it so set the file space strategy. The newly wrapped functions were introduced in HDF5 1.6.x and don't need guards. |
||
TEST_CASE("FileSizeAndUnusedSpace") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please split the test in two. One for the untracked file and one for the tracked variant. |
||
const std::string file_name_untracked("filesize_untracked_unused.h5"); | ||
const std::string file_name_tracked("filesize_tracked_unused.h5"); | ||
const std::string ds_path("/dataset"); | ||
const std::vector<int> data{13, 24, 36}; | ||
const size_t untracked_file_size = 2048; | ||
const size_t untracked_unused_space = 600; | ||
const size_t tracked_file_size = 1158; | ||
const size_t tracked_unused_space = 103; | ||
|
||
|
||
{ | ||
File file(file_name_untracked, File::ReadWrite | File::Create | File::Truncate); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI this can be reduced down to:
It's consistent with the rest of the file so there's no reason to change it. |
||
auto dset = file.createDataSet(ds_path, data); | ||
} | ||
|
||
{ | ||
FileCreateProps fcp; | ||
fcp.add(FileSpaceStrategy(H5F_FSPACE_STRATEGY_FSM_AGGR, true, 0)); | ||
File file(file_name_tracked, File::ReadWrite | File::Create | File::Truncate, fcp); | ||
auto dset = file.createDataSet(ds_path, data); | ||
} | ||
|
||
{ | ||
File file(file_name_untracked, File::ReadWrite); | ||
CHECK(file.getUnusedSpace() == 0); | ||
file.unlink(ds_path); | ||
CHECK(file.getUnusedSpace() == untracked_unused_space); | ||
} | ||
|
||
{ | ||
File file(file_name_untracked, File::ReadWrite); | ||
CHECK(file.getDiskSize() == untracked_file_size); | ||
CHECK(file.getUnusedSpace() == 0); | ||
} | ||
|
||
{ | ||
File file(file_name_tracked, File::ReadWrite); | ||
file.unlink(ds_path); | ||
} | ||
|
||
{ | ||
File file(file_name_tracked, File::ReadWrite); | ||
CHECK(file.getDiskSize() == tracked_file_size); | ||
CHECK(file.getUnusedSpace() == tracked_unused_space); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you already said, these will fail. Since we're not testing if HDF5 is correct, it might be enough to check that:
|
||
} | ||
#endif | ||
|
||
TEST_CASE("Test extensible datasets") { | ||
const std::string file_name("create_extensible_dataset_example.h5"); | ||
const std::string dataset_name("dset"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a wrapper for the function
H5Fget_filesize
. Could we usegetFileSize
instead?