diff options
author | hdftest <hdftest@hdfgroup.org> | 2018-06-24 23:26:17 (GMT) |
---|---|---|
committer | hdftest <hdftest@hdfgroup.org> | 2018-06-24 23:26:17 (GMT) |
commit | bac6bc52d33860cb67281e005dfe08336e16480e (patch) | |
tree | 83b9e6782bc080051d3056f5610952a4bef08ca9 /src/H5Spoint.c | |
parent | e9f476dad47ce593f13dacb77b1cc664d1f24e7b (diff) | |
parent | b193bc11c966d79b76ebc3bbe76728f0693693ef (diff) | |
download | hdf5-bac6bc52d33860cb67281e005dfe08336e16480e.zip hdf5-bac6bc52d33860cb67281e005dfe08336e16480e.tar.gz hdf5-bac6bc52d33860cb67281e005dfe08336e16480e.tar.bz2 |
Merge pull request #1117 in HDFFV/hdf5 from ~HDFTEST/hdf5_hft:develop to develop
* commit 'b193bc11c966d79b76ebc3bbe76728f0693693ef':
Revert "Merge pull request #1116 in HDFFV/hdf5 from ~HDFTEST/hdf5_hft:hdf5_1_10 to develop"
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r-- | src/H5Spoint.c | 197 |
1 files changed, 30 insertions, 167 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c index ab40e44..442bb2a 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -38,8 +38,8 @@ static herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); static herr_t H5S_point_release(H5S_t *space); static htri_t H5S_point_is_valid(const H5S_t *space); -static hssize_t H5S_point_serial_size(const H5S_t *space, H5F_t *f); -static herr_t H5S_point_serialize(const H5S_t *space, uint8_t **p, H5F_t *f); +static hssize_t H5S_point_serial_size(const H5S_t *space); +static herr_t H5S_point_serialize(const H5S_t *space, uint8_t **p); static herr_t H5S_point_deserialize(H5S_t *space, uint32_t version, uint8_t flags, const uint8_t **p); static herr_t H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); @@ -58,7 +58,7 @@ static herr_t H5S_point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) static herr_t H5S_point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S_point_iter_nelmts(const H5S_sel_iter_t *iter); static htri_t H5S_point_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S_point_iter_next(H5S_sel_iter_t *sel_iter, hsize_t nelem); +static herr_t H5S_point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S_point_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S_point_iter_release(H5S_sel_iter_t *sel_iter); @@ -278,7 +278,7 @@ done: USAGE herr_t H5S_point_iter_next(iter, nelem) H5S_sel_iter_t *iter; IN: Pointer to selection iterator - hsize_t nelem; IN: Number of elements to advance by + size_t nelem; IN: Number of elements to advance by RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -289,7 +289,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_iter_next(H5S_sel_iter_t *iter, hsize_t nelem) +H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -376,7 +376,7 @@ H5S_point_iter_release (H5S_sel_iter_t H5_ATTR_UNUSED * iter) USAGE herr_t H5S_point_add(space, num_elem, coord) H5S_t *space; IN: Dataspace of selection to modify - hsize_t num_elem; IN: Number of elements in COORD array. + size_t num_elem; IN: Number of elements in COORD array. const hsize_t *coord[]; IN: The location of each element selected RETURNS Non-negative on success/Negative on failure @@ -388,7 +388,7 @@ H5S_point_iter_release (H5S_sel_iter_t H5_ATTR_UNUSED * iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_add(H5S_t *space, H5S_seloper_t op, hsize_t num_elem, const hsize_t *coord) +H5S_point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord) { H5S_pnt_node_t *top = NULL, *curr = NULL, *new_node = NULL; /* Point selection nodes */ unsigned u; /* Counter */ @@ -527,7 +527,7 @@ H5S_point_release (H5S_t *space) herr_t H5S_select_elements(dsid, op, num_elem, coord) hid_t dsid; IN: Dataspace ID of selection to modify H5S_seloper_t op; IN: Operation to perform on current selection - hsize_t num_elem; IN: Number of elements in COORD array. + size_t num_elem; IN: Number of elements in COORD array. const hsize_t *coord; IN: The location of each element selected RETURNS Non-negative on success/Negative on failure @@ -549,7 +549,7 @@ H5S_point_release (H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_elements(H5S_t *space, H5S_seloper_t op, hsize_t num_elem, +H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord) { herr_t ret_value = SUCCEED; /* return value */ @@ -752,93 +752,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Sget_select_elem_npoints() */ -/*-------------------------------------------------------------------------- - NAME - H5S_point_set_version - PURPOSE - Determine the version to use for encoding points selection info - USAGE - hssize_t H5S_point_set_version(space, bounds_end, f, version) - const H5S_t *space; IN: The dataspace - hsize_t bounds_end: IN: The selection high bounds - H5F_t *f: IN: The file pointer - uint32_t *version: OUT: The version to use for encoding - RETURNS - The version to use - DESCRIPTION - Determine the version to use for encoding points selection info: - For 1.10, return 1 - - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5S_point_set_version(const H5S_t *space, hsize_t bounds_end[], H5F_t *f, uint32_t *version) -{ - hbool_t exceed = FALSE; - unsigned u; - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_NOAPI_NOINIT - - *version = H5S_POINT_VERSION_1; - - /* Determine whether the number of points or the high bounds in the selection exceed (2^32 - 1) */ - for(u = 0; u < space->extent.rank; u++) - if(bounds_end[u] > H5S_UINT32_MAX) { - exceed = TRUE; - break; - } - - if(space->select.num_elem > H5S_UINT32_MAX) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of points in point selection exceeds 2^32") - else if(exceed) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in point selection exceeds 2^32") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_set_version() */ - - -/*-------------------------------------------------------------------------- - NAME - H5S_point_set_info_size - PURPOSE - Determine the size of point info to use for encoding selection info - USAGE - hssize_t H5S_point_set_info_size(space, bounds_end, version, point_size) - const H5S_t *space: IN: Dataspace ID of selection to query - hsize_t bounds_end[]: IN: The selection high bounds - uint32_t version: IN: The version used for encoding - uint8_t *point_size: OUT: The size of point info - RETURNS - The size of the points selection info - DESCRIPTION - Determine the size for encoding points selection info: - For 1.10, return 4 - - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5S_point_set_info_size(const H5S_t *space, hsize_t H5_ATTR_UNUSED bounds_end[], uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED *point_size) -{ - hsize_t max_size = 0; - unsigned u; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(version == H5S_POINT_VERSION_1); - - *point_size = H5S_INFO_SIZE_4; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_set_info_size() */ - /*-------------------------------------------------------------------------- NAME @@ -847,9 +760,8 @@ H5S_point_set_info_size(const H5S_t *space, hsize_t H5_ATTR_UNUSED bounds_end[], Determine the number of bytes needed to store the serialized point selection information. USAGE - hssize_t H5S_point_serial_size(space, f) + hssize_t H5S_point_serial_size(space) H5S_t *space; IN: Dataspace pointer to query - H5F_t *f; IN: File pointer RETURNS The number of bytes required on success, negative on an error. DESCRIPTION @@ -861,54 +773,29 @@ H5S_point_set_info_size(const H5S_t *space, hsize_t H5_ATTR_UNUSED bounds_end[], REVISION LOG --------------------------------------------------------------------------*/ static hssize_t -H5S_point_serial_size (const H5S_t *space, H5F_t *f) +H5S_point_serial_size (const H5S_t *space) { H5S_pnt_node_t *curr; /* Point information nodes */ - hsize_t bounds_start[H5S_MAX_RANK]; - hsize_t bounds_end[H5S_MAX_RANK]; - uint32_t version; /* Version number */ - uint8_t point_size; /* Size of point info */ hssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(space); - /* Get bounding box for the selection */ - HDmemset(bounds_end, 0, sizeof(bounds_end)); - if(H5S_point_bounds(space, bounds_start, bounds_end) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") - - /* Determine the version */ - if(H5S_point_set_version(space, bounds_end, f, &version) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version") - - /* Determine the size of point info */ - if(H5S_point_set_info_size(space, bounds_end, version, &point_size) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version") - - HDassert(version == H5S_POINT_VERSION_1); - HDassert(point_size == H5S_INFO_SIZE_4); - - /* Basic number of bytes required to serialize point selection: */ - /* + /* Basic number of bytes required to serialize point selection: * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> + - * <length (4 bytes)> + <rank (4 bytes)> + * <length (4 bytes)> + <rank (4 bytes)> + <# of points (4 bytes)> = 24 bytes */ - ret_value=20; - - /* <num points (depend on point_size)> */ - ret_value += point_size; + ret_value = 24; /* Count points in selection */ curr=space->select.sel_info.pnt_lst->head; while(curr!=NULL) { - /* Add <point_size> bytes times the rank for each element selected */ - ret_value += point_size * space->extent.rank; - curr = curr->next; + /* Add 4 bytes times the rank for each element selected */ + ret_value+=4*space->extent.rank; + curr=curr->next; } /* end while */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_point_serial_size() */ @@ -919,12 +806,11 @@ done: PURPOSE Serialize the current selection into a user-provided buffer. USAGE - herr_t H5S_point_serialize(space, p, f) + herr_t H5S_point_serialize(space, p) const H5S_t *space; IN: Dataspace with selection to serialize uint8_t **p; OUT: Pointer to buffer to put serialized selection. Will be advanced to end of serialized selection. - H5F_t *f; IN: File pointer RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -936,63 +822,41 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_serialize (const H5S_t *space, uint8_t **p, H5F_t *f) +H5S_point_serialize (const H5S_t *space, uint8_t **p) { H5S_pnt_node_t *curr; /* Point information nodes */ uint8_t *pp = (*p); /* Local pointer for decoding */ uint8_t *lenp; /* pointer to length location for later storage */ uint32_t len=0; /* number of bytes used */ unsigned u; /* local counting variable */ - uint32_t version; /* Version number */ - uint8_t point_size; /* Size of point info */ - hsize_t bounds_start[H5S_MAX_RANK]; - hsize_t bounds_end[H5S_MAX_RANK]; - herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(space); HDassert(p); HDassert(pp); - /* Get bounding box for the selection */ - HDmemset(bounds_end, 0, sizeof(bounds_end)); - if(H5S_point_bounds(space, bounds_start, bounds_end) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") - - /* Determine the version */ - if(H5S_point_set_version(space, bounds_end, f, &version) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version") - - /* Determine the size of point info */ - if(H5S_point_set_info_size(space, bounds_end, version, &point_size) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version") - - HDassert(point_size == H5S_INFO_SIZE_4); - HDassert(version == H5S_POINT_VERSION_1); - /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, version); /* Store the version number */ - + UINT32ENCODE(pp, (uint32_t)1); /* Store the version number */ UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - lenp = pp; /* Keep the pointer to the length location for later */ - pp += 4; /* Skip over space for length */ - len += 8; /* Add in advance # of bytes for num of dimensions and num elements */ + lenp = pp; /* Keep the pointer to the length location for later */ + pp += 4; /* Skip over space for length */ /* Encode number of dimensions */ UINT32ENCODE(pp, (uint32_t)space->extent.rank); - + len+=4; /* Encode number of elements */ UINT32ENCODE(pp, (uint32_t)space->select.num_elem); + len+=4; /* Encode each point in selection */ curr=space->select.sel_info.pnt_lst->head; while(curr!=NULL) { /* Add 4 bytes times the rank for each element selected */ - len += 4 * space->extent.rank; + len+=4*space->extent.rank; /* Encode each point */ for(u=0; u<space->extent.rank; u++) @@ -1007,8 +871,7 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p, H5F_t *f) /* Update encoding pointer */ *p = pp; -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_serialize() */ @@ -1043,7 +906,7 @@ H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ H5S_seloper_t op = H5S_SELECT_SET; /* Selection operation */ hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */ const uint8_t *pp = (*p); /* Local pointer for decoding */ - hsize_t num_elem = 0; /* Number of elements in selection */ + size_t num_elem = 0; /* Number of elements in selection */ unsigned rank; /* Rank of points */ unsigned i, j; /* local counting variables */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1757,7 +1620,7 @@ H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem, HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "unsupported operation attempted") /* Call the real element selection routine */ - if((ret_value = H5S_select_elements(space, op, (hsize_t)num_elem, coord)) < 0) + if((ret_value = H5S_select_elements(space, op, num_elem, coord)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't select elements") done: |