删除或更新 HDF5 中的数据集?

发布于 2024-07-13 02:23:39 字数 136 浏览 5 评论 0原文

我想以编程方式更改与 HDF5 文件中的数据集关联的数据。 我似乎找不到一种方法来按名称删除数据集(允许我使用修改后的数据再次添加它)或按名称更新数据集。 我正在使用 HDF5 1.6.x 的 C API,但指向任何 HDF5 API 的指针都会很有用。

I would like to programatically change the data associated with a dataset in an HDF5 file. I can't seem to find a way to either delete a dataset by name (allowing me to add it again with the modified data) or update a dataset by name. I'm using the C API for HDF5 1.6.x but pointers towards any HDF5 API would be useful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无妨# 2024-07-20 02:23:40

根据用户指南

HDF5 目前不提供一种简单的机制来从文件中删除数据集或回收已删除对象占用的存储空间。

如此简单的删除似乎是不可能的。 但本节继续:

可以使用 H5Ldelete 函数和 h5repack 实用程序。 使用 H5Ldelete 函数,可以从文件结构中删除数据集的链接。 删除所有链接后,任何应用程序都无法访问该数据集,并且会从文件中有效删除。 恢复未链接数据集占用的空间的方法是将文件的所有对象写入新文件。 应用程序无法访问任何未链接的对象,并且不会将其包含在新文件中。 将对象写入新文件可以使用自定义程序或使用 h5repack 实用程序来完成。

According to the user guide:

HDF5 does not at this time provide an easy mechanism to remove a dataset from a file or to reclaim the storage space occupied by a deleted object.

So simple deletion appears to be out of the question. But the section continues:

Removing a dataset and reclaiming the space it used can be done with the H5Ldelete function and the h5repack utility program. With the H5Ldelete function, links to a dataset can be removed from the file structure. After all the links have been removed, the dataset becomes inaccessible to any application and is effectively removed from the file. The way to recover the space occupied by an unlinked dataset is to write all of the objects of the file into a new file. Any unlinked object is inaccessible to the application and will not be included in the new file. Writing objects to a new file can be done with a custom program or with the h5repack utility program.

-柠檬树下少年和吉他 2024-07-20 02:23:40

如果你想在c++中删除一个数据集,你需要以下命令:

H5File m_h5File (pathAndNameToHDF5File, H5F_ACC_RDWR); //The hdf5 c++ object.
std::string channelName = "/myGroup/myDataset";
int result = H5Ldelete(m_h5File.getId(), channelName.data(), H5P_DEFAULT);

如果成功,结果将是一个非负值; 否则返回负值。 https://support.hdfgroup.org/HDF5/doc/ RM/RM_H5L.html#Link-Delete

正如@MaxLybbert所说,硬盘空间没有被回收。 您必须使用重新打包工具。
但是,使用 HDF5 v.1.10 可以恢复空间。 但用户指南尚未准备好: https://support.hdfgroup.org/HDF5 /docNewFeatures/NewFeaturesFileSpaceMgmtDocs.html

If you want to delete a dataset in c++ you need the following commands:

H5File m_h5File (pathAndNameToHDF5File, H5F_ACC_RDWR); //The hdf5 c++ object.
std::string channelName = "/myGroup/myDataset";
int result = H5Ldelete(m_h5File.getId(), channelName.data(), H5P_DEFAULT);

result will be a non-negative value if successful; otherwise returns a negative value. https://support.hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-Delete

As @MaxLybbert said, the hard-disk space it is not recoverd. You must use the repack tool.
However, with HDF5 v.1.10 the space can be recovered. But the user's guide is not ready yet: https://support.hdfgroup.org/HDF5/docNewFeatures/NewFeaturesFileSpaceMgmtDocs.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文