Skip to content

Commit

Permalink
Backport to 1.12 HDFGroup#161, HDFGroup#1474, review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mkitti committed Aug 8, 2022
1 parent 1282918 commit 0b97a78
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 40 deletions.
25 changes: 17 additions & 8 deletions src/H5D.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filte
*
* 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.
*
Expand All @@ -1144,7 +1145,7 @@ H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filte
* const hsize_t *offset,
* uint32_t filter_mask,
* haddr_t addr,
* uint32_t nbytes,
* uint32_t size,
* void *op_data);
*
* H5D_chunk_iter_op_t parameters:
Expand All @@ -1171,22 +1172,30 @@ H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filte
*-------------------------------------------------------------------------
*/
herr_t
H5Dchunk_iter(hid_t dset_id, H5D_chunk_iter_op_t cb, void *op_data)
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)
H5TRACE3("e", "ix*x", dset_id, cb, op_data);
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")

/* Call private function to get the chunk info given the chunk's index */
if (H5VL_dataset_specific(vol_obj, H5VL_DATASET_CHUNK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, cb,
op_data) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't iterate over chunks")
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)
Expand Down
3 changes: 1 addition & 2 deletions src/H5VLconnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ typedef enum H5VL_dataset_get_t {
typedef enum H5VL_dataset_specific_t {
H5VL_DATASET_SET_EXTENT, /* H5Dset_extent */
H5VL_DATASET_FLUSH, /* H5Dflush */
H5VL_DATASET_REFRESH, /* H5Drefresh */
H5VL_DATASET_CHUNK_ITER /* H5Dchunk_iter */
H5VL_DATASET_REFRESH /* H5Drefresh */
} H5VL_dataset_specific_t;

/* Typedef for VOL connector dataset optional VOL operations */
Expand Down
21 changes: 11 additions & 10 deletions src/H5VLnative.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@
#endif /* H5_NO_DEPRECATED_SYMBOLS */

/* Values for native VOL connector dataset optional VOL operations */
#define H5VL_NATIVE_DATASET_FORMAT_CONVERT 0 /* H5Dformat_convert (internal) */
#define H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE 1 /* H5Dget_chunk_index_type */
#define H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE 2 /* H5Dget_chunk_storage_size */
#define H5VL_NATIVE_DATASET_GET_NUM_CHUNKS 3 /* H5Dget_num_chunks */
#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX 4 /* H5Dget_chunk_info */
#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD 5 /* H5Dget_chunk_info_by_coord */
#define H5VL_NATIVE_DATASET_CHUNK_READ 6 /* H5Dchunk_read */
#define H5VL_NATIVE_DATASET_CHUNK_WRITE 7 /* H5Dchunk_write */
#define H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE 8 /* H5Dvlen_get_buf_size */
#define H5VL_NATIVE_DATASET_GET_OFFSET 9 /* H5Dget_offset */
#define H5VL_NATIVE_DATASET_FORMAT_CONVERT 0 /* H5Dformat_convert (internal) */
#define H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE 1 /* H5Dget_chunk_index_type */
#define H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE 2 /* H5Dget_chunk_storage_size */
#define H5VL_NATIVE_DATASET_GET_NUM_CHUNKS 3 /* H5Dget_num_chunks */
#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX 4 /* H5Dget_chunk_info */
#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD 5 /* H5Dget_chunk_info_by_coord */
#define H5VL_NATIVE_DATASET_CHUNK_READ 6 /* H5Dchunk_read */
#define H5VL_NATIVE_DATASET_CHUNK_WRITE 7 /* H5Dchunk_write */
#define H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE 8 /* H5Dvlen_get_buf_size */
#define H5VL_NATIVE_DATASET_GET_OFFSET 9 /* H5Dget_offset */
#define H5VL_NATIVE_DATASET_CHUNK_ITER 10 /* H5Dchunk_iter */

/* Values for native VOL connector file optional VOL operations */
#define H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE 0 /* H5Fclear_elink_file_cache */
Expand Down
37 changes: 19 additions & 18 deletions src/H5VLnative_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,24 +346,6 @@ H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type,
break;
}

case H5VL_DATASET_CHUNK_ITER: { /* H5Dchunk_iter */
H5D_chunk_iter_op_t cb = HDva_arg(arguments, H5D_chunk_iter_op_t);
void *op_data = HDva_arg(arguments, void *);

HDassert(dset->shared);

/* Make sure the dataset is chunked */
if (H5D_CHUNKED != dset->shared->layout.type) {
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
}

/* Call private function */
if (H5D__chunk_iter(dset, cb, op_data) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't iterate over chunks")

break;
}

default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
} /* end switch */
Expand Down Expand Up @@ -605,6 +587,25 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type,
break;
}

/* H5Dchunk_iter */
case H5VL_NATIVE_DATASET_CHUNK_ITER: {
H5D_chunk_iter_op_t op = HDva_arg(arguments, H5D_chunk_iter_op_t);
void *op_data = HDva_arg(arguments, void *);

/* Sanity check */
HDassert(dset->shared);

/* Make sure the dataset is chunked */
if (H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")

/* Call private function */
if ((ret_value = H5D__chunk_iter(dset, op, op_data)) < 0)
HERROR(H5E_DATASET, H5E_BADITER, "chunk iteration failed");

break;
}

default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation")
} /* end switch */
Expand Down
4 changes: 2 additions & 2 deletions test/chunk_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ test_basic_query(hid_t fapl)

/* Iterate and stop after one iteration */
cptr = &(chunk_infos[0]);
if (H5Dchunk_iter(dset, &iter_cb_stop, &cptr) < 0)
if (H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb_stop, &cptr) < 0)
TEST_ERROR;
if (cptr != &(chunk_infos[1]))
FAIL_PUTS_ERROR("Verification of halted iterator failed");
Expand All @@ -1737,7 +1737,7 @@ test_basic_query(hid_t fapl)
cptr = &(chunk_infos[0]);
H5E_BEGIN_TRY
{
ret = H5Dchunk_iter(dset, &iter_cb_fail, &cptr);
ret = H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb_fail, &cptr);
}
H5E_END_TRY;
if (ret >= 0)
Expand Down

0 comments on commit 0b97a78

Please sign in to comment.