Skip to content

Commit

Permalink
H5Fget_obj_ids/count no longer returns transient types
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Mar 8, 2024
1 parent 84ead49 commit 1659792
Show file tree
Hide file tree
Showing 4 changed files with 321 additions and 45 deletions.
51 changes: 25 additions & 26 deletions fortran/test/tH5F.F90
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ SUBROUTINE mountingtest(cleanup, total_error)
INTEGER(HID_T) :: file1_id, file2_id

!
! Group identifier
! Group identifiers
!
INTEGER(HID_T) :: gid
INTEGER(HID_T) :: gid, g1, g2, g3, g4

!
! dataset identifier
Expand Down Expand Up @@ -206,7 +206,6 @@ SUBROUTINE mountingtest(cleanup, total_error)

!number of objects
INTEGER(SIZE_T) :: obj_count
INTEGER(HID_T) :: t1, t2, t3, t4

! File numbers
INTEGER :: file_num1
Expand Down Expand Up @@ -242,28 +241,28 @@ SUBROUTINE mountingtest(cleanup, total_error)
CALL h5_fixname_f(filename2, fix_filename2, H5P_DEFAULT_F, error)
if(error .ne. 0) stop

! Test object counts
CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t1, error)
CALL check(" h5tcopy_f",error,total_error)
CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t2, error)
CALL check(" h5tcopy_f",error,total_error)
CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t3, error)
CALL check(" h5tcopy_f",error,total_error)
CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t4, error)
CALL check(" h5tcopy_f",error,total_error)
!
!Create first file "mount1.h5" using default properties.
!
CALL h5fcreate_f(fix_filename1, H5F_ACC_TRUNC_F, file1_id, error)
CALL check("h5fcreate_f",error,total_error)

! Test object counts
CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error)
CALL check(" h5fget_obj_count_f",error,total_error)

IF(obj_count.NE.4)THEN
IF(obj_count.NE.1)THEN
total_error = total_error + 1
ENDIF

!
!Create first file "mount1.h5" using default properties.
!
CALL h5fcreate_f(fix_filename1, H5F_ACC_TRUNC_F, file1_id, error)
CALL check("h5fcreate_f",error,total_error)
CALL h5gcreate_f(file1_id, "/G1", g1, error)
CALL check(" h5gcopy_f",error, total_error)
CALL h5gcreate_f(file1_id, "/G2", g2, error)
CALL check(" h5gcopy_f",error, total_error)
CALL h5gcreate_f(file1_id, "/G3", g3, error)
CALL check(" h5gcopy_f",error, total_error)
CALL h5gcreate_f(file1_id, "/G4", g4, error)
CALL check(" h5gcopy_f",error, total_error)

CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error)
CALL check(" h5fget_obj_count_f",error,total_error)
Expand All @@ -272,14 +271,14 @@ SUBROUTINE mountingtest(cleanup, total_error)
total_error = total_error + 1
ENDIF

CALL h5tclose_f(t1, error)
CALL check("h5tclose_f",error,total_error)
CALL h5tclose_f(t2, error)
CALL check("h5tclose_f",error,total_error)
CALL h5tclose_f(t3, error)
CALL check("h5tclose_f",error,total_error)
CALL h5tclose_f(t4, error)
CALL check("h5tclose_f",error,total_error)
CALL h5gclose_f(g1, error)
CALL check("h5gclose_f",error,total_error)
CALL h5gclose_f(g2, error)
CALL check("h5gclose_f",error,total_error)
CALL h5gclose_f(g3, error)
CALL check("h5gclose_f",error,total_error)
CALL h5gclose_f(g4, error)
CALL check("h5gclose_f",error,total_error)

CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error)
CALL check(" h5fget_obj_count_f",error,total_error)
Expand Down
6 changes: 6 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ New Features

Library:
--------
- Fixed an issue where copies of transient datatypes were
considered open objects on a file by H5Fget_obj_count
and H5Fget_obj_ids

Addresses GitHub issue #3316

- Implemented optimized support for vector I/O in the Subfiling VFD

Previously, the Subfiling VFD would handle vector I/O requests by
Expand Down
56 changes: 45 additions & 11 deletions src/H5F.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,31 @@ H5Fget_access_plist(hid_t file_id)
*-------------------------------------------------------------------------
*/
static int
H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key)
H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key)
{
H5F_trav_obj_cnt_t *udata = (H5F_trav_obj_cnt_t *)key;
int ret_value = H5_ITER_CONT; /* Return value */
H5F_trav_obj_cnt_t *udata = (H5F_trav_obj_cnt_t *)key;
H5I_type_t obj_type = H5I_UNINIT;
htri_t is_committed = FAIL;
int ret_value = H5_ITER_CONT; /* Return value */

FUNC_ENTER_PACKAGE_NOERR
FUNC_ENTER_PACKAGE

if ((obj_type = H5Iget_type(obj_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5_ITER_ERROR, "object has invalid id type");

if ((obj_type != H5I_DATATYPE)) {
udata->obj_count++;
}
else {
/* Only open committed datatypes should be counted as open datatype objects on the file */
if ((is_committed = H5Tcommitted(obj_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5_ITER_ERROR, "bad datatype");

udata->obj_count++;
if (is_committed)
udata->obj_count++;
}

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_get_all_count_cb */

Expand Down Expand Up @@ -305,17 +321,35 @@ H5Fget_obj_count(hid_t file_id, unsigned types)
static int
H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key)
{
H5F_trav_obj_ids_t *udata = (H5F_trav_obj_ids_t *)key;
int ret_value = H5_ITER_CONT; /* Return value */
H5F_trav_obj_ids_t *udata = (H5F_trav_obj_ids_t *)key;
H5I_type_t obj_type = H5I_UNINIT;
htri_t is_committed = FAIL;
int ret_value = H5_ITER_CONT; /* Return value */

FUNC_ENTER_PACKAGE_NOERR
FUNC_ENTER_PACKAGE

if (udata->obj_count >= udata->max_objs)
HGOTO_DONE(H5_ITER_STOP);

/* Add the ID to the array */
udata->oid_list[udata->obj_count] = obj_id;
udata->obj_count++;
if ((obj_type = H5Iget_type(obj_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5_ITER_ERROR, "object has invalid id type");

if ((obj_type != H5I_DATATYPE)) {
/* Add the ID to the array */
udata->oid_list[udata->obj_count] = obj_id;
udata->obj_count++;
}
else {
/* Only open committed datatypes should be counted as open datatype objects on the file */
if ((is_committed = H5Tcommitted(obj_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5_ITER_ERROR, "bad datatype");

if (is_committed) {
/* Add the ID to the array */
udata->oid_list[udata->obj_count] = obj_id;
udata->obj_count++;
}
}

done:
FUNC_LEAVE_NOAPI(ret_value)
Expand Down
Loading

0 comments on commit 1659792

Please sign in to comment.