summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2019-04-08 19:11:28 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2019-04-08 19:11:28 (GMT)
commit52276f3713eec584044bc72d4724507848cfeba0 (patch)
tree2bd8e746308a6f19d0302403e3f0492dd8dc63ed
parent74677ba5ce41ab9db100e2059ceb85b44b874466 (diff)
parent3ccc98e256587c43f6ba5a31a2cf9d922f4e1773 (diff)
downloadhdf5-52276f3713eec584044bc72d4724507848cfeba0.zip
hdf5-52276f3713eec584044bc72d4724507848cfeba0.tar.gz
hdf5-52276f3713eec584044bc72d4724507848cfeba0.tar.bz2
Merge pull request #1645 in HDFFV/hdf5 from ~VCHOI/my_third_fork:bugfix/HDFFV-10365-h5sencode-decode-bug-when-num to develop
* commit '3ccc98e256587c43f6ba5a31a2cf9d922f4e1773': Modifications based on PR feedback: (1) Add H5Sdeprec.c to src/CMakeLists.txt (2) Add test for H5Sencode1. Modification for num_elem based on PR feedback. HDFFV-10365: Changes as described in the RFC: H5Sencode/H5Sdecode Format Change. This also addresses HDFFV-10255: H5Sencode/decode performance issue.
-rw-r--r--MANIFEST1
-rw-r--r--fortran/src/H5Sf.c6
-rw-r--r--fortran/src/H5Sff.F9013
-rw-r--r--fortran/src/H5f90proto.h2
-rw-r--r--fortran/test/tH5MISC_1_8.F9033
-rw-r--r--java/src/jni/h5sImp.c4
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/H5Dmpio.c3
-rw-r--r--src/H5Dvirtual.c4
-rw-r--r--src/H5P.c19
-rw-r--r--src/H5Pdeprec.c48
-rw-r--r--src/H5Ppublic.h3
-rw-r--r--src/H5Rint.c3
-rw-r--r--src/H5S.c22
-rw-r--r--src/H5Sall.c2
-rw-r--r--src/H5Sdeprec.c121
-rw-r--r--src/H5Shyper.c880
-rw-r--r--src/H5Snone.c2
-rw-r--r--src/H5Spkg.h31
-rw-r--r--src/H5Spoint.c334
-rw-r--r--src/H5Spublic.h12
-rw-r--r--src/H5vers.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--test/enc_dec_plist.c878
-rw-r--r--test/gen_plist.c4
-rw-r--r--test/th5s.c900
-rw-r--r--test/trefer.c58
-rw-r--r--test/vds.c84
-rw-r--r--testpar/t_prop.c4
29 files changed, 2701 insertions, 775 deletions
diff --git a/MANIFEST b/MANIFEST
index 7cb2cfd..16f62b1 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -847,6 +847,7 @@
./src/H5S.c
./src/H5Sall.c
./src/H5Sdbg.c
+./src/H5Sdeprec.c
./src/H5Shyper.c
./src/H5Smodule.h
./src/H5Smpio.c
diff --git a/fortran/src/H5Sf.c b/fortran/src/H5Sf.c
index 96540f7..8abea25 100644
--- a/fortran/src/H5Sf.c
+++ b/fortran/src/H5Sf.c
@@ -1149,7 +1149,7 @@ h5sdecode_c ( _fcd buf, hid_t_f *obj_id )
*/
int_f
-h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc )
+h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc, hid_t_f *fapl_id )
/******/
{
int ret_value = -1;
@@ -1162,7 +1162,7 @@ h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc )
if (*nalloc == 0) {
- if(H5Sencode((hid_t)*obj_id, c_buf, &c_size) < 0)
+ if(H5Sencode2((hid_t)*obj_id, c_buf, &c_size, (hid_t)*fapl_id) < 0)
return ret_value;
*nalloc = (size_t_f)c_size;
@@ -1180,7 +1180,7 @@ h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc )
/*
* Call H5Sencode function.
*/
- if(H5Sencode((hid_t)*obj_id, c_buf, &c_size) < 0){
+ if(H5Sencode2((hid_t)*obj_id, c_buf, &c_size, (hid_t)*fapl_id) < 0){
return ret_value;
}
diff --git a/fortran/src/H5Sff.F90 b/fortran/src/H5Sff.F90
index 3af7755..bd3dcf4 100644
--- a/fortran/src/H5Sff.F90
+++ b/fortran/src/H5Sff.F90
@@ -1379,25 +1379,32 @@ CONTAINS
! M. Scot Breitenfeld
! March 26, 2008
! SOURCE
- SUBROUTINE h5sencode_f(obj_id, buf, nalloc, hdferr)
+ SUBROUTINE h5sencode_f(obj_id, buf, nalloc, hdferr, fapl_id)
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: obj_id
CHARACTER(LEN=*), INTENT(OUT) :: buf
INTEGER(SIZE_T), INTENT(INOUT) :: nalloc
INTEGER, INTENT(OUT) :: hdferr
+ INTEGER(HID_T), OPTIONAL, INTENT(IN) :: fapl_id ! File access property list
!*****
+ INTEGER(HID_T) :: fapl_id_default
INTERFACE
- INTEGER FUNCTION h5sencode_c(buf, obj_id, nalloc) BIND(C,NAME='h5sencode_c')
+ INTEGER FUNCTION h5sencode_c(buf, obj_id, nalloc, fapl_id_default) BIND(C,NAME='h5sencode_c')
IMPORT :: C_CHAR
IMPORT :: HID_T, SIZE_T
INTEGER(HID_T), INTENT(IN) :: obj_id
CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: buf
INTEGER(SIZE_T), INTENT(INOUT) :: nalloc
+ INTEGER(HID_T) :: fapl_id_default
END FUNCTION h5sencode_c
END INTERFACE
- hdferr = h5sencode_c(buf, obj_id, nalloc)
+ fapl_id_default = H5P_DEFAULT_F
+
+ IF(PRESENT(fapl_id)) fapl_id_default = fapl_id
+
+ hdferr = h5sencode_c(buf, obj_id, nalloc, fapl_id_default)
END SUBROUTINE h5sencode_f
diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h
index fada004..554ad0f 100644
--- a/fortran/src/H5f90proto.h
+++ b/fortran/src/H5f90proto.h
@@ -121,7 +121,7 @@ H5_FCDLL int_f h5sselect_hyperslab_c( hid_t_f *space_id , int_f *op, hsize_t_f *
H5_FCDLL int_f h5sget_select_type_c( hid_t_f *space_id , int_f *op);
H5_FCDLL int_f h5sselect_elements_c( hid_t_f *space_id , int_f *op, size_t_f *nelements, hsize_t_f *coord);
H5_FCDLL int_f h5sdecode_c( _fcd buf, hid_t_f *obj_id );
-H5_FCDLL int_f h5sencode_c(_fcd buf, hid_t_f *obj_id, size_t_f *nalloc );
+H5_FCDLL int_f h5sencode_c(_fcd buf, hid_t_f *obj_id, size_t_f *nalloc, hid_t_f *fapl_id );
H5_FCDLL int_f h5sextent_equal_c( hid_t_f * space1_id, hid_t_f *space2_id, hid_t_f *c_equal);
/*
diff --git a/fortran/test/tH5MISC_1_8.F90 b/fortran/test/tH5MISC_1_8.F90
index 79fbf3e..b8c777c 100644
--- a/fortran/test/tH5MISC_1_8.F90
+++ b/fortran/test/tH5MISC_1_8.F90
@@ -189,8 +189,9 @@ SUBROUTINE test_h5s_encode(total_error)
INTEGER(hid_t) :: sid1, sid3! Dataspace ID
INTEGER(hid_t) :: decoded_sid1, decoded_sid3
+ INTEGER(hid_t) :: fapl ! File access property
INTEGER :: rank ! LOGICAL rank of dataspace
- INTEGER(size_t) :: sbuf_size=0, scalar_size=0
+ INTEGER(size_t) :: new_size = 0, old_size = 0, orig_size=0, scalar_size=0
! Make sure the size is large
CHARACTER(LEN=288) :: sbuf
@@ -228,18 +229,36 @@ SUBROUTINE test_h5s_encode(total_error)
! Encode simple data space in a buffer
- ! First find the buffer size
- CALL H5Sencode_f(sid1, sbuf, sbuf_size, error)
- CALL check("H5Sencode", error, total_error)
+ ! Find the buffer size without fapl
+ CALL H5Sencode_f(sid1, sbuf, orig_size, error)
+ CALL check("H5Sencode_f", error, total_error)
+ CALL verify("H5Sencode_f", INT(orig_size), 279, total_error)
+
+ ! Create file access property list
+ CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl, error)
+ CALL check("h5pcreate_f", error, total_error)
+
+ ! Find the buffer size with fapl (default old format)
+ CALL H5Sencode_f(sid1, sbuf, old_size, error, fapl)
+ CALL check("H5Sencode_f", error, total_error)
+ CALL verify("H5Sencode_f", INT(old_size), 279, total_error)
+ ! Set fapl to latest file format
+ CALL H5Pset_libver_bounds_f(fapl, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error)
+ CALL check("H5Pset_libver_bounds_f",error, total_error)
- ! Try decoding bogus buffer
+ ! Find the buffer size with fapl set to latest format
+ CALL H5Sencode_f(sid1, sbuf, new_size, error, fapl)
+ CALL check("H5Sencode_f", error, total_error)
+ CALL verify("H5Sencode_f", INT(new_size), 101, total_error)
+ ! Try decoding bogus buffer
CALL H5Sdecode_f(sbuf, decoded_sid1, error)
CALL verify("H5Sdecode", error, -1, total_error)
- CALL H5Sencode_f(sid1, sbuf, sbuf_size, error)
- CALL check("H5Sencode", error, total_error)
+ ! Encode according to the latest file format
+ CALL H5Sencode_f(sid1, sbuf, new_size, error, fapl)
+ CALL check("H5Sencode_f", error, total_error)
! Decode from the dataspace buffer and return an object handle
CALL H5Sdecode_f(sbuf, decoded_sid1, error)
diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c
index a91dab2..d8110a1 100644
--- a/java/src/jni/h5sImp.c
+++ b/java/src/jni/h5sImp.c
@@ -1141,7 +1141,7 @@ Java_hdf_hdf5lib_H5_H5Sencode
if (obj_id < 0)
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sencode: invalid object ID");
- if ((status = H5Sencode(obj_id, NULL, &buf_size)) < 0)
+ if ((status = H5Sencode2(obj_id, NULL, &buf_size, H5P_DEFAULT)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (buf_size == 0)
@@ -1150,7 +1150,7 @@ Java_hdf_hdf5lib_H5_H5Sencode
if (NULL == (bufPtr = (unsigned char *) HDcalloc((size_t) 1, buf_size)))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer");
- if ((status = H5Sencode((hid_t) obj_id, bufPtr, &buf_size)) < 0)
+ if ((status = H5Sencode2((hid_t) obj_id, bufPtr, &buf_size, H5P_DEFAULT)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL == (returnedArray = ENVPTR->NewByteArray(ENVONLY, (jsize) buf_size)))
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5f7bd48..9730436 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -533,6 +533,7 @@ set (H5S_SOURCES
${HDF5_SRC_DIR}/H5S.c
${HDF5_SRC_DIR}/H5Sall.c
${HDF5_SRC_DIR}/H5Sdbg.c
+ ${HDF5_SRC_DIR}/H5Sdeprec.c
${HDF5_SRC_DIR}/H5Shyper.c
${HDF5_SRC_DIR}/H5Smpio.c
${HDF5_SRC_DIR}/H5Snone.c
diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c
index d23cb63..7019362 100644
--- a/src/H5Dmpio.c
+++ b/src/H5Dmpio.c
@@ -2742,6 +2742,9 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty
if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0)
HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size")
+ /* Set to latest format for encoding dataspace */
+ H5CX_set_libver_bounds(NULL);
+
if (*local_chunk_array_num_entries)
if (NULL == (send_requests = (MPI_Request *) H5MM_malloc(*local_chunk_array_num_entries * sizeof(MPI_Request))))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate send requests buffer")
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c
index 6c0cfba..d38df1b 100644
--- a/src/H5Dvirtual.c
+++ b/src/H5Dvirtual.c
@@ -430,6 +430,10 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout)
/* Create block if # of used entries > 0 */
if(layout->storage.u.virt.list_nused > 0) {
+
+ /* Set the low/high bounds according to 'f' for the API context */
+ H5CX_set_libver_bounds(f);
+
/* Allocate array for caching results of strlen */
if(NULL == (str_size = (size_t *)H5MM_malloc(2 * layout->storage.u.virt.list_nused * sizeof(size_t))))
HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate string length array")
diff --git a/src/H5P.c b/src/H5P.c
index 72d7ae8..09ff7f0 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -817,14 +817,17 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5Pencode
+ H5Pencode2
PURPOSE
- Routine to convert the property values in a property list into a binary buffer
+ Routine to convert the property values in a property list into a binary buffer.
+ The encoding of property values will be done according to the file format
+ setting in fapl_id.
USAGE
- herr_t H5Pencode(plist_id, buf, nalloc)
+ herr_t H5Pencode(plist_id, buf, nalloc, fapl_id)
hid_t plist_id; IN: Identifier to property list to encode
void *buf: OUT: buffer to gold the encoded plist
size_t *nalloc; IN/OUT: size of buffer needed to encode plist
+ hid_t fapl_id; IN: File access property list ID
RETURNS
Returns non-negative on success, negative on failure.
DESCRIPTION
@@ -837,25 +840,29 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5Pencode(hid_t plist_id, void *buf, size_t *nalloc)
+H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id)
{
H5P_genplist_t *plist; /* Property list to query */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
- H5TRACE3("e", "i*x*z", plist_id, buf, nalloc);
+ H5TRACE4("e", "i*x*zi", plist_id, buf, nalloc, fapl_id);
/* Check arguments. */
if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
+
/* Call the internal encode routine */
if((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list");
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Pencode() */
+} /* H5Pencode2() */
/*--------------------------------------------------------------------------
diff --git a/src/H5Pdeprec.c b/src/H5Pdeprec.c
index 4a63b36..f6c2a3c 100644
--- a/src/H5Pdeprec.c
+++ b/src/H5Pdeprec.c
@@ -486,6 +486,54 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_version() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Pencode1
+ PURPOSE
+ Routine to convert the property values in a property list into a binary buffer
+ USAGE
+ herr_t H5Pencode1(plist_id, buf, nalloc)
+ hid_t plist_id; IN: Identifier to property list to encode
+ void *buf: OUT: buffer to gold the encoded plist
+ size_t *nalloc; IN/OUT: size of buffer needed to encode plist
+ RETURNS
+ Returns non-negative on success, negative on failure.
+ DESCRIPTION
+ Encodes a property list into a binary buffer. If the buffer is NULL, then
+ the call will set the size needed to encode the plist in nalloc. Otherwise
+ the routine will encode the plist in buf.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc)
+{
+ H5P_genplist_t *plist; /* Property list to query */
+ hid_t temp_fapl_id = H5P_DEFAULT;
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE3("e", "i*x*z", plist_id, buf, nalloc);
+
+ /* Check arguments. */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
+
+ /* Call the internal encode routine */
+ if((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list");
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Pencode1() */
+
/*-------------------------------------------------------------------------
* Function: H5Pset_file_space
*
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index 078fe74..90e6618 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -236,7 +236,7 @@ H5_DLL herr_t H5Pinsert2(hid_t plist_id, const char *name, size_t size,
H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close);
H5_DLL herr_t H5Pset(hid_t plist_id, const char *name, const void *value);
H5_DLL htri_t H5Pexist(hid_t plist_id, const char *name);
-H5_DLL herr_t H5Pencode(hid_t plist_id, void *buf, size_t *nalloc);
+H5_DLL herr_t H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id);
H5_DLL hid_t H5Pdecode(const void *buf);
H5_DLL herr_t H5Pget_size(hid_t id, const char *name, size_t *size);
H5_DLL herr_t H5Pget_nprops(hid_t id, size_t *nprops);
@@ -536,6 +536,7 @@ H5_DLL herr_t H5Pinsert1(hid_t plist_id, const char *name, size_t size,
void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy,
H5P_prp_close_func_t prp_close);
+H5_DLL herr_t H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc);
H5_DLL H5Z_filter_t H5Pget_filter1(hid_t plist_id, unsigned filter,
unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/,
unsigned cd_values[]/*out*/, size_t namelen, char name[]);
diff --git a/src/H5Rint.c b/src/H5Rint.c
index a4f76ce..9098a03 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -215,6 +215,9 @@ H5R__create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H
obj_loc.path = &path;
H5G_loc_reset(&obj_loc);
+ /* Set the FAPL for the API context */
+ H5CX_set_libver_bounds(loc->oloc->file);
+
/* Find the object */
if(H5G_loc_find(loc, name, &obj_loc) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "object not found")
diff --git a/src/H5S.c b/src/H5S.c
index 301060f..3926b5f 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -23,6 +23,7 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Fprivate.h" /* Files */
#include "H5FLprivate.h" /* Free lists */
#include "H5Iprivate.h" /* IDs */
@@ -1487,13 +1488,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Sencode
+ * Function: H5Sencode2
*
* Purpose: Given a dataspace ID, converts the object description
* (including selection) into binary in a buffer.
+ * The selection will be encoded according to the file
+ * format setting in fapl.
*
* Return: Success: non-negative
- * Failure: negative
+ * Failure: negative
*
* Programmer: Raymond Lu
* slu@ncsa.uiuc.edu
@@ -1502,24 +1505,29 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Sencode(hid_t obj_id, void *buf, size_t *nalloc)
+H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl_id)
{
H5S_t *dspace;
herr_t ret_value=SUCCEED;
FUNC_ENTER_API(FAIL)
- H5TRACE3("e", "i*x*z", obj_id, buf, nalloc);
+ H5TRACE4("e", "i*x*zi", obj_id, buf, nalloc, fapl_id);
/* Check argument and retrieve object */
if(NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
+
if(H5S_encode(dspace, (unsigned char **)&buf, nalloc) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace")
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace")
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Sencode() */
+} /* H5Sencode2() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 9823d36..7aa9644 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -629,7 +629,7 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p)
/* Store the preamble information */
UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */
- UINT32ENCODE(pp, (uint32_t)1); /* Store the version number */
+ UINT32ENCODE(pp, (uint32_t)H5S_ALL_VERSION_1); /* Store the version number */
UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */
UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */
diff --git a/src/H5Sdeprec.c b/src/H5Sdeprec.c
new file mode 100644
index 0000000..e4ec1b0
--- /dev/null
+++ b/src/H5Sdeprec.c
@@ -0,0 +1,121 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5Sdeprec.c
+ *
+ * Purpose: Deprecated functions from the H5S interface. These
+ * functions are here for compatibility purposes and may be
+ * removed in the future. Applications should switch to the
+ * newer APIs.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#include "H5Smodule.h" /* This source code file is part of the H5S module */
+
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Spkg.h" /* Dataspaces */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Iprivate.h" /* IDs */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+
+/********************/
+/* Package Typedefs */
+/********************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+
+/*-------------------------------------------------------------------------
+ * Function: H5Sencode1
+ *
+ * Purpose: Given a dataspace ID, converts the object description
+ * (including selection) into binary in a buffer.
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Raymond Lu
+ * slu@ncsa.uiuc.edu
+ * July 14, 2004
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc)
+{
+ H5S_t *dspace;
+ hid_t temp_fapl_id = H5P_DEFAULT;
+ herr_t ret_value=SUCCEED;
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE3("e", "i*x*z", obj_id, buf, nalloc);
+
+ /* Check argument and retrieve object */
+ if (NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
+
+ /* Use (earliest, latest) i.e. not latest format */
+ if(H5S_encode(dspace, (unsigned char **)&buf, nalloc)<0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Sencode1() */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 6d42ec1..a6494d9 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -28,13 +28,14 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* ID Functions */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Spkg.h" /* Dataspace functions */
-#include "H5VMprivate.h" /* Vector functions */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Spkg.h" /* Dataspace functions */
+#include "H5VMprivate.h" /* Vector functions */
/****************/
@@ -157,6 +158,13 @@ const H5S_select_class_t H5S_sel_hyper[1] = {{
H5S__hyper_iter_init,
}};
+/* Format version bounds for dataspace hyperslab selection */
+const unsigned H5O_sds_hyper_ver_bounds[] = {
+ H5S_HYPER_VERSION_1, /* H5F_LIBVER_EARLIEST */
+ H5S_HYPER_VERSION_1, /* H5F_LIBVER_V18 */
+ H5S_HYPER_VERSION_2, /* H5F_LIBVER_V110 */
+ H5S_HYPER_VERSION_3 /* H5F_LIBVER_LATEST */
+};
/*******************/
/* Local Variables */
@@ -3204,8 +3212,9 @@ H5S__hyper_span_nblocks(const H5S_hyper_span_info_t *spans)
PURPOSE
Get the number of hyperslab blocks in current hyperslab selection
USAGE
- hsize_t H5S__get_select_hyper_nblocks(space)
+ hsize_t H5S__get_select_hyper_nblocks(space, app_ref)
H5S_t *space; IN: Dataspace ptr of selection to query
+ hbool_t app_ref; IN: Whether this is an appl. ref. call
RETURNS
The number of hyperslab blocks in selection on success, negative on failure
DESCRIPTION
@@ -3216,7 +3225,7 @@ H5S__hyper_span_nblocks(const H5S_hyper_span_info_t *spans)
REVISION LOG
--------------------------------------------------------------------------*/
static hsize_t
-H5S__get_select_hyper_nblocks(const H5S_t *space)
+H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref)
{
hsize_t ret_value = 0; /* Return value */
@@ -3231,7 +3240,8 @@ H5S__get_select_hyper_nblocks(const H5S_t *space)
/* Check each dimension */
for(ret_value = 1, u = 0; u < space->extent.rank; u++)
- ret_value *= space->select.sel_info.hslab->app_diminfo[u].count;
+ ret_value *= (app_ref ? space->select.sel_info.hslab->app_diminfo[u].count :
+ space->select.sel_info.hslab->opt_diminfo[u].count);
} /* end if */
else
ret_value = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst);
@@ -3274,7 +3284,7 @@ H5Sget_select_hyper_nblocks(hid_t spaceid)
if(space->select.sel_info.hslab->unlim_dim >= 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot get number of blocks for unlimited selection")
- ret_value = (hssize_t)H5S__get_select_hyper_nblocks(space);
+ ret_value = (hssize_t)H5S__get_select_hyper_nblocks(space, TRUE);
done:
FUNC_LEAVE_API(ret_value)
@@ -3283,6 +3293,210 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5S__hyper_get_enc_size_real
+ PURPOSE
+ Determine the size to encode the hyperslab selection info
+ USAGE
+ hssize_t H5S__hyper_get_enc_size_real(max_size, enc_size)
+ hsize_t max_size: IN: The maximum size of the hyperslab selection info
+ unint8_t *enc_size: OUT:The encoding size
+ RETURNS
+ The size to encode hyperslab selection info
+ DESCRIPTION
+ Determine the size by comparing "max_size" with (2^32 - 1) and (2^16 - 1).
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static uint8_t
+H5S__hyper_get_enc_size_real(hsize_t max_size)
+{
+ uint8_t ret_value = H5S_SELECT_INFO_ENC_SIZE_2;
+
+ FUNC_ENTER_STATIC_NOERR
+
+ if(max_size > H5S_UINT32_MAX)
+ ret_value = H5S_SELECT_INFO_ENC_SIZE_8;
+ else if(max_size > H5S_UINT16_MAX)
+ ret_value = H5S_SELECT_INFO_ENC_SIZE_4;
+ else
+ ret_value = H5S_SELECT_INFO_ENC_SIZE_2;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__hyper_get_enc_size_real() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__hyper_get_version_enc_size
+ PURPOSE
+ Determine the version and encoded size to use for encoding hyperslab selection info
+ USAGE
+ hssize_t H5S__hyper_get_version_enc_size(space, block_count, version, enc_size)
+ const H5S_t *space: IN: The dataspace
+ hsize_t block_count: IN: The number of blocks in the selection
+ uint32_t *version: OUT: The version to use for encoding
+ uint8_t *enc_size: OUT: The encoded size to use
+
+ RETURNS
+ The version and the size to encode hyperslab selection info
+ DESCRIPTION
+ Determine the version to use for encoding hyperslab selection info based
+ on the following:
+ (1) the file format setting in fapl
+ (2) whether the number of blocks or selection high bounds exceeds H5S_UINT32_MAX or not
+
+ Determine the encoded size based on version:
+ For version 3, the encoded size is determined according to:
+ (a) regular hyperslab
+ (1) The maximum needed to store start/stride/count/block
+ (2) Special handling for count/block: need to provide room for H5S_UNLIMITED
+ (b) irregular hyperslab
+ The maximum size needed to store:
+ (1) the number of blocks
+ (2) the selection high bounds
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_t *version, uint8_t *enc_size)
+{
+ hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */
+ hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */
+ hbool_t count_up_version = FALSE; /* Whether number of blocks exceed H5S_UINT32_MAX */
+ hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */
+ H5F_libver_t low_bound; /* The 'low' bound of library format versions */
+ H5F_libver_t high_bound; /* The 'high' bound of library format versions */
+ htri_t is_regular; /* A regular hyperslab or not */
+ uint32_t tmp_version; /* Local temporay version */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Get bounding box for the selection */
+ HDmemset(bounds_end, 0, sizeof(bounds_end));
+
+ if(space->select.sel_info.hslab->unlim_dim < 0) { /* ! H5S_UNLIMITED */
+ /* Get bounding box for the selection */
+ if(H5S__hyper_bounds(space, bounds_start, bounds_end) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds")
+ }
+
+ /* Determine whether the number of blocks or the high bounds in the selection exceed (2^32 - 1) */
+ if(block_count > H5S_UINT32_MAX)
+ count_up_version = TRUE;
+ else {
+ for(u = 0; u < space->extent.rank; u++)
+ if(bounds_end[u] > H5S_UINT32_MAX) {
+ bound_up_version = TRUE;
+ break;
+ }
+ }
+
+ /* Get the file's low_bound and high_bound */
+ if(H5CX_get_libver_bounds(&low_bound, &high_bound) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context")
+
+ /* Determine regular hyperslab */
+ is_regular = H5S__hyper_is_regular(space);
+
+ if(low_bound >= H5F_LIBVER_V112 || space->select.sel_info.hslab->unlim_dim >= 0)
+ tmp_version = MAX(H5S_HYPER_VERSION_2, H5O_sds_hyper_ver_bounds[low_bound]);
+
+ else {
+ if(count_up_version || bound_up_version)
+ tmp_version = is_regular ? H5S_HYPER_VERSION_2 : H5S_HYPER_VERSION_3;
+ else
+ tmp_version = (is_regular && block_count >= 4) ? H5O_sds_hyper_ver_bounds[low_bound] : H5S_HYPER_VERSION_1;
+
+ }
+
+ /* Version bounds check */
+ if(tmp_version > H5O_sds_hyper_ver_bounds[high_bound]) {
+ /* Fail for irregular hyperslab if exceeds 32 bits */
+ if(count_up_version)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of blocks in hyperslab selection exceeds 2^32")
+ else if(bound_up_version)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in hyperslab selection exceeds 2^32")
+ else
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace hyperslab selection version out of bounds")
+ }
+
+ /* Set the message version */
+ *version = tmp_version;
+
+ /* Determine the encoded size based on version */
+ switch(tmp_version) {
+ case H5S_HYPER_VERSION_1:
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ break;
+
+ case H5S_HYPER_VERSION_2:
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_8;
+ break;
+
+ case H5S_HYPER_VERSION_3:
+ if(is_regular) {
+ uint8_t enc1, enc2;
+ hsize_t max1 = 0;
+ hsize_t max2 = 0;
+
+ /* Find max for count[] and block[] */
+ for(u = 0; u < space->extent.rank; u++) {
+ if(space->select.sel_info.hslab->opt_diminfo[u].count != H5S_UNLIMITED &&
+ space->select.sel_info.hslab->opt_diminfo[u].count > max1)
+ max1 = space->select.sel_info.hslab->opt_diminfo[u].count;
+ if(space->select.sel_info.hslab->opt_diminfo[u].block != H5S_UNLIMITED &&
+ space->select.sel_info.hslab->opt_diminfo[u].block > max1)
+ max1 = space->select.sel_info.hslab->opt_diminfo[u].block;
+ }
+
+ /* +1 to provide room for H5S_UNLIMITED */
+ enc1 = H5S__hyper_get_enc_size_real(++max1);
+
+ /* Find max for start[] and stride[] */
+ for(u = 0; u < space->extent.rank; u++) {
+ if(space->select.sel_info.hslab->opt_diminfo[u].start > max2)
+ max2 = space->select.sel_info.hslab->opt_diminfo[u].start;
+ if(space->select.sel_info.hslab->opt_diminfo[u].stride > max2)
+ max2 = space->select.sel_info.hslab->opt_diminfo[u].stride;
+ }
+
+ /* Determine the encoding size */
+ enc2 = H5S__hyper_get_enc_size_real(max2);
+
+ *enc_size = MAX(enc1, enc2);
+ } else {
+ hsize_t max_size = block_count;
+ HDassert(space->select.sel_info.hslab->unlim_dim < 0);
+
+ /* Find max for block_count and bounds_end[] */
+ for(u = 0; u < space->extent.rank; u++)
+ if(bounds_end[u] > max_size)
+ max_size = bounds_end[u];
+
+ /* Determine the encoding size */
+ *enc_size = H5S__hyper_get_enc_size_real(max_size);
+ }
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown hyperslab selection version")
+ break;
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__hyper_get_version_enc_size() */
+
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S__hyper_serial_size
PURPOSE
Determine the number of bytes needed to store the serialized hyperslab
@@ -3303,49 +3517,73 @@ done:
static hssize_t
H5S__hyper_serial_size(const H5S_t *space)
{
- hsize_t block_count; /* block counter for regular hyperslabs */
- unsigned u; /* Counter */
- hssize_t ret_value = -1; /* return value */
+ hsize_t block_count = 0; /* block counter for regular hyperslabs */
+ uint32_t version; /* Version number */
+ uint8_t enc_size; /* Encoded size of hyerslab selection info */
+ hssize_t ret_value = -1; /* return value */
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_STATIC
HDassert(space);
- /* Check for version (right now, an unlimited dimension is the only thing
- * that would bump the version) */
- if(space->select.sel_info.hslab->unlim_dim >= 0)
+ if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */
+ block_count = H5S__get_select_hyper_nblocks(space, FALSE);
+
+ /* Determine the version and the encoded size */
+ if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size")
+
+ if(version == H5S_HYPER_VERSION_3) {
+ /* Version 3: regular */
+ /* Size required is always:
+ * <type (4 bytes)> + <version (4 bytes)> + <flags (1 byte)> +
+ * <size of offset info (1 byte)> + <rank (4 bytes)> +
+ * (4 (start/stride/count/block) * <enc_size> * <rank>) =
+ * 14 + (4 * enc_size * rank) bytes
+ */
+ if(H5S__hyper_is_regular(space))
+ ret_value = (hssize_t)14 +
+ ((hssize_t)4 * (hssize_t)enc_size * (hssize_t)space->extent.rank);
+ else {
+ /* Version 3: irregular */
+ /* Size required is always:
+ * <type (4 bytes)> + <version (4 bytes)> + <flags (1 byte)> +
+ * <size of offset info (1 byte)> + <rank (4 bytes)> +
+ * < # of blocks (depend on enc_size) > +
+ * (2 (starting/ending offset) * <rank> * <enc_size> * <# of blocks) =
+ * = 14 bytes + enc_size (block_count) + (2 * enc_size * rank * block_count) bytes
+ */
+ ret_value = 14 + enc_size;
+ H5_CHECK_OVERFLOW(((unsigned)2 * enc_size * space->extent.rank * block_count), hsize_t, hssize_t);
+ ret_value += (hssize_t)((unsigned)2 * enc_size * space->extent.rank * block_count);
+ }
+ } else if(version == H5S_HYPER_VERSION_2) {
/* Version 2 */
/* Size required is always:
* <type (4 bytes)> + <version (4 bytes)> + <flags (1 byte)> +
* <length (4 bytes)> + <rank (4 bytes)> +
- * (4 (start/stride/count/block) * <rank> * <value (8 bytes)>) =
- * 17 + (4 * rank * 8) bytes
+ * (4 (start/stride/count/block) * <enc_size (8 bytes)> * <rank>) =
+ * 17 + (4 * 8 * rank) bytes
*/
- ret_value = (hssize_t)17 + ((hssize_t)4 * (hssize_t)space->extent.rank
- * (hssize_t)8);
- else {
+ HDassert(enc_size == 8);
+ ret_value = (hssize_t)17 + ((hssize_t)4 * (hssize_t)8 * (hssize_t)space->extent.rank);
+ } else {
+ HDassert(version == H5S_HYPER_VERSION_1);
+ HDassert(enc_size == 4);
/* Version 1 */
/* Basic number of bytes required to serialize hyperslab selection:
* <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> +
- * <length (4 bytes)> + <rank (4 bytes)> + <# of blocks (4 bytes)>
- * = 24 bytes
+ * <length (4 bytes)> + <rank (4 bytes)> + <# of blocks (4 bytes)> +
+ * (2 (starting/ending offset) * <enc_size (4 bytes)> * <rank> * <# of blocks) =
+ * = 24 bytes + (2 * 4 * rank * block_count)
*/
ret_value = 24;
-
- /* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
- /* Check each dimension */
- for(block_count = 1, u = 0; u < space->extent.rank; u++)
- block_count *= space->select.sel_info.hslab->opt_diminfo[u].count;
- } /* end if */
- else
- /* Spin through hyperslab spans, adding 8 * rank bytes for each block */
- block_count = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst);
-
H5_CHECK_OVERFLOW((8 * space->extent.rank * block_count), hsize_t, hssize_t);
- ret_value += (hssize_t)(8 * block_count * space->extent.rank);
+ ret_value += (hssize_t)(8 * space->extent.rank * block_count);
} /* end else */
+done:
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__hyper_serial_size() */
@@ -3356,12 +3594,13 @@ H5S__hyper_serial_size(const H5S_t *space)
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- void H5S__hyper_serialize_helper(spans, start, end, rank, buf)
+ void H5S__hyper_serialize_helper(spans, start, end, rank, enc_size, buf)
H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to serialize
hssize_t start[]; IN/OUT: Accumulated start points
hssize_t end[]; IN/OUT: Accumulated end points
hsize_t rank; IN: Current rank looking at
- uint8 *buf; OUT: Buffer to put serialized selection into
+ uint8_t enc_size IN: Encoded size of hyperslab selection info
+ uint8_t *buf; OUT: Buffer to put serialized selection into
RETURNS
None
DESCRIPTION
@@ -3374,7 +3613,7 @@ H5S__hyper_serial_size(const H5S_t *space)
--------------------------------------------------------------------------*/
static void
H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
- hsize_t *start, hsize_t *end, hsize_t rank, uint8_t **p)
+ hsize_t *start, hsize_t *end, hsize_t rank, uint8_t enc_size, uint8_t **p)
{
H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */
uint8_t *pp = (*p); /* Local pointer for decoding */
@@ -3398,26 +3637,65 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
end[rank] = curr->high;
/* Recurse down to the next dimension */
- H5S__hyper_serialize_helper(curr->down, start, end, rank + 1, &pp);
+ H5S__hyper_serialize_helper(curr->down, start, end, rank + 1, enc_size, &pp);
} /* end if */
else {
hsize_t u; /* Index variable */
/* Encode all the previous dimensions starting & ending points */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ /* Encode previous starting points */
+ for(u=0; u<rank; u++)
+ UINT16ENCODE(pp, (uint16_t)start[u]);
+
+ /* Encode starting point for this span */
+ UINT16ENCODE(pp, (uint16_t)curr->low);
+
+ /* Encode previous ending points */
+ for(u=0; u<rank; u++)
+ UINT16ENCODE(pp, (uint16_t)end[u]);
+
+ /* Encode starting point for this span */
+ UINT16ENCODE(pp, (uint16_t)curr->high);
+ break;
- /* Encode previous starting points */
- for(u = 0; u < rank; u++)
- UINT32ENCODE(pp, (uint32_t)start[u]);
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ /* Encode previous starting points */
+ for(u=0; u<rank; u++)
+ UINT32ENCODE(pp, (uint32_t)start[u]);
- /* Encode starting point for this span */
- UINT32ENCODE(pp, (uint32_t)curr->low);
+ /* Encode starting point for this span */
+ UINT32ENCODE(pp, (uint32_t)curr->low);
- /* Encode previous ending points */
- for(u = 0; u < rank; u++)
- UINT32ENCODE(pp, (uint32_t)end[u]);
+ /* Encode previous ending points */
+ for(u=0; u<rank; u++)
+ UINT32ENCODE(pp, (uint32_t)end[u]);
+
+ /* Encode starting point for this span */
+ UINT32ENCODE(pp, (uint32_t)curr->high);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ /* Encode previous starting points */
+ for(u=0; u<rank; u++)
+ UINT64ENCODE(pp, (uint64_t)start[u]);
+
+ /* Encode starting point for this span */
+ UINT64ENCODE(pp, (uint64_t)curr->low);
+
+ /* Encode previous ending points */
+ for(u=0; u<rank; u++)
+ UINT64ENCODE(pp, (uint64_t)end[u]);
+
+ /* Encode starting point for this span */
+ UINT64ENCODE(pp, (uint64_t)curr->high);
+ break;
+
+ default:
+ HDassert(0 && "Unknown enc size?!?");
- /* Encode starting point for this span */
- UINT32ENCODE(pp, (uint32_t)curr->high);
+ } /* end switch */
} /* end else */
/* Advance to next node */
@@ -3455,14 +3733,26 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
static herr_t
H5S__hyper_serialize(const H5S_t *space, uint8_t **p)
{
- uint8_t *pp; /* Local pointer for encoding */
- uint8_t *lenp; /* Pointer to length location for later storage */
- uint32_t len = 0; /* Number of bytes used */
+ const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
+ hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */
+ hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */
+ hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */
+ hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */
+ uint8_t *pp; /* Local pointer for decoding */
+ uint8_t *lenp = NULL; /* pointer to length location for later storage */
+ uint32_t len = 0; /* number of bytes used */
uint32_t version; /* Version number */
uint8_t flags = 0; /* Flags for message */
- hsize_t block_count; /* Block counter for regular hyperslabs */
+ hsize_t block_count = 0; /* block counter for regular hyperslabs */
+ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ unsigned ndims; /* Rank of the dataspace */
+ unsigned i, u; /* Local counting variable */
+ hbool_t complete = FALSE; /* Whether we are done with the iteration */
+ hbool_t is_regular; /* Whether selection is regular */
+ uint8_t enc_size;
+ herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_STATIC
/* Sanity checks */
HDassert(space);
@@ -3470,163 +3760,243 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p)
pp = (*p);
HDassert(pp);
- /* Calculate version */
- if(space->select.sel_info.hslab->unlim_dim >= 0) {
- version = 2;
- flags |= H5S_SELECT_FLAG_UNLIM;
- } /* end if */
- else
- version = 1;
+ /* Set some convienence values */
+ ndims = space->extent.rank;
+ diminfo = space->select.sel_info.hslab->opt_diminfo;
+
+ if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */
+ block_count = H5S__get_select_hyper_nblocks(space, FALSE);
+
+ /* Determine the version and the encoded size */
+ if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size")
+
+ is_regular = H5S__hyper_is_regular(space);
+ if(is_regular &&
+ (version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3))
+ flags |= H5S_HYPER_REGULAR;
/* 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 */
- if(version >= 2)
- *(pp)++ = flags; /* Store the flags */
- else
- 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 */
+
+ if(version >= 3) {
+ *(pp)++ = flags; /* Store the flags */
+ *(pp)++ = enc_size; /* Store size of offset info */
+
+ } else {
+ if(version == 2)
+ *(pp)++ = flags; /* Store the flags */
+ else
+ 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 += 4; /* ndims */
+ }
/* Encode number of dimensions */
- UINT32ENCODE(pp, (uint32_t)space->extent.rank);
- len += 4;
+ UINT32ENCODE(pp, (uint32_t)ndims);
- /* If there is an unlimited dimension, only encode opt_unlim_diminfo */
- if(flags & H5S_SELECT_FLAG_UNLIM) {
- unsigned i;
+ if(is_regular) {
- HDassert(H5S_UNLIMITED == HSIZE_UNDEF);
+ if(version >= H5S_HYPER_VERSION_2) {
+
+ HDassert(H5S_UNLIMITED == HSIZE_UNDEF);
- /* Iterate over dimensions */
- for(i = 0; i < space->extent.rank; i++) {
+ /* Iterate over dimensions */
/* Encode start/stride/block/count */
- UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].start);
- UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].stride);
- UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].count);
- UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].block);
- } /* end for */
- len += (4 * space->extent.rank * 8);
- } /* end if */
- /* Check for a "regular" hyperslab selection */
- else if(space->select.sel_info.hslab->diminfo_valid) {
- const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
- hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */
- hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */
- unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
- unsigned ndims; /* Rank of the dataspace */
- unsigned u; /* Local counting variable */
- hbool_t done; /* Whether we are done with the iteration */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ HDassert(version == H5S_HYPER_VERSION_3);
+ for(i = 0; i < space->extent.rank; i++) {
+ UINT16ENCODE(pp, diminfo[i].start);
+ UINT16ENCODE(pp, diminfo[i].stride);
+ if(diminfo[i].count == H5S_UNLIMITED) {
+ UINT16ENCODE(pp, H5S_UINT16_MAX);
+ } else {
+ UINT16ENCODE(pp, diminfo[i].count);
+ }
+
+ if(diminfo[i].block == H5S_UNLIMITED) {
+ UINT16ENCODE(pp, H5S_UINT16_MAX);
+ } else {
+ UINT16ENCODE(pp, diminfo[i].block);
+ }
+ } /* end for */
+ break;
- /* Set some convenience values */
- ndims = space->extent.rank;
- fast_dim = ndims - 1;
- diminfo = space->select.sel_info.hslab->opt_diminfo;
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ HDassert(version == H5S_HYPER_VERSION_3);
+ for(i = 0; i < space->extent.rank; i++) {
+ UINT32ENCODE(pp, diminfo[i].start);
+ UINT32ENCODE(pp, diminfo[i].stride);
+ if(diminfo[i].count == H5S_UNLIMITED) {
+ UINT32ENCODE(pp, H5S_UINT32_MAX);
+ } else {
+ UINT32ENCODE(pp, diminfo[i].count);
+ }
+ if(diminfo[i].block == H5S_UNLIMITED) {
+ UINT32ENCODE(pp, H5S_UINT32_MAX);
+ } else {
+ UINT32ENCODE(pp, diminfo[i].block);
+ }
+ } /* end for */
+ break;
- /* Check each dimension */
- for(block_count = 1, u = 0; u < ndims; u++)
- block_count *= diminfo[u].count;
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ HDassert(version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3);
+ for(i = 0; i < space->extent.rank; i++) {
+ UINT64ENCODE(pp, diminfo[i].start);
+ UINT64ENCODE(pp, diminfo[i].stride);
+ if(diminfo[i].count == H5S_UNLIMITED) {
+ UINT64ENCODE(pp, H5S_UINT64_MAX);
+ } else {
+ UINT64ENCODE(pp, diminfo[i].count);
+ }
+ if(diminfo[i].block == H5S_UNLIMITED) {
+ UINT64ENCODE(pp, H5S_UINT64_MAX);
+ } else {
+ UINT64ENCODE(pp, diminfo[i].block);
+ }
+ } /* end for */
+ if(version == H5S_HYPER_VERSION_2)
+ len += (4 * space->extent.rank * 8);
+ break;
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ } /* end switch */
- /* Encode number of hyperslabs */
- H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t);
- UINT32ENCODE(pp, (uint32_t)block_count);
- len += 4;
+ } else {
- /* Now serialize the information for the regular hyperslab */
+ HDassert(version == H5S_HYPER_VERSION_1);
+
+ /* Set some convienence values */
+ fast_dim = ndims - 1;
- /* Build the tables of count sizes as well as the initial offset */
- for(u = 0; u < ndims; u++) {
- tmp_count[u] = diminfo[u].count;
- offset[u] = diminfo[u].start;
- } /* end for */
+ /* Encode number of hyperslabs */
+ H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t);
+ UINT32ENCODE(pp, (uint32_t)block_count);
+ len += 4;
- /* We're not done with the iteration */
- done = FALSE;
+ /* Now serialize the information for the regular hyperslab */
- /* Go iterate over the hyperslabs */
- while(done == FALSE) {
- /* Iterate over the blocks in the fastest dimension */
- while(tmp_count[fast_dim] > 0) {
- /* Add 8 bytes times the rank for each hyperslab selected */
- len += 8 * ndims;
+ /* Build the tables of count sizes as well as the initial offset */
+ for(u = 0; u < ndims; u++) {
+ tmp_count[u] = diminfo[u].count;
+ offset[u] = diminfo[u].start;
+ } /* end for */
- /* Encode hyperslab starting location */
- for(u = 0; u < ndims; u++)
- UINT32ENCODE(pp, (uint32_t)offset[u]);
+ /* Go iterate over the hyperslabs */
+ while(complete == FALSE) {
+ /* Iterate over the blocks in the fastest dimension */
+ while(tmp_count[fast_dim] > 0) {
+ /* Add 8 bytes times the rank for each hyperslab selected */
+ len += 8 * ndims;
- /* Encode hyperslab ending location */
- for(u = 0; u < ndims; u++)
- UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1)));
+ /* Encode hyperslab starting location */
+ for(u = 0; u < ndims; u++)
+ UINT32ENCODE(pp, (uint32_t)offset[u]);
- /* Move the offset to the next sequence to start */
- offset[fast_dim]+=diminfo[fast_dim].stride;
+ /* Encode hyperslab ending location */
+ for(u = 0; u < ndims; u++)
+ UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1)));
- /* Decrement the block count */
- tmp_count[fast_dim]--;
- } /* end while */
+ /* Move the offset to the next sequence to start */
+ offset[fast_dim]+=diminfo[fast_dim].stride;
+
+ /* Decrement the block count */
+ tmp_count[fast_dim]--;
+ } /* end while */
- /* Work on other dimensions if necessary */
- if(fast_dim > 0) {
- int temp_dim; /* Temporary rank holder */
+ /* Work on other dimensions if necessary */
+ if(fast_dim > 0) {
+ int temp_dim; /* Temporary rank holder */
- /* Reset the block counts */
- tmp_count[fast_dim] = diminfo[fast_dim].count;
+ /* Reset the block counts */
+ tmp_count[fast_dim] = diminfo[fast_dim].count;
- /* Bubble up the decrement to the slower changing dimensions */
- temp_dim = (int)fast_dim - 1;
- while(temp_dim >= 0 && done == FALSE) {
- /* Decrement the block count */
- tmp_count[temp_dim]--;
+ /* Bubble up the decrement to the slower changing dimensions */
+ temp_dim = (int)fast_dim - 1;
+ while(temp_dim >= 0 && complete == FALSE) {
+ /* Decrement the block count */
+ tmp_count[temp_dim]--;
- /* Check if we have more blocks left */
- if(tmp_count[temp_dim] > 0)
- break;
+ /* Check if we have more blocks left */
+ if(tmp_count[temp_dim] > 0)
+ break;
- /* Check for getting out of iterator */
- if(temp_dim == 0)
- done = TRUE;
+ /* Check for getting out of iterator */
+ if(temp_dim == 0)
+ complete = TRUE;
- /* Reset the block count in this dimension */
- tmp_count[temp_dim] = diminfo[temp_dim].count;
+ /* Reset the block count in this dimension */
+ tmp_count[temp_dim] = diminfo[temp_dim].count;
- /* Wrapped a dimension, go up to next dimension */
- temp_dim--;
- } /* end while */
- } /* end if */
- else
- break; /* Break out now, for 1-D selections */
+ /* Wrapped a dimension, go up to next dimension */
+ temp_dim--;
+ } /* end while */
+ } /* end if */
+ else
+ break; /* Break out now, for 1-D selections */
- /* Re-compute offset array */
- for(u = 0; u < ndims; u++)
- offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]);
- } /* end while */
- } /* end if */
- else {
- hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */
- hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */
+ /* Re-compute offset array */
+ for(u = 0; u < ndims; u++)
+ offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]);
+ } /* end while */
+
+ } /* end else */
+
+ } else { /* irregular */
/* Encode number of hyperslabs */
- block_count = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst);
- H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t);
- UINT32ENCODE(pp, (uint32_t)block_count);
- len += 4;
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ HDassert(version == H5S_HYPER_VERSION_3);
+ H5_CHECK_OVERFLOW(block_count, hsize_t, uint16_t);
+ UINT16ENCODE(pp, (uint16_t)block_count);
+ break;
- /* Add 8 bytes times the rank for each hyperslab selected */
- H5_CHECK_OVERFLOW((8 * space->extent.rank * block_count), hsize_t, size_t);
- len += (uint32_t)(8 * space->extent.rank * block_count);
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ HDassert(version == H5S_HYPER_VERSION_1 || version == H5S_HYPER_VERSION_3);
+ H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t);
+ UINT32ENCODE(pp, (uint32_t)block_count);
+ break;
- /* Encode each hyperslab in selection */
- H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, &pp);
- } /* end else */
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ HDassert(version == H5S_HYPER_VERSION_3);
+ UINT64ENCODE(pp, block_count);
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ } /* end switch */
+
+ if(version == H5S_HYPER_VERSION_1) {
+ len+=4; /* block_count */
+
+ /* Add 8 bytes times the rank for each hyperslab selected */
+ H5_CHECK_OVERFLOW((8 * ndims * block_count), hsize_t, size_t);
+ len += (uint32_t)(8 * ndims * block_count);
+ }
+
+ H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, enc_size, &pp);
+
+ }
/* Encode length */
- UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
+ if(version <= H5S_HYPER_VERSION_2)
+ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
/* Update encoding pointer */
*p = pp;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S__hyper_serialize() */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__hyper_serialize() */
+
/*--------------------------------------------------------------------------
@@ -3657,14 +4027,15 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p)
H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use,
either *space or a newly allocated one */
hsize_t dims[H5S_MAX_RANK]; /* Dimenion sizes */
- hsize_t start[H5S_MAX_RANK]; /* Hyperslab start information */
- hsize_t block[H5S_MAX_RANK]; /* Hyperslab block information */
+ hsize_t start[H5S_MAX_RANK]; /* hyperslab start information */
+ hsize_t block[H5S_MAX_RANK]; /* hyperslab block information */
uint32_t version; /* Version number */
uint8_t flags = 0; /* Flags */
- unsigned rank; /* Rank of points */
+ uint8_t enc_size = 0; /* Encoded size of selection info */
+ unsigned rank; /* rank of points */
const uint8_t *pp; /* Local pointer for decoding */
- unsigned u; /* Local counting variable */
- herr_t ret_value = FAIL; /* Return value */
+ unsigned u; /* Local counting variable */
+ herr_t ret_value=FAIL; /* return value */
FUNC_ENTER_STATIC
@@ -3688,15 +4059,31 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p)
/* Decode version */
UINT32DECODE(pp, version);
- if(version >= (uint32_t)2) {
+ if(version >= (uint32_t)H5S_HYPER_VERSION_2) {
/* Decode flags */
flags = *(pp)++;
- /* Skip over the remainder of the header */
- pp += 4;
- } else
+ if(version >= (uint32_t)H5S_HYPER_VERSION_3)
+ /* decode size of offset info */
+ enc_size = *(pp)++;
+ else {
+ /* Skip over the remainder of the header */
+ pp += 4;
+ enc_size = H5S_SELECT_INFO_ENC_SIZE_8;
+ }
+
+ /* Check for unknown flags */
+ if(flags & ~H5S_SELECT_FLAG_BITS)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown flag for selection")
+ } else {
/* Skip over the remainder of the header */
pp += 8;
+ enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ }
+
+ /* Check encoded */
+ if(enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection")
/* Decode the rank of the point selection */
UINT32DECODE(pp,rank);
@@ -3712,24 +4099,66 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p)
if(rank != tmp_space->extent.rank)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace")
- /* If there is an unlimited dimension, only encode opt_unlim_diminfo */
- if(flags & H5S_SELECT_FLAG_UNLIM) {
+ if(flags & H5S_HYPER_REGULAR) {
hsize_t stride[H5S_MAX_RANK]; /* Hyperslab stride information */
- hsize_t count[H5S_MAX_RANK]; /* Hyperslab count information */
+ hsize_t count[H5S_MAX_RANK]; /* Hyperslab count information */
/* Sanity checks */
HDassert(H5S_UNLIMITED == HSIZE_UNDEF);
HDassert(version >= 2);
- /* Iterate over dimensions */
- for(u = 0; u < rank; u++) {
- /* Decode start/stride/block/count */
- UINT64DECODE(pp, start[u]);
- UINT64DECODE(pp, stride[u]);
- UINT64DECODE(pp, count[u]);
- UINT64DECODE(pp, block[u]);
- } /* end for */
+ /* Decode start/stride/block/count */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ for(u = 0; u < tmp_space->extent.rank; u++) {
+ UINT16DECODE(pp, start[u]);
+ UINT16DECODE(pp, stride[u]);
+
+ UINT16DECODE(pp, count[u]);
+ if((uint16_t)count[u] == H5S_UINT16_MAX)
+ count[u] = H5S_UNLIMITED;
+
+ UINT16DECODE(pp, block[u]);
+ if((uint16_t)block[u] == H5S_UINT16_MAX)
+ block[u] = H5S_UNLIMITED;
+ } /* end for */
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ for(u = 0; u < tmp_space->extent.rank; u++) {
+ UINT32DECODE(pp, start[u]);
+ UINT32DECODE(pp, stride[u]);
+
+ UINT32DECODE(pp, count[u]);
+ if((uint32_t)count[u] == H5S_UINT32_MAX)
+ count[u] = H5S_UNLIMITED;
+
+ UINT32DECODE(pp, block[u]);
+ if((uint32_t)block[u] == H5S_UINT32_MAX)
+ block[u] = H5S_UNLIMITED;
+ } /* end for */
+ break;
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ for(u = 0; u < tmp_space->extent.rank; u++) {
+ UINT64DECODE(pp, start[u]);
+ UINT64DECODE(pp, stride[u]);
+
+ UINT64DECODE(pp, count[u]);
+ if((uint64_t)count[u] == H5S_UINT64_MAX)
+ count[u] = H5S_UNLIMITED;
+
+ UINT64DECODE(pp, block[u]);
+ if((uint64_t)block[u] == H5S_UINT64_MAX)
+ block[u] = H5S_UNLIMITED;
+ } /* end for */
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ } /* end switch */
+
/* Select the hyperslab to the current selection */
if((ret_value = H5S_select_hyperslab(tmp_space, H5S_SELECT_SET, start, stride, count, block)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection")
@@ -3737,28 +4166,65 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p)
else {
const hsize_t *stride; /* Hyperslab stride information */
const hsize_t *count; /* Hyperslab count information */
- hsize_t end[H5S_MAX_RANK]; /* Hyperslab end information */
- hsize_t *tstart; /* Temporary hyperslab pointers */
- hsize_t *tend; /* Temporary hyperslab pointers */
- hsize_t *tblock; /* Temporary hyperslab pointers */
- size_t block_count; /* Number of blocks in selection */
- unsigned v; /* Local counting variable */
+ hsize_t end[H5S_MAX_RANK]; /* Hyperslab end information */
+ hsize_t *tstart; /* Temporary hyperslab pointers */
+ hsize_t *tend; /* Temporary hyperslab pointers */
+ hsize_t *tblock; /* Temporary hyperslab pointers */
+ size_t num_elem; /* Number of elements in selection */
+ unsigned v; /* Local counting variable */
+
+ /* decode the number of blocks */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ UINT16DECODE(pp, num_elem);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ UINT32DECODE(pp, num_elem);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ UINT64DECODE(pp, num_elem);
+ break;
- /* Decode the number of blocks */
- UINT32DECODE(pp, block_count);
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ }
/* Set the count & stride for all blocks */
stride = count = H5S_hyper_ones_g;
/* Retrieve the coordinates from the buffer */
- for(u = 0; u < block_count; u++) {
- /* Decode the starting points */
- for(tstart = start, v = 0; v < rank; v++, tstart++)
- UINT32DECODE(pp, *tstart);
-
- /* Decode the ending points */
- for(tend = end, v = 0; v < rank; v++, tend++)
- UINT32DECODE(pp, *tend);
+ for(u = 0; u < num_elem; u++) {
+
+ /* Decode the starting and ending points */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ for(tstart = start, v = 0; v < rank; v++, tstart++)
+ UINT16DECODE(pp, *tstart);
+ for(tend = end, v = 0; v < rank; v++, tend++)
+ UINT16DECODE(pp, *tend);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ for(tstart = start,v = 0; v < rank; v++, tstart++)
+ UINT32DECODE(pp, *tstart);
+ for(tend = end, v = 0; v < rank; v++, tend++)
+ UINT32DECODE(pp, *tend);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ for(tstart = start, v = 0; v < rank; v++, tstart++)
+ UINT64DECODE(pp, *tstart);
+ for(tend = end, v = 0; v < rank; v++, tend++)
+ UINT64DECODE(pp, *tend);
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab")
+ break;
+ }
/* Change the ending points into blocks */
for(tblock = block, tstart = start, tend = end, v = 0; v < rank; v++, tstart++, tend++, tblock++)
diff --git a/src/H5Snone.c b/src/H5Snone.c
index cae9a67..6219bb1 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -583,7 +583,7 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p)
/* Store the preamble information */
UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */
- UINT32ENCODE(pp, (uint32_t)1); /* Store the version number */
+ UINT32ENCODE(pp, (uint32_t)H5S_NONE_VERSION_1); /* Store the version number */
UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */
UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */
diff --git a/src/H5Spkg.h b/src/H5Spkg.h
index 2918648..56b1f30 100644
--- a/src/H5Spkg.h
+++ b/src/H5Spkg.h
@@ -37,8 +37,35 @@
#define H5S_VALID_PERM 0x02
/* Flags for serialization of selections */
-#define H5S_SELECT_FLAG_UNLIM 0x01
-#define H5S_SELECT_FLAG_BITS (H5S_SELECT_FLAG_UNLIM)
+#define H5S_HYPER_REGULAR 0x01
+#define H5S_SELECT_FLAG_BITS (H5S_HYPER_REGULAR)
+
+/* Versions for H5S_SEL_HYPER selection info */
+#define H5S_HYPER_VERSION_1 1
+#define H5S_HYPER_VERSION_2 2
+#define H5S_HYPER_VERSION_3 3
+
+/* Versions for H5S_SEL_POINTS selection info */
+#define H5S_POINT_VERSION_1 1
+#define H5S_POINT_VERSION_2 2
+
+/* Versions for H5S_SEL_NONE selection info */
+#define H5S_NONE_VERSION_1 1
+
+/* Versions for H5S_SEL_ALL selection info */
+#define H5S_ALL_VERSION_1 1
+
+/* Encoded size of selection info for H5S_SEL_POINTS/H5S_SEL_HYPER */
+#define H5S_SELECT_INFO_ENC_SIZE_2 0x02 /* 2 bytes: 16 bits */
+#define H5S_SELECT_INFO_ENC_SIZE_4 0x04 /* 4 bytes: 32 bits */
+#define H5S_SELECT_INFO_ENC_SIZE_8 0x08 /* 8 bytes: 64 bits */
+#define H5S_SELECT_INFO_ENC_SIZE_BITS ( H5S_SELECT_INFO_ENC_SIZE_2 | \
+ H5S_SELECT_INFO_ENC_SIZE_4 | \
+ H5S_SELECT_INFO_ENC_SIZE_8 )
+
+#define H5S_UINT16_MAX 0x0000FFFF /* 2^16 - 1 = 65,535 */
+#define H5S_UINT32_MAX 0xFFFFFFFF /* 2^32 - 1 = 4,294,967,295 */
+#define H5S_UINT64_MAX ((hsize_t)(-1L)) /* 2^64 - 1 = 18,446,744,073,709,551,615 */
/* Length of stack-allocated sequences for "project intersect" routines */
#define H5S_PROJECT_INTERSECT_NSEQS 256
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index ac9c983..0bdabb4 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -28,13 +28,14 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* ID Functions */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Spkg.h" /* Dataspace functions */
-#include "H5VMprivate.h" /* Vector functions */
+#include "H5Iprivate.h" /* ID Functions */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Spkg.h" /* Dataspace functions */
+#include "H5VMprivate.h" /* Vector functions */
/****************/
@@ -72,6 +73,8 @@ static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space,
hsize_t *offset);
static herr_t H5S__point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
+static herr_t
+ H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size);
/* Selection iteration callbacks */
static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
@@ -118,6 +121,13 @@ const H5S_select_class_t H5S_sel_point[1] = {{
H5S__point_iter_init,
}};
+/* Format version bounds for dataspace hyperslab selection */
+const unsigned H5O_sds_point_ver_bounds[] = {
+ H5S_POINT_VERSION_1, /* H5F_LIBVER_EARLIEST */
+ H5S_POINT_VERSION_1, /* H5F_LIBVER_V18 */
+ H5S_POINT_VERSION_1, /* H5F_LIBVER_V110 */
+ H5S_POINT_VERSION_2 /* H5F_LIBVER_LATEST */
+};
/*******************/
/* Local Variables */
@@ -919,6 +929,124 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Sget_select_elem_npoints() */
+/*--------------------------------------------------------------------------
+ NAME
+ H5S__point_get_version_enc_size
+ PURPOSE
+ Determine the version and the size (2, 4 or 8 bytes) to encode point selection info
+ USAGE
+ hssize_t H5S__point_set_enc_size(space, version, enc_size)
+ const H5S_t *space: IN: Dataspace ID of selection to query
+ uint32_t *version: OUT: The version to use for encoding
+ uint8_t *enc_size: OUT: The size to use for encoding
+ RETURNS
+ The version and the size to encode point selection info
+ DESCRIPTION
+ Determine the version to use for encoding points selection info based
+ on the following:
+ (1) the low/high bounds setting in fapl
+ (2) whether the number of points or selection high bounds exceeds H5S_UINT32_MAX or not
+
+ Determine the encoded size based on version:
+ --For version 2, the encoded size of point selection info is determined
+ by the maximum size for:
+ (a) storing the number of points
+ (b) storing the selection high bounds
+
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size)
+{
+ hbool_t count_up_version = FALSE; /* Whether number of points exceed H5S_UINT32_MAX */
+ hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */
+ H5F_libver_t low_bound; /* The 'low' bound of library format versions */
+ H5F_libver_t high_bound; /* The 'high' bound of library format versions */
+ uint32_t tmp_version; /* Local temporary version */
+ hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */
+ hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */
+ hsize_t max_size = 0; /* Maximum selection size */
+ unsigned u; /* Local index veriable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* 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 whether number of points or high bounds exceeds (2^32 - 1) */
+ if(space->select.num_elem > H5S_UINT32_MAX)
+ count_up_version = TRUE;
+ else {
+ for(u = 0; u < space->extent.rank; u++)
+ if(bounds_end[u] > H5S_UINT32_MAX) {
+ bound_up_version = TRUE;
+ break;
+ }
+ }
+
+ /* If exceed (2^32 -1) */
+ if(count_up_version || bound_up_version)
+ tmp_version = H5S_POINT_VERSION_2;
+ else
+ tmp_version = H5S_POINT_VERSION_1;
+
+ /* Get the file's low/high bounds */
+ if(H5CX_get_libver_bounds(&low_bound, &high_bound) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context")
+
+ /* Upgrade to the version indicated by the file's low bound if higher */
+ tmp_version = MAX(tmp_version, H5O_sds_point_ver_bounds[low_bound]);
+
+ /* Version bounds check */
+ if(tmp_version > H5O_sds_point_ver_bounds[high_bound]) {
+ if(count_up_version)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of points in point selection exceeds 2^32")
+ else if(bound_up_version)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in point selection exceeds 2^32")
+ else
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace point selection version out of bounds")
+ }
+
+ /* Set the version to return */
+ *version = tmp_version;
+
+ /* Get the encoded size use based on version */
+ switch(tmp_version) {
+ case H5S_POINT_VERSION_1:
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ break;
+
+ case H5S_POINT_VERSION_2:
+ /* Find max for num_elem and bounds_end[] */
+ max_size = space->select.num_elem;
+ for(u = 0; u < space->extent.rank; u++)
+ if(bounds_end[u] > max_size)
+ max_size = bounds_end[u];
+
+ /* Determine the encoding size */
+ if(max_size > H5S_UINT32_MAX)
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_8;
+ else if(max_size > H5S_UINT16_MAX)
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ else
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_2;
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size")
+ break;
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__point_get_version_enc_size() */
+
/*--------------------------------------------------------------------------
NAME
@@ -942,22 +1070,39 @@ done:
static hssize_t
H5S__point_serial_size(const H5S_t *space)
{
+ uint32_t version; /* Version number */
+ uint8_t enc_size; /* Encoded size of point selection info */
hssize_t ret_value = -1; /* Return value */
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_STATIC
HDassert(space);
- /* Basic number of bytes required to serialize point selection:
- * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> +
- * <length (4 bytes)> + <rank (4 bytes)> + <# of points (4 bytes)> = 24 bytes
- */
- ret_value = 24;
+ /* Determine the version and encoded size for point selection */
+ if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version")
+
+ /* Basic number of bytes required to serialize point selection: */
+ if(version >= H5S_POINT_VERSION_2)
+ /*
+ * <type (4 bytes)> + <version (4 bytes)> +
+ * <size of point info (1 byte)> + rank (4 bytes)>
+ */
+ ret_value=13;
+ else
+ /*
+ * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> +
+ * <length (4 bytes)> + <rank (4 bytes)>
+ */
+ ret_value = 20;
+
+ /* <num points (depend on enc_size)> */
+ ret_value += enc_size;
/* Count points in selection */
- /* (Add 4 bytes times the rank for each element selected) */
- ret_value += (4 * space->extent.rank) * (hssize_t)H5S_GET_SELECT_NPOINTS(space);
+ ret_value += (hssize_t) (enc_size * space->extent.rank * space->select.num_elem);
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__point_serial_size() */
@@ -987,12 +1132,15 @@ static herr_t
H5S__point_serialize(const H5S_t *space, uint8_t **p)
{
H5S_pnt_node_t *curr; /* Point information nodes */
- uint8_t *pp; /* Local pointer for encoding */
- uint8_t *lenp; /* Pointer to length location for later storage */
- uint32_t len = 0; /* Number of bytes used */
- unsigned u; /* Local counting variable */
+ uint8_t *pp; /* Local pointer for decoding */
+ uint8_t *lenp = NULL; /* 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 enc_size; /* Encoded size of point selection info */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_STATIC_NOERR
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(space);
@@ -1000,42 +1148,96 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p)
pp = (*p);
HDassert(pp);
+ /* Determine the version and encoded size for point selection info */
+ if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version")
+
/* Store the preamble information */
UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */
- 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 */
+
+ UINT32ENCODE(pp, version); /* Store the version number */
+ if(version >= 2) {
+ *(pp)++ = enc_size; /* Store size of point info */
+ } else {
+ HDassert(version == H5S_POINT_VERSION_1);
+ 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 */
+ }
/* 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;
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ HDassert(version == H5S_POINT_VERSION_2);
+
+ /* Encode number of elements */
+ UINT16ENCODE(pp, (uint16_t)space->select.num_elem);
+
+ /* Encode each point in selection */
+ curr=space->select.sel_info.pnt_lst->head;
+ while(curr!=NULL) {
+ /* Encode each point */
+ for(u=0; u<space->extent.rank; u++)
+ UINT16ENCODE(pp, (uint16_t)curr->pnt[u]);
+ curr=curr->next;
+ } /* end while */
+ break;
- /* 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;
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ HDassert(version == H5S_POINT_VERSION_1 || version == H5S_POINT_VERSION_2);
- /* Encode each point */
- for(u = 0; u < space->extent.rank; u++)
- UINT32ENCODE(pp, (uint32_t)curr->pnt[u]);
+ /* Encode number of elements */
+ UINT32ENCODE(pp, (uint32_t)space->select.num_elem);
- curr = curr->next;
- } /* end while */
+ /* Encode each point in selection */
+ curr=space->select.sel_info.pnt_lst->head;
+ while(curr!=NULL) {
+ /* Encode each point */
+ for(u=0; u<space->extent.rank; u++)
+ UINT32ENCODE(pp, (uint32_t)curr->pnt[u]);
+ curr=curr->next;
+ } /* end while */
+
+ /* Add 4 bytes times the rank for each element selected */
+ if(version == H5S_POINT_VERSION_1)
+ len += (uint32_t)space->select.num_elem * 4 * space->extent.rank;
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ HDassert(version == H5S_POINT_VERSION_2);
+
+ /* Encode number of elements */
+ UINT64ENCODE(pp, space->select.num_elem);
+
+ /* Encode each point in selection */
+ curr=space->select.sel_info.pnt_lst->head;
+ while(curr!=NULL) {
+ /* Encode each point */
+ for(u=0; u<space->extent.rank; u++)
+ UINT64ENCODE(pp, curr->pnt[u]);
+ curr=curr->next;
+ } /* end while */
+ break;
- /* Encode length */
- UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size")
+ break;
+
+ } /* end switch */
+
+ if(version == H5S_POINT_VERSION_1)
+ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
/* Update encoding pointer */
*p = pp;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S__point_serialize() */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5S__point_serialize() */
+
/*--------------------------------------------------------------------------
@@ -1067,9 +1269,10 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p)
either *space or a newly allocated one */
hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */
uint32_t version; /* Version number */
+ uint8_t enc_size = 0; /* Encoded size of selection info */
hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */
const uint8_t *pp; /* Local pointer for decoding */
- size_t num_elem = 0; /* Number of elements in selection */
+ uint64_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 */
@@ -1096,8 +1299,18 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p)
/* Decode version */
UINT32DECODE(pp, version);
- /* Skip over the remainder of the header */
- pp += 8;
+ if(version >= (uint32_t)H5S_POINT_VERSION_2)
+ /* Decode size of point info */
+ enc_size = *(pp)++;
+ else {
+ /* Skip over the remainder of the header */
+ pp += 8;
+ enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+ }
+
+ /* Check encoded size */
+ if(enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection")
/* Decode the rank of the point selection */
UINT32DECODE(pp,rank);
@@ -1113,8 +1326,22 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p)
if(rank != tmp_space->extent.rank)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace")
- /* Deserialize points to select */
- UINT32DECODE(pp, num_elem); /* decode the number of points */
+ /* decode the number of points */
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ UINT16DECODE(pp, num_elem);
+ break;
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ UINT32DECODE(pp, num_elem);
+ break;
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ UINT64DECODE(pp, num_elem);
+ break;
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size")
+ break;
+ } /* end switch */
+
/* Allocate space for the coordinates */
if(NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t))))
@@ -1123,7 +1350,22 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p)
/* Retrieve the coordinates from the buffer */
for(tcoord = coord, i = 0; i < num_elem; i++)
for(j = 0; j < (unsigned)rank; j++, tcoord++)
- UINT32DECODE(pp, *tcoord);
+ switch(enc_size) {
+ case H5S_SELECT_INFO_ENC_SIZE_2:
+ UINT16DECODE(pp, *tcoord);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_4:
+ UINT32DECODE(pp, *tcoord);
+ break;
+
+ case H5S_SELECT_INFO_ENC_SIZE_8:
+ UINT64DECODE(pp, *tcoord);
+ break;
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size")
+ break;
+ } /* end switch */
/* Select points */
if(H5S_select_elements(tmp_space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0)
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index 561875a..c01beca 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -97,7 +97,7 @@ H5_DLL herr_t H5Sset_extent_simple(hid_t space_id, int rank,
const hsize_t dims[], const hsize_t max[]);
H5_DLL hid_t H5Scopy(hid_t space_id);
H5_DLL herr_t H5Sclose(hid_t space_id);
-H5_DLL herr_t H5Sencode(hid_t obj_id, void *buf, size_t *nalloc);
+H5_DLL herr_t H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl);
H5_DLL hid_t H5Sdecode(const void *buf);
H5_DLL hssize_t H5Sget_simple_extent_npoints(hid_t space_id);
H5_DLL int H5Sget_simple_extent_ndims(hid_t space_id);
@@ -134,6 +134,16 @@ H5_DLL hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid);
H5_DLL herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock,
hsize_t numblocks, hsize_t buf[/*numblocks*/]);
+/* Symbols defined for compatibility with previous versions of the HDF5 API.
+ *
+ * Use of these symbols is deprecated.
+ */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+/* Function prototypes */
+H5_DLL herr_t H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc);
+
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
#ifdef __cplusplus
}
#endif
diff --git a/src/H5vers.txt b/src/H5vers.txt
index 914c30e..22117c3 100644
--- a/src/H5vers.txt
+++ b/src/H5vers.txt
@@ -61,12 +61,14 @@ FUNCTION: H5Oget_info_by_name; ; v18, v112
FUNCTION: H5Oget_info_by_idx; ; v18, v112
FUNCTION: H5Ovisit; ; v18, v112
FUNCTION: H5Ovisit_by_name; ; v18, v112
+FUNCTION: H5Pencode; ; v110, v112
FUNCTION: H5Pget_filter; ; v10, v18
FUNCTION: H5Pget_filter_by_id; ; v16, v18
FUNCTION: H5Pinsert; ; v14, v18
FUNCTION: H5Pregister; ; v14, v18
FUNCTION: H5Rdereference; ; v10, v110
FUNCTION: H5Rget_obj_type; ; v16, v18
+FUNCTION: H5Sencode; ; v18, v112
FUNCTION: H5Tarray_create; ; v14, v18
FUNCTION: H5Tcommit; ; v10, v18
FUNCTION: H5Tget_array_dims; ; v14, v18
diff --git a/src/Makefile.am b/src/Makefile.am
index 5532655..378e390 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -102,7 +102,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5R.c H5Rint.c H5Rdeprec.c \
H5UC.c \
H5RS.c \
- H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Snone.c H5Spoint.c \
+ H5S.c H5Sall.c H5Sdbg.c H5Sdeprec.c H5Shyper.c H5Snone.c H5Spoint.c \
H5Sselect.c H5Stest.c \
H5SL.c \
H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \
diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c
index 33d23dc..2c8f691 100644
--- a/test/enc_dec_plist.c
+++ b/test/enc_dec_plist.c
@@ -15,75 +15,139 @@
* Serial tests for encoding/decoding plists
*/
-#include "h5test.h"
+#include "testhdf5.h"
#include "H5ACprivate.h"
#include "H5Pprivate.h"
+#define SRC_FNAME "source_file.h5"
+#define SRC_DSET "src_dset"
+
static int
-test_encode_decode(hid_t orig_pl)
+test_encode_decode(hid_t orig_pl, H5F_libver_t low, H5F_libver_t high, hbool_t support_virtual)
{
- hid_t pl = (-1); /* Decoded property list */
+ hid_t pl = (-1); /* Decoded property list */
+ hid_t fapl = -1; /* File access property list */
void *temp_buf = NULL; /* Pointer to encoding buffer */
size_t temp_size = 0; /* Size of encoding buffer */
+ herr_t ret; /* Return value */
- /* first call to encode returns only the size of the buffer needed */
- if(H5Pencode(orig_pl, NULL, &temp_size) < 0)
- STACK_ERROR
+ /* Create file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR
- if(NULL == (temp_buf = (void *)HDmalloc(temp_size)))
+ /* Set library version bounds */
+ if(H5Pset_libver_bounds(fapl, low, high) < 0)
TEST_ERROR
- if(H5Pencode(orig_pl, temp_buf, &temp_size) < 0)
- STACK_ERROR
+ H5E_BEGIN_TRY {
+ ret = H5Pencode2(orig_pl, NULL, &temp_size, fapl);
+ } H5E_END_TRY;
+
+ if(support_virtual && high < H5F_LIBVER_V110)
+ VERIFY(ret, FAIL, "H5Pencode2");
+ else {
+
+ VERIFY(ret, SUCCEED, "H5Pencode2");
+
+ /* Allocate the buffer for encoding */
+ if(NULL == (temp_buf = (void *)HDmalloc(temp_size)))
+ TEST_ERROR
+
+ /* Encode the property list to the buffer */
+ if(H5Pencode2(orig_pl, temp_buf, &temp_size, fapl) < 0)
+ TEST_ERROR
+
+ /* Decode the buffer */
+ if((pl = H5Pdecode(temp_buf)) < 0)
+ STACK_ERROR
+
+ /* Check if the original and the decoded property lists are equal */
+ if(!H5Pequal(orig_pl, pl))
+ PUTS_ERROR("encoding-decoding cycle failed\n")
+
+ /* Close the decoded property list */
+ if((H5Pclose(pl)) < 0)
+ TEST_ERROR
+
+ /* Free the buffer */
+ if(temp_buf)
+ HDfree(temp_buf);
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ /* Test H5Pencode1() */
+
+ /* first call to encode returns only the size of the buffer needed */
+ if(H5Pencode1(orig_pl, NULL, &temp_size) < 0)
+ STACK_ERROR
+
+ if(NULL == (temp_buf = (void *)HDmalloc(temp_size)))
+ TEST_ERROR
+
+ if(H5Pencode1(orig_pl, temp_buf, &temp_size) < 0)
+ STACK_ERROR
- if((pl = H5Pdecode(temp_buf)) < 0)
- STACK_ERROR
+ if((pl = H5Pdecode(temp_buf)) < 0)
+ STACK_ERROR
- if(!H5Pequal(orig_pl, pl))
- PUTS_ERROR("encoding-decoding cycle failed\n")
+ if(!H5Pequal(orig_pl, pl))
+ PUTS_ERROR("encoding-decoding cycle failed\n")
- if((H5Pclose(pl)) < 0)
- STACK_ERROR
+ if((H5Pclose(pl)) < 0)
+ STACK_ERROR
- HDfree(temp_buf);
+ if(temp_buf)
+ HDfree(temp_buf);
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+ }
+
+ if((H5Pclose(fapl)) < 0)
+ TEST_ERROR
/* Success */
return(0);
error:
- if(pl > 0)
- H5Pclose(pl);
if(temp_buf)
HDfree(temp_buf);
+ H5E_BEGIN_TRY {
+ H5Pclose(pl);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
return(-1);
} /* end test_encode_decode() */
int
main(void)
{
- hid_t dcpl; /* dataset create prop. list */
- hid_t dapl; /* dataset access prop. list */
- hid_t dxpl; /* dataset xfer prop. list */
- hid_t gcpl; /* group create prop. list */
- hid_t ocpypl; /* object copy prop. list */
- hid_t ocpl; /* object create prop. list */
- hid_t lcpl; /* link create prop. list */
- hid_t lapl; /* link access prop. list */
- hid_t fapl; /* file access prop. list */
- hid_t fcpl; /* file create prop. list */
- hid_t strcpl; /* string create prop. list */
- hid_t acpl; /* attribute create prop. list */
-
+ hid_t dcpl; /* dataset create prop. list */
+ hid_t dapl; /* dataset access prop. list */
+ hid_t dxpl; /* dataset xfer prop. list */
+ hid_t gcpl; /* group create prop. list */
+ hid_t ocpypl; /* object copy prop. list */
+ hid_t ocpl; /* object create prop. list */
+ hid_t lcpl; /* link create prop. list */
+ hid_t lapl; /* link access prop. list */
+ hid_t fapl; /* file access prop. list */
+ hid_t fcpl; /* file create prop. list */
+ hid_t strcpl; /* string create prop. list */
+ hid_t acpl; /* attribute create prop. list */
+ hid_t srcspace = -1; /* Source dataspaces */
+ hid_t vspace = -1; /* Virtual dset dataspaces */
+ hsize_t dims[1] = {3}; /* Data space current size */
hsize_t chunk_size[2] = {16384, 4}; /* chunk size */
- double fill = 2.7f; /* Fill value */
- hsize_t max_size[1]; /* data space maximum size */
+ double fill = 2.7f; /* Fill value */
+ hsize_t max_size[1]; /* data space maximum size */
size_t nslots = 521 * 2;
size_t nbytes = 1048576 * 10;
double w0 = 0.5f;
unsigned max_compact;
unsigned min_dense;
const char* c_to_f = "x+32";
+ H5F_libver_t low, high; /* Low and high bounds */
+
H5AC_cache_config_t my_cache_config = {
H5AC__CURR_CACHE_CONFIG_VERSION,
TRUE,
@@ -115,467 +179,511 @@ main(void)
0.2f,
(256 * 2048),
H5AC__DEFAULT_METADATA_WRITE_STRATEGY};
+
H5AC_cache_image_config_t my_cache_image_config = {
- H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION,
- TRUE,
+ H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION,
+ TRUE,
FALSE,
- -1};
-
- if(VERBOSE_MED)
- printf("Encode/Decode DCPLs\n");
+ -1 };
+
+ /* Loop through all the combinations of low/high version bounds */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
+ char msg[80]; /* Message for file version bounds */
+ char* low_string; /* The low bound string */
+ char* high_string; /* The high bound string */
+
+ /* Invalid combinations, just continue */
+ if(high == H5F_LIBVER_EARLIEST || high < low)
+ continue;
+
+ /* Display testing info */
+ low_string = h5_get_version_string(low);
+ high_string = h5_get_version_string(high);
+ HDsprintf(msg, "Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, high_string);
+ HDputs(msg);
+
+
+ if(VERBOSE_MED)
+ printf("Encode/Decode DCPLs\n");
+
+ /******* ENCODE/DECODE DCPLS *****/
+ TESTING("Default DCPL Encoding/Decoding");
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(dcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n")
+
+ PASSED();
+
+ TESTING("DCPL Encoding/Decoding");
+
+ if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0)
+ FAIL_STACK_ERROR
+
+ if((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0)
+ FAIL_STACK_ERROR
+
+ if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0)
+ FAIL_STACK_ERROR
+
+ if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0)
+ FAIL_STACK_ERROR
+
+ max_size[0] = 100;
+ if((H5Pset_external(dcpl, "ext1.data", (off_t)0,
+ (hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_external(dcpl, "ext2.data", (off_t)0,
+ (hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_external(dcpl, "ext3.data", (off_t)0,
+ (hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_external(dcpl, "ext4.data", (off_t)0,
+ (hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(dcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n")
+
+ /* release resource */
+ if((H5Pclose(dcpl)) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED();
+
+ /******* ENCODE/DECODE DCPLS *****/
+ TESTING("DCPL Encoding/Decoding for virtual layout");
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Set virtual layout */
+ if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0)
+ TEST_ERROR
+
+ /* Create source dataspace */
+ if((srcspace = H5Screate_simple(1, dims, NULL)) < 0)
+ TEST_ERROR
+
+ /* Create virtual dataspace */
+ if((vspace = H5Screate_simple(1, dims, NULL)) < 0)
+ TEST_ERROR
+
+ /* Add virtual layout mapping */
+ if(H5Pset_virtual(dcpl, vspace, SRC_FNAME, SRC_DSET, srcspace) < 0)
+ TEST_ERROR
+
+ if(test_encode_decode(dcpl, low, high, TRUE) < 0)
+ FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n")
+
+ /* release resource */
+ if((H5Pclose(dcpl)) < 0)
+ FAIL_STACK_ERROR
+
+ /******* ENCODE/DECODE DAPLS *****/
+ TESTING("Default DAPL Encoding/Decoding");
+ if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(dapl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n")
+
+ PASSED();
+
+ TESTING("DAPL Encoding/Decoding");
+
+ if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(dapl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("DAPL encoding/decoding failed\n")
+
+ /* release resource */
+ if((H5Pclose(dapl)) < 0)
+ FAIL_STACK_ERROR
- /******* ENCODE/DECODE DCPLS *****/
- TESTING("Default DCPL Encoding/Decoding");
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- FAIL_STACK_ERROR
+ PASSED();
- /* Test encoding & decoding default property list */
- if(test_encode_decode(dcpl) < 0)
- FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n")
+ /******* ENCODE/DECODE OCPLS *****/
+ TESTING("Default OCPL Encoding/Decoding");
+ if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(ocpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n")
- PASSED();
+ PASSED();
- TESTING("DCPL Encoding/Decoding");
+ TESTING("OCPL Encoding/Decoding");
- if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0)
- FAIL_STACK_ERROR
+ if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0)
- FAIL_STACK_ERROR
+ if((H5Pset_attr_phase_change (ocpl, 110, 105)) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0)
- FAIL_STACK_ERROR
+ if((H5Pset_filter (ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0)
- FAIL_STACK_ERROR
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(ocpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("OCPL encoding/decoding failed\n")
- max_size[0] = 100;
- if((H5Pset_external(dcpl, "ext1.data", (off_t)0,
- (hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_external(dcpl, "ext2.data", (off_t)0,
- (hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_external(dcpl, "ext3.data", (off_t)0,
- (hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_external(dcpl, "ext4.data", (off_t)0,
- (hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
- FAIL_STACK_ERROR
+ /* release resource */
+ if((H5Pclose(ocpl)) < 0)
+ FAIL_STACK_ERROR
- /* Test encoding & decoding property list */
- if(test_encode_decode(dcpl) < 0)
- FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n")
-
- /* release resource */
- if((H5Pclose(dcpl)) < 0)
- FAIL_STACK_ERROR
+ PASSED();
- PASSED();
+ /******* ENCODE/DECODE DXPLS *****/
+ TESTING("Default DXPL Encoding/Decoding");
+ if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ FAIL_STACK_ERROR
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(dxpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n")
- /******* ENCODE/DECODE DAPLS *****/
- TESTING("Default DAPL Encoding/Decoding");
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
- FAIL_STACK_ERROR
+ PASSED();
- /* Test encoding & decoding default property list */
- if(test_encode_decode(dapl) < 0)
- FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n")
+ TESTING("DXPL Encoding/Decoding");
- PASSED();
+ if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_hyper_vector_size(dxpl, 5)) < 0)
+ FAIL_STACK_ERROR
- TESTING("DAPL Encoding/Decoding");
+#ifdef H5_HAVE_PARALLEL
+ if((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0)
+ FAIL_STACK_ERROR
+#endif/* H5_HAVE_PARALLEL */
+ if((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_data_transform(dxpl, c_to_f)) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0)
- FAIL_STACK_ERROR
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(dxpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("DXPL encoding/decoding failed\n")
- /* Test encoding & decoding property list */
- if(test_encode_decode(dapl) < 0)
- FAIL_PUTS_ERROR("DAPL encoding/decoding failed\n")
-
- /* release resource */
- if((H5Pclose(dapl)) < 0)
- FAIL_STACK_ERROR
+ /* release resource */
+ if((H5Pclose(dxpl)) < 0)
+ FAIL_STACK_ERROR
- PASSED();
+ PASSED();
+ /******* ENCODE/DECODE GCPLS *****/
+ TESTING("Default GCPL Encoding/Decoding");
+ if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(gcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n")
- /******* ENCODE/DECODE OCPLS *****/
- TESTING("Default OCPL Encoding/Decoding");
- if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0)
- FAIL_STACK_ERROR
+ PASSED();
- /* Test encoding & decoding default property list */
- if(test_encode_decode(ocpl) < 0)
- FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n")
+ TESTING("GCPL Encoding/Decoding");
- PASSED();
+ if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0)
+ FAIL_STACK_ERROR
- TESTING("OCPL Encoding/Decoding");
+ if((H5Pset_link_phase_change(gcpl, 2, 2)) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0)
- FAIL_STACK_ERROR
+ /* Query the group creation properties */
+ if((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_attr_phase_change (ocpl, 110, 105)) < 0)
- FAIL_STACK_ERROR
+ if((H5Pset_est_link_info(gcpl, 3, 9)) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_filter (ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0)
- FAIL_STACK_ERROR
+ if((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0)
+ FAIL_STACK_ERROR
- /* Test encoding & decoding property list */
- if(test_encode_decode(ocpl) < 0)
- FAIL_PUTS_ERROR("OCPL encoding/decoding failed\n")
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(gcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("GCPL encoding/decoding failed\n")
- /* release resource */
- if((H5Pclose(ocpl)) < 0)
- FAIL_STACK_ERROR
+ /* release resource */
+ if((H5Pclose(gcpl)) < 0)
+ FAIL_STACK_ERROR
- PASSED();
+ PASSED();
+ /******* ENCODE/DECODE LCPLS *****/
+ TESTING("Default LCPL Encoding/Decoding");
+ if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0)
+ FAIL_STACK_ERROR
- /******* ENCODE/DECODE DXPLS *****/
- TESTING("Default DXPL Encoding/Decoding");
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
- FAIL_STACK_ERROR
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(lcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n")
- /* Test encoding & decoding default property list */
- if(test_encode_decode(dxpl) < 0)
- FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n")
+ PASSED();
- PASSED();
+ TESTING("LCPL Encoding/Decoding");
- TESTING("DXPL Encoding/Decoding");
+ if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_hyper_vector_size(dxpl, 5)) < 0)
- FAIL_STACK_ERROR
-#ifdef H5_HAVE_PARALLEL
- if((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0)
- FAIL_STACK_ERROR
-#endif/* H5_HAVE_PARALLEL */
- if((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_data_transform(dxpl, c_to_f)) < 0)
- FAIL_STACK_ERROR
-
- /* Test encoding & decoding property list */
- if(test_encode_decode(dxpl) < 0)
- FAIL_PUTS_ERROR("DXPL encoding/decoding failed\n")
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(lcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("LCPL encoding/decoding failed\n")
- /* release resource */
- if((H5Pclose(dxpl)) < 0)
- FAIL_STACK_ERROR
-
- PASSED();
+ /* release resource */
+ if((H5Pclose(lcpl)) < 0)
+ FAIL_STACK_ERROR
+ PASSED();
- /******* ENCODE/DECODE GCPLS *****/
- TESTING("Default GCPL Encoding/Decoding");
- if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0)
- FAIL_STACK_ERROR
- /* Test encoding & decoding default property list */
- if(test_encode_decode(gcpl) < 0)
- FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n")
+ /******* ENCODE/DECODE LAPLS *****/
+ TESTING("Default LAPL Encoding/Decoding");
+ if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0)
+ FAIL_STACK_ERROR
- PASSED();
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(lapl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n")
- TESTING("GCPL Encoding/Decoding");
-
- if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0)
- FAIL_STACK_ERROR
-
- if((H5Pset_link_phase_change(gcpl, 2, 2)) < 0)
- FAIL_STACK_ERROR
-
- /* Query the group creation properties */
- if((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0)
- FAIL_STACK_ERROR
-
- if((H5Pset_est_link_info(gcpl, 3, 9)) < 0)
- FAIL_STACK_ERROR
-
- if((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0)
- FAIL_STACK_ERROR
-
- /* Test encoding & decoding property list */
- if(test_encode_decode(gcpl) < 0)
- FAIL_PUTS_ERROR("GCPL encoding/decoding failed\n")
-
- /* release resource */
- if((H5Pclose(gcpl)) < 0)
- FAIL_STACK_ERROR
+ PASSED();
- PASSED();
+ TESTING("LAPL Encoding/Decoding");
+ if((H5Pset_nlinks(lapl, (size_t)134)) < 0)
+ FAIL_STACK_ERROR
- /******* ENCODE/DECODE LCPLS *****/
- TESTING("Default LCPL Encoding/Decoding");
- if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0)
- FAIL_STACK_ERROR
+ if((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0)
+ FAIL_STACK_ERROR
- /* Test encoding & decoding default property list */
- if(test_encode_decode(lcpl) < 0)
- FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n")
+ if((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0)
+ FAIL_STACK_ERROR
- PASSED();
+ /* Create FAPL for the elink FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_alignment(fapl, 2, 1024)) < 0)
+ FAIL_STACK_ERROR
- TESTING("LCPL Encoding/Decoding");
+ if((H5Pset_elink_fapl(lapl, fapl)) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0)
- FAIL_STACK_ERROR
+ /* Close the elink's FAPL */
+ if((H5Pclose(fapl)) < 0)
+ FAIL_STACK_ERROR
- /* Test encoding & decoding property list */
- if(test_encode_decode(lcpl) < 0)
- FAIL_PUTS_ERROR("LCPL encoding/decoding failed\n")
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(lapl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("LAPL encoding/decoding failed\n")
- /* release resource */
- if((H5Pclose(lcpl)) < 0)
- FAIL_STACK_ERROR
+ /* release resource */
+ if((H5Pclose(lapl)) < 0)
+ FAIL_STACK_ERROR
- PASSED();
+ PASSED();
- /******* ENCODE/DECODE LAPLS *****/
- TESTING("Default LAPL Encoding/Decoding");
- if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0)
- FAIL_STACK_ERROR
+ /******* ENCODE/DECODE OCPYPLS *****/
+ TESTING("Default OCPYPL Encoding/Decoding");
+ if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ FAIL_STACK_ERROR
- /* Test encoding & decoding default property list */
- if(test_encode_decode(lapl) < 0)
- FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n")
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(ocpypl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n")
- PASSED();
+ PASSED();
- TESTING("LAPL Encoding/Decoding");
+ TESTING("OCPYPL Encoding/Decoding");
- if((H5Pset_nlinks(lapl, (size_t)134)) < 0)
- FAIL_STACK_ERROR
+ if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0)
- FAIL_STACK_ERROR
+ if((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0)
+ FAIL_STACK_ERROR
+ if((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0)
+ FAIL_STACK_ERROR
- if((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0)
- FAIL_STACK_ERROR
-
- /* Create FAPL for the elink FAPL */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_alignment(fapl, 2, 1024)) < 0)
- FAIL_STACK_ERROR
-
- if((H5Pset_elink_fapl(lapl, fapl)) < 0)
- FAIL_STACK_ERROR
-
- /* Close the elink's FAPL */
- if((H5Pclose(fapl)) < 0)
- FAIL_STACK_ERROR
-
- /* Test encoding & decoding property list */
- if(test_encode_decode(lapl) < 0)
- FAIL_PUTS_ERROR("LAPL encoding/decoding failed\n")
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(ocpypl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("OCPYPL encoding/decoding failed\n")
- /* release resource */
- if((H5Pclose(lapl)) < 0)
- FAIL_STACK_ERROR
-
- PASSED();
+ /* release resource */
+ if((H5Pclose(ocpypl)) < 0)
+ FAIL_STACK_ERROR
+ PASSED();
- /******* ENCODE/DECODE OCPYPLS *****/
- TESTING("Default OCPYPL Encoding/Decoding");
- if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0)
- FAIL_STACK_ERROR
+ /******* ENCODE/DECODE FAPLS *****/
+ TESTING("Default FAPL Encoding/Decoding");
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ FAIL_STACK_ERROR
- /* Test encoding & decoding default property list */
- if(test_encode_decode(ocpypl) < 0)
- FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n")
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(fapl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n")
- PASSED();
+ PASSED();
- TESTING("OCPYPL Encoding/Decoding");
+ TESTING("FAPL Encoding/Decoding");
- if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0)
- FAIL_STACK_ERROR
+ if((H5Pset_family_offset(fapl, 1024)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_meta_block_size(fapl, 2098452)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_sieve_buf_size(fapl, 1048576)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_alignment(fapl, 2, 1024)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_gc_references(fapl, 1)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_small_data_block_size(fapl, 2048)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_mdc_config(fapl, &my_cache_config)) < 0)
+ FAIL_STACK_ERROR
+ if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0)
+ FAIL_STACK_ERROR
- if((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0)
- FAIL_STACK_ERROR
- if((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0)
- FAIL_STACK_ERROR
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(fapl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("FAPL encoding/decoding failed\n")
- /* Test encoding & decoding property list */
- if(test_encode_decode(ocpypl) < 0)
- FAIL_PUTS_ERROR("OCPYPL encoding/decoding failed\n")
-
- /* release resource */
- if((H5Pclose(ocpypl)) < 0)
- FAIL_STACK_ERROR
-
- PASSED();
-
-
- /******* ENCODE/DECODE FAPLS *****/
- TESTING("Default FAPL Encoding/Decoding");
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- FAIL_STACK_ERROR
-
- /* Test encoding & decoding default property list */
- if(test_encode_decode(fapl) < 0)
- FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n")
-
- PASSED();
-
- TESTING("FAPL Encoding/Decoding");
-
- if((H5Pset_family_offset(fapl, 1024)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_meta_block_size(fapl, 2098452)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_sieve_buf_size(fapl, 1048576)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_alignment(fapl, 2, 1024)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_gc_references(fapl, 1)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_small_data_block_size(fapl, 2048)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_mdc_config(fapl, &my_cache_config)) < 0)
- FAIL_STACK_ERROR
- if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0)
- FAIL_STACK_ERROR
-
- /* Test encoding & decoding property list */
- if(test_encode_decode(fapl) < 0)
- FAIL_PUTS_ERROR("FAPL encoding/decoding failed\n")
-
- /* release resource */
- if((H5Pclose(fapl)) < 0)
- FAIL_STACK_ERROR
+ /* release resource */
+ if((H5Pclose(fapl)) < 0)
+ FAIL_STACK_ERROR
- PASSED();
+ PASSED();
- /******* ENCODE/DECODE FCPLS *****/
- TESTING("Default FCPL Encoding/Decoding");
+ /******* ENCODE/DECODE FCPLS *****/
+ TESTING("Default FCPL Encoding/Decoding");
- if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- FAIL_STACK_ERROR
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ FAIL_STACK_ERROR
- /* Test encoding & decoding default property list */
- if(test_encode_decode(fcpl) < 0)
- FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n")
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(fcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n")
- PASSED();
+ PASSED();
- TESTING("FCPL Encoding/Decoding");
+ TESTING("FCPL Encoding/Decoding");
- if((H5Pset_userblock(fcpl, 1024) < 0))
- FAIL_STACK_ERROR
+ if((H5Pset_userblock(fcpl, 1024) < 0))
+ FAIL_STACK_ERROR
- if((H5Pset_istore_k(fcpl, 3) < 0))
- FAIL_STACK_ERROR
+ if((H5Pset_istore_k(fcpl, 3) < 0))
+ FAIL_STACK_ERROR
- if((H5Pset_sym_k(fcpl, 4, 5) < 0))
- FAIL_STACK_ERROR
+ if((H5Pset_sym_k(fcpl, 4, 5) < 0))
+ FAIL_STACK_ERROR
- if((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0))
- FAIL_STACK_ERROR
+ if((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0))
+ FAIL_STACK_ERROR
- if((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0))
- FAIL_STACK_ERROR
+ if((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0))
+ FAIL_STACK_ERROR
- if((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0))
- FAIL_STACK_ERROR
+ if((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0))
+ FAIL_STACK_ERROR
- if((H5Pset_sizes(fcpl, 8, 4) < 0))
- FAIL_STACK_ERROR
+ if((H5Pset_sizes(fcpl, 8, 4) < 0))
+ FAIL_STACK_ERROR
- /* Test encoding & decoding property list */
- if(test_encode_decode(fcpl) < 0)
- FAIL_PUTS_ERROR("FCPL encoding/decoding failed\n")
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(fcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("FCPL encoding/decoding failed\n")
- /* release resource */
- if((H5Pclose(fcpl)) < 0)
- FAIL_STACK_ERROR
+ /* release resource */
+ if((H5Pclose(fcpl)) < 0)
+ FAIL_STACK_ERROR
- PASSED();
+ PASSED();
- /******* ENCODE/DECODE STRCPLS *****/
- TESTING("Default STRCPL Encoding/Decoding");
+ /******* ENCODE/DECODE STRCPLS *****/
+ TESTING("Default STRCPL Encoding/Decoding");
- if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0)
- FAIL_STACK_ERROR
+ if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0)
+ FAIL_STACK_ERROR
- /* Test encoding & decoding default property list */
- if(test_encode_decode(strcpl) < 0)
- FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n")
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(strcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n")
- PASSED();
+ PASSED();
- TESTING("STRCPL Encoding/Decoding");
+ TESTING("STRCPL Encoding/Decoding");
- if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0))
- FAIL_STACK_ERROR
+ if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0))
+ FAIL_STACK_ERROR
- /* Test encoding & decoding property list */
- if(test_encode_decode(strcpl) < 0)
- FAIL_PUTS_ERROR("STRCPL encoding/decoding failed\n")
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(strcpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("STRCPL encoding/decoding failed\n")
- /* release resource */
- if((H5Pclose(strcpl)) < 0)
- FAIL_STACK_ERROR
+ /* release resource */
+ if((H5Pclose(strcpl)) < 0)
+ FAIL_STACK_ERROR
- PASSED();
+ PASSED();
- /******* ENCODE/DECODE ACPLS *****/
- TESTING("Default ACPL Encoding/Decoding");
+ /******* ENCODE/DECODE ACPLS *****/
+ TESTING("Default ACPL Encoding/Decoding");
- if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0)
- FAIL_STACK_ERROR
+ if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0)
+ FAIL_STACK_ERROR
- /* Test encoding & decoding default property list */
- if(test_encode_decode(acpl) < 0)
- FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n")
+ /* Test encoding & decoding default property list */
+ if(test_encode_decode(acpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n")
- PASSED();
+ PASSED();
- TESTING("ACPL Encoding/Decoding");
+ TESTING("ACPL Encoding/Decoding");
- if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0))
- FAIL_STACK_ERROR
+ if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0))
+ FAIL_STACK_ERROR
- /* Test encoding & decoding property list */
- if(test_encode_decode(acpl) < 0)
- FAIL_PUTS_ERROR("ACPL encoding/decoding failed\n")
+ /* Test encoding & decoding property list */
+ if(test_encode_decode(acpl, low, high, FALSE) < 0)
+ FAIL_PUTS_ERROR("ACPL encoding/decoding failed\n")
- /* release resource */
- if((H5Pclose(acpl)) < 0)
- FAIL_STACK_ERROR
+ /* release resource */
+ if((H5Pclose(acpl)) < 0)
+ FAIL_STACK_ERROR
- PASSED();
+ PASSED();
+ } /* end high */
+ } /* end low */
return 0;
diff --git a/test/gen_plist.c b/test/gen_plist.c
index 68da6cc..8f38b1a 100644
--- a/test/gen_plist.c
+++ b/test/gen_plist.c
@@ -466,13 +466,13 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil
HDassert(ret > 0);
/* first call to encode returns only the size of the buffer needed */
- if((ret = H5Pencode(plist_id, NULL, &temp_size)) < 0)
+ if((ret = H5Pencode2(plist_id, NULL, &temp_size, H5P_DEFAULT)) < 0)
HDassert(ret > 0);
temp_buf = (void *)HDmalloc(temp_size);
HDassert(temp_buf);
- if((ret = H5Pencode(plist_id, temp_buf, &temp_size)) < 0)
+ if((ret = H5Pencode2(plist_id, temp_buf, &temp_size, H5P_DEFAULT)) < 0)
HDassert(ret > 0);
fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW);
diff --git a/test/th5s.c b/test/th5s.c
index 07d31ed..6632a4c 100644
--- a/test/th5s.c
+++ b/test/th5s.c
@@ -90,7 +90,21 @@ struct space4_struct {
unsigned u;
float f;
char c2;
- } space4_data={'v',987123,-3.14F,'g'}; /* Test data for 4th dataspace */
+} space4_data={'v',987123,-3.14F,'g'}; /* Test data for 4th dataspace */
+
+/*
+ * Testing configuration defines used by:
+ * test_h5s_encode_regular_hyper()
+ * test_h5s_encode_irregular_hyper()
+ * test_h5s_encode_points()
+ */
+#define CONFIG_8 1
+#define CONFIG_16 2
+#define CONFIG_32 3
+#define POWER8 256 /* 2^8 */
+#define POWER16 65536 /* 2^16 */
+#define POWER32 4294967296 /* 2^32 */
+
/****************************************************************
**
@@ -1163,27 +1177,30 @@ test_h5s_zero_dim(void)
**
** test_h5s_encode(): Test H5S (dataspace) encoding and decoding.
**
+** Note: See "RFC: H5Sencode/H5Sdecode Format Change".
+**
****************************************************************/
static void
-test_h5s_encode(void)
+test_h5s_encode(H5F_libver_t low, H5F_libver_t high)
{
- hid_t sid1, sid2, sid3; /* Dataspace ID */
- hid_t decoded_sid1, decoded_sid2, decoded_sid3;
- int rank; /* Logical rank of dataspace */
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
- size_t sbuf_size=0, null_size=0, scalar_size=0;
- unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL;
- hsize_t tdims[4]; /* Dimension array to test with */
- hssize_t n; /* Number of dataspace elements */
- hsize_t start[] = {0, 0, 0};
- hsize_t stride[] = {2, 5, 3};
- hsize_t count[] = {2, 2, 2};
- hsize_t block[] = {1, 3, 1};
- H5S_sel_type sel_type;
- H5S_class_t space_type;
- hssize_t nblocks;
- hid_t ret_id; /* Generic hid_t return value */
- herr_t ret; /* Generic return value */
+ hid_t sid1, sid2, sid3; /* Dataspace ID */
+ hid_t decoded_sid1, decoded_sid2, decoded_sid3;
+ int rank; /* Logical rank of dataspace */
+ hid_t fapl = -1; /* File access property list ID */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ size_t sbuf_size=0, null_size=0, scalar_size=0;
+ unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL;
+ hsize_t tdims[4]; /* Dimension array to test with */
+ hssize_t n; /* Number of dataspace elements */
+ hsize_t start[] = {0, 0, 0};
+ hsize_t stride[] = {2, 5, 3};
+ hsize_t count[] = {2, 2, 2};
+ hsize_t block[] = {1, 3, 1};
+ H5S_sel_type sel_type;
+ H5S_class_t space_type;
+ hssize_t nblocks;
+ hid_t ret_id; /* Generic hid_t return value */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Dataspace Encoding and Decoding\n"));
@@ -1192,26 +1209,40 @@ test_h5s_encode(void)
* Test encoding and decoding of simple dataspace and hyperslab selection.
*-------------------------------------------------------------------------
*/
+
+ /* Create the file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set low/high bounds in the fapl */
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create the dataspace */
sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
CHECK(sid1, FAIL, "H5Screate_simple");
+ /* Set the hyperslab selection */
ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
- /* Encode simple data space in a buffer */
- ret = H5Sencode(sid1, NULL, &sbuf_size);
- CHECK(ret, FAIL, "H5Sencode");
+ /* Encode simple data space in a buffer with the fapl setting */
+ ret = H5Sencode2(sid1, NULL, &sbuf_size, fapl);
+ CHECK(ret, FAIL, "H5Sencode2");
- if(sbuf_size>0)
+ if(sbuf_size>0) {
sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size);
+ CHECK(sbuf, NULL, "HDcalloc");
+ }
/* Try decoding bogus buffer */
H5E_BEGIN_TRY {
- ret_id = H5Sdecode(sbuf);
+ ret_id = H5Sdecode(sbuf);
} H5E_END_TRY;
VERIFY(ret_id, FAIL, "H5Sdecode");
- ret = H5Sencode(sid1, sbuf, &sbuf_size);
+ /* Encode the simple data space in a buffer with the fapl setting */
+ ret = H5Sencode2(sid1, sbuf, &sbuf_size, fapl);
CHECK(ret, FAIL, "H5Sencode");
/* Decode from the dataspace buffer and return an object handle */
@@ -1224,22 +1255,26 @@ test_h5s_encode(void)
VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3,
"H5Sget_simple_extent_npoints");
+ /* Retrieve and verify the dataspace rank */
rank = H5Sget_simple_extent_ndims(decoded_sid1);
CHECK(rank, FAIL, "H5Sget_simple_extent_ndims");
VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims");
+ /* Retrieve and verify the dataspace dimensions */
rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL);
CHECK(rank, FAIL, "H5Sget_simple_extent_dims");
VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0,
"H5Sget_simple_extent_dims");
- /* Verify hyperslabe selection */
+ /* Verify the type of dataspace selection */
sel_type = H5Sget_select_type(decoded_sid1);
VERIFY(sel_type, H5S_SEL_HYPERSLABS, "H5Sget_select_type");
+ /* Verify the number of hyperslab blocks */
nblocks = H5Sget_select_hyper_nblocks(decoded_sid1);
VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks");
+ /* Close the dataspaces */
ret = H5Sclose(sid1);
CHECK(ret, FAIL, "H5Sclose");
@@ -1254,23 +1289,27 @@ test_h5s_encode(void)
CHECK(sid2, FAIL, "H5Screate");
/* Encode null data space in a buffer */
- ret = H5Sencode(sid2, NULL, &null_size);
+ ret = H5Sencode2(sid2, NULL, &null_size, fapl);
CHECK(ret, FAIL, "H5Sencode");
- if(null_size>0)
+ if(null_size>0) {
null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size);
+ CHECK(null_sbuf, NULL, "HDcalloc");
+ }
- ret = H5Sencode(sid2, null_sbuf, &null_size);
- CHECK(ret, FAIL, "H5Sencode");
+ /* Encode the null data space in the buffer */
+ ret = H5Sencode2(sid2, null_sbuf, &null_size, fapl);
+ CHECK(ret, FAIL, "H5Sencode2");
/* Decode from the dataspace buffer and return an object handle */
decoded_sid2=H5Sdecode(null_sbuf);
CHECK(decoded_sid2, FAIL, "H5Sdecode");
- /* Verify decoded dataspace */
+ /* Verify the decoded dataspace type */
space_type = H5Sget_simple_extent_type(decoded_sid2);
VERIFY(space_type, H5S_NULL, "H5Sget_simple_extent_type");
+ /* Close the dataspaces */
ret = H5Sclose(sid2);
CHECK(ret, FAIL, "H5Sclose");
@@ -1286,16 +1325,211 @@ test_h5s_encode(void)
CHECK(sid3, FAIL, "H5Screate_simple");
/* Encode scalar data space in a buffer */
- ret = H5Sencode(sid3, NULL, &scalar_size);
+ ret = H5Sencode2(sid3, NULL, &scalar_size, fapl);
CHECK(ret, FAIL, "H5Sencode");
- if(scalar_size>0)
+ if(scalar_size>0) {
scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size);
+ CHECK(scalar_buf, NULL, "HDcalloc");
+ }
+
+ /* Encode the scalar data space in the buffer */
+ ret = H5Sencode2(sid3, scalar_buf, &scalar_size, fapl);
+ CHECK(ret, FAIL, "H5Sencode2");
+
+ /* Decode from the dataspace buffer and return an object handle */
+ decoded_sid3=H5Sdecode(scalar_buf);
+ CHECK(decoded_sid3, FAIL, "H5Sdecode");
+
+ /* Verify extent type */
+ space_type = H5Sget_simple_extent_type(decoded_sid3);
+ VERIFY(space_type, H5S_SCALAR, "H5Sget_simple_extent_type");
+
+ /* Verify decoded dataspace */
+ n = H5Sget_simple_extent_npoints(decoded_sid3);
+ CHECK(n, FAIL, "H5Sget_simple_extent_npoints");
+ VERIFY(n, 1, "H5Sget_simple_extent_npoints");
+
+ /* Retrieve and verify the dataspace rank */
+ rank = H5Sget_simple_extent_ndims(decoded_sid3);
+ CHECK(rank, FAIL, "H5Sget_simple_extent_ndims");
+ VERIFY(rank, 0, "H5Sget_simple_extent_ndims");
- ret = H5Sencode(sid3, scalar_buf, &scalar_size);
+ /* Close the dataspaces */
+ ret = H5Sclose(sid3);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(decoded_sid3);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close the file access property list */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Release resources */
+ if(sbuf)
+ HDfree(sbuf);
+ if(null_sbuf)
+ HDfree(null_sbuf);
+ if(scalar_buf)
+ HDfree(scalar_buf);
+} /* test_h5s_encode() */
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+
+/****************************************************************
+**
+** test_h5s_encode(): Test H5S (dataspace) encoding and decoding.
+**
+****************************************************************/
+static void
+test_h5s_encode1(void)
+{
+ hid_t sid1, sid2, sid3; /* Dataspace ID */
+ hid_t decoded_sid1, decoded_sid2, decoded_sid3;
+ int rank; /* Logical rank of dataspace */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ size_t sbuf_size=0, null_size=0, scalar_size=0;
+ unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL;
+ hsize_t tdims[4]; /* Dimension array to test with */
+ hssize_t n; /* Number of dataspace elements */
+ hsize_t start[] = {0, 0, 0};
+ hsize_t stride[] = {2, 5, 3};
+ hsize_t count[] = {2, 2, 2};
+ hsize_t block[] = {1, 3, 1};
+ H5S_sel_type sel_type;
+ H5S_class_t space_type;
+ hssize_t nblocks;
+ hid_t ret_id; /* Generic hid_t return value */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Dataspace Encoding (H5Sencode1) and Decoding\n"));
+
+ /*-------------------------------------------------------------------------
+ * Test encoding and decoding of simple dataspace and hyperslab selection.
+ *-------------------------------------------------------------------------
+ */
+ /* Create the dataspace */
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Set the hyperslab selection */
+ ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Encode simple data space in a buffer with the fapl setting */
+ ret = H5Sencode1(sid1, NULL, &sbuf_size);
+ CHECK(ret, FAIL, "H5Sencode2");
+
+ if(sbuf_size>0) {
+ sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size);
+ CHECK(sbuf, NULL, "HDcalloc");
+ }
+
+ /* Try decoding bogus buffer */
+ H5E_BEGIN_TRY {
+ ret_id = H5Sdecode(sbuf);
+ } H5E_END_TRY;
+ VERIFY(ret_id, FAIL, "H5Sdecode");
+
+ /* Encode the simple data space in a buffer */
+ ret = H5Sencode1(sid1, sbuf, &sbuf_size);
CHECK(ret, FAIL, "H5Sencode");
/* Decode from the dataspace buffer and return an object handle */
+ decoded_sid1=H5Sdecode(sbuf);
+ CHECK(decoded_sid1, FAIL, "H5Sdecode");
+
+ /* Verify the decoded dataspace */
+ n = H5Sget_simple_extent_npoints(decoded_sid1);
+ CHECK(n, FAIL, "H5Sget_simple_extent_npoints");
+ VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3,
+ "H5Sget_simple_extent_npoints");
+
+ /* Retrieve and verify the dataspace rank */
+ rank = H5Sget_simple_extent_ndims(decoded_sid1);
+ CHECK(rank, FAIL, "H5Sget_simple_extent_ndims");
+ VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims");
+
+ /* Retrieve and verify the dataspace dimensions */
+ rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL);
+ CHECK(rank, FAIL, "H5Sget_simple_extent_dims");
+ VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0,
+ "H5Sget_simple_extent_dims");
+
+ /* Verify the type of dataspace selection */
+ sel_type = H5Sget_select_type(decoded_sid1);
+ VERIFY(sel_type, H5S_SEL_HYPERSLABS, "H5Sget_select_type");
+
+ /* Verify the number of hyperslab blocks */
+ nblocks = H5Sget_select_hyper_nblocks(decoded_sid1);
+ VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks");
+
+ /* Close the dataspaces */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(decoded_sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /*-------------------------------------------------------------------------
+ * Test encoding and decoding of null dataspace.
+ *-------------------------------------------------------------------------
+ */
+ sid2 = H5Screate(H5S_NULL);
+ CHECK(sid2, FAIL, "H5Screate");
+
+ /* Encode null data space in a buffer */
+ ret = H5Sencode1(sid2, NULL, &null_size);
+ CHECK(ret, FAIL, "H5Sencode");
+
+ if(null_size>0) {
+ null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size);
+ CHECK(null_sbuf, NULL, "HDcalloc");
+ }
+
+ /* Encode the null data space in the buffer */
+ ret = H5Sencode1(sid2, null_sbuf, &null_size);
+ CHECK(ret, FAIL, "H5Sencode2");
+
+ /* Decode from the dataspace buffer and return an object handle */
+ decoded_sid2=H5Sdecode(null_sbuf);
+ CHECK(decoded_sid2, FAIL, "H5Sdecode");
+
+ /* Verify the decoded dataspace type */
+ space_type = H5Sget_simple_extent_type(decoded_sid2);
+ VERIFY(space_type, H5S_NULL, "H5Sget_simple_extent_type");
+
+ /* Close the dataspaces */
+ ret = H5Sclose(sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Sclose(decoded_sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /*-------------------------------------------------------------------------
+ * Test encoding and decoding of scalar dataspace.
+ *-------------------------------------------------------------------------
+ */
+ /* Create scalar dataspace */
+ sid3 = H5Screate(H5S_SCALAR);
+ CHECK(sid3, FAIL, "H5Screate_simple");
+
+ /* Encode scalar data space in a buffer */
+ ret = H5Sencode1(sid3, NULL, &scalar_size);
+ CHECK(ret, FAIL, "H5Sencode");
+
+ if(scalar_size>0) {
+ scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size);
+ CHECK(scalar_buf, NULL, "HDcalloc");
+ }
+
+ /* Encode the scalar data space in the buffer */
+ ret = H5Sencode1(sid3, scalar_buf, &scalar_size);
+ CHECK(ret, FAIL, "H5Sencode2");
+
+ /* Decode from the dataspace buffer and return an object handle */
decoded_sid3=H5Sdecode(scalar_buf);
CHECK(decoded_sid3, FAIL, "H5Sdecode");
@@ -1308,20 +1542,551 @@ test_h5s_encode(void)
CHECK(n, FAIL, "H5Sget_simple_extent_npoints");
VERIFY(n, 1, "H5Sget_simple_extent_npoints");
+ /* Retrieve and verify the dataspace rank */
rank = H5Sget_simple_extent_ndims(decoded_sid3);
CHECK(rank, FAIL, "H5Sget_simple_extent_ndims");
VERIFY(rank, 0, "H5Sget_simple_extent_ndims");
+ /* Close the dataspaces */
ret = H5Sclose(sid3);
CHECK(ret, FAIL, "H5Sclose");
ret = H5Sclose(decoded_sid3);
CHECK(ret, FAIL, "H5Sclose");
- HDfree(sbuf);
- HDfree(null_sbuf);
- HDfree(scalar_buf);
-} /* test_h5s_encode() */
+ /* Release resources */
+ if(sbuf)
+ HDfree(sbuf);
+ if(null_sbuf)
+ HDfree(null_sbuf);
+ if(scalar_buf)
+ HDfree(scalar_buf);
+} /* test_h5s_encode1() */
+
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+
+/****************************************************************
+**
+** test_h5s_check_encoding():
+** This is the helper routine to verify that H5Sencode2()
+** works as specified in the RFC for the library format setting
+** in the file access property list.
+** See "RFC: H5Sencode/H5Sdeocde Format Change".
+**
+** This routine is used by:
+** test_h5s_encode_regular_hyper()
+** test_h5s_encode_irregular_hyper()
+** test_h5s_encode_points()
+**
+****************************************************************/
+static herr_t
+test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid,
+ uint32_t expected_version, uint8_t expected_enc_size, hbool_t expected_to_fail)
+{
+ char *buf = NULL; /* Pointer to the encoded buffer */
+ size_t buf_size; /* Size of the encoded buffer */
+ hid_t d_sid = -1; /* The decoded dataspace ID */
+ htri_t check;
+ hsize_t in_low_bounds[1]; /* The low bounds for the selection for in_sid */
+ hsize_t in_high_bounds[1]; /* The high bounds for the selection for in_sid */
+ hsize_t d_low_bounds[1]; /* The low bounds for the selection for d_sid */
+ hsize_t d_high_bounds[1]; /* The high bounds for the selection for d_sid */
+ herr_t ret; /* Return value */
+
+ /* Get buffer size for encoding with the format setting in in_fapl */
+ H5E_BEGIN_TRY {
+ ret = H5Sencode2(in_sid, NULL, &buf_size, in_fapl);
+ } H5E_END_TRY
+
+ if(expected_to_fail) {
+ VERIFY(ret, FAIL, "H5Screate_simple");
+ } else {
+
+ CHECK(ret, FAIL, "H5Sencode2");
+
+ /* Allocate the buffer for encoding */
+ buf = (char *)HDmalloc(buf_size);
+ CHECK(buf, NULL, "H5Dmalloc");
+
+ /* Encode according to the setting in in_fapl */
+ ret = H5Sencode2(in_sid, buf, &buf_size, in_fapl);
+ CHECK(ret, FAIL, "H5Sencode2");
+
+ /* Decode the buffer */
+ d_sid = H5Sdecode(buf);
+ CHECK(d_sid, FAIL, "H5Sdecode");
+
+ /* Verify the number of selected points for in_sid and d_sid */
+ VERIFY(H5Sget_select_npoints(in_sid), H5Sget_select_npoints(d_sid), "Compare npoints");
+
+ /* Verify if the two dataspace selections (in_sid, d_sid) are the same shape */
+ check = H5S__select_shape_same_test(in_sid, d_sid);
+ VERIFY(check, TRUE, "H5S__select_shape_same_test");
+
+ /* Compare the starting/ending coordinates of the bounding box for in_sid and d_sid */
+ ret = H5Sget_select_bounds(in_sid, in_low_bounds, in_high_bounds);
+ CHECK(ret, FAIL, "H5Sget_select_bounds");
+ ret = H5Sget_select_bounds(d_sid, d_low_bounds, d_high_bounds);
+ CHECK(ret, FAIL, "H5Sget_select_bounds");
+ VERIFY(in_low_bounds[0], d_low_bounds[0], "Compare selection low bounds");
+ VERIFY(in_high_bounds[0], d_high_bounds[0], "Compare selection high bounds");
+
+ /*
+ * See "RFC: H5Sencode/H5Sdeocde Format Change" for the verification of:
+ * H5S_SEL_POINTS:
+ * --the expected version for point selection info
+ * --the expected encoded size (version 2 points selection info)
+ * H5S_SEL_HYPERSLABS:
+ * --the expected version for hyperslab selection info
+ * --the expected encoded size (version 3 hyperslab selection info)
+ */
+
+ if(H5Sget_select_type(in_sid) == H5S_SEL_POINTS) {
+
+ /* Verify the version */
+ VERIFY((uint32_t)buf[35], expected_version, "Version for point selection");
+
+ /* Verify the encoded size for version 2 */
+ if(expected_version == 2)
+ VERIFY((uint8_t)buf[39], expected_enc_size, "Encoded size of point selection info");
+ }
+
+ if(H5Sget_select_type(in_sid) == H5S_SEL_HYPERSLABS) {
+
+ /* Verify the version */
+ VERIFY((uint32_t)buf[35], expected_version, "Version for hyperslab selection info");
+
+ /* Verify the encoded size for version 3 */
+ if(expected_version == 3)
+ VERIFY((uint8_t)buf[40], expected_enc_size, "Encoded size of selection info");
+
+ } /* hyperslab selection */
+
+ ret = H5Sclose(d_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ if(buf)
+ HDfree(buf);
+
+ }
+
+ return(0);
+
+} /* test_h5s_check_encoding */
+
+/****************************************************************
+**
+** test_h5s_encode_regular_hyper():
+** This test verifies that H5Sencode2() works as specified in
+** the RFC for regular hyperslabs.
+** See "RFC: H5Sencode/H5Sdeocde Format Change".
+**
+****************************************************************/
+static void
+test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high)
+{
+ hid_t fapl = -1; /* File access property list ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hsize_t numparticles = 8388608; /* Used to calculate dimension size */
+ unsigned num_dsets = 513; /* Used to calculate dimension size */
+ hsize_t total_particles = numparticles * num_dsets;
+ hsize_t vdsdims[1] = {total_particles}; /* Dimension size */
+ hsize_t start, stride, count, block; /* Selection info */
+ unsigned config; /* Testing configuration */
+ unsigned unlim; /* H5S_UNLIMITED setting or not */
+ herr_t ret; /* Generic return value */
+ uint32_t expected_version = 0; /* Expected version for selection info */
+ uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Dataspace encoding of regular hyperslabs\n"));
+
+ /* Create the file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set the low/high bounds in the fapl */
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create the dataspace */
+ sid = H5Screate_simple(1, vdsdims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Testing with each configuration */
+ for(config = CONFIG_16; config <= CONFIG_32; config++) {
+ hbool_t expected_to_fail = FALSE;
+
+ /* Testing with unlimited or not */
+ for(unlim = 0; unlim <= 1; unlim++) {
+ start = 0;
+ count = unlim? H5S_UNLIMITED : 2;
+
+ if((high <= H5F_LIBVER_V18) &&
+ (unlim || config == CONFIG_32))
+ expected_to_fail = TRUE;
+
+ if(low >= H5F_LIBVER_V112)
+ expected_version = 3;
+ else if(config == CONFIG_16 && !unlim)
+ expected_version = 1;
+ else
+ expected_version = 2;
+
+ /* test 1 */
+ switch(config) {
+ case CONFIG_16:
+ stride = POWER16 - 1;
+ block = 4;
+ expected_enc_size = expected_version == 3 ? 2 : 4;
+ break;
+ case CONFIG_32:
+ stride = POWER32 - 1;
+ block = 4;
+ expected_enc_size = expected_version == 3 ? 4 : 8;
+
+ break;
+ default:
+ HDassert(0);
+ break;
+ } /* end switch */
+
+ /* Set the hyperslab selection */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Verify the version and encoded size expected for this configuration */
+ ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail);
+ CHECK(ret, FAIL, "test_h5s_check_encoding");
+
+ /* test 2 */
+ switch(config) {
+ case CONFIG_16:
+ stride = POWER16 - 1;
+ block = POWER16 - 2;
+ expected_enc_size = expected_version == 3 ? 2 : 4;
+ break;
+ case CONFIG_32:
+ stride = POWER32 - 1;
+ block = POWER32 - 2;
+ expected_enc_size = expected_version == 3 ? 4 : 8;
+ break;
+ default:
+ HDassert(0);
+ break;
+ } /* end switch */
+
+ /* Set the hyperslab selection */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Verify the version and encoded size for this configuration */
+ ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail);
+ CHECK(ret, FAIL, "test_h5s_check_encoding");
+
+ /* test 3 */
+ switch(config) {
+ case CONFIG_16:
+ stride = POWER16 - 1;
+ block = POWER16 - 1;
+ expected_enc_size = 4;
+ break;
+ case CONFIG_32:
+ stride = POWER32 - 1;
+ block = POWER32 - 1;
+ expected_enc_size = 8;
+ break;
+ default:
+ HDassert(0);
+ break;
+ }
+
+ /* Set the hyperslab selection */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Verify the version and encoded size expected for this configuration */
+ ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail);
+ CHECK(ret, FAIL, "test_h5s_check_encoding");
+
+ /* test 4 */
+ switch(config) {
+ case CONFIG_16:
+ stride = POWER16;
+ block = POWER16 - 2;
+ expected_enc_size = 4;
+ break;
+ case CONFIG_32:
+ stride = POWER32;
+ block = POWER32 - 2;
+ expected_enc_size = 8;
+ break;
+ default:
+ HDassert(0);
+ break;
+ } /* end switch */
+
+ /* Set the hyperslab selection */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Verify the version and encoded size expected for this configuration */
+ ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail);
+ CHECK(ret, FAIL, "test_h5s_check_encoding");
+
+ /* test 5 */
+ switch(config) {
+ case CONFIG_16:
+ stride = POWER16;
+ block = 1;
+ expected_enc_size = 4;
+ break;
+ case CONFIG_32:
+ stride = POWER32;
+ block = 1;
+ expected_enc_size = 8;
+ break;
+ default:
+ HDassert(0);
+ break;
+ }
+
+ /* Set the hyperslab selection */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Verify the version and encoded size expected for this configuration */
+ ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail);
+ CHECK(ret, FAIL, "test_h5s_check_encoding");
+
+ } /* for unlim */
+ } /* for config */
+
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+} /* test_h5s_encode_regular_hyper() */
+
+/****************************************************************
+**
+** test_h5s_encode_irregular_hyper():
+** This test verifies that H5Sencode2() works as specified in
+** the RFC for irregular hyperslabs.
+** See "RFC: H5Sencode/H5Sdeocde Format Change".
+**
+****************************************************************/
+static void
+test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high)
+{
+ hid_t fapl = -1; /* File access property list ID */
+ hid_t sid; /* Dataspace ID */
+ hsize_t numparticles = 8388608; /* Used to calculate dimension size */
+ unsigned num_dsets = 513; /* Used to calculate dimension size */
+ hsize_t total_particles = numparticles * num_dsets;
+ hsize_t vdsdims[1] = {total_particles}; /* Dimension size */
+ hsize_t start, stride, count, block; /* Selection info */
+ htri_t is_regular; /* Is this a regular hyperslab */
+ unsigned config; /* Testing configuration */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Dataspace encoding of irregular hyperslabs\n"));
+
+ /* Create the file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set the low/high bounds in the fapl */
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create the dataspace */
+ sid = H5Screate_simple(1, vdsdims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Testing with each configuration */
+ for(config = CONFIG_8; config <= CONFIG_32; config++) {
+ hbool_t expected_to_fail = FALSE; /* Whether H5Sencode2 is expected to fail */
+ uint32_t expected_version = 0; /* Expected version for selection info */
+ uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */
+
+ start = 0;
+ count = 2;
+ block = 4;
+
+ /* H5Sencode2 is expected to fail for library v110 and below
+ when the selection exceeds the 32 bits integer limit */
+ if(high <= H5F_LIBVER_V110 && config == CONFIG_32)
+ expected_to_fail = TRUE;
+
+ if(low >= H5F_LIBVER_V112 || config == CONFIG_32)
+ expected_version = 3;
+ else
+ expected_version = 1;
+
+ switch(config) {
+ case CONFIG_8:
+ stride = POWER8 - 2;
+ break;
+
+ case CONFIG_16:
+ stride = POWER16 - 2;
+ break;
+
+ case CONFIG_32:
+ stride = POWER32 - 2;
+ break;
+
+ default:
+ HDassert(0);
+ break;
+ }
+
+ /* Set the hyperslab selection */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ start = 8;
+ count = 5;
+ block = 2;
+
+ switch(config) {
+ case CONFIG_8:
+ stride = POWER8;
+ expected_enc_size = expected_version == 3 ? 2 : 4;
+ break;
+
+ case CONFIG_16:
+ stride = POWER16;
+ expected_enc_size = 4;
+ break;
+
+ case CONFIG_32:
+ stride = POWER32;
+ expected_enc_size = 8;
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+
+ /* Set the hyperslab selection */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, &start, &stride, &count, &block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Should be irregular hyperslab */
+ is_regular = H5Sis_regular_hyperslab(sid);
+ VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab");
+
+ /* Verify the version and encoded size expected for the configuration */
+ ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail);
+ CHECK(ret, FAIL, "test_h5s_check_encoding");
+
+ } /* for config */
+
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_h5s_encode_irregular_hyper() */
+
+/****************************************************************
+**
+** test_h5s_encode_points():
+** This test verifies that H5Sencode2() works as specified in
+** the RFC for point selection.
+** See "RFC: H5Sencode/H5Sdeocde Format Change".
+**
+****************************************************************/
+static void
+test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high)
+{
+ hid_t fapl = -1; /* File access property list ID */
+ hid_t sid; /* Dataspace ID */
+ hsize_t numparticles = 8388608; /* Used to calculate dimenion size */
+ unsigned num_dsets = 513; /* used to calculate dimension size */
+ hsize_t total_particles = numparticles * num_dsets;
+ hsize_t vdsdims[1] = {total_particles}; /* Dimension size */
+ hsize_t coord[4]; /* The point coordinates */
+ herr_t ret; /* Generic return value */
+ hbool_t expected_to_fail = FALSE; /* Expected to fail or not */
+ uint32_t expected_version = 0; /* Expected version for selection info */
+ uint8_t expected_enc_size = 0; /* Expected encoded size of selection info */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Dataspace encoding of points selection\n"));
+
+ /* Create the file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set the low/high bounds in the fapl */
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create the dataspace */
+ sid = H5Screate_simple(1, vdsdims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* test 1 */
+ coord[0] = 5;
+ coord[1] = 15;
+ coord[2] = POWER16;
+ coord[3] = 19;
+ ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ expected_to_fail = FALSE;
+ expected_enc_size = 4;
+ expected_version = 1;
+
+ if(low >= H5F_LIBVER_V112)
+ expected_version = 2;
+
+ /* Verify the version and encoded size expected for the configuration */
+ ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail);
+ CHECK(ret, FAIL, "test_h5s_check_encoding");
+
+ /* test 2 */
+ coord[0] = 5;
+ coord[1] = 15;
+ coord[2] = POWER32 - 1;
+ coord[3] = 19;
+ ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ /* Expected result same as test 1 */
+ ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail);
+ CHECK(ret, FAIL, "test_h5s_check_encoding");
+
+ /* test 3 */
+ if(high <= H5F_LIBVER_V110)
+ expected_to_fail = TRUE;
+
+ if(high >= H5F_LIBVER_V112) {
+ expected_version = 2;
+ expected_enc_size = 8;
+ }
+
+ coord[0] = 5;
+ coord[1] = 15;
+ coord[2] = POWER32 + 1;
+ coord[3] = 19;
+ ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ /* Verify the version and encoded size expected for the configuration */
+ ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail);
+ CHECK(ret, FAIL, "test_h5s_check_encoding");
+
+ /* Close the dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_h5s_encode_points() */
/****************************************************************
**
@@ -1362,7 +2127,7 @@ test_h5s_encode_length(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Encode simple data space in a buffer */
- ret = H5Sencode(sid, NULL, &sbuf_size);
+ ret = H5Sencode2(sid, NULL, &sbuf_size, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Sencode");
/* Allocate the buffer */
@@ -1372,7 +2137,7 @@ test_h5s_encode_length(void)
}
/* Encode the dataspace */
- ret = H5Sencode(sid, sbuf, &sbuf_size);
+ ret = H5Sencode2(sid, sbuf, &sbuf_size, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Sencode");
/* Verify that length stored at this location in the buffer is correct */
@@ -1400,7 +2165,6 @@ test_h5s_encode_length(void)
} /* test_h5s_encode_length() */
-
/****************************************************************
**
** test_h5s_scalar_write(): Test scalar H5S (dataspace) writing code.
@@ -1409,14 +2173,14 @@ test_h5s_encode_length(void)
static void
test_h5s_scalar_write(void)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t sid1; /* Dataspace ID */
- int rank; /* Logical rank of dataspace */
- hsize_t tdims[4]; /* Dimension array to test with */
- hssize_t n; /* Number of dataspace elements */
- H5S_class_t ext_type; /* Extent type */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1; /* Dataspace ID */
+ int rank; /* Logical rank of dataspace */
+ hsize_t tdims[4]; /* Dimension array to test with */
+ hssize_t n; /* Number of dataspace elements */
+ H5S_class_t ext_type; /* Extent type */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Scalar Dataspace Manipulation during Writing\n"));
@@ -1435,14 +2199,17 @@ test_h5s_scalar_write(void)
sid1 = H5Screate_simple(SPACE3_RANK, NULL, NULL);
CHECK(sid1, FAIL, "H5Screate_simple");
+ /* Retrieve the number of elements in the dataspace selection */
n = H5Sget_simple_extent_npoints(sid1);
CHECK(n, FAIL, "H5Sget_simple_extent_npoints");
VERIFY(n, 1, "H5Sget_simple_extent_npoints");
+ /* Get the dataspace rank */
rank = H5Sget_simple_extent_ndims(sid1);
CHECK(rank, FAIL, "H5Sget_simple_extent_ndims");
VERIFY(rank, SPACE3_RANK, "H5Sget_simple_extent_ndims");
+ /* Get the dataspace dimension sizes */
rank = H5Sget_simple_extent_dims(sid1, tdims, NULL);
VERIFY(rank, 0, "H5Sget_simple_extent_dims");
@@ -1454,6 +2221,7 @@ test_h5s_scalar_write(void)
dataset = H5Dcreate2(fid1, "Dataset1", H5T_NATIVE_UINT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
+ /* Write to the dataset */
ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &space3_data);
CHECK(ret, FAIL, "H5Dwrite");
@@ -1468,7 +2236,7 @@ test_h5s_scalar_write(void)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_h5s_scalar_write() */
+} /* test_h5s_scalar_write() */
/****************************************************************
**
@@ -2587,16 +3355,38 @@ test_versionbounds(void)
void
test_h5s(void)
{
+ H5F_libver_t low, high; /* Low and high bounds */
+
/* Output message about test being performed */
MESSAGE(5, ("Testing Dataspaces\n"));
- test_h5s_basic(); /* Test basic H5S code */
- test_h5s_null(); /* Test Null dataspace H5S code */
+ test_h5s_basic(); /* Test basic H5S code */
+ test_h5s_null(); /* Test Null dataspace H5S code */
test_h5s_zero_dim(); /* Test dataspace with zero dimension size */
- test_h5s_encode(); /* Test encoding and decoding */
- test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */
+
+ /* Loop through all the combinations of low/high version bounds */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
+
+ /* Invalid combinations, just continue */
+ if(high == H5F_LIBVER_EARLIEST || high < low)
+ continue;
+
+ test_h5s_encode(low, high); /* Test encoding and decoding */
+ test_h5s_encode_regular_hyper(low, high); /* Test encoding regular hyperslabs */
+ test_h5s_encode_irregular_hyper(low, high); /* Test encoding irregular hyperslabs */
+ test_h5s_encode_points(low, high); /* Test encoding points */
+
+ } /* end high bound */
+ } /* end low bound */
+
+ test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ test_h5s_encode1(); /* Test operations with old API routine (H5Sencode1) */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
test_h5s_scalar_write(); /* Test scalar H5S writing code */
- test_h5s_scalar_read(); /* Test scalar H5S reading code */
+ test_h5s_scalar_read(); /* Test scalar H5S reading code */
test_h5s_compound_scalar_write(); /* Test compound datatype scalar H5S writing code */
test_h5s_compound_scalar_read(); /* Test compound datatype scalar H5S reading code */
diff --git a/test/trefer.c b/test/trefer.c
index 938f040..4bf9caf 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -490,16 +490,20 @@ test_reference_obj(void)
** test_reference_region(): Test basic H5R (reference) object reference code.
** Tests references to various kinds of objects
**
+** Note: The libver_low/libver_high parameters are added to create the file
+** with the low and high bounds setting in fapl.
+** Please see the RFC for "H5Sencode/H5Sdecode Format Change".
+**
****************************************************************/
static void
test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high)
{
- hid_t fid1; /* HDF5 File IDs */
+ hid_t fid1; /* HDF5 File IDs */
hid_t fapl = -1; /* File access property list */
- hid_t dset1, /* Dataset ID */
+ hid_t dset1, /* Dataset ID */
dset2; /* Dereferenced dataset ID */
- hid_t sid1, /* Dataspace ID #1 */
- sid2; /* Dataspace ID #2 */
+ hid_t sid1, /* Dataspace ID #1 */
+ sid2; /* Dataspace ID #2 */
hid_t dapl_id; /* Dataset access property list */
hsize_t dims1[] = {SPACE1_DIM1},
dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
@@ -508,24 +512,24 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high)
hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */
- hsize_t *coords; /* Coordinate buffer */
- hsize_t low[SPACE2_RANK]; /* Selection bounds */
- hsize_t high[SPACE2_RANK]; /* Selection bounds */
- hdset_reg_ref_t *wbuf, /* buffer to write to disk */
- *rbuf; /* buffer read from disk */
- hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */
- uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
- *drbuf; /* Buffer for reading numeric data from disk */
- uint8_t *tu8; /* Temporary pointer to uint8 data */
- H5O_type_t obj_type; /* Type of object */
- int i, j; /* counting variables */
- hssize_t hssize_ret; /* hssize_t return value */
- htri_t tri_ret; /* htri_t return value */
- herr_t ret; /* Generic return value */
- haddr_t addr = HADDR_UNDEF; /* test for undefined reference */
- hid_t dset_NA; /* Dataset id for undefined reference */
- hid_t space_NA; /* Dataspace id for undefined reference */
- hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */
+ hsize_t *coords; /* Coordinate buffer */
+ hsize_t low[SPACE2_RANK]; /* Selection bounds */
+ hsize_t high[SPACE2_RANK]; /* Selection bounds */
+ hdset_reg_ref_t *wbuf, /* buffer to write to disk */
+ *rbuf; /* buffer read from disk */
+ hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */
+ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
+ *drbuf; /* Buffer for reading numeric data from disk */
+ uint8_t *tu8; /* Temporary pointer to uint8 data */
+ H5O_type_t obj_type; /* Type of object */
+ int i, j; /* counting variables */
+ hssize_t hssize_ret; /* hssize_t return value */
+ htri_t tri_ret; /* htri_t return value */
+ herr_t ret; /* Generic return value */
+ haddr_t addr = HADDR_UNDEF; /* test for undefined reference */
+ hid_t dset_NA; /* Dataset id for undefined reference */
+ hid_t space_NA; /* Dataspace id for undefined reference */
+ hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */
hdset_reg_ref_t wdata_NA[1], /* Write buffer */
rdata_NA[1]; /* Read buffer */
@@ -634,8 +638,14 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high)
VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints");
/* Store third dataset region */
- ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2);
- CHECK(ret, FAIL, "H5Rcreate");
+ H5E_BEGIN_TRY {
+ ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2);
+ } H5E_END_TRY;
+
+ if(libver_high < H5F_LIBVER_V110)
+ VERIFY(ret, FAIL, "H5Rcreate");
+ else
+ CHECK(ret, FAIL, "H5Rcreate");
ret = H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &wbuf[0], &obj_type);
CHECK(ret, FAIL, "H5Rget_obj_type2");
diff --git a/test/vds.c b/test/vds.c
index 67af8e3..db01b2b 100644
--- a/test/vds.c
+++ b/test/vds.c
@@ -420,11 +420,11 @@ test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl,
size_t plist_buf_size;
/* Encode property list to plist_buf */
- if(H5Pencode(dcpl, NULL, &plist_buf_size) < 0)
+ if(H5Pencode2(dcpl, NULL, &plist_buf_size, fapl) < 0)
TEST_ERROR
if(NULL == (plist_buf = HDmalloc(plist_buf_size)))
TEST_ERROR
- if(H5Pencode(dcpl, plist_buf, &plist_buf_size) < 0)
+ if(H5Pencode2(dcpl, plist_buf, &plist_buf_size, fapl) < 0)
TEST_ERROR
/* Decode serialized property list to *ex_dcpl */
@@ -469,7 +469,7 @@ error:
/* Main test function */
static int
-test_api(test_api_config_t config, hid_t fapl)
+test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low)
{
char filename[FILENAME_BUF_SIZE];
hid_t dcpl = -1; /* Dataset creation property list */
@@ -618,7 +618,8 @@ test_api(test_api_config_t config, hid_t fapl)
TEST_ERROR
/* Get examination DCPL */
- if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)213) < 0)
+ if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename,
+ (low >= H5F_LIBVER_V112)?(hsize_t)99:(low >= H5F_LIBVER_V110?174:213)) < 0)
TEST_ERROR
/* Test H5Pget_virtual_count */
@@ -1025,7 +1026,8 @@ test_api(test_api_config_t config, hid_t fapl)
}
/* Get examination DCPL */
- if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)697) < 0)
+ if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename,
+ (low >= H5F_LIBVER_V112)?(hsize_t)607:(hsize_t)697) < 0)
TEST_ERROR
/* Test H5Pget_virtual_count */
@@ -11598,6 +11600,11 @@ test_dapl_values(hid_t fapl_id)
*
* Purpose: Tests datasets with virtual layout
*
+ * Note:
+ * Tests are modified to test with the low/high bounds combination
+ * set in fapl.
+ * Please see RFC for "H5Sencode/H5Sdecode Format Change".
+ *
* Return: EXIT_SUCCESS/EXIT_FAILURE
*-------------------------------------------------------------------------
*/
@@ -11606,8 +11613,11 @@ main(void)
{
char filename[FILENAME_BUF_SIZE];
hid_t fapl;
+ hid_t my_fapl = -1; /* File access property list */
int test_api_config;
unsigned bit_config;
+ unsigned latest = FALSE; /* Using the latest library version bound */
+ H5F_libver_t low, high; /* Low and high bounds */
int nerrors = 0;
/* Testing setup */
@@ -11616,21 +11626,59 @@ main(void)
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
- for(test_api_config = (int)TEST_API_BASIC; test_api_config < (int)TEST_API_NTESTS; test_api_config++)
- nerrors += test_api((test_api_config_t)test_api_config, fapl);
- for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) {
- HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : "");
- nerrors += test_basic_io(bit_config, fapl);
- nerrors += test_vds_prefix(bit_config, fapl);
- nerrors += test_unlim(bit_config, fapl);
- nerrors += test_printf(bit_config, fapl);
- nerrors += test_all(bit_config, fapl);
- }
+ /* Set to use the latest file format */
+ if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* Loop through all the combinations of low/high version bounds */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
+ char msg[80]; /* Message for file version bounds */
+ char *low_string; /* The low bound string */
+ char *high_string; /* The high bound string */
+
+ /* Invalid combinations, just continue */
+ if(high == H5F_LIBVER_EARLIEST || high < low)
+ continue;
+
+ /* Test virtual dataset only for V110 and above */
+ if(high < H5F_LIBVER_V110)
+ continue;
+
+ /* Whether to use latest hyperslab/point selection version */
+ if(low >= H5F_LIBVER_V112)
+ latest = TRUE;
+
+ /* Set the low/high version bounds */
+ if(H5Pset_libver_bounds(my_fapl, low, high) < 0)
+ TEST_ERROR
+
+ /* Display testing info */
+ low_string = h5_get_version_string(low);
+ high_string = h5_get_version_string(high);
+ HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string);
+ HDputs(msg);
+
+ for(test_api_config = (int)TEST_API_BASIC; test_api_config < (int)TEST_API_NTESTS; test_api_config++)
+ nerrors += test_api((test_api_config_t)test_api_config, my_fapl, low);
+ for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) {
+ HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : "");
+ nerrors += test_basic_io(bit_config, my_fapl);
+ nerrors += test_vds_prefix(bit_config, my_fapl);
+ nerrors += test_unlim(bit_config, my_fapl);
+ nerrors += test_printf(bit_config, my_fapl);
+ nerrors += test_all(bit_config, my_fapl);
+ }
- nerrors += test_dapl_values(fapl);
+ nerrors += test_dapl_values(my_fapl);
- /* Verify symbol table messages are cached */
- nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
+ /* Verify symbol table messages are cached */
+ nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0);
+
+ } /* end for high */
+ } /* end for low */
+
+ if(H5Pclose(my_fapl) < 0)
+ TEST_ERROR
if(nerrors)
goto error;
diff --git a/testpar/t_prop.c b/testpar/t_prop.c
index d5efa94..2eb3914 100644
--- a/testpar/t_prop.c
+++ b/testpar/t_prop.c
@@ -33,12 +33,12 @@ test_encode_decode(hid_t orig_pl, int mpi_rank, int recv_proc)
int send_size = 0;
/* first call to encode returns only the size of the buffer needed */
- ret = H5Pencode(orig_pl, NULL, &buf_size);
+ ret = H5Pencode2(orig_pl, NULL, &buf_size, H5P_DEFAULT);
VRFY((ret >= 0), "H5Pencode succeeded");
sbuf = (uint8_t *)HDmalloc(buf_size);
- ret = H5Pencode(orig_pl, sbuf, &buf_size);
+ ret = H5Pencode2(orig_pl, sbuf, &buf_size, H5P_DEFAULT);
VRFY((ret >= 0), "H5Pencode succeeded");
/* this is a temp fix to send this size_t */