diff options
-rw-r--r-- | release_docs/RELEASE.txt | 6 | ||||
-rw-r--r-- | src/H5G.c | 249 | ||||
-rw-r--r-- | src/H5Gdeprec.c | 62 | ||||
-rw-r--r-- | src/H5Gent.c | 2 | ||||
-rw-r--r-- | src/H5Gobj.c | 35 | ||||
-rw-r--r-- | src/H5Gpkg.h | 9 | ||||
-rw-r--r-- | src/H5Gpublic.h | 29 | ||||
-rw-r--r-- | src/H5O.c | 25 | ||||
-rw-r--r-- | test/links.c | 522 |
9 files changed, 815 insertions, 124 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 821b071..5c8b8de 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -160,6 +160,12 @@ New Features Library: -------- + - Added new H5Gget_info_by_idx() routine to query the information about + a group according to the order within an index. + - QAK - 2006/11/27 + - Added new H5Gget_info() routine to query the information about a + group by name. + - QAK - 2006/11/27 - Added new H5Oget_info_by_idx() routine to query the information about an object in a group according to the order within an index. - QAK - 2006/11/26 @@ -404,7 +404,7 @@ done: } /* end if */ FUNC_LEAVE_API(ret_value) -} /* H5Gopen() */ +} /* end H5Gopen() */ /*------------------------------------------------------------------------- @@ -489,88 +489,7 @@ done: } /* end if */ FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Gclose - * - * Purpose: Closes the specified group. The group ID will no longer be - * valid for accessing the group. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Wednesday, December 31, 1997 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Gclose(hid_t group_id) -{ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_API(H5Gclose, FAIL); - H5TRACE1("e","i",group_id); - - /* Check args */ - if (NULL == H5I_object_verify(group_id,H5I_GROUP)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); - - /* - * Decrement the counter on the group atom. It will be freed if the count - * reaches zero. - */ - if (H5I_dec_ref(group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group"); - -done: - FUNC_LEAVE_API(ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5Gget_num_objs - * - * Purpose: Returns the number of objects in the group. It iterates - * all B-tree leaves and sum up total number of group members. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Raymond Lu - * Nov 20, 2002 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) -{ - H5G_loc_t loc; /* Location of object */ - H5O_type_t obj_type; /* Type of object at location */ - herr_t ret_value; - - FUNC_ENTER_API(H5Gget_num_objs, FAIL) - H5TRACE2("e","i*h",loc_id,num_objs); - - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - if(!num_objs) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nil pointer") - - /* Call private function. */ - if((ret_value = H5G_obj_count(loc.oloc, num_objs, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine ") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Gget_num_objs() */ +} /* end H5Gopen_expand() */ /*------------------------------------------------------------------------- @@ -657,6 +576,170 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_create_plist() */ + +/*------------------------------------------------------------------------- + * Function: H5Gget_info + * + * Purpose: Retrieve information about a group. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 27 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gget_info(hid_t loc_id, const char *name, H5G_info_t *grp_info, hid_t lapl_id) +{ + H5G_loc_t loc; /* Location of group */ + H5G_loc_t grp_loc; /* Location used to open group */ + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Gget_info, FAIL) + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if(!grp_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Set up opened group location to fill in */ + grp_loc.oloc = &grp_oloc; + grp_loc.path = &grp_path; + H5G_loc_reset(&grp_loc); + + /* Find the group object */ + if(H5G_loc_find(&loc, name, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + loc_found = TRUE; + + /* Retrieve the group's information */ + if(H5G_obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + +done: + if(loc_found && H5G_loc_free(&grp_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5Gget_info_by_idx + * + * Purpose: Retrieve information about a group, according to the order + * of an index. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 27 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info, hid_t lapl_id) +{ + H5G_loc_t loc; /* Location of group */ + H5G_loc_t grp_loc; /* Location used to open group */ + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Gget_info_by_idx, FAIL) + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!group_name || !*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if(!grp_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Set up opened group location to fill in */ + grp_loc.oloc = &grp_oloc; + grp_loc.path = &grp_path; + H5G_loc_reset(&grp_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + loc_found = TRUE; + + /* Retrieve the group's information */ + if(H5G_obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + +done: + /* Release the object location */ + if(loc_found && H5G_loc_free(&grp_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_info_by_idx() */ + + +/*------------------------------------------------------------------------- + * Function: H5Gclose + * + * Purpose: Closes the specified group. The group ID will no longer be + * valid for accessing the group. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Wednesday, December 31, 1997 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gclose(hid_t group_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Gclose, FAIL); + H5TRACE1("e","i",group_id); + + /* Check args */ + if(NULL == H5I_object_verify(group_id,H5I_GROUP)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + + /* + * Decrement the counter on the group atom. It will be freed if the count + * reaches zero. + */ + if(H5I_dec_ref(group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Gclose() */ + /* *------------------------------------------------------------------------- *------------------------------------------------------------------------- diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 2a3d150..20b3096 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -625,9 +625,8 @@ H5G_set_comment(H5G_loc_t *loc, const char *name, const char *buf, hid_t dxpl_id done: /* Release obj_loc */ - if(loc_valid) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location") + if(loc_valid && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_set_comment() */ @@ -684,9 +683,8 @@ H5G_get_comment(H5G_loc_t *loc, const char *name, size_t bufsize, char *buf, hid done: /* Release obj_loc */ - if(loc_valid) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location") + if(loc_valid && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_comment() */ @@ -704,6 +702,8 @@ done: * group being iterated, a member name, and OP_DATA for each * member. * + * Note: Deprecated in favor of H5Literate + * * Return: Success: The return value of the first operator that * returns non-zero, or zero if all members were * processed with no operator returning non-zero. @@ -766,7 +766,6 @@ done: * Note: Deprecated in favor of H5Lget_info/H5Oget_info * * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) - * * Failure: H5G_UNKNOWN * * Programmer: Raymond Lu @@ -990,3 +989,52 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_objinfo() */ + +/*------------------------------------------------------------------------- + * Function: H5Gget_num_objs + * + * Purpose: Returns the number of objects in the group. It iterates + * all B-tree leaves and sum up total number of group members. + * + * Note: Deprecated in favor of H5Gget_info + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Raymond Lu + * Nov 20, 2002 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) +{ + H5G_loc_t loc; /* Location of object */ + H5G_info_t grp_info; /* Group information */ + H5O_type_t obj_type; /* Type of object at location */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(H5Gget_num_objs, FAIL) + H5TRACE2("e","i*h",loc_id,num_objs); + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_GROUP) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + if(!num_objs) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") + + /* Retrieve information about the group */ + if(H5G_obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine") + + /* Set the number of objects [sic: links] in the group */ + *num_objs = grp_info.nlinks; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_num_objs() */ + diff --git a/src/H5Gent.c b/src/H5Gent.c index e011a05..56ec885 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -128,7 +128,7 @@ H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) H5F_addr_decode(f, pp, &(ent->header)); UINT32DECODE(*pp, tmp); *pp += 4; /*reserved*/ - ent->type=(H5G_type_t)tmp; + ent->type=(H5G_cache_type_t)tmp; /* decode scratch-pad */ switch (ent->type) { diff --git a/src/H5Gobj.c b/src/H5Gobj.c index c1d81b5..45e6640 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -657,47 +657,60 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_obj_count + * Function: H5G_obj_info * - * Purpose: Check the number of objects in a group + * Purpose: Retrieve information about a group * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 6 2005 + * koziol@hdfgroup.org + * Nov 27 2006 * *------------------------------------------------------------------------- */ herr_t -H5G_obj_count(H5O_loc_t *oloc, hsize_t *num_objs, hid_t dxpl_id) +H5G_obj_info(H5O_loc_t *oloc, H5G_info_t *grp_info, hid_t dxpl_id) { H5O_linfo_t linfo; /* Link info message */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5G_obj_count, FAIL) + FUNC_ENTER_NOAPI(H5G_obj_info, FAIL) /* Sanity check */ HDassert(oloc); - HDassert(num_objs); + HDassert(grp_info); /* Attempt to get the link info for this group */ if(H5O_read(oloc, H5O_LINFO_ID, 0, &linfo, dxpl_id)) { - /* Set the number of objects */ - *num_objs = linfo.nlinks; + /* Retrieve the information about the links */ + grp_info->nlinks = linfo.nlinks; + grp_info->min_corder = linfo.min_corder; + grp_info->max_corder = linfo.max_corder; + + /* Check if the group is using compact or dense storage for its links */ + if(H5F_addr_defined(linfo.link_fheap_addr)) + grp_info->storage_type = H5G_STORAGE_TYPE_DENSE; + else + grp_info->storage_type = H5G_STORAGE_TYPE_COMPACT; } /* end if */ else { /* Clear error stack from not finding the link info message */ H5E_clear_stack(NULL); /* Get the number of objects in this group by iterating over symbol table */ - if(H5G_stab_count(oloc, num_objs, dxpl_id) < 0) + if(H5G_stab_count(oloc, &grp_info->nlinks, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't count objects") + + /* Set the other information about the group */ + grp_info->storage_type = H5G_STORAGE_TYPE_SYMBOL_TABLE; + grp_info->min_corder = 0; + grp_info->max_corder = 0; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_obj_count() */ +} /* end H5G_obj_info() */ /*------------------------------------------------------------------------- diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 8b23cd5..fdc0515 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -65,14 +65,14 @@ * points). This datatype determines what (if anything) is cached in the * symbol table entry. */ -typedef enum H5G_type_t { +typedef enum H5G_cache_type_t { H5G_CACHED_ERROR = -1, /*force enum to be signed */ H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */ H5G_CACHED_STAB = 1, /*symbol table, `stab' */ H5G_CACHED_SLINK = 2, /*symbolic link */ H5G_NCACHED /*THIS MUST BE LAST */ -} H5G_type_t; +} H5G_cache_type_t; /* * A symbol table entry caches these parameters from object header @@ -100,7 +100,7 @@ typedef union H5G_cache_t { */ typedef struct H5G_entry_t { hbool_t dirty; /*entry out-of-date? */ - H5G_type_t type; /*type of information cached */ + H5G_cache_type_t type; /*type of information cached */ H5G_cache_t cache; /*cached data from object header */ size_t name_off; /*offset of name within name heap */ haddr_t header; /*file address of object header */ @@ -510,8 +510,7 @@ H5_DLL herr_t H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5_DLL herr_t H5G_obj_iterate(hid_t loc_id, const char *group_name, H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_obj, H5G_link_iterate_t *lnk_op, void *op_data, hid_t dxpl_id); -H5_DLL herr_t H5G_obj_count(struct H5O_loc_t *oloc, hsize_t *num_objs, - hid_t dxpl_id); +H5_DLL herr_t H5G_obj_info(H5O_loc_t *oloc, H5G_info_t *grp_info, hid_t dxpl_id); H5_DLL ssize_t H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id); H5_DLL H5G_obj_t H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 26e6c89..61c419a 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -38,13 +38,14 @@ /* Public Macros */ /*****************/ +/* Deprecated macros, for backward compatibility */ + /* Macros for types of objects in a group (see H5G_obj_t definition) */ #define H5G_NTYPES 256 /* Max possible number of types */ #define H5G_NLIBTYPES 8 /* Number of internal types */ #define H5G_NUSERTYPES (H5G_NTYPES-H5G_NLIBTYPES) #define H5G_USERTYPE(X) (8+(X)) /* User defined types */ -/* Deprecated macros, for backward compatibility */ #define H5G_LINK_ERROR H5L_TYPE_ERROR #define H5G_LINK_HARD H5L_TYPE_HARD #define H5G_LINK_SOFT H5L_TYPE_SOFT @@ -59,6 +60,25 @@ extern "C" { /* Public Typedefs */ /*******************/ +/* Types of link storage for groups */ +typedef enum H5G_storage_type_t { + H5G_STORAGE_TYPE_UNKNOWN = -1, /* Unknown link storage type */ + H5G_STORAGE_TYPE_SYMBOL_TABLE, /* Links in group are stored with a "symbol table" */ + /* (this is sometimes called "old-style" groups) */ + H5G_STORAGE_TYPE_COMPACT, /* Links are stored in object header */ + H5G_STORAGE_TYPE_DENSE /* Links are stored in fractal heap & indexed with v2 B-tree */ +} H5G_storage_type_t; + +/* Information struct for group (for H5Gget_info/H5Gget_info_by_idx) */ +typedef struct H5G_info_t { + H5G_storage_type_t storage_type; /* Type of storage for links in group */ + hsize_t nlinks; /* Number of links in group */ + int64_t min_corder; /* Current min. creation order value for group */ + int64_t max_corder; /* Current max. creation order value for group */ +} H5G_info_t; + +/* Deprecated typedefs, for backward compatibility */ + /* * An object has a certain type. The first few numbers are reserved for use * internally by HDF5. Users may add their own types with higher values. The @@ -104,8 +124,12 @@ H5_DLL hid_t H5Gcreate(hid_t loc_id, const char *name, size_t size_hint); H5_DLL hid_t H5Gcreate_expand(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id); H5_DLL hid_t H5Gopen(hid_t loc_id, const char *name); H5_DLL hid_t H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id); -H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); H5_DLL hid_t H5Gget_create_plist(hid_t group_id); +H5_DLL herr_t H5Gget_info(hid_t loc_id, const char *name, H5G_info_t *ginfo, + hid_t lapl_id); +H5_DLL herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, + H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *ginfo, + hid_t lapl_id); H5_DLL herr_t H5Gclose(hid_t group_id); /* Functions and variables defined for compatibility with previous versions @@ -134,6 +158,7 @@ H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/); +H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); #ifdef __cplusplus } @@ -273,10 +273,9 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: - if(ret_value < 0) - if(loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + if(ret_value < 0 && loc_found) + if(H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ @@ -425,10 +424,9 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: - if(ret_value < 0) - if(loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + if(ret_value < 0 && loc_found) + if(H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_addr() */ @@ -599,7 +597,7 @@ H5Oget_info(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, oinfo/*out*/, lapl_id, H5AC_dxpl_id) < 0) + if(H5G_loc_info(&loc, name, oinfo/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") done: @@ -657,19 +655,18 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_dxpl_id) < 0) + if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, oinfo, H5AC_dxpl_id) < 0) + if(H5O_get_info(obj_loc.oloc, oinfo, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve object info") done: /* Release the object location */ - if(loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx() */ diff --git a/test/links.c b/test/links.c index c71e1b9..1eba67e 100644 --- a/test/links.c +++ b/test/links.c @@ -8329,7 +8329,6 @@ error: return -1; } /* end open_by_idx_old() */ -#endif /* QAK */ /*------------------------------------------------------------------------- @@ -8808,6 +8807,525 @@ error: return -1; } /* end object_info_old() */ +#endif /* QAK */ + + +/*------------------------------------------------------------------------- + * Function: group_info + * + * Purpose: Create a group with creation order indices and test querying + * group info. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * Monday, November 27, 2006 + * + *------------------------------------------------------------------------- + */ +static int +group_info(hid_t fapl) +{ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ + H5L_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + hbool_t use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + H5G_info_t grp_info; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE];/* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char objname2[NAME_BUF_SIZE]; /* Object name */ + char valname[NAME_BUF_SIZE]; /* Link value */ + herr_t ret; /* Generic return value */ + unsigned u, v; /* Local index variables */ + + /* Create group creation property list */ + if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + + /* Query the group creation properties */ + if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + + /* Loop over operating on different indices on link fields */ + for(idx_type = H5L_INDEX_NAME; idx_type <=H5L_INDEX_CRT_ORDER; idx_type++) { + /* Loop over operating in different orders */ + for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + /* Loop over using index for creation order value */ + for(use_index = FALSE; use_index <= TRUE; use_index++) { + /* Print appropriate test message */ + if(idx_type == H5L_INDEX_CRT_ORDER) { + if(order == H5_ITER_INC) { + if(use_index) + TESTING("query group info by creation order index in increasing order w/creation order index") + else + TESTING("query group info by creation order index in increasing order w/o creation order index") + } /* end if */ + else if(order == H5_ITER_DEC) { + if(use_index) + TESTING("query group info by creation order index in decreasing order w/creation order index") + else + TESTING("query group info by creation order index in decreasing order w/o creation order index") + } /* end else */ + else { + HDassert(order == H5_ITER_NATIVE); + if(use_index) + TESTING("query group info by creation order index in native order w/creation order index") + else + TESTING("query group info by creation order index in native order w/o creation order index") + } /* end else */ + } /* end if */ + else { + if(order == H5_ITER_INC) { + if(use_index) + TESTING("query group info by name index in increasing order w/creation order index") + else + TESTING("query group info by name index in increasing order w/o creation order index") + } /* end if */ + else if(order == H5_ITER_DEC) { + if(use_index) + TESTING("query group info by name index in decreasing order w/creation order index") + else + TESTING("query group info by name index in decreasing order w/o creation order index") + } /* end else */ + else { + HDassert(order == H5_ITER_NATIVE); + if(use_index) + TESTING("query group info by name index in native order w/creation order index") + else + TESTING("query group info by name index in native order w/o creation order index") + } /* end else */ + } /* end else */ + + /* Create file */ + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + 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 + + /* Create group with creation order tracking on */ + if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Create group with creation order tracking on for soft links */ + if((soft_group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + + /* Check for out of bound query by index on empty group */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + /* Create several links, up to limit of compact form */ + for(u = 0; u < max_compact; u++) { + hid_t group_id2, group_id3; /* Group IDs */ + + /* Make name for link */ + sprintf(objname, "filler %02u", u); + + /* Create hard link, with group object */ + if((group_id2 = H5Gcreate_expand(group_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(group_id, objname, group_id2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new/empty) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != 0) TEST_ERROR + + /* Create objects in new group created */ + for(v = 0; v <= u; v++) { + /* Make name for link */ + sprintf(objname2, "filler %02u", v); + + /* Create hard link, with group object */ + if((group_id3 = H5Gcreate(group_id2, objname2, (size_t)0)) < 0) TEST_ERROR + + /* Close group created */ + if(H5Gclose(group_id3) < 0) TEST_ERROR + } /* end for */ + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + /* Retrieve group's information */ + if(order != H5_ITER_NATIVE) { + if(order == H5_ITER_INC) { + if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end if */ + else { + if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end else */ + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end if */ + + /* Close group created */ + if(H5Gclose(group_id2) < 0) TEST_ERROR + + + /* Retrieve main group's information, by name */ + if(H5Gget_info(group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check main group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + + /* Create soft link in another group, to objects in main group */ + sprintf(valname, "/%s/%s", CORDER_GROUP_NAME, objname); + if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve soft link group's information, by name */ + if(H5Gget_info(soft_group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check soft link group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end for */ + + /* Verify state of group (compact) */ + if(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR + + /* Check for out of bound query by index */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + + /* Create more links, to push group into dense form */ + for(; u < (max_compact * 2); u++) { + hid_t group_id2, group_id3; /* Group IDs */ + + /* Make name for link */ + sprintf(objname, "filler %02u", u); + + /* Create hard link, with group object */ + if((group_id2 = H5Gcreate_expand(group_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(group_id, objname, group_id2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new/empty) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != 0) TEST_ERROR + + /* Create objects in new group created */ + for(v = 0; v <= u; v++) { + /* Make name for link */ + sprintf(objname2, "filler %02u", v); + + /* Create hard link, with group object */ + if((group_id3 = H5Gcreate(group_id2, objname2, (size_t)0)) < 0) TEST_ERROR + + /* Close group created */ + if(H5Gclose(group_id3) < 0) TEST_ERROR + } /* end for */ + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + /* Retrieve group's information */ + if(order != H5_ITER_NATIVE) { + if(order == H5_ITER_INC) { + if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end if */ + else { + if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end else */ + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end if */ + + /* Close group created */ + if(H5Gclose(group_id2) < 0) TEST_ERROR + + + /* Retrieve main group's information, by name */ + if(H5Gget_info(group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check main group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + + /* Create soft link in another group, to objects in main group */ + sprintf(valname, "/%s/%s", CORDER_GROUP_NAME, objname); + if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve soft link group's information, by name */ + if(H5Gget_info(soft_group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check soft link group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end for */ + + /* Verify state of group (dense) */ + if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + + /* Check for out of bound query by index */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + + /* Close the groups */ + if(H5Gclose(group_id) < 0) TEST_ERROR + if(H5Gclose(soft_group_id) < 0) TEST_ERROR + + /* Close the file */ + if(H5Fclose(file_id) < 0) TEST_ERROR + + PASSED(); + } /* end for */ + } /* end for */ + } /* end for */ + + /* Free resources */ + if(H5Pclose(gcpl_id) < 0) TEST_ERROR + + return 0; + +error: + /* Free resources */ + H5E_BEGIN_TRY { + H5Pclose(gcpl_id); + H5Gclose(group_id); + H5Gclose(soft_group_id); + H5Fclose(file_id); + } H5E_END_TRY; + + return -1; +} /* end group_info() */ + + +/*------------------------------------------------------------------------- + * Function: group_info_old + * + * Purpose: Create an old-style group and test querying + * group info. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * Monday, November 27, 2006 + * + *------------------------------------------------------------------------- + */ +static int +group_info_old(hid_t fapl) +{ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ + H5_iter_order_t order; /* Order within in the index */ + H5G_info_t grp_info; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE];/* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char objname2[NAME_BUF_SIZE]; /* Object name */ + char valname[NAME_BUF_SIZE]; /* Link value */ + herr_t ret; /* Generic return value */ + unsigned u, v; /* Local index variables */ + + /* Loop over operating in different orders */ + for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + if(order == H5_ITER_INC) { + TESTING("query group info by name index in increasing order in old-style group") + } /* end if */ + else if(order == H5_ITER_DEC) { + TESTING("query group info by name index in decreasing order in old-style group") + } /* end else */ + else { + HDassert(order == H5_ITER_NATIVE); + TESTING("query group info by name index in native order in old-style group") + } /* end else */ + + /* Create file */ + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create old-style group */ + if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Create old-style group for soft links */ + if((soft_group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + + /* Check for out of bound query by index on empty group */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + /* Create several links */ + for(u = 0; u < CORDER_NLINKS; u++) { + hid_t group_id2, group_id3; /* Group IDs */ + + /* Make name for link */ + sprintf(objname, "filler %02u", u); + + /* Create hard link, with group object */ + if((group_id2 = H5Gcreate(group_id, objname, (size_t)0)) < 0) TEST_ERROR + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new/empty) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != 0) TEST_ERROR + + /* Create objects in new group created */ + for(v = 0; v <= u; v++) { + /* Make name for link */ + sprintf(objname2, "filler %02u", v); + + /* Create hard link, with group object */ + if((group_id3 = H5Gcreate(group_id2, objname2, (size_t)0)) < 0) TEST_ERROR + + /* Close group created */ + if(H5Gclose(group_id3) < 0) TEST_ERROR + } /* end for */ + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + /* Retrieve group's information */ + if(order != H5_ITER_NATIVE) { + if(order == H5_ITER_INC) { + if(H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end if */ + else { + if(H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end else */ + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end if */ + + /* Close group created */ + if(H5Gclose(group_id2) < 0) TEST_ERROR + + + /* Retrieve main group's information, by name */ + if(H5Gget_info(group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check main group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + + /* Create soft link in another group, to objects in main group */ + sprintf(valname, "/%s/%s", CORDER_GROUP_NAME, objname); + if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve soft link group's information, by name */ + if(H5Gget_info(soft_group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check soft link group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end for */ + + /* Verify state of group (old-style) */ + if(H5G_has_stab_test(group_id) != TRUE) TEST_ERROR + + /* Check for out of bound query by index */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + /* Check for bad index query by index group */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_CRT_ORDER, order, (hsize_t)0, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + + /* Close the groups */ + if(H5Gclose(group_id) < 0) TEST_ERROR + if(H5Gclose(soft_group_id) < 0) TEST_ERROR + + /* Close the file */ + if(H5Fclose(file_id) < 0) TEST_ERROR + + PASSED(); + } /* end for */ + + return 0; + +error: + /* Free resources */ + H5E_BEGIN_TRY { + H5Gclose(group_id); + H5Gclose(soft_group_id); + H5Fclose(file_id); + } H5E_END_TRY; + + return -1; +} /* end group_info_old() */ /*------------------------------------------------------------------------- @@ -8918,6 +9436,7 @@ main(void) nerrors += link_iterate(fapl2) < 0 ? 1 : 0; nerrors += open_by_idx(fapl2) < 0 ? 1 : 0; nerrors += object_info(fapl2) < 0 ? 1 : 0; + nerrors += group_info(fapl2) < 0 ? 1 : 0; } /* end if */ else { /* Test new API calls on old-style groups */ @@ -8926,6 +9445,7 @@ main(void) nerrors += link_iterate_old(fapl) < 0 ? 1 : 0; nerrors += open_by_idx_old(fapl) < 0 ? 1 : 0; nerrors += object_info_old(fapl) < 0 ? 1 : 0; + nerrors += group_info_old(fapl) < 0 ? 1 : 0; } } /* end for */ #else /* QAK */ |