- Make sure the other .h5 file isn't open before accessing the link. HDF5 handles the file read permissions in this way.
- Make sure there is a link in the file you mentioned, you can use H5L.exists or look at the example on this page to make sure of that. https://in.mathworks.com/help/matlab/ref/linkh5l.html#mw_681053e1-87e1-4ad1-b9a9-255d5cd7e182
- As from the errors, it says link not found and traversal failed, you can try to iterate through all the links, if more than one are available, using the functions available on the previous link.
- As for H5P_SET_ELINK_PREFIX, sets the "External Link Prefix" property for accessing the links in the hdf5 file and is probably not implemented, in MATLAB low-level H5 functions. This property prepends a prefix in the external link. However if the files are in the same directory, this shouldn't be the root cause.
Repairing external links in hdf5 files - equivalent to H5P_SET_ELINK_PREFIX
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have two hdf5 files foo.h5 and bar.h5. Foo has an external link to data contained in bar. However, when I attempt to read data via the link I get an hdf5lib2 error. I suspect that the issue is being unable to traverse the external link; it is not looking in the right place for the linked file. I found other folks with a similar question (not in Matlab) that pointed to https://portal.hdfgroup.org/display/HDF5/H5P_SET_ELINK_PREFIX . However, that does not appear to be implemented in the Matlab H5 library. Any suggestions would be very helpful.
General example:
foo.h5 and bar.h5 are in the same folder
grp = '/example'; % dataset with other links in bar.h5
% Using low level functions
fid = H5F.open('foo.h5');
gid = H5G.open(fid,grp);
info = H5G.get_info(gid); % returns Struct with fields:
% storage_type: 0 (not sure what this means)
% nlinks : 10
% max_corder : 0 (not sure what this means)
regInfo = h5info('foo.h5'); % Returns struct with fields:
% Filename: 'C:\foo.h5
% Name : '/example'
% Type : 'external link'
% Value : {'bar.h5','/example')
% So far so good. However, this is where things break
idx_type = 'H5_INDEX_NAME';
order = 'H5_ITER_INC';
lapl_id = 'H5P_DEFAULT';
name = H5L.get_name_by_idx(fid,grp,idx_type,order,info.nlinks,lapl_id)
% This returns a large error message.
% Error using hdf5lib2
% The HDF5 library encountered an error and produced the following stack trace information:
%
% H5O_protect address undefined
% H5O_msg_exists unable to protect object header
% H5G__obj_get_linfo unable to read object header
% H5G_obj_get_name_by_idx can't check for link info message
% H5L_get_name_by_idx_cb link not found
% H5G_traverse_real traversal operator failed
% H5G_traverse internal path traversal failed
% H5Lget_name_by_idx name doesn't exist
My interpretation is that it is the external link that is the issue.
I'll note that I can succesfully access the data if I go directly through bar.h5, but this defeats the purpose of the external link. E.g.
fid = H5F.open('bar.h5');
gid = H5G.open(fid,grp);
info = H5G.get_info(gid);
name = H5L.get_name_by_idx(fid,grp,idx_type,order,info.nlinks,lapl_id)
The above works fine.
Thanks in advance.
0 Kommentare
Antworten (1)
Gyan Vaibhav
am 1 Feb. 2024
Hi Dan,
I understand that you have two hdf5 files with one having an external link to the other. However, you mentioned that you can access the link if you open bar.h5, while you have a link in foo.h5, this seems unusual to me. This is my understanding please correct me, if I misunderstood your code and statements.
You can look into the following things:
You can go through this documentation to know more about the various library packages present in the HDF5.
Thanks
Gyan
0 Kommentare
Siehe auch
Kategorien
Mehr zu HDF5 finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!