diff options
-rw-r--r-- | src/H5Pgcpl.c | 122 | ||||
-rw-r--r-- | src/H5Ppublic.h | 10 | ||||
-rw-r--r-- | test/links.c | 78 |
3 files changed, 68 insertions, 142 deletions
diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index 2fa79e1..16046db 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -395,9 +395,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pset_creation_order_tracking + * Function: H5Pset_link_creation_order * - * Purpose: Set the flag to track creation order of links in a group + * Purpose: Set the flags for creation order of links in a group * * Return: Non-negative on success/Negative on failure * @@ -406,14 +406,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_creation_order_tracking(hid_t plist_id, hbool_t track_corder) +H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags) { H5P_genplist_t *plist; /* Property list pointer */ H5O_ginfo_t ginfo; /* Group information structure */ + H5O_linfo_t linfo; /* Link information structure */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Pset_creation_order_tracking, FAIL) - H5TRACE2("e","ib",plist_id,track_corder); + FUNC_ENTER_API(H5Pset_link_creation_order, FAIL) + + /* Check for bad combination of flags */ + if(!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tracking creation order is required for index") /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) @@ -423,90 +427,19 @@ H5Pset_creation_order_tracking(hid_t plist_id, hbool_t track_corder) if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") - /* Update fields */ - ginfo.track_corder = track_corder; + /* Update field */ + ginfo.track_corder = (crt_order_flags & H5P_CRT_ORDER_TRACKED) ? TRUE : FALSE; /* Set group info */ if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pset_creation_order_tracking() */ - - -/*------------------------------------------------------------------------- - * Function: H5Pget_creation_order_tracking - * - * Purpose: Returns the flag indicating that creation order is tracked - * for links in a group. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * September 12, 2006 - *------------------------------------------------------------------------- - */ -herr_t -H5Pget_creation_order_tracking(hid_t plist_id, hbool_t *track_corder /*out*/) -{ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_API(H5Pget_creation_order_tracking, FAIL) - H5TRACE2("e","ix",plist_id,track_corder); - - /* Get values */ - if(track_corder) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ - - /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - - /* Get group info */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") - - *track_corder = ginfo.track_corder; - } /* end if */ - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pget_creation_order_tracking() */ - - -/*------------------------------------------------------------------------- - * Function: H5Pset_creation_order_index - * - * Purpose: Set the flag to index creation order of links in a group - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * October 30, 2006 - *------------------------------------------------------------------------- - */ -herr_t -H5Pset_creation_order_index(hid_t plist_id, hbool_t index_corder) -{ - H5P_genplist_t *plist; /* Property list pointer */ - H5O_linfo_t linfo; /* Link information structure */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(H5Pset_creation_order_index, FAIL) - H5TRACE2("e","ib",plist_id,index_corder); - - /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Get link info */ if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") - /* Update fields */ - linfo.index_corder = index_corder; + /* Update field */ + linfo.index_corder = (crt_order_flags & H5P_CRT_ORDER_INDEXED) ? TRUE : FALSE; /* Set link info */ if(H5P_set(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) @@ -514,46 +447,55 @@ H5Pset_creation_order_index(hid_t plist_id, hbool_t index_corder) done: FUNC_LEAVE_API(ret_value) -} /* end H5Pset_creation_order_index() */ +} /* end H5Pset_link_creation_order() */ /*------------------------------------------------------------------------- - * Function: H5Pget_creation_order_index + * Function: H5Pget_creation_order_tracking * - * Purpose: Returns the flag indicating that creation order is indexed + * Purpose: Returns the flag indicating that creation order is tracked * for links in a group. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * October 30, 2006 + * September 12, 2006 *------------------------------------------------------------------------- */ herr_t -H5Pget_creation_order_index(hid_t plist_id, hbool_t *index_corder /*out*/) +H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /*out*/) { herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_API(H5Pget_creation_order_index, FAIL) - H5TRACE2("e","ix",plist_id,index_corder); + FUNC_ENTER_API(H5Pget_link_creation_order, FAIL) /* Get values */ - if(index_corder) { + if(crt_order_flags) { H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ H5O_linfo_t linfo; /* Link information structure */ + /* Reset the value to return */ + *crt_order_flags = 0; + /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + /* Get group info */ + if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") + + *crt_order_flags |= ginfo.track_corder ? H5P_CRT_ORDER_TRACKED : 0; + /* Get link info */ if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") - *index_corder = linfo.index_corder; + *crt_order_flags |= linfo.index_corder ? H5P_CRT_ORDER_INDEXED : 0; } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* end H5Pget_creation_order_index() */ +} /* end H5Pget_link_creation_order() */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index ea929b8..8d15c22 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -88,6 +88,10 @@ #define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_g) #define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_g) +/* Common creation order flags (for links in groups and attributes on objects) */ +#define H5P_CRT_ORDER_TRACKED 0x0001 +#define H5P_CRT_ORDER_INDEXED 0x0002 + #ifdef __cplusplus extern "C" { #endif @@ -382,10 +386,8 @@ H5_DLL herr_t H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, uns H5_DLL herr_t H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, unsigned *min_dense /*out*/); H5_DLL herr_t H5Pset_est_link_info(hid_t plist_id, unsigned est_num_entries, unsigned est_name_len); H5_DLL herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /* out */, unsigned *est_name_len /* out */); -H5_DLL herr_t H5Pset_creation_order_tracking(hid_t plist_id, hbool_t track_corder); -H5_DLL herr_t H5Pget_creation_order_tracking(hid_t plist_id, hbool_t *track_corder /* out */); -H5_DLL herr_t H5Pset_creation_order_index(hid_t plist_id, hbool_t index_corder); -H5_DLL herr_t H5Pget_creation_order_index(hid_t plist_id, hbool_t *index_corder /* out */); +H5_DLL herr_t H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags); +H5_DLL herr_t H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /* out */); /* String creation property list (SCPL) routines */ H5_DLL herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding); diff --git a/test/links.c b/test/links.c index 1eba67e..8623c82 100644 --- a/test/links.c +++ b/test/links.c @@ -1297,7 +1297,7 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) int64_t old_corder; /* Creation order value of link */ time_t old_modification_time; time_t curr_time; - hbool_t track_corder; /* Status of creation order tracking for GCPL */ + unsigned crt_order_flags; /* Status of creation order info for GCPL */ char filename[1024]; if(new_format) @@ -1309,11 +1309,11 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) * in the root group */ if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR - if(H5Pget_creation_order_tracking(fcpl_id, &track_corder) < 0) TEST_ERROR - if(track_corder != FALSE) TEST_ERROR - if(H5Pset_creation_order_tracking(fcpl_id, TRUE) < 0) TEST_ERROR - if(H5Pget_creation_order_tracking(fcpl_id, &track_corder) < 0) TEST_ERROR - if(track_corder != TRUE) TEST_ERROR + if(H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) TEST_ERROR + if(crt_order_flags != 0) TEST_ERROR + if(H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED) < 0) TEST_ERROR + if(H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) TEST_ERROR + if(crt_order_flags != H5P_CRT_ORDER_TRACKED) TEST_ERROR /* Create file */ /* (with creation order tracking for the root group) */ @@ -5199,8 +5199,8 @@ corder_create_empty(hid_t fapl) hid_t file_id = (-1); /* File ID */ hid_t group_id = (-1); /* Group ID */ hid_t gcpl_id = (-1); /* Group creation property list ID */ - hbool_t track_corder; /* Status of creation order tracking for GCPL */ - hbool_t index_corder; /* Status of creation order indexing for GCPL */ + unsigned crt_order_flags; /* Status of creation order info for GCPL */ + herr_t ret; /* Generic return value */ char filename[NAME_BUF_SIZE];/* File name */ TESTING("creating empty group with creation order indexing") @@ -5213,29 +5213,25 @@ corder_create_empty(hid_t fapl) if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR /* Set creation order indexing on group */ - if(H5Pget_creation_order_index(gcpl_id, &index_corder) < 0) TEST_ERROR - if(index_corder != FALSE) TEST_ERROR - if(H5Pset_creation_order_index(gcpl_id, TRUE) < 0) TEST_ERROR - if(H5Pget_creation_order_index(gcpl_id, &index_corder) < 0) TEST_ERROR - if(index_corder != TRUE) TEST_ERROR + if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) TEST_ERROR + if(crt_order_flags != 0) TEST_ERROR /* Creating a group with onder creation order indexing on should fail */ H5E_BEGIN_TRY { - group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT); + ret = H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_INDEXED); } H5E_END_TRY; if(group_id > 0) { - H5Gclose(group_id); H5_FAILED(); - puts(" H5Gcreate_expand() should have failed for a creation order index with no tracking."); + puts(" H5Pset_link_create_order() should have failed for a creation order index with no tracking."); TEST_ERROR } /* end if */ - /* Set creation order tracking on group */ - if(H5Pget_creation_order_tracking(gcpl_id, &track_corder) < 0) TEST_ERROR - if(track_corder != FALSE) TEST_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR - if(H5Pget_creation_order_tracking(gcpl_id, &track_corder) < 0) TEST_ERROR - if(track_corder != TRUE) TEST_ERROR + /* Set creation order tracking & indexing on group */ + if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) TEST_ERROR + if(crt_order_flags != 0) TEST_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR + if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) TEST_ERROR + if(crt_order_flags != (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) TEST_ERROR /* Create group with creation order indexing & tracking on */ if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5267,10 +5263,8 @@ corder_create_empty(hid_t fapl) if((gcpl_id = H5Gget_create_plist(group_id)) < 0) TEST_ERROR /* Query the group creation properties */ - if(H5Pget_creation_order_index(gcpl_id, &index_corder) < 0) TEST_ERROR - if(index_corder != TRUE) TEST_ERROR - if(H5Pget_creation_order_tracking(gcpl_id, &track_corder) < 0) TEST_ERROR - if(track_corder != TRUE) TEST_ERROR + if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) TEST_ERROR + if(crt_order_flags != (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) TEST_ERROR /* Close the group creation property list */ if(H5Pclose(gcpl_id) < 0) TEST_ERROR @@ -5331,8 +5325,7 @@ corder_create_compact(hid_t fapl) if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_creation_order_index(gcpl_id, TRUE) < 0) TEST_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR /* Create group with creation order indexing & tracking on */ if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5453,8 +5446,7 @@ corder_create_dense(hid_t fapl) if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_creation_order_index(gcpl_id, TRUE) < 0) TEST_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR /* Create group with creation order indexing & tracking on */ if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5590,8 +5582,7 @@ corder_transition(hid_t fapl) if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) FAIL_STACK_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_creation_order_index(gcpl_id, TRUE) < 0) FAIL_STACK_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) FAIL_STACK_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR /* Query the group creation properties */ if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) FAIL_STACK_ERROR @@ -5834,8 +5825,7 @@ corder_delete(hid_t fapl) if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) FAIL_STACK_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_creation_order_index(gcpl_id, TRUE) < 0) FAIL_STACK_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) FAIL_STACK_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR /* Query the group creation properties */ if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) FAIL_STACK_ERROR @@ -6125,9 +6115,7 @@ link_info_by_idx(hid_t fapl) if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR /* Set creation order tracking & indexing on group */ - if(use_index) - if(H5Pset_creation_order_index(gcpl_id, TRUE) < 0) TEST_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR /* Create group with creation order indexing & tracking on */ if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6501,9 +6489,7 @@ delete_by_idx(hid_t fapl) if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR /* Set creation order tracking & indexing on group */ - if(use_index) - if(H5Pset_creation_order_index(gcpl_id, TRUE) < 0) TEST_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR /* Create group with creation order tracking on */ if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR @@ -7359,8 +7345,7 @@ link_iterate(hid_t fapl) if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_creation_order_index(gcpl_id, use_index) < 0) TEST_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR /* Create group with creation order tracking on */ if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR @@ -8052,8 +8037,7 @@ open_by_idx(hid_t fapl) if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_creation_order_index(gcpl_id, use_index) < 0) TEST_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR /* Create group with creation order tracking on */ if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR @@ -8510,8 +8494,7 @@ object_info(hid_t fapl) if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_creation_order_index(gcpl_id, use_index) < 0) TEST_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR /* Create group with creation order tracking on */ if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR @@ -8905,8 +8888,7 @@ group_info(hid_t fapl) if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_creation_order_index(gcpl_id, use_index) < 0) TEST_ERROR - if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR + if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR /* Create group with creation order tracking on */ if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR |