Skip to content

Commit

Permalink
Type info table uses hash of URI (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala authored Dec 6, 2023
1 parent c3c9d09 commit f4c06bd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 39 deletions.
8 changes: 4 additions & 4 deletions src/rest_vol_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ RV_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_
printf("-> Created attribute\n\n");
#endif

if (rv_hash_table_insert(RV_type_info_array_g[H5I_ATTR]->table, (char *)new_attribute,
if (rv_hash_table_insert(RV_type_info_array_g[H5I_ATTR]->table, (char *)new_attribute->URI,
(char *)new_attribute) == 0)
FUNC_GOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "Failed to add attribute to type info array");

Expand Down Expand Up @@ -756,8 +756,8 @@ RV_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_na
if ((attribute->u.attribute.acpl_id = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0)
FUNC_GOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create ACPL for attribute");

if (rv_hash_table_insert(RV_type_info_array_g[H5I_ATTR]->table, (char *)attribute, (char *)attribute) ==
0)
if (rv_hash_table_insert(RV_type_info_array_g[H5I_ATTR]->table, (char *)attribute->URI,
(char *)attribute) == 0)
FUNC_GOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "Failed to add attribute to type info array");

ret_value = (void *)attribute;
Expand Down Expand Up @@ -2990,7 +2990,7 @@ RV_attr_close(void *attr, hid_t dxpl_id, void **req)
} /* end if */

if (RV_type_info_array_g[H5I_ATTR])
rv_hash_table_remove(RV_type_info_array_g[H5I_ATTR]->table, (char *)_attr);
rv_hash_table_remove(RV_type_info_array_g[H5I_ATTR]->table, (char *)_attr->URI);

if (RV_file_close(_attr->domain, H5P_DEFAULT, NULL) < 0)
FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "couldn't close attr domain");
Expand Down
43 changes: 19 additions & 24 deletions src/rest_vol_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ RV_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *na
if ((new_dataset->u.dataset.space_id = H5Scopy(space_id)) < 0)
FUNC_GOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "failed to copy dataset's dataspace");

if (rv_hash_table_insert(RV_type_info_array_g[H5I_DATASET]->table, (char *)new_dataset,
if (rv_hash_table_insert(RV_type_info_array_g[H5I_DATASET]->table, (char *)new_dataset->URI,
(char *)new_dataset) == 0)
FUNC_GOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "Failed to add dataset to type info array");

Expand Down Expand Up @@ -341,20 +341,17 @@ void *
RV_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id,
hid_t dxpl_id, void **req)
{
RV_object_t *parent = (RV_object_t *)obj;
RV_object_t *dataset = NULL;
H5I_type_t obj_type = H5I_UNINIT;
htri_t search_ret;
void *ret_value = NULL;
loc_info loc_info_out;
size_t path_size = 0;
size_t path_len = 0;

RV_type_info *type_info = RV_type_info_array_g[H5I_DATASET];
rv_hash_table_iter_t iterator;
rv_hash_table_iterate(type_info->table, &iterator);
hid_t matching_dspace = H5I_INVALID_HID;
RV_object_t *other_dataset = NULL;
RV_object_t *parent = (RV_object_t *)obj;
RV_object_t *dataset = NULL;
H5I_type_t obj_type = H5I_UNINIT;
htri_t search_ret;
void *ret_value = NULL;
loc_info loc_info_out;
size_t path_size = 0;
size_t path_len = 0;
hid_t matching_dspace = H5I_INVALID_HID;
RV_object_t *other_dataset = NULL;
rv_hash_table_value_t table_value = RV_HASH_TABLE_NULL;

#ifdef RV_CONNECTOR_DEBUG
printf("-> Received dataset open call with following parameters:\n");
Expand Down Expand Up @@ -411,13 +408,10 @@ RV_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name

/* If this is another view of an already-opened dataset, make them share the same dataspace
* so that changes to it (e.g. resizes) are visible to both views */
while (rv_hash_table_iter_has_more(&iterator)) {
other_dataset = (RV_object_t *)rv_hash_table_iter_next(&iterator);

if (!strcmp(other_dataset->URI, dataset->URI)) {
matching_dspace = other_dataset->u.dataset.space_id;
break;
}
if ((table_value = rv_hash_table_lookup(RV_type_info_array_g[H5I_DATASET]->table, dataset->URI)) !=
RV_HASH_TABLE_NULL) {
other_dataset = (RV_object_t *)table_value;
matching_dspace = other_dataset->u.dataset.space_id;
}

if (matching_dspace != H5I_INVALID_HID) {
Expand Down Expand Up @@ -453,7 +447,8 @@ RV_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name
FUNC_GOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, NULL,
"can't parse dataset's creation properties from JSON representation");

if (rv_hash_table_insert(RV_type_info_array_g[H5I_DATASET]->table, (char *)dataset, (char *)dataset) == 0)
if (rv_hash_table_insert(RV_type_info_array_g[H5I_DATASET]->table, (char *)dataset->URI,
(char *)dataset) == 0)
FUNC_GOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "Failed to add dataset to type info array");

ret_value = (void *)dataset;
Expand Down Expand Up @@ -1724,7 +1719,7 @@ RV_dataset_close(void *dset, hid_t dxpl_id, void **req)
} /* end if */

if (RV_type_info_array_g[H5I_DATASET])
rv_hash_table_remove(RV_type_info_array_g[H5I_DATASET]->table, (char *)_dset);
rv_hash_table_remove(RV_type_info_array_g[H5I_DATASET]->table, (char *)_dset->URI);

