diff options
Diffstat (limited to 'src/H5Doh.c')
-rw-r--r-- | src/H5Doh.c | 81 |
1 files changed, 45 insertions, 36 deletions
diff --git a/src/H5Doh.c b/src/H5Doh.c index 9abbdff..f8ce69f 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -23,6 +23,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ @@ -45,15 +46,13 @@ /********************/ static void *H5O__dset_get_copy_file_udata(void); static void H5O__dset_free_copy_file_udata(void *); -static htri_t H5O__dset_isa(H5O_t *loc); -static hid_t H5O__dset_open(const H5G_loc_t *obj_loc, hid_t lapl_id, - hid_t dxpl_id, hbool_t app_ref); -static void *H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, - hid_t dxpl_id); +static htri_t H5O__dset_isa(const H5O_t *loc); +static hid_t H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref); +static void *H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__dset_get_oloc(hid_t obj_id); -static herr_t H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, +static herr_t H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info); -static herr_t H5O__dset_flush(void *_obj_ptr, hid_t dxpl_id); +static herr_t H5O__dset_flush(void *_obj_ptr); /*********************/ @@ -148,7 +147,7 @@ H5O__dset_free_copy_file_udata(void *_udata) /* Release copy of dataset's datatype, if it was set */ if(udata->src_dtype) - H5T_close(udata->src_dtype); + H5T_close_real(udata->src_dtype); /* Release copy of dataset's filter pipeline, if it was set */ if(udata->common.src_pline) @@ -179,7 +178,7 @@ H5O__dset_free_copy_file_udata(void *_udata) *------------------------------------------------------------------------- */ static htri_t -H5O__dset_isa(H5O_t *oh) +H5O__dset_isa(const H5O_t *oh) { htri_t exists; /* Flag if header message of interest exists */ htri_t ret_value = TRUE; /* Return value */ @@ -219,10 +218,9 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5O__dset_open(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) +H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref) { H5D_t *dset = NULL; /* Dataset opened */ - htri_t isdapl; /* lapl_id is a dapl */ hid_t dapl_id; /* dapl to use to open this dataset */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -230,30 +228,41 @@ H5O__dset_open(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t a HDassert(obj_loc); - /* If the lapl passed in is a dapl, use it. Otherwise, use the default dapl */ - if(lapl_id == H5P_DEFAULT) - isdapl = FALSE; - else - if((isdapl = H5P_isa_class(lapl_id, H5P_DATASET_ACCESS)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOMPARE, FAIL, "unable to compare property list classes") - - if(isdapl) - dapl_id = lapl_id; - else + /* Get the LAPL (which is a superclass of DAPLs) from the API context, but + * if it's the default link access property list or a custom link access + * property list but not a dataset access property list, use the default + * dataset access property list instead. (Since LAPLs don't have the + * additional properties that DAPLs have) + */ + dapl_id = H5CX_get_lapl(); + if(dapl_id == H5P_LINK_ACCESS_DEFAULT) dapl_id = H5P_DATASET_ACCESS_DEFAULT; + else { + htri_t is_lapl, is_dapl; /* Class of LAPL from API context */ + + /* Check class of LAPL from API context */ + if((is_lapl = H5P_isa_class(dapl_id, H5P_LINK_ACCESS)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get LAPL status") + if((is_dapl = H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get DAPL status") + + /* Switch to default DAPL if not an actual DAPL in the API context */ + if(!is_dapl && is_lapl) + dapl_id = H5P_DATASET_ACCESS_DEFAULT; + } /* end else */ /* Open the dataset */ - if(NULL == (dset = H5D_open(obj_loc, dapl_id, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") + if(NULL == (dset = H5D_open(obj_loc, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") /* Register an ID for the dataset */ if((ret_value = H5I_register(H5I_DATASET, dset, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataset") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: if(ret_value < 0) if(dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_open() */ @@ -273,7 +282,7 @@ done: *------------------------------------------------------------------------- */ static void * -H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id) +H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) { H5D_obj_create_t *crt_info = (H5D_obj_create_t *)_crt_info; /* Dataset creation parameters */ H5D_t *dset = NULL; /* New dataset created */ @@ -287,7 +296,7 @@ H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id) HDassert(obj_loc); /* Create the the dataset */ - if(NULL == (dset = H5D__create(f, crt_info->type_id, crt_info->space, crt_info->dcpl_id, crt_info->dapl_id, dxpl_id))) + if(NULL == (dset = H5D__create(f, crt_info->type_id, crt_info->space, crt_info->dcpl_id, crt_info->dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") /* Set up the new dataset's location */ @@ -357,7 +366,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) +H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) { H5O_layout_t layout; /* Data storage layout message */ H5O_efl_t efl; /* External File List message */ @@ -376,14 +385,14 @@ H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t * HDassert(bh_info); /* Get the layout message from the object header */ - if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_LAYOUT_ID, &layout)) + if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_LAYOUT_ID, &layout)) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find layout message") layout_read = TRUE; /* Check for chunked dataset storage */ if(layout.type == H5D_CHUNKED && H5D__chunk_is_space_alloc(&layout.storage)) { /* Get size of chunk index */ - if(H5D__chunk_bh_info(loc, dxpl_id, oh, &layout, &(bh_info->index_size)) < 0) + if(H5D__chunk_bh_info(loc, oh, &layout, &(bh_info->index_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine chunked dataset btree info") } /* end if */ else if(layout.type == H5D_VIRTUAL @@ -391,7 +400,7 @@ H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t * size_t virtual_heap_size; /* Get size of global heap object for virtual dataset */ - if(H5HG_get_obj_size(loc->file, dxpl_id, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0) + if(H5HG_get_obj_size(loc->file, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get global heap size for virtual dataset mapping") /* Return heap size */ @@ -407,12 +416,12 @@ H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t * HDmemset(&efl, 0, sizeof(efl)); /* Get External File List message from the object header */ - if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_EFL_ID, &efl)) + if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_EFL_ID, &efl)) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find EFL message") efl_read = TRUE; /* Get size of local heap for EFL message's file list */ - if(H5D__efl_bh_info(loc->file, dxpl_id, &efl, &(bh_info->heap_size)) < 0) + if(H5D__efl_bh_info(loc->file, &efl, &(bh_info->heap_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine EFL heap info") } /* end if */ @@ -441,7 +450,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__dset_flush(void *_obj_ptr, hid_t dxpl_id) +H5O__dset_flush(void *_obj_ptr) { H5D_t *dset = (H5D_t *)_obj_ptr; /* Pointer to dataset object */ H5O_type_t obj_type; /* Type of object at location */ @@ -453,12 +462,12 @@ H5O__dset_flush(void *_obj_ptr, hid_t dxpl_id) HDassert(&dset->oloc); /* Check that the object found is the correct type */ - if(H5O_obj_type(&dset->oloc, &obj_type, dxpl_id) < 0) + if(H5O_obj_type(&dset->oloc, &obj_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") if(obj_type != H5O_TYPE_DATASET) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - if(H5D__flush_real(dset, dxpl_id) < 0) + if(H5D__flush_real(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") done: |