summaryrefslogtreecommitdiffstats
path: root/src/H5D.c
diff options
context:
space:
mode:
authorMark Kittisopikul <mkitti@users.noreply.github.com>2022-08-16 21:59:55 (GMT)
committerGitHub <noreply@github.com>2022-08-16 21:59:55 (GMT)
commit0c1898d6f5707d1844cfcbb4db116ab6dcee77d2 (patch)
tree329d6d08307e21b85dca5c65a7b742419f94f5c5 /src/H5D.c
parentd9247ec17e8abe53af0a439e1a1b58ade6ae5310 (diff)
downloadhdf5-0c1898d6f5707d1844cfcbb4db116ab6dcee77d2.zip
hdf5-0c1898d6f5707d1844cfcbb4db116ab6dcee77d2.tar.gz
hdf5-0c1898d6f5707d1844cfcbb4db116ab6dcee77d2.tar.bz2
Backport H5Dchunk_iter to 1.12 branch (#1970)
* Revert "Revert H5Dchunk_iter changes in hdf5_1_12_1 (#733)" This reverts commit 10abe9a8b4985a18a0c88615686184d233d7b845. * Apply clang-format * Reincorporate spelling fix from #1166 * Incorporate H5Dchunk_iter changes from #161 * Backport to 1.12: Adds a quick for for some egregious chunk_info badness (#722) * Backport to 1.12: Converts testhdf5 macros to h5test macros in chunk_info.c (#1820) The two macro schemes were not designed to work together. Also quiets some MSVC warnings about comparing pointers and integers. * Backport to 1.12: H5Dchunk_iter now passes offsets in units of dataset elements, fix #1419 (#1969) * H5Dchunk_iter now passes chunk dimension scaled offsets, fix #1419 * Update docs for H5Dchunk_iter, H5Dget_chunk_info* Modified description for `H5Dchunk_iter`, `H5Dget_chunk_info`, and `H5Dget_chunk_info_by_coord` to the following * offset Logical position of the chunk’s first element in units of dataset elements * filter_mask Bitmask indicating the filters used when the chunk was written * size Chunk size in bytes, 0 if the chunk does not exist * Sync H5Dchunk_iter documentation with develop * Remove H5VL_DATASET_WAIT references from 1.12 * Backport to 1.12 #161, #1474, review comments Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Diffstat (limited to 'src/H5D.c')
-rw-r--r--src/H5D.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 2347c93..ceadc64 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1126,3 +1126,77 @@ H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filte
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Dget_chunk_info_by_coord() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Dchunk_iter
+ *
+ * Purpose: Iterates over all chunks in dataset with given callback and user data.
+ *
+ * Parameters:
+ * hid_t dset_id; IN: Chunked dataset ID
+ * hid_t dxpl_id; IN: Dataset transfer property list ID
+ * H5D_chunk_iter_op_t cb IN: User callback function, called for every chunk.
+ * void *op_data IN/OUT: Optional user data passed on to user callback.
+ *
+ * Callback information:
+ * H5D_chunk_iter_op_t is defined as:
+ *
+ * typedef int (*H5D_chunk_iter_op_t)(
+ * const hsize_t *offset,
+ * uint32_t filter_mask,
+ * haddr_t addr,
+ * uint32_t size,
+ * void *op_data);
+ *
+ * H5D_chunk_iter_op_t parameters:
+ * hsize_t *offset; IN/OUT: Array of starting logical coordinates of chunk.
+ * uint32_t filter_mask; IN: Filter mask of chunk.
+ * haddr_t addr; IN: Offset in file of chunk data.
+ * uint32_t nbytes; IN: Size in number of bytes of chunk data in file.
+ * void *op_data; IN/OUT: Pointer to any user-defined data
+ * associated with the operation.
+ *
+ * The return values from an operator are:
+ * Zero (H5_ITER_CONT) causes the iterator to continue, returning zero when all
+ * elements have been processed.
+ * Positive (H5_ITER_STOP) causes the iterator to immediately return that positive
+ * value, indicating short-circuit success.
+ * Negative (H5_ITER_ERROR) causes the iterator to immediately return that value,
+ * indicating failure.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Gaute Hope
+ * August 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t op, void *op_data)
+{
+ H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE4("e", "iix*x", dset_id, dxpl_id, op, op_data);
+
+ /* Check arguments */
+ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+ if (NULL == op)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback to chunk iteration")
+
+ /* Get the default dataset transfer property list if the user didn't provide one */
+ if (H5P_DEFAULT == dxpl_id)
+ dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID")
+
+ /* Iterate over the chunks */
+ if ((ret_value = H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_ITER, dxpl_id, H5_REQUEST_NULL,
+ op, op_data)) < 0)
+ HGOTO_ERROR(H5E_BADITER, H5E_BADITER, FAIL, "error iterating over dataset chunks")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Dchunk_iter() */