if (RV_file_close(_dset->domain, H5P_DEFAULT, NULL)) {
FUNC_DONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file");
Expand Down
8 changes: 4 additions & 4 deletions src/rest_vol_datatype.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ RV_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *n
if (RV_parse_response(response_buffer.buffer, NULL, new_datatype->URI, RV_copy_object_URI_callback) < 0)
FUNC_GOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't parse committed datatype's URI");

if (rv_hash_table_insert(RV_type_info_array_g[H5I_DATATYPE]->table, (char *)new_datatype,
if (rv_hash_table_insert(RV_type_info_array_g[H5I_DATATYPE]->table, (char *)new_datatype->URI,
(char *)new_datatype) == 0)
FUNC_GOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "Failed to add datatype to type info array");

Expand Down Expand Up @@ -423,8 +423,8 @@ RV_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *nam
if ((datatype->u.datatype.tcpl_id = H5Pcreate(H5P_DATATYPE_CREATE)) < 0)
FUNC_GOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create TCPL for datatype");

if (rv_hash_table_insert(RV_type_info_array_g[H5I_DATATYPE]->table, (char *)datatype, (char *)datatype) ==
0)
if (rv_hash_table_insert(RV_type_info_array_g[H5I_DATATYPE]->table, (char *)datatype->URI,
(char *)datatype) == 0)
FUNC_GOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "Failed to add datatype to type info array");

ret_value = (void *)datatype;
Expand Down Expand Up @@ -576,7 +576,7 @@ RV_datatype_close(void *dt, hid_t dxpl_id, void **req)
} /* end if */

if (RV_type_info_array_g[H5I_DATATYPE])
rv_hash_table_remove(RV_type_info_array_g[H5I_DATATYPE]->table, (char *)_dtype);
rv_hash_table_remove(RV_type_info_array_g[H5I_DATATYPE]->table, (char *)_dtype->URI);

if (RV_file_close(_dtype->domain, H5P_DEFAULT, NULL) < 0)
FUNC_DONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file");
Expand Down
7 changes: 4 additions & 3 deletions src/rest_vol_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ RV_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, h
RV_parse_server_version) < 0)
FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTCREATE, NULL, "can't parse server version");

if (rv_hash_table_insert(RV_type_info_array_g[H5I_FILE]->table, (char *)new_file, (char *)new_file) == 0)
if (rv_hash_table_insert(RV_type_info_array_g[H5I_FILE]->table, (char *)new_file->URI,
(char *)new_file) == 0)
FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "Failed to add file to type info array");

ret_value = (void *)new_file;
Expand Down Expand Up @@ -433,7 +434,7 @@ RV_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, voi
if ((file->u.file.fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0)
FUNC_GOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create FCPL for file");

if (rv_hash_table_insert(RV_type_info_array_g[H5I_FILE]->table, (char *)file, (char *)file) == 0)
if (rv_hash_table_insert(RV_type_info_array_g[H5I_FILE]->table, (char *)file->URI, (char *)file) == 0)
FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "Failed to add file to type info array");

ret_value = (void *)file;
Expand Down Expand Up @@ -894,7 +895,7 @@ RV_file_close(void *file, hid_t dxpl_id, void **req)
}

if (RV_type_info_array_g[H5I_FILE])
rv_hash_table_remove(RV_type_info_array_g[H5I_FILE]->table, (char *)_file);
rv_hash_table_remove(RV_type_info_array_g[H5I_FILE]->table, (char *)_file->URI);

RV_free(_file);
}
Expand Down
8 changes: 4 additions & 4 deletions src/rest_vol_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ RV_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name
if (RV_parse_response(response_buffer.buffer, NULL, new_group->URI, RV_copy_object_URI_callback) < 0)
FUNC_GOTO_ERROR(H5E_SYM, H5E_CANTCREATE, NULL, "can't parse new group's URI");

if (rv_hash_table_insert(RV_type_info_array_g[H5I_GROUP]->table, (char *)new_group, (char *)new_group) ==
0)
if (rv_hash_table_insert(RV_type_info_array_g[H5I_GROUP]->table, (char *)new_group->URI,
(char *)new_group) == 0)
FUNC_GOTO_ERROR(H5E_SYM, H5E_CANTALLOC, NULL, "Failed to add group to type info array");

ret_value = (void *)new_group;
Expand Down Expand Up @@ -438,7 +438,7 @@ RV_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name,
else
group->u.group.gapl_id = H5P_GROUP_ACCESS_DEFAULT;

if (rv_hash_table_insert(RV_type_info_array_g[H5I_GROUP]->table, (char *)group, (char *)group) == 0)
if (rv_hash_table_insert(RV_type_info_array_g[H5I_GROUP]->table, (char *)group->URI, (char *)group) == 0)
FUNC_GOTO_ERROR(H5E_SYM, H5E_CANTALLOC, NULL, "Failed to add group to type info array");

ret_value = (void *)group;
Expand Down Expand Up @@ -717,7 +717,7 @@ RV_group_close(void *grp, hid_t dxpl_id, void **req)
} /* end if */

if (RV_type_info_array_g[H5I_GROUP])
rv_hash_table_remove(RV_type_info_array_g[H5I_GROUP]->table, (char *)_grp);
rv_hash_table_remove(RV_type_info_array_g[H5I_GROUP]->table, (char *)_grp->URI);

if (RV_file_close(_grp->domain, H5P_DEFAULT, NULL) < 0) {
FUNC_DONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file");
Expand Down

0 comments on commit f4c06bd

Please sign in to comment.