diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5D.c | 41 | ||||
-rw-r--r-- | src/H5G.c | 16 | ||||
-rw-r--r-- | src/H5Gobj.c | 4 | ||||
-rw-r--r-- | src/H5Gpkg.h | 3 | ||||
-rw-r--r-- | src/H5Gprivate.h | 1 | ||||
-rw-r--r-- | src/H5Gtraverse.c | 26 | ||||
-rw-r--r-- | src/H5O.c | 79 | ||||
-rw-r--r-- | src/H5Ocache.c | 2 | ||||
-rw-r--r-- | src/H5Odbg.c | 41 | ||||
-rw-r--r-- | src/H5Oprivate.h | 10 | ||||
-rw-r--r-- | src/H5P.c | 20 | ||||
-rw-r--r-- | src/H5Pfcpl.c | 12 | ||||
-rw-r--r-- | src/H5Pgcpl.c | 4 | ||||
-rwxr-xr-x | src/H5Pocpl.c | 158 | ||||
-rwxr-xr-x | src/H5Pocpypl.c | 209 | ||||
-rw-r--r-- | src/H5Ppublic.h | 9 | ||||
-rw-r--r-- | src/H5Tcommit.c | 83 | ||||
-rw-r--r-- | src/H5Tpublic.h | 1 | ||||
-rwxr-xr-x | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/Makefile.in | 5 |
20 files changed, 574 insertions, 153 deletions
@@ -966,6 +966,10 @@ H5Dget_create_plist(hid_t dset_id) if (NULL == (new_plist = H5I_object(new_dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Retrieve any object creation properties */ + if(H5O_get_create_plist(&dset->oloc, H5AC_ind_dxpl_id, new_plist) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info") + /* Get the fill value property */ if(H5P_get(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") @@ -1177,15 +1181,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *plist) +H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) { size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ H5O_loc_t *oloc = NULL; /* Dataset's object location */ - H5O_layout_t *layout; /* Dataset's layout information */ - H5T_t *type; /* Dataset's datatype */ - H5S_t *space; /* Dataset's dataspace */ - H5D_alloc_time_t alloc_time;/* Dataset's allocation time */ - H5O_efl_t *efl; /* Dataset's external file list */ + H5O_layout_t *layout; /* Dataset's layout information */ + H5T_t *type; /* Dataset's datatype */ + H5D_alloc_time_t alloc_time; /* Dataset's allocation time */ + H5O_efl_t *efl; /* Dataset's external file list */ + H5P_genplist_t *dc_plist = NULL; /* Dataset's creation property list */ hbool_t use_latest_format; /* Flag indicating the newest file format should be used */ /* fill value variables */ @@ -1204,11 +1208,10 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p HDassert(file); HDassert(dset); - /* Pick up former parameters */ + /* Set some location variables, for convenience */ oloc = &dset->oloc; layout = &dset->shared->layout; type = dset->shared->type; - space = dset->shared->space; alloc_time = dset->shared->alloc_time; efl = &dset->shared->efl; @@ -1227,16 +1230,20 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p /* Check if dataset has non-default creation property list */ if(dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) { + /* Get new dataset's property list object */ + if (NULL == (dc_plist = H5I_object(dset->shared->dcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") + /* * Retrieve properties of fill value and others. Copy them into new fill * value struct. */ - if(H5P_get(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) + if(H5P_get(dc_plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time") dset->shared->fill_time=fill_time; /* Cache this for later */ /* Get the fill value information from the property list */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) + if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value") } /* end if */ @@ -1251,7 +1258,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p /* Update dataset creation property */ HDassert(dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT); - if(H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) + if(H5P_set(dc_plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill time") } /* end if */ @@ -1286,8 +1293,8 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p if(layout->type == H5D_COMPACT) ohdr_size += layout->u.compact.size; - /* Create (open for write access) an object header */ - if(H5O_create(file, dxpl_id, ohdr_size, oloc) < 0) + /* Create an object header for the dataset */ + if(H5O_create(file, dxpl_id, ohdr_size, dset->shared->dcpl_id, oloc/*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") /* Get a pointer to the object header itself */ @@ -1315,20 +1322,20 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p /* Update dataset creation property */ HDassert(dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT); - if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) + if(H5P_set(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") } /* end if */ /* Update the type and space header messages */ if(H5O_append(file, dxpl_id, oh, H5O_DTYPE_ID, H5O_FLAG_CONSTANT | H5O_FLAG_SHARED, type, &oh_flags) < 0 || - H5S_append(file, dxpl_id, oh, space, &oh_flags) < 0) + H5S_append(file, dxpl_id, oh, dset->shared->space, &oh_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update type or space header messages") /* Update the filters message, if this is a chunked dataset */ if(layout->type == H5D_CHUNKED) { H5O_pline_t pline; /* Chunked data I/O pipeline info */ - if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) + if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve pipeline filter") if(pline.nused > 0 && H5O_append(file, dxpl_id, oh, H5O_PLINE_ID, H5O_FLAG_CONSTANT, &pline, &oh_flags) < 0) @@ -1687,7 +1694,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Update the dataset's entry info. */ - if (H5D_update_entry_info(file, dxpl_id, new_dset, dc_plist) != SUCCEED) + if(H5D_update_entry_info(file, dxpl_id, new_dset) != SUCCEED) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't update the metadata cache") /* Get the dataset's DCPL cache info */ @@ -534,14 +534,18 @@ H5Gget_create_plist(hid_t group_id) if(NULL == (new_plist = H5I_object(new_gcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Retrieve any object creation properties */ + if(H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info") + /* Check for the group having a group info message */ - if((ginfo_exists = H5O_exists(&(grp->oloc), H5O_GINFO_ID, 0, H5AC_dxpl_id)) < 0) + if((ginfo_exists = H5O_exists(&(grp->oloc), H5O_GINFO_ID, 0, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(ginfo_exists) { H5O_ginfo_t ginfo; /* Group info message */ /* Read the group info */ - if(NULL == H5O_read(&(grp->oloc), H5O_GINFO_ID, 0, &ginfo, H5AC_dxpl_id)) + if(NULL == H5O_read(&(grp->oloc), H5O_GINFO_ID, 0, &ginfo, H5AC_ind_dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") /* Set the group info for the property list */ @@ -550,13 +554,13 @@ H5Gget_create_plist(hid_t group_id) } /* end if */ /* Check for the group having a link info message */ - if((linfo_exists = H5O_exists(&(grp->oloc), H5O_LINFO_ID, 0, H5AC_dxpl_id)) < 0) + if((linfo_exists = H5O_exists(&(grp->oloc), H5O_LINFO_ID, 0, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if(linfo_exists) { H5O_linfo_t linfo; /* Link info message */ /* Read the link info */ - if(NULL == H5O_read(&(grp->oloc), H5O_LINFO_ID, 0, &linfo, H5AC_dxpl_id)) + if(NULL == H5O_read(&(grp->oloc), H5O_LINFO_ID, 0, &linfo, H5AC_ind_dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Set the link info for the property list */ @@ -1017,7 +1021,7 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, H5G_loc_t *loc) H5G_loc_reset(&new_root_loc); loc = &new_root_loc; - if(H5G_obj_create(f, dxpl_id, &ginfo, &linfo, loc->oloc/*out*/) < 0) + if(H5G_obj_create(f, dxpl_id, &ginfo, &linfo, f->shared->fcpl_id, loc->oloc/*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") if(1 != H5O_link(loc->oloc, 1, dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "internal error (wrong link count)") @@ -1115,7 +1119,7 @@ H5G_create(H5F_t *file, hid_t dxpl_id, hid_t gcpl_id, hid_t UNUSED gapl_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get group info") /* Create the group object header */ - if(H5G_obj_create(file, dxpl_id, &ginfo, &linfo, &(grp->oloc)/*out*/) < 0) + if(H5G_obj_create(file, dxpl_id, &ginfo, &linfo, gcpl_id, &(grp->oloc)/*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group object header") oloc_init = 1; /* Indicate that the object location information is valid */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 45e6640..c1b7fdc 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -125,7 +125,7 @@ static herr_t H5G_obj_remove_update_linfo(H5O_loc_t *oloc, H5O_linfo_t *linfo, */ herr_t H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, - const H5O_linfo_t *linfo, H5O_loc_t *oloc/*out*/) + const H5O_linfo_t *linfo, hid_t gcpl_id, H5O_loc_t *oloc/*out*/) { size_t hdr_size; /* Size of object header to request */ hbool_t use_latest_format; /* Flag indicating the new group format should be used */ @@ -188,7 +188,7 @@ H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, * since nothing refers to it yet. The link count will be * incremented if the object is added to the group directed graph. */ - if(H5O_create(f, dxpl_id, hdr_size, oloc/*out*/) < 0) + if(H5O_create(f, dxpl_id, hdr_size, gcpl_id, oloc/*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header") /* Check for format of group to create */ diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index fdc0515..c5949b1 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -363,7 +363,6 @@ H5_DLL herr_t H5G_traverse_special(const H5G_loc_t *grp_loc, H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, void *op_data, hid_t lapl_id, hid_t dxpl_id); -H5_DLL H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type); /******************************/ /* Package Private Prototypes */ @@ -504,7 +503,7 @@ H5_DLL herr_t H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, /* Functions that understand group objects */ H5_DLL herr_t H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, - const H5O_linfo_t *linfo, H5O_loc_t *oloc/*out*/); + const H5O_linfo_t *linfo, hid_t gcpl_id, H5O_loc_t *oloc/*out*/); H5_DLL herr_t H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, hbool_t adj_link, hid_t dxpl_id); H5_DLL herr_t H5G_obj_iterate(hid_t loc_id, const char *group_name, diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index b905ada..aadcc9a 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -157,6 +157,7 @@ H5_DLL herr_t H5G_free_grp_name(H5G_t *grp); H5_DLL herr_t H5G_get_shared_count(H5G_t *grp); H5_DLL herr_t H5G_mount(H5G_t *grp); H5_DLL herr_t H5G_unmount(H5G_t *grp); +H5_DLL H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type); /* * These functions operate on symbol table nodes. diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index ff5f9c0..8047eb6 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -691,36 +691,40 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, if(lookup_status < 0) { /* If an intermediate group doesn't exist & flag is set, create the group */ if(target & H5G_CRT_INTMD_GROUP) { - H5O_ginfo_t ginfo; /* Group info message for parent group */ - H5O_linfo_t linfo; /* Link info message for parent group */ + const H5O_ginfo_t def_ginfo = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ + const H5O_linfo_t def_linfo = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ + H5O_ginfo_t par_ginfo; /* Group info settings for parent group */ + H5O_linfo_t par_linfo; /* Link info settings for parent group */ + const H5O_ginfo_t *ginfo; /* Group info settings for new group */ + const H5O_linfo_t *linfo; /* Link info settings for new group */ /* Get the group info for parent group */ /* (OK if not found) */ - if(NULL == H5O_read(grp_loc.oloc, H5O_GINFO_ID, 0, &ginfo, dxpl_id)) { - H5O_ginfo_t def_ginfo = H5G_CRT_GROUP_INFO_DEF; - + if(NULL == H5O_read(grp_loc.oloc, H5O_GINFO_ID, 0, &par_ginfo, dxpl_id)) { /* Clear error stack from not finding the group info message */ H5E_clear_stack(NULL); /* Use default group info settings */ - HDmemcpy(&ginfo, &def_ginfo, sizeof(H5O_ginfo_t)); + ginfo = &def_ginfo; } /* end if */ + else + ginfo = &par_ginfo; /* Get the link info for parent group */ /* (OK if not found) */ - if(NULL == H5O_read(grp_loc.oloc, H5O_LINFO_ID, 0, &linfo, dxpl_id)) { - H5O_linfo_t def_linfo = H5G_CRT_LINK_INFO_DEF; - + if(NULL == H5O_read(grp_loc.oloc, H5O_LINFO_ID, 0, &par_linfo, dxpl_id)) { /* Clear error stack from not finding the link info message */ H5E_clear_stack(NULL); /* Use default link info settings */ - HDmemcpy(&linfo, &def_linfo, sizeof(H5O_linfo_t)); + linfo = &def_linfo; } /* end if */ + else + linfo = &par_linfo; /* Create the intermediate group */ /* XXX: Should we allow user to control the group creation params here? -QAK */ - if(H5G_obj_create(grp_oloc.file, dxpl_id, &ginfo, &linfo, obj_loc.oloc/*out*/) < 0) + if(H5G_obj_create(grp_oloc.file, dxpl_id, ginfo, linfo, H5P_GROUP_CREATE_DEFAULT, obj_loc.oloc/*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") /* Insert new group into current group's symbol table */ @@ -114,8 +114,8 @@ typedef struct H5O_typeinfo_t { static hid_t H5O_open_by_loc(H5G_loc_t *obj_loc, hid_t dxpl_id); static H5O_loc_t * H5O_get_oloc(hid_t id); -static herr_t H5O_new(H5F_t *f, hid_t dxpl_id, size_t chunk_size, - H5O_loc_t *loc/*out*/, haddr_t header); +static herr_t H5O_new(H5F_t *f, hid_t dxpl_id, haddr_t header, size_t chunk_size, + hid_t ocpl_id, H5O_loc_t *loc/*out*/); static herr_t H5O_reset_real(const H5O_msg_class_t *type, void *native); static void * H5O_copy_real(const H5O_msg_class_t *type, const void *mesg, void *dst); @@ -772,7 +772,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5O_loc_t *loc/*out*/) +H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, + H5O_loc_t *loc/*out*/) { haddr_t header; /* Address of object header */ herr_t ret_value = SUCCEED; /* return value */ @@ -792,7 +793,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5O_loc_t *loc/*out*/) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header header") /* initialize the object header */ - if(H5O_new(f, dxpl_id, size_hint, loc, header) != SUCCEED) + if(H5O_new(f, dxpl_id, header, size_hint, ocpl_id, loc) != SUCCEED) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to initialize object header") done: @@ -819,8 +820,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_new(H5F_t *f, hid_t dxpl_id, size_t chunk_size, H5O_loc_t *loc/*out*/, - haddr_t header) +H5O_new(H5F_t *f, hid_t dxpl_id, haddr_t header, size_t chunk_size, + hid_t ocpl_id, H5O_loc_t *loc/*out*/) { H5O_t *oh = NULL; size_t oh_size; /* Size of initial object header */ @@ -831,6 +832,7 @@ H5O_new(H5F_t *f, hid_t dxpl_id, size_t chunk_size, H5O_loc_t *loc/*out*/, /* check args */ HDassert(f); HDassert(loc); + HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); /* Set up object location */ loc->file = f; @@ -849,12 +851,24 @@ H5O_new(H5F_t *f, hid_t dxpl_id, size_t chunk_size, H5O_loc_t *loc/*out*/, /* Initialize version-specific fields */ if(oh->version > H5O_VERSION_1) { + H5P_genplist_t *oc_plist; /* Object creation property list */ + /* Initialize all time fields with current time */ oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now(); + /* Get the property list */ + if(NULL == (oc_plist = H5I_object(ocpl_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") + /* Initialize attribute tracking fields */ - oh->max_compact = 0; - oh->min_dense = 0; + + /* Retrieve phase change values from property list */ + if(H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") + if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") + + /* Set starting values for attribute info */ oh->nattrs = 0; oh->attr_fheap_addr = HADDR_UNDEF; oh->name_bt2_addr = HADDR_UNDEF; @@ -3968,3 +3982,52 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_info() */ + +/*------------------------------------------------------------------------- + * Function: H5O_get_create_plist + * + * Purpose: Retrieve the object creation properties for an object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 28 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_get_create_plist(const H5O_loc_t *oloc, hid_t dxpl_id, H5P_genplist_t *oc_plist) +{ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5O_get_create_plist, FAIL) + + /* Check args */ + HDassert(oloc); + HDassert(oc_plist); + + /* Get the object header */ + if(NULL == (oh = H5AC_protect(oloc->file, dxpl_id, H5AC_OHDR, oloc->addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") + + /* Set property values, if they were used for the object */ + if(oh->version > H5O_VERSION_1) { + unsigned max_compact = oh->max_compact; /* Alias for setting the max. compact value */ + unsigned min_dense = oh->min_dense; /* Alias for setting the min. dense value */ + + /* Set the property list values with aliases, so the sizes are correct */ + if(H5P_set(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &max_compact) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list") + if(H5P_set(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &min_dense) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list") + } /* end if */ + +done: + if(oh && H5AC_unprotect(oloc->file, dxpl_id, H5AC_OHDR, oloc->addr, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_get_info() */ + diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 9f0da22..8f34860 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -461,7 +461,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, oh->mesg[mesgno].dirty = FALSE; oh->mesg[mesgno].flags = flags; oh->mesg[mesgno].native = NULL; - oh->mesg[mesgno].raw = p; + oh->mesg[mesgno].raw = (uint8_t *)p; /* Casting away const OK - QAK */ oh->mesg[mesgno].raw_size = mesg_size; oh->mesg[mesgno].chunkno = chunkno; } /* end else */ diff --git a/src/H5Odbg.c b/src/H5Odbg.c index df40d65..bbc1ce5 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -269,6 +269,47 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of links:", oh->nlink); + /* Extra information for later versions */ + if(oh->version > H5O_VERSION_1) { + struct tm *tm; /* Time structure */ + char buf[128]; /* Buffer for formatting time info */ + + /* Time fields */ + tm = HDlocaltime(&oh->atime); + HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Access Time:", buf); + tm = HDlocaltime(&oh->mtime); + HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Modification Time:", buf); + tm = HDlocaltime(&oh->ctime); + HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Change Time:", buf); + tm = HDlocaltime(&oh->btime); + HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Birth Time:", buf); + + /* Attribute tracking fields */ + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + "Max. compact attributes:", + (unsigned)oh->max_compact); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + "Min. dense attributes:", + (unsigned)oh->min_dense); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + "Number of attributes:", + oh->nattrs); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + "Attribute heap address:", + oh->attr_fheap_addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + "Attribute name index address:", + oh->name_bt2_addr); + } /* end if */ + HDfprintf(stream, "%*s%-*s %Zu (%Zu)\n", indent, "", fwidth, "Number of messages (allocated):", oh->nmesgs, oh->alloc_nmesgs); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 61fa573..d0d57c7 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -83,8 +83,12 @@ typedef uint64_t H5SM_fheap_id_t; #define H5O_HASH_SIZE 32 #define H5O_HASH_UNDEF ((uint32_t)FAIL) +/* ========= Object Creation properties ============ */ +#define H5O_CRT_ATTR_MAX_COMPACT_NAME "max compact attr" /* Max. # of attributes to store compactly */ +#define H5O_CRT_ATTR_MIN_DENSE_NAME "min dense attr" /* Min. # of attributes to store densely */ + /* ========= Object Copy properties ============ */ -#define H5O_CPY_OPTION_NAME "copy object" /* Copy options */ +#define H5O_CPY_OPTION_NAME "copy object" /* Copy options */ /* The object location information for an object */ typedef struct H5O_loc_t { @@ -370,13 +374,14 @@ typedef herr_t (*H5O_operator_t)(const void *mesg/*in*/, unsigned idx, void *operator_data/*in,out*/); /* Forward declarations for prototype arguments */ +struct H5P_genplist_t; struct H5SL_t; struct H5O_t; /* General message operators */ H5_DLL herr_t H5O_init(void); H5_DLL herr_t H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, - H5O_loc_t *loc/*out*/); + hid_t ocpl_id, H5O_loc_t *loc/*out*/); H5_DLL herr_t H5O_open(const H5O_loc_t *loc); H5_DLL herr_t H5O_close(H5O_loc_t *loc); H5_DLL int H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id); @@ -425,6 +430,7 @@ H5_DLL herr_t H5O_iterate(const H5O_loc_t *loc, unsigned type_id, H5O_operator_t void *op_data, hid_t dxpl_id); H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id); H5_DLL uint32_t H5O_mesg_hash(unsigned type_id, H5F_t *f, const void *mesg); +H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, struct H5P_genplist_t *oc_plist); /* Object copying routines */ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, @@ -128,22 +128,6 @@ const H5P_libclass_t H5P_CLS_ROOT[1] = {{ NULL /* Class close callback info */ }}; -/* Object creation property list class library initialization object */ -/* (move to proper source code file when used for real) */ -const H5P_libclass_t H5P_CLS_OCRT[1] = {{ - "object create", /* Class name for debugging */ - &H5P_CLS_ROOT_g, /* Parent class ID */ - &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class ID */ - NULL, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ -}}; - /* Group access property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_GACC[1] = {{ @@ -210,6 +194,7 @@ const H5P_libclass_t H5P_CLS_TACC[1] = {{ /* Library property list classes defined in other code modules */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_OCRT[1]; /* Object creation */ H5_DLLVAR const H5P_libclass_t H5P_CLS_STRCRT[1]; /* String create */ H5_DLLVAR const H5P_libclass_t H5P_CLS_LACC[1]; /* Link access */ H5_DLLVAR const H5P_libclass_t H5P_CLS_GCRT[1]; /* Group create */ @@ -233,7 +218,7 @@ H5_DLLVAR const H5P_libclass_t H5P_CLS_LCRT[1]; /* Link creation */ /*******************/ /* Track the revision count of a class, to make comparisons faster */ -static unsigned H5P_next_rev=0; +static unsigned H5P_next_rev = 0; #define H5P_GET_NEXT_REV (H5P_next_rev++) /* List of all property list classes in the library */ @@ -269,7 +254,6 @@ H5FL_DEFINE_STATIC(H5P_genprop_t); /* Declare a free list to manage the H5P_genplist_t struct */ H5FL_DEFINE_STATIC(H5P_genplist_t); - /*-------------------------------------------------------------------------- NAME diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index 97c468f..da8e0fa 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -961,7 +961,6 @@ done: } - /*------------------------------------------------------------------------- * Function: H5Pset_shared_mesg_phase_change * @@ -992,10 +991,15 @@ H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_ /* Check that values are sensible. The min_btree value must be no greater * than the max list plus one. - * No need to check values otherwise, since they can't be negative. + * + * Range check to make certain they will fit into encoded form. */ if(max_list + 1 < min_btree) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "minimum B-tree value is greater than maximum list value") + if(max_list > 65535) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max list value must be < 65536") + if(min_btree > 65535) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min btree value must be < 65536") /* Avoid the strange case where max_list == 0 and min_btree == 1, so deleting the * last message in a B-tree makes it become an empty list. @@ -1018,7 +1022,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pget_sohm_list_max + * Function: H5Pget_shared_mesg_phase_change * * Purpose: Gets the maximum size of a SOHM list index before it becomes * a B-tree. @@ -1056,4 +1060,4 @@ H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list, unsigned *mi done: FUNC_LEAVE_API(ret_value); } - + diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index cc9449a..b80e8f6 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -102,14 +102,14 @@ const H5P_libclass_t H5P_CLS_GCRT[1] = {{ * October 31, 2006 *------------------------------------------------------------------------- */ -herr_t +static herr_t H5P_gcrt_reg_prop(H5P_genclass_t *pclass) { H5O_ginfo_t ginfo = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ H5O_linfo_t linfo = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5P_gcrt_reg_prop, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5P_gcrt_reg_prop) /* Register group info property */ if(H5P_register(pclass, H5G_CRT_GROUP_INFO_NAME, H5G_CRT_GROUP_INFO_SIZE, diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index 339dc21..671c85c 100755 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -15,10 +15,10 @@ /*------------------------------------------------------------------------- * * Created: H5Pocpl.c - * Mar 13 2006 - * Peter Cao <xcao@ncsa.uiuc.edu> + * Nov 28 2006 + * Quincey Koziol <koziol@hdfgroup.org> * - * Purpose: Object copying property list class routines + * Purpose: Object creation property list class routines * *------------------------------------------------------------------------- */ @@ -42,10 +42,13 @@ /* Local Macros */ /****************/ -/* ========= Object Copy properties ============ */ -/* Definitions for copy options */ -#define H5O_CPY_OPTION_SIZE sizeof(unsigned) -#define H5O_CPY_OPTION_DEF 0 +/* ========= Object Creation properties ============ */ +/* Definitions for the max. # of attributes to store compactly */ +#define H5O_CRT_ATTR_MAX_COMPACT_SIZE sizeof(unsigned) +#define H5O_CRT_ATTR_MAX_COMPACT_DEF 8 +/* Definitions for the min. # of attributes to store densely */ +#define H5O_CRT_ATTR_MIN_DENSE_SIZE sizeof(unsigned) +#define H5O_CRT_ATTR_MIN_DENSE_DEF 6 /******************/ @@ -63,20 +66,20 @@ /********************/ /* Property class callbacks */ -static herr_t H5P_ocpy_reg_prop(H5P_genclass_t *pclass); +static herr_t H5P_ocrt_reg_prop(H5P_genclass_t *pclass); /*********************/ /* Package Variables */ /*********************/ -/* Object copy property list class library initialization object */ -const H5P_libclass_t H5P_CLS_OCPY[1] = {{ - "object copy", /* Class name for debugging */ +/* Object creation property list class library initialization object */ +const H5P_libclass_t H5P_CLS_OCRT[1] = {{ + "object create", /* Class name for debugging */ &H5P_CLS_ROOT_g, /* Parent class ID */ - &H5P_CLS_OBJECT_COPY_g, /* Pointer to class ID */ - &H5P_LST_OBJECT_COPY_g, /* Pointer to default property list ID */ - H5P_ocpy_reg_prop, /* Default property registration routine */ + &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class ID */ + NULL, /* Pointer to default property list ID */ + H5P_ocrt_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ @@ -86,6 +89,7 @@ const H5P_libclass_t H5P_CLS_OCPY[1] = {{ }}; + /*****************************/ /* Library Private Variables */ /*****************************/ @@ -98,112 +102,130 @@ const H5P_libclass_t H5P_CLS_OCPY[1] = {{ /*------------------------------------------------------------------------- - * Function: H5P_ocpy_reg_prop + * Function: H5P_ocrt_reg_prop * - * Purpose: Initialize the object copy property list class + * Purpose: Initialize the object creation property list class * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * October 31, 2006 + * November 28, 2006 *------------------------------------------------------------------------- */ -herr_t -H5P_ocpy_reg_prop(H5P_genclass_t *pclass) +static herr_t +H5P_ocrt_reg_prop(H5P_genclass_t *pclass) { - unsigned ocpy_option = H5O_CPY_OPTION_DEF; /* Default object copy flags */ + unsigned attr_max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF; /* Default max. compact attribute storage settings */ + unsigned attr_min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF; /* Default min. dense attribute storage settings */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5P_ocpy_reg_prop, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5P_ocrt_reg_prop) - /* Register copy options property */ - if(H5P_register(pclass, H5O_CPY_OPTION_NAME, H5O_CPY_OPTION_SIZE, - &ocpy_option, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + /* Register max. compact attribute storage property */ + if(H5P_register(pclass, H5O_CRT_ATTR_MAX_COMPACT_NAME, H5O_CRT_ATTR_MAX_COMPACT_SIZE, + &attr_max_compact, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register min. dense attribute storage property */ + if(H5P_register(pclass, H5O_CRT_ATTR_MIN_DENSE_NAME, H5O_CRT_ATTR_MIN_DENSE_SIZE, + &attr_min_dense, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_ocpy_reg_prop() */ +} /* end H5P_ocrt_reg_prop() */ /*------------------------------------------------------------------------- - * Function: H5Pset_copy_object + * Function: H5Pset_attr_phase_change * - * Purpose: Set properties when copying an object (group, dataset, and datatype) - * from one location to another + * Purpose: Sets the cutoff values for indexes storing attributes + * in object headers for this file. If more than max_compact + * attributes are in an object header, the attributes will be + * moved to a heap and indexed with a B-tree. + * Likewise, an object header containing fewer than min_dense + * attributes will be converted back to storing the attributes + * directly in the object header. * - * Usage: H5Pset_copy_group(plist_id, cpy_option) - * hid_t plist_id; IN: Property list to copy object - * unsigned cpy_option; IN: Options to copy object such as - * H5O_COPY_SHALLOW_HIERARCHY_FLAG -- Copy only immediate members - * H5O_COPY_EXPAND_SOFT_LINK_FLAG -- Expand soft links into new objects/ - * H5O_COPY_EXPAND_EXT_LINK_FLAG -- Expand external links into new objects - * H5O_COPY_EXPAND_REFERENCE_FLAG -- Copy objects that are pointed by references - * H5O_COPY_WITHOUT_ATTR_FLAG -- Copy object without copying attributes + * If the max_compact is zero then attributes for this object will + * never be stored in the object header but will be always be + * stored in a heap. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Tuesday, November 28, 2006 * - * Programmer: Peter Cao - * March 13, 2006 *------------------------------------------------------------------------- */ herr_t -H5Pset_copy_object(hid_t plist_id, unsigned cpy_option) +H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Pset_copy_object, FAIL) - H5TRACE2("e","iIu",plist_id,cpy_option); + FUNC_ENTER_API(H5Pset_attr_phase_change, FAIL) + H5TRACE3("e","iIuIu",plist_id,max_compact,min_dense); - /* Check parameters */ - if(cpy_option & ~H5O_COPY_ALL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown option specified") + /* Range check values */ + if(max_compact < min_dense) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be >= min dense value") + if(max_compact > 65535) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be < 65536") + if(min_dense > 65535) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min dense value must be < 65536") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Set value */ - if(H5P_set(plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set copy object flag") + /* Set property values */ + if(H5P_set(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &max_compact) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list") + if(H5P_set(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &min_dense) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list") done: FUNC_LEAVE_API(ret_value) -} /* end H5Pset_copy_object() */ +} /* end H5Pset_attr_phase_change */ /*------------------------------------------------------------------------- - * Function: H5Pget_copy_object + * Function: H5Pget_attr_phase_change * - * Purpose: Returns the cpy_option, which is set for H5Ocopy(hid_t loc_id, - * const char* name, ... ) for copying objects + * Purpose: Gets the phase change values for attribute storage * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Tuesday, November 28, 2006 * - * Programmer: Peter Cao - * March 13, 2006 *------------------------------------------------------------------------- */ herr_t -H5Pget_copy_object(hid_t plist_id, unsigned *cpy_option /*out*/) +H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, unsigned *min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Pget_copy_object, FAIL) - H5TRACE2("e","ix",plist_id,cpy_option); + FUNC_ENTER_API(H5Pget_attr_phase_change, FAIL) + H5TRACE3("e","i*Iu*Iu",plist_id,max_compact,min_dense); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(cpy_option) - if(H5P_get(plist, H5O_CPY_OPTION_NAME, cpy_option) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object copy flag") + if(max_compact) { + if(H5P_get(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, max_compact) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") + } /* end if */ + if(min_dense) { + if(H5P_get(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, min_dense) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") + } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* end H5Pget_copy_object() */ +} /* end H5Pget_attr_phase_change() */ diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c new file mode 100755 index 0000000..2ee5882 --- /dev/null +++ b/src/H5Pocpypl.c @@ -0,0 +1,209 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Pocpypl.c + * Mar 13 2006 + * Peter Cao <xcao@ncsa.uiuc.edu> + * + * Purpose: Object copying property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* ========= Object Copy properties ============ */ +/* Definitions for copy options */ +#define H5O_CPY_OPTION_SIZE sizeof(unsigned) +#define H5O_CPY_OPTION_DEF 0 + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P_ocpy_reg_prop(H5P_genclass_t *pclass); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Object copy property list class library initialization object */ +const H5P_libclass_t H5P_CLS_OCPY[1] = {{ + "object copy", /* Class name for debugging */ + &H5P_CLS_ROOT_g, /* Parent class ID */ + &H5P_CLS_OBJECT_COPY_g, /* Pointer to class ID */ + &H5P_LST_OBJECT_COPY_g, /* Pointer to default property list ID */ + H5P_ocpy_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5P_ocpy_reg_prop + * + * Purpose: Initialize the object copy property list class + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * October 31, 2006 + *------------------------------------------------------------------------- + */ +herr_t +H5P_ocpy_reg_prop(H5P_genclass_t *pclass) +{ + unsigned ocpy_option = H5O_CPY_OPTION_DEF; /* Default object copy flags */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5P_ocpy_reg_prop, FAIL) + + /* Register copy options property */ + if(H5P_register(pclass, H5O_CPY_OPTION_NAME, H5O_CPY_OPTION_SIZE, + &ocpy_option, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_ocpy_reg_prop() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_copy_object + * + * Purpose: Set properties when copying an object (group, dataset, and datatype) + * from one location to another + * + * Usage: H5Pset_copy_group(plist_id, cpy_option) + * hid_t plist_id; IN: Property list to copy object + * unsigned cpy_option; IN: Options to copy object such as + * H5O_COPY_SHALLOW_HIERARCHY_FLAG -- Copy only immediate members + * H5O_COPY_EXPAND_SOFT_LINK_FLAG -- Expand soft links into new objects/ + * H5O_COPY_EXPAND_EXT_LINK_FLAG -- Expand external links into new objects + * H5O_COPY_EXPAND_REFERENCE_FLAG -- Copy objects that are pointed by references + * H5O_COPY_WITHOUT_ATTR_FLAG -- Copy object without copying attributes + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Peter Cao + * March 13, 2006 + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_copy_object(hid_t plist_id, unsigned cpy_option) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Pset_copy_object, FAIL) + H5TRACE2("e","iIu",plist_id,cpy_option); + + /* Check parameters */ + if(cpy_option & ~H5O_COPY_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown option specified") + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Set value */ + if(H5P_set(plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set copy object flag") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_copy_object() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_copy_object + * + * Purpose: Returns the cpy_option, which is set for H5Ocopy(hid_t loc_id, + * const char* name, ... ) for copying objects + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Peter Cao + * March 13, 2006 + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_copy_object(hid_t plist_id, unsigned *cpy_option /*out*/) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(H5Pget_copy_object, FAIL) + H5TRACE2("e","ix",plist_id,cpy_option); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Get values */ + if(cpy_option) + if(H5P_get(plist, H5O_CPY_OPTION_NAME, cpy_option) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object copy flag") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_copy_object() */ + diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 8d15c22..515120b 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -166,6 +166,7 @@ H5_DLLVAR hid_t H5P_LST_LINK_ACCESS_g; /* Public Prototypes */ /*********************/ +/* Generic property list routines */ H5_DLL hid_t H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func_t cls_create, void *create_data, H5P_cls_copy_func_t cls_copy, void *copy_data, @@ -217,6 +218,10 @@ H5_DLL herr_t H5Pclose_class(hid_t plist_id); H5_DLL herr_t H5Pclose(hid_t plist_id); H5_DLL hid_t H5Pcopy(hid_t plist_id); +/* Object creation property list (OCPL) routines */ +H5_DLL herr_t H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense); +H5_DLL herr_t H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, unsigned *min_dense); + /* File creation property list (FCPL) routines */ H5_DLL herr_t H5Pget_version(hid_t plist_id, unsigned *boot/*out*/, unsigned *freelist/*out*/, unsigned *stab/*out*/, @@ -389,7 +394,7 @@ H5_DLL herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /* 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 */ +/* String creation property list (STRCPL) routines */ H5_DLL herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding); H5_DLL herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding /*out*/); @@ -399,7 +404,7 @@ H5_DLL herr_t H5Pget_nlinks(hid_t plist_id, size_t *nlinks); H5_DLL herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix); H5_DLL ssize_t H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size); -/* Object copy property list (OCPL) routines */ +/* Object copy property list (OCPYPL) routines */ H5_DLL herr_t H5Pset_copy_object(hid_t plist_id, unsigned crt_intmd); H5_DLL herr_t H5Pget_copy_object(hid_t plist_id, unsigned *crt_intmd /*out*/); diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 5a5beb5..4a46b9d 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -230,7 +230,6 @@ done: static herr_t H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t UNUSED tapl_id) { - H5P_genplist_t *tc_plist; /* Property list created */ H5O_loc_t temp_oloc; /* Temporary object header location */ H5G_name_t temp_path; /* Temporary path */ hbool_t loc_init=FALSE; /* Have temp_oloc and temp_path been initialized? */ @@ -280,7 +279,7 @@ H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t UNUSED * Create the object header and open it for write access. Insert the data * type message and then give the object header a name. */ - if(H5O_create(file, dxpl_id, dtype_size, &temp_oloc) < 0) + if(H5O_create(file, dxpl_id, dtype_size, tcpl_id, &temp_oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header") if(H5O_modify(&temp_oloc, H5O_DTYPE_ID, 0, H5O_FLAG_CONSTANT | H5O_FLAG_DONTSOHM, H5O_UPDATE_TIME, type, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message") @@ -292,13 +291,10 @@ H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t UNUSED HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location") loc_init = FALSE; - /* Get the property list */ - if(NULL == (tc_plist = H5I_object(tcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - + /* Set the shared info fields */ type->sh_loc.flags = H5O_COMMITTED_FLAG; type->shared->state = H5T_STATE_OPEN; - type->shared->fo_count=1; + type->shared->fo_count = 1; /* Add datatype to the list of open objects in the file */ if(H5FO_top_incr(type->sh_loc.u.oloc.file, type->sh_loc.u.oloc.addr) < 0) @@ -587,6 +583,79 @@ done: /*------------------------------------------------------------------------- + * Function: H5Tget_create_plist + * + * Purpose: Returns a copy of the datatype creation property list. + * + * Return: Success: ID for a copy of the datatype creation + * property list. The property list ID should be + * released by calling H5Pclose(). + * + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Tuesday, November 28, 2006 + * + *------------------------------------------------------------------------- + */ +hid_t +H5Tget_create_plist(hid_t dtype_id) +{ + H5T_t *type; /* Datatype object for ID */ + H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */ + hid_t new_tcpl_id = FAIL; /* New datatype creation property list */ + herr_t status; /* Generic status value */ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5Tget_create_plist, FAIL) + H5TRACE1("i","i",dtype_id); + + /* Check arguments */ + if(NULL == (type = H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Copy the default datatype creation property list */ + if(NULL == (tcpl_plist = H5I_object(H5P_LST_DATATYPE_CREATE_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default creation property list") + if((new_tcpl_id = H5P_copy_plist(tcpl_plist)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list") + + /* Check if the datatype is committed */ + if((status = H5T_committed(type)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check whether datatype is committed") + + /* Retrieve further information, if the datatype is committed */ + if(status > 0) { + H5P_genplist_t *new_plist; /* New datatype creation property list */ + H5O_loc_t *type_oloc; /* Object location for committed datatype */ + + /* Get property list object for new TCPL */ + if(NULL == (new_plist = H5I_object(new_tcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + + /* Get the datatype's object location */ + if(NULL == (type_oloc = H5T_oloc(type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of datatype") + + /* Retrieve any object creation properties */ + if(H5O_get_create_plist(type_oloc, H5AC_ind_dxpl_id, new_plist) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info") + } /* end if */ + + /* Set the return value */ + ret_value = new_tcpl_id; + +done: + if(ret_value < 0) { + if(new_tcpl_id > 0) + (void)H5I_dec_ref(new_tcpl_id); + } /* end if */ + + FUNC_LEAVE_API(ret_value) +} /* end H5Tget_create_plist() */ + + +/*------------------------------------------------------------------------- * Function: H5T_open * * Purpose: Open a named datatype. diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 80e3124..60fe5c7 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -505,6 +505,7 @@ H5_DLL htri_t H5Tequal(hid_t type1_id, hid_t type2_id); H5_DLL herr_t H5Tlock(hid_t type_id); H5_DLL herr_t H5Tcommit(hid_t loc_id, const char *name, hid_t type_id); H5_DLL herr_t H5Tcommit_expand(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id); +H5_DLL hid_t H5Tget_create_plist(hid_t type_id); H5_DLL htri_t H5Tcommitted(hid_t type_id); H5_DLL herr_t H5Tencode(hid_t obj_id, void *buf, size_t *nalloc); H5_DLL hid_t H5Tdecode(const void *buf); diff --git a/src/Makefile.am b/src/Makefile.am index 298b488..d7fdb0d 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,7 +65,8 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Oname.c H5Onull.c H5Opline.c H5Osdspace.c H5Oshared.c H5Ostab.c \ H5P.c H5Pacpl.c H5Pdcpl.c H5Pdxpl.c H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \ H5Pgcpl.c \ - H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pstrcpl.c H5Ptest.c H5R.c H5RC.c \ + H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ + H5R.c H5RC.c \ H5RS.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \ H5SMcache.c H5ST.c H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c \ diff --git a/src/Makefile.in b/src/Makefile.in index b4a7135..cf86dba 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -104,7 +104,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Olayout.lo H5Olinfo.lo H5Olink.lo H5Omtime.lo H5Oname.lo \ H5Onull.lo H5Opline.lo H5Osdspace.lo H5Oshared.lo H5Ostab.lo \ H5P.lo H5Pacpl.lo H5Pdcpl.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo \ - H5Pfmpl.lo H5Pgcpl.lo H5Plapl.lo H5Plcpl.lo H5Pocpl.lo \ + H5Pfmpl.lo H5Pgcpl.lo H5Plapl.lo H5Plcpl.lo H5Pocpl.lo H5Pocpypl.lo \ H5Pstrcpl.lo H5Ptest.lo H5R.lo H5RC.lo H5RS.lo H5S.lo \ H5Sall.lo H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo \ H5Sselect.lo H5Stest.lo H5SL.lo H5SM.lo H5SMbtree2.lo \ @@ -421,7 +421,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Oname.c H5Onull.c H5Opline.c H5Osdspace.c H5Oshared.c H5Ostab.c \ H5P.c H5Pacpl.c H5Pdcpl.c H5Pdxpl.c H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \ H5Pgcpl.c \ - H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pstrcpl.c H5Ptest.c H5R.c H5RC.c \ + H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c H5R.c H5RC.c \ H5RS.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \ H5SMcache.c H5ST.c H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c \ @@ -688,6 +688,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Plapl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Plcpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pocpl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pocpypl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pstrcpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ptest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5R.Plo@am__quote@ |