HDFGroup / vol-rest

HDF5 REST VOL Connector
Other
5 stars 8 forks source link

External Links Failing in Vol-Rest #24

Closed ron-kuhn closed 1 year ago

ron-kuhn commented 1 year ago

I have a main hdf5 object that has external links to other child hdf5 objects. When using the vol-rest to open a group across the external link, vol-rest recognizes the external link and HSDS actually finds the linked object in the child but the vol-rest sets the main file for the domain in the RV_object_t object instead of the child file. When doing the next operation on the child object, the vol specifies the main file in the URL header. HSDS does find the URI for the child in its cache but returns that the "Object id is not a member of the given domain" and result in failure for the call.

In don't think this is a hard fix and will fix a couple of my issues.

ron-kuhn commented 1 year ago

After some more investigation, inside the RV_group_open function in rest_vol_group.c, the group domain is set to parent's: group->domain = parent->domain The HTTP response has the name of the child file for external links so it can be parsed by RV_copy_object_URI_callback and compared with the parent and updated in the group.

ron-kuhn commented 1 year ago

Made a temporary fix just to test out updating the domain if call to RV_find_object_by_path has to go through an external link. This is only to test if this will fix the problem stated above:

` if (H5L_TYPE_EXTERNAL == link_info.type) { / Unpack the external link's value buffer / if (H5Lunpack_elink_val(tmp_link_val, link_val_len, NULL, &ext_filename, &ext_obj_path) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't unpack external link's value buffer");

            /* Attempt to open the file referenced by the external link using the same access flags as
             * used to open the file that the link resides within.
             */
            if (external_file)
            {
                RV_object_t* external_file_tmp = external_file;
                external_file = NULL;
                if (RV_file_close(external_file_tmp, H5P_DEFAULT, NULL) < 0)
                    FUNC_DONE_ERROR(H5E_LINK, H5E_CANTCLOSEOBJ, FAIL, "can't close file referenced by external link");
            }

            if (NULL == (external_file = RV_file_open(ext_filename, parent_obj->domain->u.file.intent,
                    parent_obj->domain->u.file.fapl_id, H5P_DEFAULT, NULL)))
                FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "can't open file referenced by external link");

            parent_obj = external_file;
            obj_path = ext_obj_path;
        } /* end if */`

`htri_t RV_find_object_by_path(RV_object_t parent_obj, const char obj_path, H5I_type_t target_object_type, herr_t(obj_found_callback)(char, void, void), void callback_data_in, void* callback_data_out) { if (external_file) { RV_file_close(external_file, H5P_DEFAULT, NULL); external_file = NULL; }

return RV_find_object_by_path2(parent_obj, obj_path, target_object_type, obj_found_callback, callback_data_in, callback_data_out);

} `

This allowed me to access my external groups from the main file. Obviously, there is a better way to do this but fixes my immediate problem and shows you the problem. If I were to write the vol-rest, I would do it in cpp so that you won't have to copy everything (std::share_ptr) and remove the need for global data in rest_vol.c.

mattjala commented 1 year ago

Fixed in #30