Skip to content

Commit

Permalink
H5Dchunk_iter now passes offsets in units of dataset elements, fix HD…
Browse files Browse the repository at this point in the history
…FGroup#1419 (HDFGroup#1969)

* H5Dchunk_iter now passes chunk dimension scaled offsets, fix HDFGroup#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
  • Loading branch information
mkitti committed Dec 21, 2022
1 parent 6e8e527 commit 1984703
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/H5Dchunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ typedef struct H5D_chunk_coll_fill_info_t {
typedef struct H5D_chunk_iter_ud_t {
H5D_chunk_iter_op_t op; /* User defined callback */
void *op_data; /* User data for user defined callback */
H5O_layout_chunk_t *chunk; /* Chunk layout */
} H5D_chunk_iter_ud_t;

/********************/
Expand Down Expand Up @@ -7681,7 +7682,14 @@ static int
H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata)
{
const H5D_chunk_iter_ud_t *data = (H5D_chunk_iter_ud_t *)udata;
const H5O_layout_chunk_t *chunk = data->chunk;
int ret_value = H5_ITER_CONT;
hsize_t offset[H5O_LAYOUT_NDIMS];
unsigned ii; /* Match H5O_layout_chunk_t.ndims */

/* Similar to H5D__get_chunk_info */
for (ii = 0; ii < chunk->ndims; ii++)
offset[ii] = chunk_rec->scaled[ii] * chunk->dim[ii];

FUNC_ENTER_PACKAGE_NOERR

Expand Down Expand Up @@ -7747,6 +7755,7 @@ H5D__chunk_iter(H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data)
/* Set up info for iteration callback */
ud.op = op;
ud.op_data = op_data;
ud.chunk = &dset->shared->layout.u.chunk;

/* Iterate over the allocated chunks calling the iterator callback */
if ((ret_value = (layout->storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0)
Expand Down
10 changes: 5 additions & 5 deletions src/H5Dpublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, size_t dst_buf_bytes_us
/**
* \brief Callback for H5Dchunk_iter()
*
* \param[in] offset Array of starting logical coordinates of chunk.
* \param[in] filter_mask Filter mask of chunk.
* \param[in] addr Offset in file of chunk data.
* \param[in] nbytes Size in bytes of chunk data in file.
* \param[in] offset Logical position of the chunk’s first element in units of dataset elements
* \param[in] filter_mask Bitmask indicating the filters used when the chunk was written
* \param[in] addr Chunk address in the file
* \param[in] size Chunk size in bytes, 0 if the chunk does not exist
* \param[in,out] op_data Pointer to any user-defined data associated with
* the operation.
* \returns \li Zero (#H5_ITER_CONT) causes the iterator to continue, returning
Expand Down Expand Up @@ -647,7 +647,7 @@ H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, u
*
* \return \herr_t
*
* \details H5Dget_chunk_iter iterates over all chunks in the dataset, calling the
* \details H5Dchunk_iter iterates over all chunks in the dataset, calling the
* user supplied callback with the details of the chunk and the supplied
* context \p op_data.
*
Expand Down

0 comments on commit 1984703

Please sign in to comment.