summaryrefslogtreecommitdiffstats
path: root/src/H5Oint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Oint.c')
-rw-r--r--src/H5Oint.c278
1 files changed, 183 insertions, 95 deletions
diff --git a/src/H5Oint.c b/src/H5Oint.c
index ecf347c..04220af 100644
--- a/src/H5Oint.c
+++ b/src/H5Oint.c
@@ -31,6 +31,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* File access */
#include "H5FLprivate.h" /* Free lists */
@@ -42,6 +43,8 @@
#include "H5Opkg.h" /* Object headers */
#include "H5VLprivate.h" /* Virtual Object Layer */
+#include "H5VLnative_private.h" /* Native VOL connector */
+
/****************/
/* Local Macros */
@@ -55,9 +58,9 @@
/* User data for recursive traversal over objects from a group */
typedef struct {
hid_t obj_id; /* The ID for the starting group */
- H5G_loc_t *start_loc; /* Location of starting group */
+ H5G_loc_t *start_loc; /* Location of starting group */
H5SL_t *visited; /* Skip list for tracking visited nodes */
- H5O_iterate_t op; /* Application callback */
+ H5O_iterate2_t op; /* Application callback */
void *op_data; /* Application's op data */
unsigned fields; /* Selection of object info */
} H5O_iter_visit_ud_t;
@@ -77,9 +80,11 @@ static herr_t H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type);
static herr_t H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr);
static herr_t H5O__free_visit_visited(void *item, void *key,
void *operator_data/*in,out*/);
-static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info_t *linfo,
+static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info2_t *linfo,
void *_udata);
static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh);
+static herr_t H5O__reset_info2(H5O_info2_t *oinfo);
+
/*********************/
/* Package Variables */
@@ -150,6 +155,13 @@ H5FL_BLK_DEFINE(chunk_image);
/* Declare external the free list for H5O_cont_t sequences */
H5FL_SEQ_EXTERN(H5O_cont_t);
+/* The canonical 'undefined' token */
+const H5O_token_t H5O_TOKEN_UNDEF_g = {{
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255}};
+
/*****************************/
/* Library Private Variables */
@@ -239,7 +251,7 @@ H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx
version = H5O_VERSION_1;
/* Upgrade to the version indicated by the file's low bound if higher */
- version = MAX(version, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(f)]);
+ version = (uint8_t)MAX(version, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(f)]);
/* Version bounds check */
if(version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(f)])
@@ -352,8 +364,18 @@ H5O__create_ohdr(H5F_t *f, hid_t ocpl_id)
HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a property list")
/* Get any object header status flags set by properties */
- if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags")
+ if(H5P_DATASET_CREATE_DEFAULT == ocpl_id)
+ {
+ /* If the OCPL is the default DCPL, we can get the header flags from the
+ * API context. Otherwise we have to call H5P_get */
+ if(H5CX_get_ohdr_flags(&oh_flags) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags")
+ }
+ else
+ {
+ if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags")
+ }
if(H5O_set_version(f, oh, oh_flags, H5F_STORE_MSG_CRT_IDX(f)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, NULL, "can't set version of object header")
@@ -1891,27 +1913,19 @@ H5O_loc_reset(H5O_loc_t *loc)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_loc_reset() */
-
+
/*-------------------------------------------------------------------------
* Function: H5O_loc_copy
*
- * Purpose: Copy object location information
+ * Purpose: Copy object location information, according to the depth.
*
* Return: Success: Non-negative
- * Failure: Negative
+ * Failure: Negative
*
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
* Monday, September 19, 2005
*
- * Notes: 'depth' parameter determines how much of the group entry
- * structure we want to copy. The values are:
- * H5_COPY_SHALLOW - Copy all the field values from the source
- * to the destination, but not copying objects pointed to.
- * (Destination "takes ownership" of objects pointed to)
- * H5_COPY_DEEP - Copy all the fields from the source to
- * the destination, deep copying objects pointed to.
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -1924,25 +1938,88 @@ H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth)
HDassert(dst);
HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP);
+ /* Invoke correct routine */
+ if(depth == H5_COPY_SHALLOW)
+ H5O_loc_copy_shallow(dst, src);
+ else
+ H5O_loc_copy_deep(dst, src);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_loc_copy() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_loc_copy_shallow
+ *
+ * Purpose: Shallow copy object location information. Copies all the field
+ * values from the source to the destination, but not copying
+ * objects pointed to. (i.e. destination "takes ownership" of
+ * objects pointed to)
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * January 18, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_loc_copy_shallow(H5O_loc_t *dst, H5O_loc_t *src)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Check arguments */
+ HDassert(src);
+ HDassert(dst);
+
/* Copy the top level information */
H5MM_memcpy(dst, src, sizeof(H5O_loc_t));
- /* Deep copy the names */
- if(depth == H5_COPY_DEEP) {
- /* If the original entry was holding open the file, this one should
- * hold it open, too.
- */
- if(src->holding_file)
- H5F_INCR_NOPEN_OBJS(dst->file);
- }
- else if(depth == H5_COPY_SHALLOW) {
- H5O_loc_reset(src);
- }
+ /* Reset the source location, as the destination 'owns' it now */
+ H5O_loc_reset(src);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O_loc_copy() */
+} /* end H5O_loc_copy_shallow() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_loc_copy_deep
+ *
+ * Purpose: Deep copy object location information. Copies all the fields
+ * from the source to the destination, deep copying objects
+ * pointed to.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: David Young
+ * January 18, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_loc_copy_deep(H5O_loc_t *dst, const H5O_loc_t *src)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Check arguments */
+ HDassert(src);
+ HDassert(dst);
+
+ /* Copy the top level information */
+ H5MM_memcpy(dst, src, sizeof(H5O_loc_t));
+
+ /* If the original entry was holding open the file, this one should
+ * hold it open, too.
+ */
+ if(src->holding_file)
+ H5F_INCR_NOPEN_OBJS(dst->file);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_loc_copy_deep() */
+
/*-------------------------------------------------------------------------
* Function: H5O_loc_hold_file
*
@@ -2144,9 +2221,7 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
/*-------------------------------------------------------------------------
* Function: H5O_get_info
*
- * Purpose: Retrieve the information for an object
- *
- * Note: Add a parameter "fields" to indicate selection of object info.
+ * Purpose: Retrieve the data model information for an object
*
* Return: Success: Non-negative
* Failure: Negative
@@ -2157,7 +2232,7 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
*-------------------------------------------------------------------------
*/
herr_t
-H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
+H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields)
{
const H5O_obj_class_t *obj_class; /* Class of object for header */
H5O_t *oh = NULL; /* Object header */
@@ -2178,15 +2253,17 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
/* Reset the object info structure */
- HDmemset(oinfo, 0, sizeof(*oinfo));
+ if(H5O__reset_info2(oinfo) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct")
/* Get basic information, if requested */
if(fields & H5O_INFO_BASIC) {
/* Retrieve the file's fileno */
H5F_GET_FILENO(loc->file, oinfo->fileno);
- /* Set the object's address */
- oinfo->addr = loc->addr;
+ /* Set the object's address into the token */
+ if(H5VL_native_addr_to_token(loc->file, H5I_FILE, loc->addr, &oinfo->token) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token")
/* Retrieve the type of the object */
oinfo->type = obj_class->type;
@@ -2238,31 +2315,11 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
} /* end else */
} /* end if */
- /* Get the information for the object header, if requested */
- if(fields & H5O_INFO_HDR)
- if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
-
/* Retrieve # of attributes */
if(fields & H5O_INFO_NUM_ATTRS)
if(H5O__attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count")
- /* Get B-tree & heap metadata storage size, if requested */
- if(fields & H5O_INFO_META_SIZE) {
- /* Check for 'bh_info' callback for this type of object */
- if(obj_class->bh_info)
- /* Call the object's class 'bh_info' routine */
- if((obj_class->bh_info)(loc, oh, &oinfo->meta_size.obj) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info")
-
- /* Get B-tree & heap info for any attributes */
- if(!(fields & H5O_INFO_NUM_ATTRS) || oinfo->num_attrs > 0) {
- if(H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info")
- } /* end if */
- } /* end if */
-
done:
if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
@@ -2272,60 +2329,66 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O__get_info_by_idx
- *
- * Purpose: Internal routine to retrieve an object's info according to
- * an index within a group.
+ * Function: H5O_get_native_info
*
- *
- * Note: Add a parameter "fields" to indicate selection of object info.
+ * Purpose: Retrieve the native file-format information for an object
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
- * December 28, 2017
+ * November 21 2006
*
*-------------------------------------------------------------------------
*/
herr_t
-H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type,
- H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields)
+H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fields)
{
- H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
- hbool_t loc_found = FALSE; /* Entry at 'name' found */
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5O_obj_class_t *obj_class; /* Class of object for header */
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_PACKAGE
+ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL)
- /* Check arguments */
+ /* Check args */
HDassert(loc);
- HDassert(group_name && *group_name);
HDassert(oinfo);
- /* Set up opened group location to fill in */
- obj_loc.oloc = &obj_oloc;
- obj_loc.path = &obj_path;
- H5G_loc_reset(&obj_loc);
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
- /* 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*/) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
- loc_found = TRUE;
+ /* Get class for object */
+ if(NULL == (obj_class = H5O__obj_class_real(oh)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
- /* Retrieve the object's information */
- if(H5O_get_info(obj_loc.oloc, oinfo, fields) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info")
+ /* Reset the object info structure */
+ HDmemset(oinfo, 0, sizeof(*oinfo));
+
+ /* Get the information for the object header, if requested */
+ if(fields & H5O_NATIVE_INFO_HDR)
+ if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
+
+ /* Get B-tree & heap metadata storage size, if requested */
+ if(fields & H5O_NATIVE_INFO_META_SIZE) {
+ /* Check for 'bh_info' callback for this type of object */
+ if(obj_class->bh_info)
+ /* Call the object's class 'bh_info' routine */
+ if((obj_class->bh_info)(loc, oh, &oinfo->meta_size.obj) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info")
+
+ /* Get B-tree & heap info for any attributes */
+ if(H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info")
+ } /* end if */
done:
- /* Release the object location */
- if(loc_found && H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
+ if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O__get_info_by_idx() */
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
+} /* end H5O_get_native_info() */
/*-------------------------------------------------------------------------
@@ -2368,7 +2431,7 @@ H5O_get_create_plist(const H5O_loc_t *loc, H5P_genplist_t *oc_plist)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list")
/* Mask off non-"user visible" flags */
- ohdr_flags = oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES);
+ H5_CHECKED_ASSIGN(ohdr_flags, uint8_t, oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES), int);
/* Set object header flags */
if(H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0)
@@ -2639,7 +2702,7 @@ H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSE
*-------------------------------------------------------------------------
*/
static herr_t
-H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *linfo,
+H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *linfo,
void *_udata)
{
H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */
@@ -2677,7 +2740,7 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *li
/* Check if we've seen the object the link references before */
if(NULL == H5SL_search(udata->visited, &obj_pos)) {
- H5O_info_t oinfo; /* Object info */
+ H5O_info2_t oinfo; /* Object info */
/* Get the object's info */
if(H5O_get_info(&obj_oloc, &oinfo, udata->fields) < 0)
@@ -2753,14 +2816,14 @@ done:
*/
herr_t
H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type,
- H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields)
+ H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields)
{
H5O_iter_visit_ud_t udata; /* User data for callback */
H5G_loc_t obj_loc; /* Location used to open object */
H5G_name_t obj_path; /* Opened object group hier. path */
H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'name' found */
- H5O_info_t oinfo; /* Object info struct */
+ H5O_info2_t oinfo; /* Object info struct */
void *obj = NULL; /* Object */
H5I_type_t opened_type; /* ID type of object */
hid_t obj_id = H5I_INVALID_HID; /* ID of object */
@@ -2836,7 +2899,10 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type,
/* Construct unique "position" for this object */
obj_pos->fileno = oinfo.fileno;
- obj_pos->addr = oinfo.addr;
+
+ /* De-serialize object token into an object address */
+ if(H5VL_native_token_to_addr(loc->oloc->file, H5I_FILE, oinfo.token, &(obj_pos->addr)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address")
/* Add to list of visited objects */
if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0)
@@ -3073,3 +3139,25 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__free() */
+/*-------------------------------------------------------------------------
+ * Function: H5O__reset_info2
+ *
+ * Purpose: Resets/initializes an H5O_info2_t struct.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O__reset_info2(H5O_info2_t *oinfo)
+{
+ FUNC_ENTER_STATIC_NOERR;
+
+ /* Reset the passed-in info struct */
+ HDmemset(oinfo, 0, sizeof(H5O_info2_t));
+ oinfo->type = H5O_TYPE_UNKNOWN;
+ oinfo->token = H5O_TOKEN_UNDEF;
+
+ FUNC_LEAVE_NOAPI(SUCCEED);
+} /* end H5O__reset_info2() */
+