summaryrefslogtreecommitdiffstats
path: root/src/H5O.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@lbl.gov>2020-11-30 19:54:44 (GMT)
committerGitHub <noreply@github.com>2020-11-30 19:54:44 (GMT)
commitcadd6db431e2664e6dd3f2460639a27d21c6c8a9 (patch)
tree79bad4f1b2615f8662499a6d986e89514894acf8 /src/H5O.c
parentc256612e0950f3389249aa3a151d66ce01704d89 (diff)
downloadhdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.zip
hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.tar.gz
hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.tar.bz2
Move API routines for VOL objects to main source file. (#133)
Diffstat (limited to 'src/H5O.c')
-rw-r--r--src/H5O.c219
1 files changed, 219 insertions, 0 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 3306b2e..709f479 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -263,6 +263,225 @@ done:
} /* end H5Oopen_by_token() */
/*-------------------------------------------------------------------------
+ * Function: H5Ocopy
+ *
+ * Purpose: Copy an object (group or dataset) to destination location
+ * within a file or cross files. PLIST_ID is a property list
+ * which is used to pass user options and properties to the
+ * copy. The name, dst_name, must not already be taken by some
+ * other object in the destination group.
+ *
+ * H5Ocopy() will fail if the name of the destination object
+ * exists in the destination group. For example,
+ * H5Ocopy(fid_src, "/dset", fid_dst, "/dset", ...)
+ * will fail if "/dset" exists in the destination file
+ *
+ * OPTIONS THAT HAVE BEEN IMPLEMENTED.
+ * H5O_COPY_SHALLOW_HIERARCHY_FLAG
+ * If this flag is specified, only immediate members of
+ * the group are copied. Otherwise (default), it will
+ * recursively copy all objects below the group
+ * H5O_COPY_EXPAND_SOFT_LINK_FLAG
+ * If this flag is specified, it will copy the objects
+ * pointed by the soft links. Otherwise (default), it
+ * will copy the soft link as they are
+ * H5O_COPY_WITHOUT_ATTR_FLAG
+ * If this flag is specified, it will copy object without
+ * copying attributes. Otherwise (default), it will
+ * copy object along with all its attributes
+ * H5O_COPY_EXPAND_REFERENCE_FLAG
+ * 1) Copy object between two different files:
+ * When this flag is specified, it will copy objects that
+ * are pointed by the references and update the values of
+ * references in the destination file. Otherwise (default)
+ * the values of references in the destination will set to
+ * zero
+ * The current implementation does not handle references
+ * inside of other datatype structure. For example, if
+ * a member of compound datatype is reference, H5Ocopy()
+ * will copy that field as it is. It will not set the
+ * value to zero as default is used nor copy the object
+ * pointed by that field the flag is set
+ * 2) Copy object within the same file:
+ * This flag does not have any effect to the H5Ocopy().
+ * Datasets or attributes of references are copied as they
+ * are, i.e. values of references of the destination object
+ * are the same as the values of the source object
+ *
+ * OPTIONS THAT MAY APPLY TO COPY IN THE FUTURE.
+ * H5O_COPY_EXPAND_EXT_LINK_FLAG
+ * If this flag is specified, it will expand the external links
+ * into new objects, Otherwise (default), it will keep external
+ * links as they are (default)
+ *
+ * PROPERTIES THAT MAY APPLY TO COPY IN FUTURE
+ * Change data layout such as chunk size
+ * Add filter such as data compression.
+ * Add an attribute to the copied object(s) that say the date/time
+ * for the copy or other information about the source file.
+ *
+ * The intermediate group creation property should be passed in
+ * using the lcpl instead of the ocpypl.
+ *
+ * Usage: H5Ocopy(src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id)
+ * hid_t src_loc_id IN: Source file or group identifier.
+ * const char *src_name IN: Name of the source object to be copied
+ * hid_t dst_loc_id IN: Destination file or group identifier
+ * const char *dst_name IN: Name of the destination object
+ * hid_t ocpypl_id IN: Properties which apply to the copy
+ * hid_t lcpl_id IN: Properties which apply to the new hard link
+ *
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id,
+ hid_t lcpl_id)
+{
+ H5VL_object_t * vol_obj1 = NULL; /* object of src_id */
+ H5VL_loc_params_t loc_params1;
+ H5VL_object_t * vol_obj2 = NULL; /* object of dst_id */
+ H5VL_loc_params_t loc_params2;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id);
+
+ /* Check arguments */
+ if (!src_name || !*src_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source name specified")
+ if (!dst_name || !*dst_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified")
+
+ /* Get correct property lists */
+ if (H5P_DEFAULT == lcpl_id)
+ lcpl_id = H5P_LINK_CREATE_DEFAULT;
+ else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list")
+
+ /* Get object copy property list */
+ if (H5P_DEFAULT == ocpypl_id)
+ ocpypl_id = H5P_OBJECT_COPY_DEFAULT;
+ else if (TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list")
+
+ /* Set the LCPL for the API context */
+ H5CX_set_lcpl(lcpl_id);
+
+ /* Set up collective metadata if appropriate */
+ if (H5CX_set_loc(src_loc_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set collective metadata read info")
+
+ /* get the object */
+ if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ loc_params1.type = H5VL_OBJECT_BY_SELF;
+ loc_params1.obj_type = H5I_get_type(src_loc_id);
+
+ /* get the object */
+ if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ loc_params2.type = H5VL_OBJECT_BY_SELF;
+ loc_params2.obj_type = H5I_get_type(dst_loc_id);
+
+ /* Copy the object */
+ if (H5VL_object_copy(vol_obj1, &loc_params1, src_name, vol_obj2, &loc_params2, dst_name, ocpypl_id,
+ lcpl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Ocopy() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Oflush
+ *
+ * Purpose: Flushes all buffers associated with an object to disk.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Mike McGreevy
+ * May 19, 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Oflush(hid_t obj_id)
+{
+ H5VL_object_t * vol_obj = NULL; /* Object of obj_id */
+ H5VL_loc_params_t loc_params;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "i", obj_id);
+
+ /* Check args */
+ if (NULL == (vol_obj = H5VL_vol_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ /* Set up collective metadata if appropriate */
+ if (H5CX_set_loc(obj_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info")
+
+ /* Set location parameters */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(obj_id);
+
+ /* Flush the object */
+ if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_FLUSH, H5P_DATASET_XFER_DEFAULT,
+ H5_REQUEST_NULL, obj_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Oflush() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Orefresh
+ *
+ * Purpose: Refreshes all buffers associated with an object.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Mike McGreevy
+ * July 28, 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Orefresh(hid_t oid)
+{
+ H5VL_object_t * vol_obj = NULL; /* Object of oid */
+ H5VL_loc_params_t loc_params;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "i", oid);
+
+ /* Check args */
+ if (NULL == (vol_obj = H5VL_vol_object(oid)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ /* Set up collective metadata if appropriate */
+ if (H5CX_set_loc(oid) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info")
+
+ /* Set location parameters */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(oid);
+
+ /* Refresh the object */
+ if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT,
+ H5_REQUEST_NULL, oid) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Orefresh() */
+
+/*-------------------------------------------------------------------------
* Function: H5Olink
*
* Purpose: Creates a hard link from NEW_NAME to the object specified