summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-07-31 15:27:07 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-07-31 15:27:07 (GMT)
commit17275779d07c094741039d0c263fdf055c32bfb6 (patch)
treeb8c90295b95498184125853f93fbb8717e2c5e8e
parent79b2b5a3213eb3dd950b5ad4d806f828e7fedb88 (diff)
downloadhdf5-17275779d07c094741039d0c263fdf055c32bfb6.zip
hdf5-17275779d07c094741039d0c263fdf055c32bfb6.tar.gz
hdf5-17275779d07c094741039d0c263fdf055c32bfb6.tar.bz2
[svn-r5839] Purpose:
Code cleanup Description: Move operations on each type of selection into the source code file for each selection type (all->H5Sall.c, hyperslab->H5Shyper.c, etc.) Remove central H5S_select_<foo> operations, instead calling the operations through function pointers in each selection (a much more object-oriented approach). Platforms tested: FreeBSD 4.6 (sleipnir)
-rw-r--r--src/H5D.c62
-rw-r--r--src/H5Distore.c2
-rw-r--r--src/H5Fistore.c2
-rw-r--r--src/H5I.c13
-rw-r--r--src/H5Oattr.c3
-rw-r--r--src/H5R.c7
-rw-r--r--src/H5S.c331
-rw-r--r--src/H5Sall.c286
-rw-r--r--src/H5Shyper.c548
-rw-r--r--src/H5Smpio.c8
-rw-r--r--src/H5Snone.c456
-rw-r--r--src/H5Spkg.h148
-rw-r--r--src/H5Spoint.c554
-rw-r--r--src/H5Sprivate.h28
-rw-r--r--src/H5Spublic.h2
-rw-r--r--src/H5Sselect.c1341
16 files changed, 1829 insertions, 1962 deletions
diff --git a/src/H5D.c b/src/H5D.c
index df68439..0468091 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -12,6 +12,8 @@
/* $Id$ */
+#define H5S_PACKAGE /*suppress error about including H5Spkg */
+
#include "H5private.h" /* Generic Functions */
#include "H5Dprivate.h" /* Dataset functions */
#include "H5Eprivate.h" /* Error handling */
@@ -23,7 +25,7 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
-#include "H5Sprivate.h" /* Dataspace functions */
+#include "H5Spkg.h" /* Dataspace functions */
#include "H5Vprivate.h" /* Vector and array functions */
#include "H5Zprivate.h" /* Data filters */
@@ -1214,7 +1216,7 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
}
/* Check for valid selection */
- if(H5S_select_valid(mem_space)!=TRUE) {
+ if((*mem_space->select.is_valid)(mem_space)!=TRUE) {
HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"selection+offset not within extent");
}
@@ -1225,7 +1227,7 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
}
/* Check for valid selection */
- if(H5S_select_valid(file_space)!=TRUE) {
+ if((*file_space->select.is_valid)(file_space)!=TRUE) {
HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"selection+offset not within extent");
}
@@ -1312,7 +1314,7 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
}
/* Check for valid selection */
- if (H5S_select_valid(mem_space)!=TRUE) {
+ if ((*mem_space->select.is_valid)(mem_space)!=TRUE) {
HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"selection+offset not within extent");
}
@@ -1323,7 +1325,7 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
}
/* Check for valid selection */
- if (H5S_select_valid(file_space)!=TRUE) {
+ if ((*file_space->select.is_valid)(file_space)!=TRUE) {
HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"selection+offset not within extent");
}
@@ -2203,7 +2205,7 @@ herr_t
H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
const H5S_t *file_space, hid_t dxpl_id, void *buf/*out*/)
{
- hssize_t nelmts; /*total number of elmts */
+ hsize_t nelmts; /*total number of elmts */
hsize_t smine_start; /*strip mine start loc */
hsize_t n, smine_nelmts; /*elements per strip */
uint8_t *tconv_buf = NULL; /*data type conv buffer */
@@ -2268,7 +2270,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
} /* end if */
if (!mem_space)
mem_space = file_space;
- nelmts = H5S_get_select_npoints(mem_space);
+ nelmts = (*mem_space->select.get_npoints)(mem_space);
#ifdef H5_HAVE_PARALLEL
/* Collect Parallel I/O information for possible later use */
@@ -2297,7 +2299,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
#endif /*H5_HAVE_PARALLEL*/
/* Make certain that the number of elements in each selection is the same */
- if (nelmts!=H5S_get_select_npoints (file_space))
+ if (nelmts!=(*file_space->select.get_npoints) (file_space))
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes");
/* Retrieve dataset properties */
@@ -2432,11 +2434,11 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
request_nelmts = target_size / MAX(src_type_size, dst_type_size);
/* Figure out the strip mine size. */
- if (H5S_select_iter_init(file_space, src_type_size, &file_iter)<0)
+ if ((*file_space->select.iter_init)(file_space, src_type_size, &file_iter)<0)
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information");
- if (H5S_select_iter_init(mem_space, dst_type_size, &mem_iter)<0)
+ if ((*mem_space->select.iter_init)(mem_space, dst_type_size, &mem_iter)<0)
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information");
- if (H5S_select_iter_init(mem_space, dst_type_size, &bkg_iter)<0)
+ if ((*mem_space->select.iter_init)(mem_space, dst_type_size, &bkg_iter)<0)
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information");
/* Sanity check elements in temporary buffer */
@@ -2471,11 +2473,10 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
} /* end if */
/* Start strip mining... */
- H5_CHECK_OVERFLOW(nelmts,hssize_t,hsize_t);
- for (smine_start=0; smine_start<(hsize_t)nelmts; smine_start+=smine_nelmts) {
+ for (smine_start=0; smine_start<nelmts; smine_start+=smine_nelmts) {
/* Go figure out how many elements to read from the file */
- smine_nelmts = H5S_select_favail(file_space,&file_iter,
- MIN(request_nelmts, (nelmts-smine_start)));
+ assert((*file_space->select.iter_nelmts)(&file_iter)==(nelmts-smine_start));
+ smine_nelmts = MIN(request_nelmts, (nelmts-smine_start));
/*
* Gather the data from disk into the data type conversion
@@ -2552,9 +2553,9 @@ done:
} /* end if */
#endif /*H5_HAVE_PARALLEL*/
/* Release selection iterators */
- H5S_sel_iter_release(file_space,&file_iter);
- H5S_sel_iter_release(mem_space,&mem_iter);
- H5S_sel_iter_release(mem_space,&bkg_iter);
+ (*file_space->select.iter_release)(&file_iter);
+ (*mem_space->select.iter_release)(&mem_iter);
+ (*mem_space->select.iter_release)(&bkg_iter);
if (src_id >= 0)
H5I_dec_ref(src_id);
@@ -2619,7 +2620,7 @@ herr_t
H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
const H5S_t *file_space, hid_t dxpl_id, const void *buf)
{
- hssize_t nelmts; /*total number of elmts */
+ hsize_t nelmts; /*total number of elmts */
hsize_t smine_start; /*strip mine start loc */
hsize_t n, smine_nelmts; /*elements per strip */
uint8_t *tconv_buf = NULL; /*data type conv buffer */
@@ -2703,7 +2704,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
} /* end if */
if (!mem_space)
mem_space = file_space;
- nelmts = H5S_get_select_npoints(mem_space);
+ nelmts = (*mem_space->select.get_npoints)(mem_space);
#ifdef H5_HAVE_PARALLEL
/* Collect Parallel I/O information for possible later use */
@@ -2732,7 +2733,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
#endif /*H5_HAVE_PARALLEL*/
/* Make certain that the number of elements in each selection is the same */
- if (nelmts!=H5S_get_select_npoints (file_space))
+ if (nelmts!=(*file_space->select.get_npoints) (file_space))
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes");
/* Retrieve dataset properties */
@@ -2863,11 +2864,11 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small");
/* Figure out the strip mine size. */
- if (H5S_select_iter_init(file_space, dst_type_size, &file_iter)<0)
+ if ((*file_space->select.iter_init)(file_space, dst_type_size, &file_iter)<0)
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information");
- if (H5S_select_iter_init(mem_space, src_type_size, &mem_iter)<0)
+ if ((*mem_space->select.iter_init)(mem_space, src_type_size, &mem_iter)<0)
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information");
- if (H5S_select_iter_init(file_space, dst_type_size, &bkg_iter)<0)
+ if ((*file_space->select.iter_init)(file_space, dst_type_size, &bkg_iter)<0)
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information");
/*
@@ -2902,11 +2903,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
} /* end if */
/* Start strip mining... */
- H5_CHECK_OVERFLOW(nelmts,hssize_t,hsize_t);
- for (smine_start=0; smine_start<(hsize_t)nelmts; smine_start+=smine_nelmts) {
+ for (smine_start=0; smine_start<nelmts; smine_start+=smine_nelmts) {
/* Go figure out how many elements to read from the file */
- smine_nelmts = H5S_select_favail(file_space,&file_iter,
- MIN(request_nelmts, (nelmts-smine_start)));
+ assert((*file_space->select.iter_nelmts)(&file_iter)==(nelmts-smine_start));
+ smine_nelmts = MIN(request_nelmts, (nelmts-smine_start));
/*
* Gather data from application buffer into the data type conversion
@@ -2991,9 +2991,9 @@ done:
} /* end if */
#endif /*H5_HAVE_PARALLEL*/
/* Release selection iterators */
- H5S_sel_iter_release(file_space,&file_iter);
- H5S_sel_iter_release(mem_space,&mem_iter);
- H5S_sel_iter_release(file_space,&bkg_iter);
+ (*file_space->select.iter_release)(&file_iter);
+ (*mem_space->select.iter_release)(&mem_iter);
+ (*file_space->select.iter_release)(&bkg_iter);
if (src_id >= 0)
H5I_dec_ref(src_id);
diff --git a/src/H5Distore.c b/src/H5Distore.c
index a9f7f56..bac14c2 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -2908,7 +2908,7 @@ H5F_istore_initialize_by_extent(H5F_t *f, const H5O_layout_t *layout,
chunk_offset, FALSE, &idx_hint)))
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk");
- if(H5S_select_all(space_chunk) < 0)
+ if(H5S_select_all(space_chunk,1) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select space");
for(i = 0; i < rank; i++)
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index a9f7f56..bac14c2 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -2908,7 +2908,7 @@ H5F_istore_initialize_by_extent(H5F_t *f, const H5O_layout_t *layout,
chunk_offset, FALSE, &idx_hint)))
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk");
- if(H5S_select_all(space_chunk) < 0)
+ if(H5S_select_all(space_chunk,1) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select space");
for(i = 0; i < rank; i++)
diff --git a/src/H5I.c b/src/H5I.c
index 2bf2389..3e9ad18 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -641,12 +641,11 @@ H5I_object(hid_t id)
FUNC_ENTER_NOAPI(H5I_object, NULL);
/* General lookup of the ID */
- if (NULL==(id_ptr = H5I_find_id(id))) HGOTO_DONE(NULL);
+ if (NULL!=(id_ptr = H5I_find_id(id))) {
+ /* Get the object pointer to return */
+ ret_value = id_ptr->obj_ptr;
+ } /* end if */
- /* Check if we've found the correct ID */
- if (id_ptr) ret_value = id_ptr->obj_ptr;
-
- done:
FUNC_LEAVE(ret_value);
}
@@ -677,7 +676,9 @@ H5I_get_type(hid_t id)
FUNC_ENTER_NOAPI(H5I_get_type, H5I_BADID);
- if (id>0) ret_value = H5I_GROUP(id);
+ if (id>0)
+ ret_value = H5I_GROUP(id);
+
assert(ret_value>=H5I_BADID && ret_value<H5I_NGROUPS);
FUNC_LEAVE(ret_value);
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index d1f4c74..a15a624 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -142,6 +142,9 @@ H5O_attr_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
} else {
attr->ds->extent.type = H5S_SCALAR;
}
+ /* Default to entire dataspace being selected */
+ if(H5S_select_all(attr->ds,0)<0)
+ HRETURN_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
p += H5O_ALIGN(attr->ds_size);
/* Compute the size of the data */
diff --git a/src/H5R.c b/src/H5R.c
index 6a2384c..722496e 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -13,6 +13,7 @@
/* $Id$ */
#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+#define H5S_PACKAGE /*suppress error about including H5Spkg */
#include "H5private.h" /* Generic Functions */
#include "H5Iprivate.h" /* ID Functions */
@@ -23,7 +24,7 @@
#include "H5HGprivate.h" /* Global Heaps */
#include "H5MMprivate.h" /* Memory Management */
#include "H5Rprivate.h" /* References */
-#include "H5Sprivate.h" /* Dataspaces */
+#include "H5Spkg.h" /* Dataspaces */
#include "H5Tprivate.h" /* Datatypes */
/* Interface initialization */
@@ -194,7 +195,7 @@ H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type,
HDmemset(ref->heapid,H5R_DSET_REG_REF_BUF_SIZE,0);
/* Get the amount of space required to serialize the selection */
- if ((buf_size = H5S_select_serial_size(space)) < 0)
+ if ((buf_size = (*space->select.serial_size)(space)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL,
"Invalid amount of space for serializing selection");
@@ -212,7 +213,7 @@ H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type,
H5F_addr_encode(loc->file,&p,addr);
/* Serialize the selection */
- if (H5S_select_serialize(space,p) < 0)
+ if ((*space->select.serialize)(space,p) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection");
/* Save the serialized buffer for later */
diff --git a/src/H5S.c b/src/H5S.c
index 8d5e8b9..49182b0 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -81,10 +81,8 @@ H5S_init_interface(void)
/* Initialize the atom group for the file IDs */
if (H5I_init_group(H5I_DATASPACE, H5I_DATASPACEID_HASHSIZE,
- H5S_RESERVED_ATOMS, (H5I_free_t)H5S_close)<0) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "unable to initialize interface");
- }
+ H5S_RESERVED_ATOMS, (H5I_free_t)H5S_close)<0)
+ HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface");
#ifdef H5_HAVE_PARALLEL
{
@@ -287,8 +285,8 @@ H5S_term_interface(void)
RETURNS
Pointer to dataspace on success, NULL on failure
DESCRIPTION
- Creates a new dataspace of a given type. The extent & selection are
- undefined
+ Creates a new dataspace of a given type. The extent is undefined and the
+ selection is set to the "all" selection.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
@@ -302,17 +300,15 @@ H5S_create(H5S_class_t type)
FUNC_ENTER_NOAPI(H5S_create, NULL);
/* Create a new data space */
- if((ret_value = H5FL_ALLOC(H5S_t,1))!=NULL)
- {
+ if((ret_value = H5FL_ALLOC(H5S_t,1))!=NULL) {
ret_value->extent.type = type;
- ret_value->select.type = H5S_SEL_ALL; /* Entire extent selected by default */
- }
+ if(H5S_select_all(ret_value,0)<0)
+ HRETURN_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
+ } /* end if */
-#ifdef LATER
-done:
-#endif
FUNC_LEAVE(ret_value);
} /* end H5S_create() */
+
/*--------------------------------------------------------------------------
NAME
@@ -335,31 +331,32 @@ done:
hid_t
H5Screate(H5S_class_t type)
{
- H5S_t *new_ds=NULL;
- hid_t ret_value = FAIL;
+ H5S_t *new_ds=NULL; /* New dataspace structure */
+ hid_t ret_value = FAIL; /* Return value */
FUNC_ENTER_API(H5Screate, FAIL);
H5TRACE1("i","Sc",type);
/* Check args */
if(type<=H5S_NO_CLASS || type> H5S_SIMPLE) /* don't allow complex dataspace yet */
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid dataspace type");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace type");
- if (NULL==(new_ds=H5S_create(type))) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace");
- }
+ if (NULL==(new_ds=H5S_create(type)))
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace");
/* Atomize */
- if ((ret_value=H5I_register (H5I_DATASPACE, new_ds))<0) {
+ if ((ret_value=H5I_register (H5I_DATASPACE, new_ds))<0)
HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space atom");
- }
done:
if (ret_value < 0) {
- }
+ if(new_ds!=NULL)
+ H5S_close(new_ds);
+ } /* end if */
+
FUNC_LEAVE(ret_value);
} /* end H5Screate() */
+
/*-------------------------------------------------------------------------
* Function: H5S_extent_release
@@ -378,6 +375,8 @@ done:
herr_t
H5S_extent_release(H5S_t *ds)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5S_extent_release, FAIL);
assert(ds);
@@ -393,7 +392,7 @@ H5S_extent_release(H5S_t *ds)
break;
case H5S_SIMPLE:
- H5S_release_simple(&(ds->extent.u.simple));
+ ret_value=H5S_release_simple(&(ds->extent.u.simple));
break;
case H5S_COMPLEX:
@@ -404,8 +403,10 @@ H5S_extent_release(H5S_t *ds)
assert("unknown dataspace (extent) type" && 0);
break;
}
- FUNC_LEAVE(SUCCEED);
+
+ FUNC_LEAVE(ret_value);
} /* end H5S_extent_release() */
+
/*-------------------------------------------------------------------------
* Function: H5S_close
@@ -433,7 +434,7 @@ H5S_close(H5S_t *ds)
ds->select.offset=H5FL_ARR_FREE(hssize_t,ds->select.offset);
/* Release selection (this should come before the extent release) */
- H5S_select_release(ds);
+ (*ds->select.release)(ds);
/* Release extent */
H5S_extent_release(ds);
@@ -443,6 +444,7 @@ H5S_close(H5S_t *ds)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Sclose
@@ -467,14 +469,13 @@ H5Sclose(hid_t space_id)
H5TRACE1("e","i",space_id);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(space_id) ||
- NULL == H5I_object(space_id)) {
+ if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == H5I_object(space_id))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
+
/* When the reference count reaches zero the resources are freed */
- if (H5I_dec_ref(space_id) < 0) {
+ if (H5I_dec_ref(space_id) < 0)
HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
- }
+
FUNC_LEAVE(SUCCEED);
}
@@ -539,19 +540,16 @@ H5Scopy(hid_t space_id)
H5TRACE1("i","i",space_id);
/* Check args */
- if (H5I_DATASPACE!=H5I_get_type (space_id) || NULL==(src=H5I_object (space_id))) {
+ if (H5I_DATASPACE!=H5I_get_type (space_id) || NULL==(src=H5I_object (space_id)))
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
/* Copy */
- if (NULL==(dst=H5S_copy (src))) {
+ if (NULL==(dst=H5S_copy (src)))
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy data space");
- }
/* Atomize */
- if ((ret_value=H5I_register (H5I_DATASPACE, dst))<0) {
+ if ((ret_value=H5I_register (H5I_DATASPACE, dst))<0)
HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space atom");
- }
FUNC_LEAVE (ret_value);
}
@@ -582,12 +580,10 @@ H5Sextent_copy(hid_t dst_id,hid_t src_id)
H5TRACE2("e","ii",dst_id,src_id);
/* Check args */
- if (H5I_DATASPACE!=H5I_get_type (src_id) || NULL==(src=H5I_object (src_id))) {
+ if (H5I_DATASPACE!=H5I_get_type (src_id) || NULL==(src=H5I_object (src_id)))
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- if (H5I_DATASPACE!=H5I_get_type (dst_id) || NULL==(dst=H5I_object (dst_id))) {
+ if (H5I_DATASPACE!=H5I_get_type (dst_id) || NULL==(dst=H5I_object (dst_id)))
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
/* Copy */
if (H5S_extent_copy(&(dst->extent),&(src->extent))<0)
@@ -629,15 +625,13 @@ H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src)
case H5S_SIMPLE:
if (src->u.simple.size) {
dst->u.simple.size = H5FL_ARR_ALLOC(hsize_t,src->u.simple.rank,0);
- for (u = 0; u < src->u.simple.rank; u++) {
+ for (u = 0; u < src->u.simple.rank; u++)
dst->u.simple.size[u] = src->u.simple.size[u];
- }
}
if (src->u.simple.max) {
dst->u.simple.max = H5FL_ARR_ALLOC(hsize_t,src->u.simple.rank,0);
- for (u = 0; u < src->u.simple.rank; u++) {
+ for (u = 0; u < src->u.simple.rank; u++)
dst->u.simple.max[u] = src->u.simple.max[u];
- }
}
break;
@@ -652,6 +646,7 @@ H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5S_copy
@@ -677,9 +672,10 @@ H5S_copy(const H5S_t *src)
FUNC_ENTER_NOAPI(H5S_copy, NULL);
- if (NULL==(dst = H5FL_ALLOC(H5S_t,0))) {
+ if (NULL==(dst = H5FL_ALLOC(H5S_t,0)))
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- }
+
+ /* Copy the field in the struct */
*dst = *src;
/* Copy the source dataspace's extent */
@@ -728,19 +724,16 @@ H5S_get_simple_extent_npoints(const H5S_t *ds)
break;
case H5S_SIMPLE:
- for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) {
+ for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++)
ret_value *= ds->extent.u.simple.size[u];
- }
break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, -1,
- "complex data spaces are not supported yet");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, -1, "complex data spaces are not supported yet");
default:
assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, -1,
- "internal error (unknown data space class)");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, -1, "internal error (unknown data space class)");
}
FUNC_LEAVE(ret_value);
@@ -774,13 +767,14 @@ H5Sget_simple_extent_npoints(hid_t space_id)
H5TRACE1("Hs","i",space_id);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (ds = H5I_object(space_id))) {
+ if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (ds = H5I_object(space_id)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "not a data space");
- }
+
ret_value = H5S_get_simple_extent_npoints(ds);
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5S_get_npoints_max
@@ -825,25 +819,23 @@ H5S_get_npoints_max(const H5S_t *ds)
if (H5S_UNLIMITED==ds->extent.u.simple.max[u]) {
ret_value = HSIZET_MAX;
break;
- } else {
- ret_value *= ds->extent.u.simple.max[u];
}
+ else
+ ret_value *= ds->extent.u.simple.max[u];
}
- } else {
- for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) {
+ }
+ else {
+ for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++)
ret_value *= ds->extent.u.simple.size[u];
- }
}
break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
- "complex data spaces are not supported yet");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "complex data spaces are not supported yet");
default:
assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
- "internal error (unknown data space class)");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown data space class)");
}
FUNC_LEAVE(ret_value);
@@ -876,14 +868,14 @@ H5Sget_simple_extent_ndims(hid_t space_id)
H5TRACE1("Is","i",space_id);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(space_id) ||
- NULL == (ds = H5I_object(space_id))) {
+ if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (ds = H5I_object(space_id)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
+
ret_value = H5S_get_simple_extent_ndims(ds);
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5S_get_simple_extent_ndims
@@ -933,6 +925,7 @@ H5S_get_simple_extent_ndims(const H5S_t *ds)
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5Sget_simple_extent_dims
@@ -967,14 +960,14 @@ H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/,
H5TRACE3("Is","ixx",space_id,dims,maxdims);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(space_id) ||
- NULL == (ds = H5I_object(space_id))) {
+ if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (ds = H5I_object(space_id)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
- }
+
ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims);
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5S_get_simple_extent_dims
@@ -1015,27 +1008,25 @@ H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[])
if (dims)
dims[i] = ds->extent.u.simple.size[i];
if (max_dims) {
- if (ds->extent.u.simple.max) {
+ if (ds->extent.u.simple.max)
max_dims[i] = ds->extent.u.simple.max[i];
- } else {
+ else
max_dims[i] = ds->extent.u.simple.size[i];
- }
}
}
break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex data spaces are not supported yet");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not supported yet");
default:
assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "internal error (unknown data space class)");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown data space class)");
}
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5S_modify
@@ -1063,15 +1054,12 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds)
switch (ds->extent.type) {
case H5S_SCALAR:
case H5S_SIMPLE:
- if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->extent.u.simple))<0) {
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "can't update simple data space message");
- }
+ if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->extent.u.simple))<0)
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple data space message");
break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex data spaces are not implemented yet");
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not implemented yet");
default:
assert("unknown data space class" && 0);
@@ -1080,6 +1068,7 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5S_read
@@ -1116,14 +1105,14 @@ H5S_read(H5G_entry_t *ent)
if (H5O_read(ent, H5O_SDSPACE, 0, &(ds->extent.u.simple)) == NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to load dataspace info from dataset header");
- if(ds->extent.u.simple.rank != 0) {
+ if(ds->extent.u.simple.rank != 0)
ds->extent.type = H5S_SIMPLE;
- } else {
+ else
ds->extent.type = H5S_SCALAR;
- }
/* Default to entire dataspace being selected */
- ds->select.type=H5S_SEL_ALL;
+ if(H5S_select_all(ds,0)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
/* Allocate space for the offset and set it to zeros */
if (NULL==(ds->select.offset = H5FL_ARR_ALLOC(hssize_t,ds->extent.u.simple.rank,1)))
@@ -1140,6 +1129,7 @@ done:
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5S_cmp
@@ -1314,43 +1304,30 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/],
H5TRACE4("e","iIs*[a1]h*[a1]h",space_id,rank,dims,max);
/* Check args */
- if ((space = H5I_object(space_id)) == NULL) {
+ if ((space = H5I_object(space_id)) == NULL)
HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
- }
- if (rank > 0 && dims == NULL) {
+ if (rank > 0 && dims == NULL)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
- }
- if (rank<0 || rank>H5S_MAX_RANK) {
+ if (rank<0 || rank>H5S_MAX_RANK)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank");
- }
if (dims) {
for (u=0; u<rank; u++) {
- if (((max!=NULL && max[u]!=H5S_UNLIMITED) || max==NULL)
- && dims[u]==0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid dimension size");
- }
+ if (((max!=NULL && max[u]!=H5S_UNLIMITED) || max==NULL) && dims[u]==0)
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimension size");
}
}
if (max!=NULL) {
- if(dims==NULL) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "maximum dimension specified, but no current "
- "dimensions specified");
- }
+ if(dims==NULL)
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "maximum dimension specified, but no current dimensions specified");
for (u=0; u<rank; u++) {
- if (max[u]!=H5S_UNLIMITED && max[u]<dims[u]) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid maximum dimension size");
- }
+ if (max[u]!=H5S_UNLIMITED && max[u]<dims[u])
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid maximum dimension size");
}
}
/* Do it */
- if (H5S_set_extent_simple(space, (unsigned)rank, dims, max)<0) {
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "unable to set simple extent");
- }
+ if (H5S_set_extent_simple(space, (unsigned)rank, dims, max)<0)
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent");
FUNC_LEAVE(SUCCEED);
}
@@ -1386,10 +1363,8 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims,
space->select.offset=H5FL_ARR_FREE(hssize_t,space->select.offset);
/* Allocate space for the offset and set it to zeros */
- if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,rank,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,rank,1)))
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* shift out of the previous state to a "simple" dataspace */
switch (space->extent.type) {
@@ -1485,7 +1460,7 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
* We can't do conversion if the source and destination select a
* different number of data points.
*/
- if (H5S_get_select_npoints(mem_space) != H5S_get_select_npoints (file_space))
+ if ((*mem_space->select.get_npoints)(mem_space) != (*file_space->select.get_npoints) (file_space))
HRETURN_ERROR (H5E_DATASPACE, H5E_BADRANGE, NULL, "memory and file data spaces are different sizes");
/*
@@ -1602,10 +1577,8 @@ H5S_extend (H5S_t *space, const hsize_t *size)
if (space->extent.u.simple.size[u]<size[u]) {
if (space->extent.u.simple.max &&
H5S_UNLIMITED!=space->extent.u.simple.max[u] &&
- space->extent.u.simple.max[u]<size[u]) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "dimension cannot be increased");
- }
+ space->extent.u.simple.max[u]<size[u])
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "dimension cannot be increased");
ret_value++;
}
}
@@ -1613,17 +1586,14 @@ H5S_extend (H5S_t *space, const hsize_t *size)
/* Update */
if (ret_value) {
for (u=0; u<space->extent.u.simple.rank; u++) {
- if (space->extent.u.simple.size[u]<size[u]) {
+ if (space->extent.u.simple.size[u]<size[u])
space->extent.u.simple.size[u] = size[u];
- }
}
}
FUNC_LEAVE (ret_value);
}
-
-
/*-------------------------------------------------------------------------
* Function: H5Screate_simple
@@ -1662,56 +1632,42 @@ H5Screate_simple(int rank, const hsize_t dims[/*rank*/],
H5TRACE3("i","Is*[a0]h*[a0]h",rank,dims,maxdims);
/* Check arguments */
- if (rank<0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "dimensionality cannot be negative");
- }
- if (rank>H5S_MAX_RANK) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "dimensionality is too large");
- }
- if (!dims && dims!=0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "no dimensions specified");
- }
+ if (rank<0)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality cannot be negative");
+ if (rank>H5S_MAX_RANK)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality is too large");
+ if (!dims && dims!=0)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
/* Check whether the current dimensions are valid */
for (i=0; i<rank; i++) {
if (maxdims) {
- if (H5S_UNLIMITED!=maxdims[i] && maxdims[i]<dims[i]) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "maxdims is smaller than dims");
- }
- if (H5S_UNLIMITED!=maxdims[i] && dims[i]==0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "zero sized dimension for non-unlimited dimension");
- }
+ if (H5S_UNLIMITED!=maxdims[i] && maxdims[i]<dims[i])
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "maxdims is smaller than dims");
+ if (H5S_UNLIMITED!=maxdims[i] && dims[i]==0)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "zero sized dimension for non-unlimited dimension");
}
else {
- if (dims[i]==0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "zero sized dimension for non-unlimited dimension");
- }
+ if (dims[i]==0)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "zero sized dimension for non-unlimited dimension");
}
}
/* Create the space and set the extent */
- if(NULL==(space=H5S_create(H5S_SIMPLE))) {
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL,
- "can't create simple dataspace");
- }
- if(H5S_set_extent_simple(space,(unsigned)rank,dims,maxdims)<0) {
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "can't set dimensions");
- }
+ if(NULL==(space=H5S_create(H5S_SIMPLE)))
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace");
+ if(H5S_set_extent_simple(space,(unsigned)rank,dims,maxdims)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions");
/* Atomize */
- if ((ret_value=H5I_register (H5I_DATASPACE, space))<0) {
- HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register data space atom");
- }
+ if ((ret_value=H5I_register (H5I_DATASPACE, space))<0)
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space atom");
- done:
- if (ret_value<0 && space) H5S_close(space);
+done:
+ if (ret_value<0) {
+ if (space!=NULL)
+ H5S_close(space);
+ } /* end if */
+
FUNC_LEAVE(ret_value);
}
@@ -1777,9 +1733,8 @@ H5Sget_simple_extent_type(hid_t sid)
H5TRACE1("Sc","i",sid);
/* Check arguments */
- if (H5I_DATASPACE != H5I_get_type(sid) || NULL == (space = H5I_object(sid))) {
+ if (H5I_DATASPACE != H5I_get_type(sid) || NULL == (space = H5I_object(sid)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5S_NO_CLASS, "not a dataspace");
- }
ret_value=H5S_get_simple_extent_type(space);
@@ -1810,9 +1765,8 @@ H5Sset_extent_none(hid_t space_id)
H5TRACE1("e","i",space_id);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (space = H5I_object(space_id))) {
+ if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (space = H5I_object(space_id)))
HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
- }
/* Clear the previous extent from the dataspace */
if(H5S_extent_release(space)<0)
@@ -1822,6 +1776,7 @@ H5Sset_extent_none(hid_t space_id)
FUNC_LEAVE(SUCCEED);
} /* end H5Sset_extent_none() */
+
/*--------------------------------------------------------------------------
NAME
@@ -1848,19 +1803,15 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset)
H5TRACE2("e","i*Hs",space_id,offset);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (space = H5I_object(space_id))) {
+ if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (space = H5I_object(space_id)))
HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
- }
- if (offset == NULL) {
+ if (offset == NULL)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified");
- }
/* Allocate space for new offset */
if(space->select.offset==NULL) {
- if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,space->extent.u.simple.rank,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,space->extent.u.simple.rank,0)))
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
}
/* Copy the offset over */
@@ -1937,22 +1888,22 @@ H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth)
FUNC_ENTER_NOAPI(H5S_debug, FAIL);
switch (mesg->extent.type) {
- case H5S_SCALAR:
- fprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth,
- "Space class:");
- break;
-
- case H5S_SIMPLE:
- fprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth,
- "Space class:");
- (H5O_SDSPACE->debug)(f, &(mesg->extent.u.simple), stream,
- indent+3, MAX(0, fwidth-3));
- break;
-
- default:
- fprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth,
- "Space class:", (long)(mesg->extent.type));
- break;
+ case H5S_SCALAR:
+ fprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth,
+ "Space class:");
+ break;
+
+ case H5S_SIMPLE:
+ fprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth,
+ "Space class:");
+ (H5O_SDSPACE->debug)(f, &(mesg->extent.u.simple), stream,
+ indent+3, MAX(0, fwidth-3));
+ break;
+
+ default:
+ fprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth,
+ "Space class:", (long)(mesg->extent.type));
+ break;
}
FUNC_LEAVE(SUCCEED);
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 6b975d9..16686e2 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -23,9 +23,9 @@ static int interface_initialize_g = 0;
/*-------------------------------------------------------------------------
- * Function: H5S_all_init
+ * Function: H5S_all_iter_init
*
- * Purpose: Initializes iteration information for all selection.
+ * Purpose: Initializes iteration information for "all" selection.
*
* Return: non-negative on success, negative on failure.
*
@@ -37,9 +37,9 @@ static int interface_initialize_g = 0;
*-------------------------------------------------------------------------
*/
herr_t
-H5S_all_init (const H5S_t *space, size_t UNUSED elmt_size, H5S_sel_iter_t *sel_iter)
+H5S_all_iter_init (const H5S_t *space, size_t UNUSED elmt_size, H5S_sel_iter_t *sel_iter)
{
- FUNC_ENTER_NOAPI(H5S_all_init, FAIL);
+ FUNC_ENTER_NOAPI(H5S_all_iter_init, FAIL);
/* Check args */
assert (space && H5S_SEL_ALL==space->select.type);
@@ -52,17 +52,15 @@ H5S_all_init (const H5S_t *space, size_t UNUSED elmt_size, H5S_sel_iter_t *sel_i
sel_iter->all.offset=0;
FUNC_LEAVE (SUCCEED);
-}
+} /* H5S_all_iter_init() */
/*-------------------------------------------------------------------------
- * Function: H5S_all_favail
+ * Function: H5S_all_iter_nelmts
*
- * Purpose: Figure out the optimal number of elements to transfer to/from
- * the file.
+ * Purpose: Return number of elements left to process in iterator
*
- * Return: non-negative number of elements on success, zero on
- * failure.
+ * Return: non-negative number of elements on success, zero on failure
*
* Programmer: Quincey Koziol
* Tuesday, June 16, 1998
@@ -72,16 +70,44 @@ H5S_all_init (const H5S_t *space, size_t UNUSED elmt_size, H5S_sel_iter_t *sel_i
*-------------------------------------------------------------------------
*/
hsize_t
-H5S_all_favail (const H5S_t * UNUSED space, const H5S_sel_iter_t *sel_iter, hsize_t max)
+H5S_all_iter_nelmts (const H5S_sel_iter_t *sel_iter)
{
- FUNC_ENTER_NOAPI(H5S_all_favail, 0);
+ FUNC_ENTER_NOAPI(H5S_all_iter_nelmts, 0);
/* Check args */
- assert (space && H5S_SEL_ALL==space->select.type);
assert (sel_iter);
- FUNC_LEAVE (MIN(sel_iter->all.elmt_left,max));
-} /* H5S_all_favail() */
+ FUNC_LEAVE (sel_iter->all.elmt_left);
+} /* H5S_all_iter_nelmts() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_all_iter_release
+ PURPOSE
+ Release "all" selection iterator information for a dataspace
+ USAGE
+ herr_t H5S_all_iter_release(sel_iter)
+ H5S_sel_iter_t *sel_iter; IN: Pointer to selection iterator
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Releases all information for a dataspace "all" selection iterator
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_all_iter_release (H5S_sel_iter_t * UNUSED sel_iter)
+{
+ FUNC_ENTER_NOAPI(H5S_all_iter_release, FAIL);
+
+ /* Check args */
+ assert (sel_iter);
+
+ FUNC_LEAVE (SUCCEED);
+} /* H5S_all_iter_release() */
/*--------------------------------------------------------------------------
@@ -151,11 +177,80 @@ H5S_all_npoints (const H5S_t *space)
/*--------------------------------------------------------------------------
NAME
- H5S_all_select_serialize
+ H5S_all_is_valid
+ PURPOSE
+ Check whether the selection fits within the extent, with the current
+ offset defined.
+ USAGE
+ htri_t H5S_all_is_valid(space);
+ H5S_t *space; IN: Dataspace pointer to query
+ RETURNS
+ TRUE if the selection fits within the extent, FALSE if it does not and
+ Negative on an error.
+ DESCRIPTION
+ Determines if the current selection at the current offet fits within the
+ extent for the dataspace. Offset is irrelevant for this type of selection.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+htri_t
+H5S_all_is_valid (const H5S_t UNUSED *space)
+{
+ FUNC_ENTER_NOAPI(H5S_all_is_valid, FAIL);
+
+ assert(space);
+
+ FUNC_LEAVE (TRUE);
+} /* end H5S_all_is_valid() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_all_serial_size
+ PURPOSE
+ Determine the number of bytes needed to store the serialized "all"
+ selection information.
+ USAGE
+ hssize_t H5S_all_serial_size(space)
+ H5S_t *space; IN: Dataspace pointer to query
+ RETURNS
+ The number of bytes required on success, negative on an error.
+ DESCRIPTION
+ Determines the number of bytes required to serialize an "all"
+ selection for storage on disk.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hssize_t
+H5S_all_serial_size (const H5S_t *space)
+{
+ hssize_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER_NOAPI(H5S_all_serial_size, FAIL);
+
+ assert(space);
+
+ /* Basic number of bytes required to serialize point selection:
+ * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> +
+ * <length (4 bytes)> = 16 bytes
+ */
+ ret_value=16;
+
+ FUNC_LEAVE (ret_value);
+} /* end H5S_all_serial_size() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_all_serialize
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_all_select_serialize(space, buf)
+ herr_t H5S_all_serialize(space, buf)
H5S_t *space; IN: Dataspace pointer of selection to serialize
uint8 *buf; OUT: Buffer to put serialized selection into
RETURNS
@@ -169,11 +264,11 @@ H5S_all_npoints (const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_all_select_serialize (const H5S_t *space, uint8_t *buf)
+H5S_all_serialize (const H5S_t *space, uint8_t *buf)
{
herr_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_all_select_serialize, FAIL);
+ FUNC_ENTER_NOAPI(H5S_all_serialize, FAIL);
assert(space);
@@ -187,16 +282,16 @@ H5S_all_select_serialize (const H5S_t *space, uint8_t *buf)
ret_value=SUCCEED;
FUNC_LEAVE (ret_value);
-} /* H5S_all_select_serialize() */
+} /* H5S_all_serialize() */
/*--------------------------------------------------------------------------
NAME
- H5S_all_select_deserialize
+ H5S_all_deserialize
PURPOSE
Deserialize the current selection from a user-provided buffer.
USAGE
- herr_t H5S_all_select_deserialize(space, buf)
+ herr_t H5S_all_deserialize(space, buf)
H5S_t *space; IN/OUT: Dataspace pointer to place selection into
uint8 *buf; IN: Buffer to retrieve serialized selection from
RETURNS
@@ -210,22 +305,21 @@ H5S_all_select_serialize (const H5S_t *space, uint8_t *buf)
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_all_select_deserialize (H5S_t *space, const uint8_t UNUSED *buf)
+H5S_all_deserialize (H5S_t *space, const uint8_t UNUSED *buf)
{
herr_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_all_select_deserialize, FAIL);
+ FUNC_ENTER_NOAPI(H5S_all_deserialize, FAIL);
assert(space);
/* Change to "all" selection */
- if((ret_value=H5S_select_all(space))<0) {
+ if((ret_value=H5S_select_all(space,1))<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
- } /* end if */
done:
FUNC_LEAVE (ret_value);
-} /* H5S_all_select_deserialize() */
+} /* H5S_all_deserialize() */
/*--------------------------------------------------------------------------
@@ -254,7 +348,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_all_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
+H5S_all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
{
int rank; /* Dataspace rank */
int i; /* index variable */
@@ -281,12 +375,102 @@ H5S_all_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
/*--------------------------------------------------------------------------
NAME
+ H5S_all_is_contiguous
+ PURPOSE
+ Check if a "all" selection is contiguous within the dataspace extent.
+ USAGE
+ htri_t H5S_all_is_contiguous(space)
+ H5S_t *space; IN: Dataspace pointer to check
+ RETURNS
+ TRUE/FALSE/FAIL
+ DESCRIPTION
+ Checks to see if the current selection in the dataspace is contiguous.
+ This is primarily used for reading the entire selection in one swoop.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+htri_t
+H5S_all_is_contiguous(const H5S_t UNUSED *space)
+{
+ FUNC_ENTER_NOAPI(H5S_all_is_contiguous, FAIL);
+
+ assert(space);
+
+ FUNC_LEAVE (TRUE);
+} /* H5S_all_is_contiguous() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_all_is_single
+ PURPOSE
+ Check if a "all" selection is a single block within the dataspace extent.
+ USAGE
+ htri_t H5S_all_is_single(space)
+ H5S_t *space; IN: Dataspace pointer to check
+ RETURNS
+ TRUE/FALSE/FAIL
+ DESCRIPTION
+ Checks to see if the current selection in the dataspace is a single block.
+ This is primarily used for reading the entire selection in one swoop.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+htri_t
+H5S_all_is_single(const H5S_t UNUSED *space)
+{
+ FUNC_ENTER_NOAPI(H5S_all_is_single, FAIL);
+
+ assert(space);
+
+ FUNC_LEAVE (TRUE);
+} /* H5S_all_is_single() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_all_is_regular
+ PURPOSE
+ Check if a "all" selection is "regular"
+ USAGE
+ htri_t H5S_all_is_regular(space)
+ const H5S_t *space; IN: Dataspace pointer to check
+ RETURNS
+ TRUE/FALSE/FAIL
+ DESCRIPTION
+ Checks to see if the current selection in a dataspace is the a regular
+ pattern.
+ This is primarily used for reading the entire selection in one swoop.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+htri_t
+H5S_all_is_regular(const H5S_t UNUSED *space)
+{
+ FUNC_ENTER_NOAPI(H5S_all_is_regular, FAIL);
+
+ /* Check args */
+ assert(space);
+
+ FUNC_LEAVE (TRUE);
+} /* H5S_all_is_regular() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S_select_all
PURPOSE
Specify the the entire extent is selected
USAGE
herr_t H5S_select_all(dsid)
hid_t dsid; IN: Dataspace ID of selection to modify
+ unsigned rel_prev; IN: Flag whether to release previous selection or not
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -297,7 +481,7 @@ H5S_all_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_select_all (H5S_t *space)
+H5S_select_all (H5S_t *space, unsigned rel_prev)
{
herr_t ret_value=SUCCEED; /* return value */
@@ -307,13 +491,28 @@ H5S_select_all (H5S_t *space)
assert(space);
/* Remove current selection first */
- if(H5S_select_release(space)<0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection");
- } /* end if */
+ if(rel_prev)
+ if((*space->select.release)(space)<0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection");
/* Set selection type */
space->select.type=H5S_SEL_ALL;
+ /* Set selection methods */
+ space->select.get_seq_list=H5S_all_get_seq_list;
+ space->select.get_npoints=H5S_all_npoints;
+ space->select.release=H5S_all_release;
+ space->select.iter_init=H5S_all_iter_init;
+ space->select.iter_nelmts=H5S_all_iter_nelmts;
+ space->select.iter_release=H5S_all_iter_release;
+ space->select.is_valid=H5S_all_is_valid;
+ space->select.serial_size=H5S_all_serial_size;
+ space->select.serialize=H5S_all_serialize;
+ space->select.bounds=H5S_all_bounds;
+ space->select.is_contiguous=H5S_all_is_contiguous;
+ space->select.is_single=H5S_all_is_single;
+ space->select.is_regular=H5S_all_is_regular;
+
done:
FUNC_LEAVE (ret_value);
} /* H5S_select_all() */
@@ -344,14 +543,12 @@ herr_t H5Sselect_all (hid_t spaceid)
FUNC_ENTER_API(H5Sselect_all, FAIL);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- /* Remove current selection first */
- if((ret_value=H5S_select_all(space))<0) {
+ /* Call internal routine to do the work */
+ if((ret_value=H5S_select_all(space,1))<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
- } /* end if */
done:
FUNC_LEAVE (ret_value);
@@ -360,13 +557,13 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_all_select_get_seq_list
+ H5S_all_get_seq_list
PURPOSE
Create a list of offsets & lengths for a selection
USAGE
- herr_t H5S_all_select_get_seq_list(flags,space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len)
- unsigned flags; IN: Flags for extra information about operation
+ herr_t H5S_all_get_seq_list(space,flags,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len)
H5S_t *space; IN: Dataspace containing selection to use.
+ unsigned flags; IN: Flags for extra information about operation
H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
position of interest in selection.
size_t elem_size; IN: Size of an element
@@ -391,7 +588,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_all_select_get_seq_list(unsigned UNUSED flags, const H5S_t *space,H5S_sel_iter_t *iter,
+H5S_all_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t *iter,
size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
hsize_t *off, size_t *len)
{
@@ -399,7 +596,7 @@ H5S_all_select_get_seq_list(unsigned UNUSED flags, const H5S_t *space,H5S_sel_it
hsize_t elem_used; /* The number of bytes used */
herr_t ret_value=SUCCEED; /* return value */
- FUNC_ENTER_NOAPI (H5S_all_select_get_seq_list, FAIL);
+ FUNC_ENTER_NOAPI (H5S_all_get_seq_list, FAIL);
/* Check args */
assert(space);
@@ -437,4 +634,5 @@ H5S_all_select_get_seq_list(unsigned UNUSED flags, const H5S_t *space,H5S_sel_it
done:
#endif /* LATER */
FUNC_LEAVE (ret_value);
-} /* end H5S_all_select_get_seq_list() */
+} /* end H5S_all_get_seq_list() */
+
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 04cecf6..4be5952 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -86,7 +86,7 @@ H5S_hyper_print_spans(const struct H5S_hyper_span_info_t *span_lst)
/*-------------------------------------------------------------------------
- * Function: H5S_hyper_init
+ * Function: H5S_hyper_iter_init
*
* Purpose: Initializes iteration information for hyperslab span tree selection.
*
@@ -100,7 +100,7 @@ H5S_hyper_print_spans(const struct H5S_hyper_span_info_t *span_lst)
*-------------------------------------------------------------------------
*/
herr_t
-H5S_hyper_init (const H5S_t *space, size_t elmt_size, H5S_sel_iter_t *sel_iter)
+H5S_hyper_iter_init (const H5S_t *space, size_t elmt_size, H5S_sel_iter_t *sel_iter)
{
unsigned cont_dim; /* Maximum contiguous dimension */
const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
@@ -108,7 +108,7 @@ H5S_hyper_init (const H5S_t *space, size_t elmt_size, H5S_sel_iter_t *sel_iter)
unsigned u; /* Index variable */
int i; /* Index variable */
- FUNC_ENTER_NOAPI(H5S_hyper_init, FAIL);
+ FUNC_ENTER_NOAPI(H5S_hyper_iter_init, FAIL);
/* Check args */
assert(space && H5S_SEL_HYPERSLABS==space->select.type);
@@ -230,30 +230,56 @@ H5S_hyper_init (const H5S_t *space, size_t elmt_size, H5S_sel_iter_t *sel_iter)
} /* end else */
FUNC_LEAVE (SUCCEED);
-} /* H5S_hyper_init() */
+} /* H5S_hyper_iter_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5S_hyper_iter_nelmts
+ *
+ * Purpose: Return number of elements left to process in iterator
+ *
+ * Return: non-negative number of elements on success, zero on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hsize_t
+H5S_hyper_iter_nelmts (const H5S_sel_iter_t *sel_iter)
+{
+ FUNC_ENTER_NOAPI(H5S_hyper_iter_nelmts, 0);
+
+ /* Check args */
+ assert (sel_iter);
+
+ FUNC_LEAVE (sel_iter->hyp.elmt_left);
+} /* H5S_hyper_iter_nelmts() */
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_sel_iter_release
+ H5S_hyper_iter_release
PURPOSE
- Release "new" hyperslab selection iterator information for a dataspace
+ Release hyperslab selection iterator information for a dataspace
USAGE
- herr_t H5S_hyper_sel_iter_release(sel_iter)
+ herr_t H5S_hyper_iter_release(sel_iter)
H5S_sel_iter_t *sel_iter; IN: Pointer to selection iterator
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
- Releases all information for a dataspace "new" hyperslab selection iterator
+ Releases all information for a dataspace hyperslab selection iterator
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_hyper_sel_iter_release (H5S_sel_iter_t *sel_iter)
+H5S_hyper_iter_release (H5S_sel_iter_t *sel_iter)
{
- FUNC_ENTER_NOAPI(H5S_hyper_sel_iter_release, FAIL);
+ FUNC_ENTER_NOAPI(H5S_hyper_iter_release, FAIL);
/* Check args */
assert (sel_iter);
@@ -285,35 +311,7 @@ H5S_hyper_sel_iter_release (H5S_sel_iter_t *sel_iter)
H5FL_ARR_FREE(H5S_hyper_span_t,sel_iter->hyp.span);
FUNC_LEAVE (SUCCEED);
-} /* H5S_hyper_sel_iter_release() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5S_hyper_favail
- *
- * Purpose: Figure out the optimal number of elements to transfer to/from the file
- *
- * Return: non-negative number of elements on success, zero on failure
- *
- * Programmer: Quincey Koziol
- * Tuesday, June 16, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-hsize_t
-H5S_hyper_favail (const H5S_t * UNUSED space,
- const H5S_sel_iter_t *sel_iter, hsize_t max)
-{
- FUNC_ENTER_NOAPI(H5S_hyper_favail, 0);
-
- /* Check args */
- assert (space && H5S_SEL_HYPERSLABS==space->select.type);
- assert (sel_iter);
-
- FUNC_LEAVE (MIN(sel_iter->hyp.elmt_left,max));
-} /* H5S_hyper_favail() */
+} /* H5S_hyper_iter_release() */
/*-------------------------------------------------------------------------
@@ -1068,12 +1066,12 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_valid_helper
+ H5S_hyper_is_valid_helper
PURPOSE
Check whether the selection fits within the extent, with the current
offset defined.
USAGE
- htri_t H5S_hyper_select_valid_helper(spans, offset, rank);
+ htri_t H5S_hyper_is_valid_helper(spans, offset, rank);
const H5S_hyper_span_info_t *spans; IN: Pointer to current hyperslab span tree
const hssize_t *offset; IN: Pointer to offset array
const hsize_t *size; IN: Pointer to size array
@@ -1090,13 +1088,13 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static htri_t
-H5S_hyper_select_valid_helper (const H5S_hyper_span_info_t *spans, const hssize_t *offset, const hsize_t *size, hsize_t rank)
+H5S_hyper_is_valid_helper (const H5S_hyper_span_info_t *spans, const hssize_t *offset, const hsize_t *size, hsize_t rank)
{
H5S_hyper_span_t *curr; /* Hyperslab information nodes */
htri_t tmp; /* temporary return value */
htri_t ret_value=TRUE; /* return value */
- FUNC_ENTER_NOINIT(H5S_hyper_select_valid_helper);
+ FUNC_ENTER_NOINIT(H5S_hyper_is_valid_helper);
assert(spans);
assert(offset);
@@ -1118,7 +1116,7 @@ H5S_hyper_select_valid_helper (const H5S_hyper_span_info_t *spans, const hssize_
/* Recurse if this node has down spans */
if(curr->down!=NULL) {
- if((tmp=H5S_hyper_select_valid_helper(curr->down,offset,size,rank+1))!=TRUE) {
+ if((tmp=H5S_hyper_is_valid_helper(curr->down,offset,size,rank+1))!=TRUE) {
ret_value=tmp;
break;
} /* end if */
@@ -1129,17 +1127,17 @@ H5S_hyper_select_valid_helper (const H5S_hyper_span_info_t *spans, const hssize_
} /* end while */
FUNC_LEAVE (ret_value);
-} /* end H5S_hyper_select_valid_helper() */
+} /* end H5S_hyper_is_valid_helper() */
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_valid
+ H5S_hyper_is_valid
PURPOSE
Check whether the selection fits within the extent, with the current
offset defined.
USAGE
- htri_t H5S_hyper_select_valid(space);
+ htri_t H5S_hyper_is_valid(space);
H5S_t *space; IN: Dataspace pointer to query
RETURNS
TRUE if the selection fits within the extent, FALSE if it does not and
@@ -1153,12 +1151,12 @@ H5S_hyper_select_valid_helper (const H5S_hyper_span_info_t *spans, const hssize_
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
-H5S_hyper_select_valid (const H5S_t *space)
+H5S_hyper_is_valid (const H5S_t *space)
{
unsigned u; /* Counter */
htri_t ret_value=TRUE; /* return value */
- FUNC_ENTER_NOAPI(H5S_hyper_select_valid, FAIL);
+ FUNC_ENTER_NOAPI(H5S_hyper_is_valid, FAIL);
assert(space);
@@ -1192,11 +1190,11 @@ H5S_hyper_select_valid (const H5S_t *space)
} /* end if */
else {
/* Call the recursive routine to validate the span tree */
- ret_value=H5S_hyper_select_valid_helper(space->select.sel_info.hslab.span_lst,space->select.offset,space->extent.u.simple.size,(hsize_t)0);
+ ret_value=H5S_hyper_is_valid_helper(space->select.sel_info.hslab.span_lst,space->select.offset,space->extent.u.simple.size,(hsize_t)0);
} /* end else */
FUNC_LEAVE (ret_value);
-} /* end H5S_hyper_select_valid() */
+} /* end H5S_hyper_is_valid() */
/*--------------------------------------------------------------------------
@@ -1216,13 +1214,13 @@ H5S_hyper_select_valid (const H5S_t *space)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-hssize_t
+static hssize_t
H5S_hyper_span_nblocks (H5S_hyper_span_info_t *spans)
{
H5S_hyper_span_t *span; /* Hyperslab span */
hssize_t ret_value=FAIL;
- FUNC_ENTER_NOAPI(H5S_hyper_span_nblocks, FAIL);
+ FUNC_ENTER_NOINIT(H5S_hyper_span_nblocks);
/* Count the number of elements in the span tree */
if(spans==NULL)
@@ -1252,12 +1250,90 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_serial_size
+ H5S_get_select_hyper_nblocks
+ PURPOSE
+ Get the number of hyperslab blocks in current hyperslab selection
+ USAGE
+ hssize_t H5S_get_select_hyper_nblocks(space)
+ H5S_t *space; IN: Dataspace ptr of selection to query
+ RETURNS
+ The number of hyperslab blocks in selection on success, negative on failure
+ DESCRIPTION
+ Returns the number of hyperslab blocks in current selection for dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static hssize_t
+H5S_get_select_hyper_nblocks(H5S_t *space)
+{
+ hssize_t ret_value=FAIL; /* return value */
+ unsigned u; /* Counter */
+
+ FUNC_ENTER_NOINIT(H5S_get_select_hyper_nblocks);
+
+ assert(space);
+
+ /* Check for a "regular" hyperslab selection */
+ if(space->select.sel_info.hslab.diminfo != NULL) {
+ /* Check each dimension */
+ for(ret_value=1,u=0; u<space->extent.u.simple.rank; u++)
+ ret_value*=space->select.sel_info.hslab.app_diminfo[u].count;
+ } /* end if */
+ else
+ ret_value = H5S_hyper_span_nblocks(space->select.sel_info.hslab.span_lst);
+
+ FUNC_LEAVE (ret_value);
+} /* H5S_get_select_hyper_nblocks() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_select_hyper_nblocks
+ PURPOSE
+ Get the number of hyperslab blocks in current hyperslab selection
+ USAGE
+ hssize_t H5Sget_select_hyper_nblocks(dsid)
+ hid_t dsid; IN: Dataspace ID of selection to query
+ RETURNS
+ The number of hyperslab blocks in selection on success, negative on failure
+ DESCRIPTION
+ Returns the number of hyperslab blocks in current selection for dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hssize_t
+H5Sget_select_hyper_nblocks(hid_t spaceid)
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ hssize_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER_API(H5Sget_select_hyper_nblocks, FAIL);
+ H5TRACE1("Hs","i",spaceid);
+
+ /* Check args */
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ if(space->select.type!=H5S_SEL_HYPERSLABS)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
+
+ ret_value = H5S_get_select_hyper_nblocks(space);
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_hyper_nblocks() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_hyper_serial_size
PURPOSE
Determine the number of bytes needed to store the serialized hyperslab
selection information.
USAGE
- hssize_t H5S_hyper_select_serial_size(space)
+ hssize_t H5S_hyper_serial_size(space)
H5S_t *space; IN: Dataspace pointer to query
RETURNS
The number of bytes required on success, negative on an error.
@@ -1270,17 +1346,17 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hssize_t
-H5S_hyper_select_serial_size (const H5S_t *space)
+H5S_hyper_serial_size (const H5S_t *space)
{
unsigned u; /* Counter */
hssize_t block_count; /* block counter for regular hyperslabs */
hssize_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_hyper_select_serial_size, FAIL);
+ FUNC_ENTER_NOAPI(H5S_hyper_serial_size, FAIL);
assert(space);
- /* Basic number of bytes required to serialize point selection:
+ /* 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
*/
@@ -1300,16 +1376,16 @@ H5S_hyper_select_serial_size (const H5S_t *space)
} /* end else */
FUNC_LEAVE (ret_value);
-} /* end H5S_hyper_select_serial_size() */
+} /* end H5S_hyper_serial_size() */
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_serialize_helper
+ H5S_hyper_serialize_helper
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_hyper_select_serialize_helper(spans, start, end, rank, buf)
+ herr_t H5S_hyper_serialize_helper(spans, start, end, rank, 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
@@ -1326,13 +1402,13 @@ H5S_hyper_select_serial_size (const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_hyper_select_serialize_helper (const H5S_hyper_span_info_t *spans, hssize_t *start, hssize_t *end, hsize_t rank, uint8_t **buf)
+H5S_hyper_serialize_helper (const H5S_hyper_span_info_t *spans, hssize_t *start, hssize_t *end, hsize_t rank, uint8_t **buf)
{
H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */
hsize_t u; /* Index variable */
herr_t ret_value=SUCCEED; /* return value */
- FUNC_ENTER_NOINIT(H5S_hyper_select_serialize_helper);
+ FUNC_ENTER_NOINIT(H5S_hyper_serialize_helper);
/* Sanity checks */
assert(spans);
@@ -1351,7 +1427,7 @@ H5S_hyper_select_serialize_helper (const H5S_hyper_span_info_t *spans, hssize_t
end[rank]=curr->high;
/* Recurse down to the next dimension */
- if(H5S_hyper_select_serialize_helper(curr->down,start,end,rank+1,buf)<0)
+ if(H5S_hyper_serialize_helper(curr->down,start,end,rank+1,buf)<0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans");
} /* end if */
else {
@@ -1378,16 +1454,16 @@ H5S_hyper_select_serialize_helper (const H5S_hyper_span_info_t *spans, hssize_t
done:
FUNC_LEAVE (ret_value);
-} /* H5S_hyper_select_serialize_helper() */
+} /* H5S_hyper_serialize_helper() */
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_serialize
+ H5S_hyper_serialize
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_hyper_select_serialize(space, buf)
+ herr_t H5S_hyper_serialize(space, buf)
H5S_t *space; IN: Dataspace pointer of selection to serialize
uint8 *buf; OUT: Buffer to put serialized selection into
RETURNS
@@ -1401,7 +1477,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_hyper_select_serialize (const H5S_t *space, uint8_t *buf)
+H5S_hyper_serialize (const H5S_t *space, uint8_t *buf)
{
H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */
@@ -1419,7 +1495,7 @@ H5S_hyper_select_serialize (const H5S_t *space, uint8_t *buf)
int done; /* Whether we are done with the iteration */
herr_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_hyper_select_serialize, FAIL);
+ FUNC_ENTER_NOAPI(H5S_hyper_serialize, FAIL);
assert(space);
@@ -1530,7 +1606,7 @@ H5S_hyper_select_serialize (const H5S_t *space, uint8_t *buf)
len+=(size_t)(8*space->extent.u.simple.rank*block_count);
/* Encode each hyperslab in selection */
- H5S_hyper_select_serialize_helper(space->select.sel_info.hslab.span_lst,start,end,(hsize_t)0,&buf);
+ H5S_hyper_serialize_helper(space->select.sel_info.hslab.span_lst,start,end,(hsize_t)0,&buf);
} /* end else */
/* Encode length */
@@ -1540,16 +1616,16 @@ H5S_hyper_select_serialize (const H5S_t *space, uint8_t *buf)
ret_value=SUCCEED;
FUNC_LEAVE (ret_value);
-} /* H5S_hyper_select_serialize() */
+} /* H5S_hyper_serialize() */
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_deserialize
+ H5S_hyper_deserialize
PURPOSE
Deserialize the current selection from a user-provided buffer.
USAGE
- herr_t H5S_hyper_select_deserialize(space, buf)
+ herr_t H5S_hyper_deserialize(space, buf)
H5S_t *space; IN/OUT: Dataspace pointer to place selection into
uint8 *buf; IN: Buffer to retrieve serialized selection from
RETURNS
@@ -1563,7 +1639,7 @@ H5S_hyper_select_serialize (const H5S_t *space, uint8_t *buf)
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_hyper_select_deserialize (H5S_t *space, const uint8_t *buf)
+H5S_hyper_deserialize (H5S_t *space, const uint8_t *buf)
{
uint32_t rank; /* rank of points */
size_t num_elem=0; /* number of elements in selection */
@@ -1578,7 +1654,7 @@ H5S_hyper_select_deserialize (H5S_t *space, const uint8_t *buf)
unsigned i,j; /* local counting variables */
herr_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_hyper_select_deserialize, FAIL);
+ FUNC_ENTER_NOAPI(H5S_hyper_deserialize, FAIL);
/* Check args */
assert(space);
@@ -1632,7 +1708,7 @@ H5S_hyper_select_deserialize (H5S_t *space, const uint8_t *buf)
done:
FUNC_LEAVE (ret_value);
-} /* H5S_hyper_select_deserialize() */
+} /* H5S_hyper_deserialize() */
/*--------------------------------------------------------------------------
@@ -1668,7 +1744,7 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t
+static herr_t
H5S_hyper_span_blocklist(H5S_hyper_span_info_t *spans, hssize_t start[], hssize_t end[], hsize_t rank, hsize_t *startblock, hsize_t *numblocks, hsize_t **buf)
{
H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */
@@ -1741,6 +1817,205 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5S_get_select_hyper_blocklist
+ PURPOSE
+ Get the list of hyperslab blocks currently selected
+ USAGE
+ herr_t H5S_get_select_hyper_blocklist(space, startblock, numblocks, buf)
+ H5S_t *space; IN: Dataspace pointer of selection to query
+ hsize_t startblock; IN: Hyperslab block to start with
+ hsize_t numblocks; IN: Number of hyperslab blocks to get
+ hsize_t *buf; OUT: List of hyperslab blocks selected
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Puts a list of the hyperslab blocks into the user's buffer. The blocks
+ start with the 'startblock'th block in the list of blocks and put
+ 'numblocks' number of blocks into the user's buffer (or until the end of
+ the list of blocks, whichever happens first)
+ The block coordinates have the same dimensionality (rank) as the
+ dataspace they are located within. The list of blocks is formatted as
+ follows: <"start" coordinate> immediately followed by <"opposite" corner
+ coordinate>, followed by the next "start" and "opposite" coordinate, etc.
+ until all the block information requested has been put into the user's
+ buffer.
+ No guarantee of any order of the blocks is implied.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S_get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblocks, hsize_t *buf)
+{
+ H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
+ hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */
+ hssize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */
+ hssize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */
+ hssize_t end[H5O_LAYOUT_NDIMS]; /* Location of end of hyperslab */
+ hssize_t temp_off; /* Offset in a given dimension */
+ int i; /* Counter */
+ int fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ int temp_dim; /* Temporary rank holder */
+ int ndims; /* Rank of the dataspace */
+ int done; /* Whether we are done with the iteration */
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER_NOINIT(H5S_get_select_hyper_blocklist);
+
+ assert(space);
+ assert(buf);
+
+ /* Check for a "regular" hyperslab selection */
+ if(space->select.sel_info.hslab.diminfo != NULL) {
+ /* Set some convienence values */
+ ndims=space->extent.u.simple.rank;
+ fast_dim=ndims-1;
+ /*
+ * Use the "application dimension information" to pass back to the user
+ * the blocks they set, not the optimized, internal information.
+ */
+ diminfo=space->select.sel_info.hslab.app_diminfo;
+
+ /* Build the tables of count sizes as well as the initial offset */
+ for(i=0; i<ndims; i++) {
+ tmp_count[i]=diminfo[i].count;
+ offset[i]=diminfo[i].start;
+ } /* end for */
+
+ /* We're not done with the iteration */
+ done=0;
+
+ /* Go iterate over the hyperslabs */
+ while(done==0 && numblocks>0) {
+ /* Iterate over the blocks in the fastest dimension */
+ while(tmp_count[fast_dim]>0 && numblocks>0) {
+
+ /* Check if we should copy this block information */
+ if(startblock==0) {
+ /* Copy the starting location */
+ HDmemcpy(buf,offset,sizeof(hsize_t)*ndims);
+ buf+=ndims;
+
+ /* Compute the ending location */
+ HDmemcpy(buf,offset,sizeof(hsize_t)*ndims);
+ for(i=0; i<ndims; i++)
+ buf[i]+=(diminfo[i].block-1);
+ buf+=ndims;
+
+ /* Decrement the number of blocks to retrieve */
+ numblocks--;
+ } /* end if */
+ else
+ startblock--;
+
+ /* 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 && numblocks>0) {
+ /* Reset the block counts */
+ tmp_count[fast_dim]=diminfo[fast_dim].count;
+
+ /* Bubble up the decrement to the slower changing dimensions */
+ temp_dim=fast_dim-1;
+ while(temp_dim>=0 && done==0) {
+ /* Decrement the block count */
+ tmp_count[temp_dim]--;
+
+ /* 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=1;
+
+ /* 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 */
+
+ /* Re-compute offset array */
+ for(i=0; i<ndims; i++) {
+ temp_off=diminfo[i].start+diminfo[i].stride*(diminfo[i].count-tmp_count[i]);
+ offset[i]=temp_off;
+ } /* end for */
+ } /* end while */
+ } /* end if */
+ else
+ ret_value=H5S_hyper_span_blocklist(space->select.sel_info.hslab.span_lst,start,end,(hsize_t)0,&startblock,&numblocks,&buf);
+
+ FUNC_LEAVE (ret_value);
+} /* H5S_get_select_hyper_blocklist() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_select_hyper_blocklist
+ PURPOSE
+ Get the list of hyperslab blocks currently selected
+ USAGE
+ herr_t H5Sget_select_hyper_blocklist(dsid, startblock, numblocks, buf)
+ hid_t dsid; IN: Dataspace ID of selection to query
+ hsize_t startblock; IN: Hyperslab block to start with
+ hsize_t numblocks; IN: Number of hyperslab blocks to get
+ hsize_t *buf; OUT: List of hyperslab blocks selected
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Puts a list of the hyperslab blocks into the user's buffer. The blocks
+ start with the 'startblock'th block in the list of blocks and put
+ 'numblocks' number of blocks into the user's buffer (or until the end of
+ the list of blocks, whichever happen first)
+ The block coordinates have the same dimensionality (rank) as the
+ dataspace they are located within. The list of blocks is formatted as
+ follows: <"start" coordinate> immediately followed by <"opposite" corner
+ coordinate>, followed by the next "start" and "opposite" coordinate, etc.
+ until all the block information requested has been put into the user's
+ buffer.
+ No guarantee of any order of the blocks is implied.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, hsize_t *buf)
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ herr_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER_API(H5Sget_select_hyper_blocklist, FAIL);
+ H5TRACE4("e","ihh*h",spaceid,startblock,numblocks,buf);
+
+ /* Check args */
+ if(buf==NULL)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ if(space->select.type!=H5S_SEL_HYPERSLABS)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
+
+ /* Go get the correct number of blocks */
+ if(numblocks>0)
+ ret_value = H5S_get_select_hyper_blocklist(space,startblock,numblocks,buf);
+ else
+ ret_value=SUCCEED; /* Successfully got 0 blocks... */
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_hyper_blocklist() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S_hyper_bounds_helper
PURPOSE
Gets the bounding box containing the selection.
@@ -1833,9 +2108,11 @@ H5S_hyper_bounds_helper (const H5S_hyper_span_info_t *spans, const hssize_t *off
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_hyper_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
+H5S_hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
{
- herr_t ret_value=SUCCEED; /* return value */
+ int rank; /* Dataspace rank */
+ int i; /* index variable */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5S_hyper_bounds, FAIL);
@@ -1843,14 +2120,16 @@ H5S_hyper_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
assert(start);
assert(end);
+ /* Set the start and end arrays up */
+ rank=space->extent.u.simple.rank;
+ for(i=0; i<rank; i++) {
+ start[i]=UINT_MAX;
+ end[i]=0;
+ } /* end for */
+
/* Check for a "regular" hyperslab selection */
if(space->select.sel_info.hslab.diminfo!=NULL) {
const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab.diminfo; /* local alias for diminfo */
- int rank; /* Dataspace rank */
- int i; /* index variable */
-
- /* Get the dataspace extent rank */
- rank=space->extent.u.simple.rank;
/* Check each dimension */
for(i=0; i<rank; i++) {
@@ -1872,11 +2151,11 @@ H5S_hyper_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_contiguous
+ H5S_hyper_is_contiguous
PURPOSE
Check if a hyperslab selection is contiguous within the dataspace extent.
USAGE
- htri_t H5S_select_contiguous(space)
+ htri_t H5S_hyper_is_contiguous(space)
H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -1889,7 +2168,7 @@ H5S_hyper_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
-H5S_hyper_select_contiguous(const H5S_t *space)
+H5S_hyper_is_contiguous(const H5S_t *space)
{
H5S_hyper_span_info_t *spans; /* Hyperslab span info node */
H5S_hyper_span_t *span; /* Hyperslab span node */
@@ -1898,7 +2177,7 @@ H5S_hyper_select_contiguous(const H5S_t *space)
large_contiguous; /* Flag for large contiguous block */
htri_t ret_value=FALSE; /* return value */
- FUNC_ENTER_NOAPI(H5S_hyper_select_contiguous, FAIL);
+ FUNC_ENTER_NOAPI(H5S_hyper_is_contiguous, FAIL);
assert(space);
@@ -2049,16 +2328,16 @@ H5S_hyper_select_contiguous(const H5S_t *space)
} /* end else */
FUNC_LEAVE (ret_value);
-} /* H5S_hyper_select_contiguous() */
+} /* H5S_hyper_is_contiguous() */
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_single
+ H5S_hyper_is_single
PURPOSE
Check if a hyperslab selection is a single block within the dataspace extent.
USAGE
- htri_t H5S_select_single(space)
+ htri_t H5S_hyper_is_single(space)
H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -2071,14 +2350,14 @@ H5S_hyper_select_contiguous(const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
-H5S_hyper_select_single(const H5S_t *space)
+H5S_hyper_is_single(const H5S_t *space)
{
H5S_hyper_span_info_t *spans; /* Hyperslab span info node */
H5S_hyper_span_t *span; /* Hyperslab span node */
unsigned u; /* index variable */
htri_t ret_value=FALSE; /* return value */
- FUNC_ENTER_NOAPI(H5S_hyper_select_single, FAIL);
+ FUNC_ENTER_NOAPI(H5S_hyper_is_single, FAIL);
assert(space);
@@ -2127,16 +2406,16 @@ H5S_hyper_select_single(const H5S_t *space)
} /* end else */
FUNC_LEAVE (ret_value);
-} /* H5S_hyper_select_single() */
+} /* H5S_hyper_is_single() */
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_regular
+ H5S_hyper_is_regular
PURPOSE
Check if a hyperslab selection is "regular"
USAGE
- htri_t H5S_hyper_select_regular(space)
+ htri_t H5S_hyper_is_regular(space)
const H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -2151,11 +2430,11 @@ H5S_hyper_select_single(const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
-H5S_hyper_select_regular(const H5S_t *space)
+H5S_hyper_is_regular(const H5S_t *space)
{
htri_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_hyper_select_regular, FAIL);
+ FUNC_ENTER_NOAPI(H5S_hyper_is_regular, FAIL);
/* Check args */
assert(space);
@@ -2167,7 +2446,7 @@ H5S_hyper_select_regular(const H5S_t *space)
ret_value=FALSE;
FUNC_LEAVE (ret_value);
-} /* H5S_hyper_select_regular() */
+} /* H5S_hyper_is_regular() */
/*--------------------------------------------------------------------------
@@ -3778,7 +4057,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
} /* end for */
/* If we are setting a new selection, remove current selection first */
- if(H5S_select_release(space)<0)
+ if((*space->select.release)(space)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab");
/* Copy all the application per-dimension selection info into the space descriptor */
@@ -3845,6 +4124,21 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
/* Set selection type */
space->select.type=H5S_SEL_HYPERSLABS;
+ /* Set selection methods */
+ space->select.get_seq_list=H5S_hyper_get_seq_list;
+ space->select.get_npoints=H5S_hyper_npoints;
+ space->select.release=H5S_hyper_release;
+ space->select.iter_init=H5S_hyper_iter_init;
+ space->select.iter_nelmts=H5S_hyper_iter_nelmts;
+ space->select.iter_release=H5S_hyper_iter_release;
+ space->select.is_valid=H5S_hyper_is_valid;
+ space->select.serial_size=H5S_hyper_serial_size;
+ space->select.serialize=H5S_hyper_serialize;
+ space->select.bounds=H5S_hyper_bounds;
+ space->select.is_contiguous=H5S_hyper_is_contiguous;
+ space->select.is_single=H5S_hyper_is_single;
+ space->select.is_regular=H5S_hyper_is_regular;
+
ret_value=SUCCEED;
done:
@@ -3941,7 +4235,7 @@ H5S_operate_hyperslab (H5S_t *result, H5S_hyper_span_info_t *spans1, H5S_seloper
assert(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID);
/* Free the current selection for the result space */
- if(H5S_select_release(result)<0)
+ if((*result->select.release)(result)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release result selection");
/* Just copy the selection from spans2 if we are setting the selection */
@@ -4065,6 +4359,20 @@ H5S_operate_hyperslab (H5S_t *result, H5S_hyper_span_info_t *spans1, H5S_seloper
/* Set selection type */
result->select.type=H5S_SEL_HYPERSLABS;
+ /* Set selection methods */
+ space->select.get_seq_list=H5S_hyper_get_seq_list;
+ space->select.get_npoints=H5S_hyper_npoints;
+ space->select.release=H5S_hyper_release;
+ space->select.iter_init=H5S_hyper_iter_init;
+ space->select.iter_nelmts=H5S_hyper_iter_nelmts;
+ space->select.iter_release=H5S_hyper_iter_release;
+ space->select.is_valid=H5S_hyper_is_valid;
+ space->select.serial_size=H5S_hyper_serial_size;
+ space->select.serialize=H5S_hyper_serialize;
+ space->select.bounds=H5S_hyper_bounds;
+ space->select.is_contiguous=H5S_hyper_is_contiguous;
+ space->select.is_single=H5S_hyper_is_single;
+
/* Set the return value */
ret_value=SUCCEED;
@@ -4307,7 +4615,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
} /* end for */
/* If we are setting a new selection, remove current selection first */
- if(H5S_select_release(space)<0)
+ if((*space->select.release)(space)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab");
/* Copy all the application per-dimension selection info into the space descriptor */
@@ -4734,11 +5042,11 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_get_seq_list_gen
+ H5S_hyper_get_seq_list_gen
PURPOSE
Create a list of offsets & lengths for a selection
USAGE
- herr_t H5S_hyper_select_get_file_list_gen(space,iter,maxseq,nseq,off,len)
+ herr_t H5S_select_hyper_get_file_list_gen(space,iter,maxseq,nseq,off,len)
H5S_t *space; IN: Dataspace containing selection to use.
H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
position of interest in selection.
@@ -4764,7 +5072,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_hyper_select_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
+H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
hsize_t *off, size_t *len)
{
@@ -4786,7 +5094,7 @@ H5S_hyper_select_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
int i; /* Index variable */
herr_t ret_value=SUCCEED; /* return value */
- FUNC_ENTER_NOINIT (H5S_hyper_select_get_seq_list_gen);
+ FUNC_ENTER_NOINIT (H5S_hyper_get_seq_list_gen);
/* Check args */
assert(space);
@@ -5144,16 +5452,16 @@ partial_done: /* Yes, goto's are evil, so sue me... :-) */
done:
#endif /* LATER */
FUNC_LEAVE (ret_value);
-} /* end H5S_hyper_select_get_seq_list_gen() */
+} /* end H5S_hyper_get_seq_list_gen() */
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_get_seq_list_opt
+ H5S_hyper_get_seq_list_opt
PURPOSE
Create a list of offsets & lengths for a selection
USAGE
- herr_t H5S_hyper_select_get_file_list_opt(space,iter,maxseq,nseq,off,len)
+ herr_t H5S_select_hyper_get_file_list_opt(space,iter,maxseq,nseq,off,len)
H5S_t *space; IN: Dataspace containing selection to use.
H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
position of interest in selection.
@@ -5179,7 +5487,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_hyper_select_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
+H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
size_t elmt_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
hsize_t *off, size_t *len)
{
@@ -5219,7 +5527,7 @@ H5S_hyper_select_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
#endif /* NO_DUFFS_DEVICE */
herr_t ret_value=SUCCEED; /* return value */
- FUNC_ENTER_NOINIT (H5S_hyper_select_get_seq_list_opt);
+ FUNC_ENTER_NOINIT (H5S_hyper_get_seq_list_opt);
/* Check args */
assert(space);
@@ -5707,18 +6015,18 @@ H5S_hyper_select_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
done:
#endif /* LATER */
FUNC_LEAVE (ret_value);
-} /* end H5S_hyper_select_get_seq_list_opt() */
+} /* end H5S_hyper_get_seq_list_opt() */
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_select_get_seq_list
+ H5S_hyper_get_seq_list
PURPOSE
Create a list of offsets & lengths for a selection
USAGE
- herr_t H5S_hyper_select_get_seq_list(flags,space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len)
- unsigned flags; IN: Flags for extra information about operation
+ herr_t H5S_hyper_get_seq_list(space,flags,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len)
H5S_t *space; IN: Dataspace containing selection to use.
+ unsigned flags; IN: Flags for extra information about operation
H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
position of interest in selection.
size_t elem_size; IN: Size of an element
@@ -5743,13 +6051,13 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_hyper_select_get_seq_list(unsigned UNUSED flags, const H5S_t *space,H5S_sel_iter_t *iter,
+H5S_hyper_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t *iter,
size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
hsize_t *off, size_t *len)
{
herr_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI (H5S_hyper_select_get_seq_list, FAIL);
+ FUNC_ENTER_NOAPI (H5S_hyper_get_seq_list, FAIL);
/* Check args */
assert(space);
@@ -5765,14 +6073,14 @@ H5S_hyper_select_get_seq_list(unsigned UNUSED flags, const H5S_t *space,H5S_sel_
/* Check for the special case of just one H5Sselect_hyperslab call made */
if(space->select.sel_info.hslab.diminfo!=NULL)
/* Use optimized call to generate sequence list */
- ret_value=H5S_hyper_select_get_seq_list_opt(space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len);
+ ret_value=H5S_hyper_get_seq_list_opt(space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len);
else
/* Call the general sequence generator routine */
- ret_value=H5S_hyper_select_get_seq_list_gen(space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len);
+ ret_value=H5S_hyper_get_seq_list_gen(space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len);
#ifdef LATER
done:
#endif /* LATER */
FUNC_LEAVE (ret_value);
-} /* end H5S_hyper_select_get_seq_list() */
+} /* end H5S_hyper_get_seq_list() */
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index 5aaedaf..ab91b21 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -544,7 +544,7 @@ H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, hbool_t prefer
assert (space);
/* Get the number of elements in the selection */
- nelem=H5S_get_select_npoints(space);
+ nelem=(*space->select.get_npoints)(space);
/* Compute the number of bytes in selection */
total_bytes = (hsize_t)elmt_size*nelem;
@@ -664,7 +664,7 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derive
break;
case H5S_SEL_HYPERSLABS:
- if(H5S_select_contiguous(space)) {
+ if((*space->select.is_contiguous)(space)) {
err = H5S_mpio_hyper_contig_type( space, elmt_size, prefer_derived_types,
/* out: */ new_type, count, extra_offset, use_view, is_derived_type );
} /* end if */
@@ -967,8 +967,8 @@ H5S_mpio_opt_possible( const H5S_t *mem_space, const H5S_t *file_space, const un
HGOTO_DONE(FALSE);
/* Check whether both selections are "regular" */
- c1=H5S_select_regular(file_space);
- c2=H5S_select_regular(mem_space);
+ c1=(*file_space->select.is_regular)(file_space);
+ c2=(*mem_space->select.is_regular)(mem_space);
if(c1==FAIL || c2==FAIL)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "invalid check for single selection blocks");
if(c1==FALSE || c2==FALSE)
diff --git a/src/H5Snone.c b/src/H5Snone.c
index 11ad5f5..eee07bd 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -23,13 +23,225 @@
static int interface_initialize_g = 0;
+/*-------------------------------------------------------------------------
+ * Function: H5S_none_iter_init
+ *
+ * Purpose: Initializes iteration information for "none" selection.
+ *
+ * Return: non-negative on success, negative on failure.
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5S_none_iter_init (const H5S_t UNUSED *space, size_t UNUSED elmt_size, H5S_sel_iter_t UNUSED *sel_iter)
+{
+ FUNC_ENTER_NOAPI(H5S_none_iter_init, FAIL);
+
+ /* Check args */
+ assert (space && H5S_SEL_NONE==space->select.type);
+ assert (sel_iter);
+
+ FUNC_LEAVE (SUCCEED);
+} /* H5S_none_iter_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5S_none_iter_nelmts
+ *
+ * Purpose: Return number of elements left to process in iterator
+ *
+ * Return: non-negative number of elements on success, zero on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hsize_t
+H5S_none_iter_nelmts (const H5S_sel_iter_t UNUSED *sel_iter)
+{
+ FUNC_ENTER_NOAPI(H5S_none_iter_nelmts, 0);
+
+ /* Check args */
+ assert (sel_iter);
+
+ FUNC_LEAVE (0);
+} /* H5S_none_iter_nelmts() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_none_iter_release
+ PURPOSE
+ Release "none" selection iterator information for a dataspace
+ USAGE
+ herr_t H5S_none_iter_release(sel_iter)
+ H5S_sel_iter_t *sel_iter; IN: Pointer to selection iterator
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Releases all information for a dataspace "none" selection iterator
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_none_iter_release (H5S_sel_iter_t * UNUSED sel_iter)
+{
+ FUNC_ENTER_NOAPI(H5S_none_iter_release, FAIL);
+
+ /* Check args */
+ assert (sel_iter);
+
+ FUNC_LEAVE (SUCCEED);
+} /* H5S_none_iter_release() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_none_release
+ PURPOSE
+ Release none selection information for a dataspace
+ USAGE
+ herr_t H5S_none_release(space)
+ H5S_t *space; IN: Pointer to dataspace
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Releases "none" selection information for a dataspace
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_none_release (H5S_t * UNUSED space)
+{
+ FUNC_ENTER_NOAPI(H5S_none_release, FAIL);
+
+ /* Check args */
+ assert (space);
+
+ FUNC_LEAVE (SUCCEED);
+} /* H5S_none_release() */
+
+
/*--------------------------------------------------------------------------
NAME
- H5S_none_select_serialize
+ H5S_none_npoints
+ PURPOSE
+ Compute number of elements in current selection
+ USAGE
+ hsize_t H5S_none_npoints(space)
+ H5S_t *space; IN: Pointer to dataspace
+ RETURNS
+ The number of elements in selection on success, 0 on failure
+ DESCRIPTION
+ Compute number of elements in current selection. For "none" selections,
+ this is always 0.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hsize_t
+H5S_none_npoints (const H5S_t *space)
+{
+ hsize_t ret_value=0;
+
+ FUNC_ENTER_NOAPI(H5S_none_npoints, 0);
+
+ /* Check args */
+ assert (space);
+
+ FUNC_LEAVE (ret_value);
+} /* H5S_none_npoints() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_none_is_valid
+ PURPOSE
+ Check whether the selection fits within the extent, with the current
+ offset defined.
+ USAGE
+ htri_t H5S_none_is_valid(space);
+ H5S_t *space; IN: Dataspace pointer to query
+ RETURNS
+ TRUE if the selection fits within the extent, FALSE if it does not and
+ Negative on an error.
+ DESCRIPTION
+ Determines if the current selection at the current offet fits within the
+ extent for the dataspace. Offset is irrelevant for this type of selection.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+htri_t
+H5S_none_is_valid (const H5S_t UNUSED *space)
+{
+ FUNC_ENTER_NOAPI(H5S_none_is_valid, FAIL);
+
+ assert(space);
+
+ FUNC_LEAVE (TRUE);
+} /* end H5S_none_is_valid() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_none_serial_size
+ PURPOSE
+ Determine the number of bytes needed to store the serialized "none"
+ selection information.
+ USAGE
+ hssize_t H5S_none_serial_size(space)
+ H5S_t *space; IN: Dataspace pointer to query
+ RETURNS
+ The number of bytes required on success, negative on an error.
+ DESCRIPTION
+ Determines the number of bytes required to serialize an "none"
+ selection for storage on disk.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hssize_t
+H5S_none_serial_size (const H5S_t *space)
+{
+ hssize_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER_NOAPI(H5S_none_serial_size, FAIL);
+
+ assert(space);
+
+ /* Basic number of bytes required to serialize point selection:
+ * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> +
+ * <length (4 bytes)> = 16 bytes
+ */
+ ret_value=16;
+
+ FUNC_LEAVE (ret_value);
+} /* end H5S_none_serial_size() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_none_serialize
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_none_select_serialize(space, buf)
+ herr_t H5S_none_serialize(space, buf)
H5S_t *space; IN: Dataspace pointer of selection to serialize
uint8 *buf; OUT: Buffer to put serialized selection into
RETURNS
@@ -43,11 +255,11 @@ static int interface_initialize_g = 0;
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_none_select_serialize (const H5S_t *space, uint8_t *buf)
+H5S_none_serialize (const H5S_t *space, uint8_t *buf)
{
herr_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_none_select_serialize, FAIL);
+ FUNC_ENTER_NOAPI(H5S_none_serialize, FAIL);
assert(space);
@@ -61,15 +273,15 @@ H5S_none_select_serialize (const H5S_t *space, uint8_t *buf)
ret_value=SUCCEED;
FUNC_LEAVE (ret_value);
-} /* H5S_none_select_serialize() */
+} /* H5S_none_serialize() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_select_deserialize
+ H5S_none_deserialize
PURPOSE
Deserialize the current selection from a user-provided buffer.
USAGE
- herr_t H5S_none_select_deserialize(space, buf)
+ herr_t H5S_none_deserialize(space, buf)
H5S_t *space; IN/OUT: Dataspace pointer to place selection into
uint8 *buf; IN: Buffer to retrieve serialized selection from
RETURNS
@@ -83,22 +295,148 @@ H5S_none_select_serialize (const H5S_t *space, uint8_t *buf)
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_none_select_deserialize (H5S_t *space, const uint8_t UNUSED *buf)
+H5S_none_deserialize (H5S_t *space, const uint8_t UNUSED *buf)
{
herr_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_none_select_deserialize, FAIL);
+ FUNC_ENTER_NOAPI(H5S_none_deserialize, FAIL);
assert(space);
/* Change to "none" selection */
- if((ret_value=H5S_select_none(space))<0) {
+ if((ret_value=H5S_select_none(space))<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
- } /* end if */
done:
FUNC_LEAVE (ret_value);
-} /* H5S_none_select_deserialize() */
+} /* H5S_none_deserialize() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_none_bounds
+ PURPOSE
+ Gets the bounding box containing the selection.
+ USAGE
+ herr_t H5S_none_bounds(space, hsize_t *start, hsize_t *end)
+ H5S_t *space; IN: Dataspace pointer of selection to query
+ hsize_t *start; OUT: Starting coordinate of bounding box
+ hsize_t *end; OUT: Opposite coordinate of bounding box
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Retrieves the bounding box containing the current selection and places
+ it into the user's buffers. The start and end buffers must be large
+ enough to hold the dataspace rank number of coordinates. The bounding box
+ exactly contains the selection, ie. if a 2-D element selection is currently
+ defined with the following points: (4,5), (6,8) (10,7), the bounding box
+ with be (4, 5), (10, 8). Calling this function on a "none" selection
+ returns fail.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_none_bounds(const H5S_t UNUSED *space, hsize_t UNUSED *start, hsize_t UNUSED *end)
+{
+ FUNC_ENTER_NOAPI(H5S_none_bounds, FAIL);
+
+ assert(space);
+ assert(start);
+ assert(end);
+
+ FUNC_LEAVE (FAIL);
+} /* H5Sget_none_bounds() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_none_is_contiguous
+ PURPOSE
+ Check if a "none" selection is contiguous within the dataspace extent.
+ USAGE
+ htri_t H5S_all_is_contiguous(space)
+ H5S_t *space; IN: Dataspace pointer to check
+ RETURNS
+ TRUE/FALSE/FAIL
+ DESCRIPTION
+ Checks to see if the current selection in the dataspace is contiguous.
+ This is primarily used for reading the entire selection in one swoop.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+htri_t
+H5S_none_is_contiguous(const H5S_t UNUSED *space)
+{
+ FUNC_ENTER_NOAPI(H5S_none_is_contiguous, FAIL);
+
+ assert(space);
+
+ FUNC_LEAVE (FALSE);
+} /* H5S_none_is_contiguous() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_none_is_single
+ PURPOSE
+ Check if a "none" selection is a single block within the dataspace extent.
+ USAGE
+ htri_t H5S_none_is_single(space)
+ H5S_t *space; IN: Dataspace pointer to check
+ RETURNS
+ TRUE/FALSE/FAIL
+ DESCRIPTION
+ Checks to see if the current selection in the dataspace is a single block.
+ This is primarily used for reading the entire selection in one swoop.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+htri_t
+H5S_none_is_single(const H5S_t UNUSED *space)
+{
+ FUNC_ENTER_NOAPI(H5S_none_is_single, FAIL);
+
+ assert(space);
+
+ FUNC_LEAVE (FALSE);
+} /* H5S_none_is_single() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_none_is_regular
+ PURPOSE
+ Check if a "none" selection is "regular"
+ USAGE
+ htri_t H5S_none_is_regular(space)
+ const H5S_t *space; IN: Dataspace pointer to check
+ RETURNS
+ TRUE/FALSE/FAIL
+ DESCRIPTION
+ Checks to see if the current selection in a dataspace is the a regular
+ pattern.
+ This is primarily used for reading the entire selection in one swoop.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+htri_t
+H5S_none_is_regular(const H5S_t UNUSED *space)
+{
+ FUNC_ENTER_NOAPI(H5S_none_is_regular, FAIL);
+
+ /* Check args */
+ assert(space);
+
+ FUNC_LEAVE (TRUE);
+} /* H5S_none_is_regular() */
/*--------------------------------------------------------------------------
@@ -128,14 +466,27 @@ herr_t H5S_select_none (H5S_t *space)
assert(space);
/* Remove current selection first */
- if(H5S_select_release(space)<0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL,
- "can't release hyperslab");
- } /* end if */
+ if((*space->select.release)(space)<0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab");
/* Set selection type */
space->select.type=H5S_SEL_NONE;
+ /* Set selection methods */
+ space->select.get_seq_list=H5S_none_get_seq_list;
+ space->select.get_npoints=H5S_none_npoints;
+ space->select.release=H5S_none_release;
+ space->select.iter_init=H5S_none_iter_init;
+ space->select.iter_nelmts=H5S_none_iter_nelmts;
+ space->select.iter_release=H5S_none_iter_release;
+ space->select.is_valid=H5S_none_is_valid;
+ space->select.serial_size=H5S_none_serial_size;
+ space->select.serialize=H5S_none_serialize;
+ space->select.bounds=H5S_none_bounds;
+ space->select.is_contiguous=H5S_none_is_contiguous;
+ space->select.is_single=H5S_none_is_single;
+ space->select.is_regular=H5S_none_is_regular;
+
done:
FUNC_LEAVE (ret_value);
} /* H5S_select_none() */
@@ -166,57 +517,74 @@ herr_t H5Sselect_none (hid_t spaceid)
FUNC_ENTER_API(H5Sselect_none, FAIL);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(spaceid) ||
- NULL == (space=H5I_object(spaceid))) {
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
/* Change to "none" selection */
- if((ret_value=H5S_select_none(space))<0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
- } /* end if */
+ if((ret_value=H5S_select_none(space))<0)
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
-done:
FUNC_LEAVE (ret_value);
} /* H5Sselect_none() */
/*--------------------------------------------------------------------------
NAME
- H5S_none_select_iterate
+ H5S_none_get_seq_list
PURPOSE
- Iterate over a none selection, calling a user's function for each
- element. (i.e. the user's function is not called because there are
- zero elements selected)
+ Create a list of offsets & lengths for a selection
USAGE
- herr_t H5S_none_select_iterate(buf, type_id, space, op, operator_data)
- void *buf; IN/OUT: Buffer containing elements to iterate over
- hid_t type_id; IN: Datatype ID of BUF array.
- H5S_t *space; IN: Dataspace object containing selection to iterate over
- H5D_operator_t op; IN: Function pointer to the routine to be
- called for each element in BUF iterated over.
- void *operator_data; IN/OUT: Pointer to any user-defined data
- associated with the operation.
+ herr_t H5S_all_get_seq_list(space,flags,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len)
+ H5S_t *space; IN: Dataspace containing selection to use.
+ unsigned flags; IN: Flags for extra information about operation
+ H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
+ position of interest in selection.
+ size_t elem_size; IN: Size of an element
+ size_t maxseq; IN: Maximum number of sequences to generate
+ size_t maxbytes; IN: Maximum number of bytes to include in the
+ generated sequences
+ size_t *nseq; OUT: Actual number of sequences generated
+ size_t *nbytes; OUT: Actual number of bytes in sequences generated
+ hsize_t *off; OUT: Array of offsets
+ size_t *len; OUT: Array of lengths
RETURNS
- Returns success (0).
+ Non-negative on success/Negative on failure.
DESCRIPTION
+ Use the selection in the dataspace to generate a list of byte offsets and
+ lengths for the region(s) selected. Start/Restart from the position in the
+ ITER parameter. The number of sequences generated is limited by the MAXSEQ
+ parameter and the number of sequences actually generated is stored in the
+ NSEQ parameter.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_none_select_iterate(void * UNUSED buf, hid_t UNUSED type_id, H5S_t * UNUSED space, H5D_operator_t UNUSED op,
- void UNUSED *operator_data)
+H5S_none_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t *iter,
+ size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
+ hsize_t *off, size_t *len)
{
- herr_t ret_value=SUCCEED; /* return value */
+ herr_t ret_value=SUCCEED; /* return value */
- FUNC_ENTER_NOAPI(H5S_none_select_iterate, FAIL);
+ FUNC_ENTER_NOAPI (H5S_none_get_seq_list, FAIL);
- assert(buf);
+ /* Check args */
assert(space);
- assert(op);
- assert(H5I_DATATYPE == H5I_get_type(type_id));
+ assert(iter);
+ assert(elem_size>0);
+ assert(maxseq>0);
+ assert(maxbytes>0);
+ assert(nseq);
+ assert(nbytes);
+ assert(off);
+ assert(len);
+
+ /* "none" selection don't generate sequences of bytes */
+ *nseq=0;
+
+ /* The don't use any bytes, either */
+ *nbytes=0;
FUNC_LEAVE (ret_value);
-} /* H5S_hyper_select_iterate() */
+} /* end H5S_all_get_seq_list() */
diff --git a/src/H5Spkg.h b/src/H5Spkg.h
index d31d894..288fffe 100644
--- a/src/H5Spkg.h
+++ b/src/H5Spkg.h
@@ -96,7 +96,37 @@ typedef struct {
H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information */
} H5S_hyper_sel_t;
-/* Selection information container */
+/* Selection information methods */
+/* Method to retrieve a list of offset/length sequences for selection */
+typedef herr_t (*H5S_sel_get_seq_list_func_t)(const H5S_t *space, unsigned flags,
+ H5S_sel_iter_t *iter, size_t elem_size, size_t maxseq, size_t maxbytes,
+ size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
+/* Method to compute number of elements in current selection */
+typedef hsize_t (*H5S_sel_get_npoints_func_t)(const H5S_t *space);
+/* Method to release current selection */
+typedef herr_t (*H5S_sel_release_func_t)(H5S_t *space);
+/* Method to initialize iterator for current selection */
+typedef herr_t (*H5S_sel_iter_init_func_t)(const H5S_t *space, size_t elmt_size, H5S_sel_iter_t *sel_iter);
+/* Method to determine number of elements left in iterator for current selection */
+typedef hsize_t (*H5S_sel_iter_nelmts_func_t)(const H5S_sel_iter_t *iter);
+/* Method to release iterator for current selection */
+typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter);
+/* Method to determine if current selection is valid for dataspace */
+typedef htri_t (*H5S_sel_is_valid_func_t)(const H5S_t *space);
+/* Method to determine number of bytes required to store current selection */
+typedef hssize_t (*H5S_sel_serial_size_func_t)(const H5S_t *space);
+/* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */
+typedef herr_t (*H5S_sel_serialize_func_t)(const H5S_t *space, uint8_t *buf);
+/* Method to determine to smallest n-D bounding box containing the current selection */
+typedef herr_t (*H5S_sel_bounds_func_t)(const H5S_t *space, hsize_t *start, hsize_t *end);
+/* Method to determine if current selection is contiguous */
+typedef htri_t (*H5S_sel_is_contiguous_func_t)(const H5S_t *space);
+/* Method to determine if current selection is a single block */
+typedef htri_t (*H5S_sel_is_single_func_t)(const H5S_t *space);
+/* Method to determine if current selection is "regular" */
+typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space);
+
+/* Selection information object */
typedef struct {
H5S_sel_type type; /* Type of selection (list of points or hyperslabs) */
hssize_t *offset; /* Offset within the extent (NULL means a 0 offset) */
@@ -106,6 +136,19 @@ typedef struct {
H5S_pnt_list_t *pnt_lst; /* List of selected points (order is important) */
H5S_hyper_sel_t hslab; /* Info about new-style hyperslab selections */
} sel_info;
+ H5S_sel_get_seq_list_func_t get_seq_list; /* Method to retrieve a list of offset/length sequences for selection */
+ H5S_sel_get_npoints_func_t get_npoints; /* Method to compute number of elements in current selection */
+ H5S_sel_release_func_t release; /* Method to release current selection */
+ H5S_sel_iter_init_func_t iter_init; /* Method to initialize iterator for current selection */
+ H5S_sel_iter_nelmts_func_t iter_nelmts; /* Method to determine number of elements left in iterator for current selection */
+ H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */
+ H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */
+ H5S_sel_serial_size_func_t serial_size; /* Method to determine number of bytes required to store current selection */
+ H5S_sel_serialize_func_t serialize; /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */
+ H5S_sel_bounds_func_t bounds; /* Method to determine to smallest n-D bounding box containing the current selection */
+ H5S_sel_is_contiguous_func_t is_contiguous; /* Method to determine if current selection is contiguous */
+ H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */
+ H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */
} H5S_select_t;
/* Main dataspace structure (typedef'd in H5Sprivate.h) */
@@ -114,76 +157,89 @@ struct H5S_t {
H5S_select_t select; /* Dataspace selection */
};
+/* Extent functions */
__DLL__ herr_t H5S_close_simple(H5S_simple_t *simple);
__DLL__ herr_t H5S_release_simple(H5S_simple_t *simple);
__DLL__ herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src);
/* Point select functions */
-__DLL__ herr_t H5S_point_init (const H5S_t *space, size_t elmt_size,
+__DLL__ herr_t H5S_point_iter_init (const H5S_t *space, size_t elmt_size,
H5S_sel_iter_t *iter);
-__DLL__ hsize_t H5S_point_favail (const H5S_t *space, const H5S_sel_iter_t *iter,
- hsize_t max);
-__DLL__ herr_t H5S_point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem,
- const hssize_t **coord);
+__DLL__ hsize_t H5S_point_iter_nelmts (const H5S_sel_iter_t *iter);
+__DLL__ herr_t H5S_point_iter_release(H5S_sel_iter_t *sel_iter);
__DLL__ herr_t H5S_point_release(H5S_t *space);
__DLL__ hsize_t H5S_point_npoints(const H5S_t *space);
__DLL__ herr_t H5S_point_copy(H5S_t *dst, const H5S_t *src);
-__DLL__ htri_t H5S_point_select_valid(const H5S_t *space);
-__DLL__ hssize_t H5S_point_select_serial_size(const H5S_t *space);
-__DLL__ herr_t H5S_point_select_serialize(const H5S_t *space, uint8_t *buf);
-__DLL__ herr_t H5S_point_select_deserialize(H5S_t *space, const uint8_t *buf);
-__DLL__ herr_t H5S_point_bounds(H5S_t *space, hsize_t *start, hsize_t *end);
-__DLL__ htri_t H5S_point_select_contiguous(const H5S_t *space);
-__DLL__ htri_t H5S_point_select_single(const H5S_t *space);
-__DLL__ htri_t H5S_point_select_regular(const H5S_t *space);
-__DLL__ herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op,
- size_t num_elem, const hssize_t **coord);
-__DLL__ herr_t H5S_point_select_get_seq_list(unsigned flags, const H5S_t *space,H5S_sel_iter_t *iter,
- size_t elem_size, size_t maxseq, size_t maxbytes,
+__DLL__ htri_t H5S_point_is_valid(const H5S_t *space);
+__DLL__ hssize_t H5S_point_serial_size(const H5S_t *space);
+__DLL__ herr_t H5S_point_serialize(const H5S_t *space, uint8_t *buf);
+__DLL__ herr_t H5S_point_deserialize(H5S_t *space, const uint8_t *buf);
+__DLL__ herr_t H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
+__DLL__ htri_t H5S_point_is_contiguous(const H5S_t *space);
+__DLL__ htri_t H5S_point_is_single(const H5S_t *space);
+__DLL__ htri_t H5S_point_is_regular(const H5S_t *space);
+__DLL__ herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags,
+ H5S_sel_iter_t *iter, size_t elem_size, size_t maxseq, size_t maxbytes,
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
/* "All" select functions */
-__DLL__ herr_t H5S_all_init (const H5S_t *space, size_t elmt_size,
+__DLL__ herr_t H5S_all_iter_init (const H5S_t *space, size_t elmt_size,
H5S_sel_iter_t *iter);
-__DLL__ hsize_t H5S_all_favail (const H5S_t *space, const H5S_sel_iter_t *iter,
- hsize_t max);
+__DLL__ hsize_t H5S_all_iter_nelmts (const H5S_sel_iter_t *iter);
+__DLL__ herr_t H5S_all_iter_release(H5S_sel_iter_t *sel_iter);
__DLL__ herr_t H5S_all_release(H5S_t *space);
__DLL__ hsize_t H5S_all_npoints(const H5S_t *space);
-__DLL__ herr_t H5S_all_select_serialize(const H5S_t *space, uint8_t *buf);
-__DLL__ herr_t H5S_all_select_deserialize(H5S_t *space, const uint8_t *buf);
-__DLL__ herr_t H5S_all_bounds(H5S_t *space, hsize_t *start, hsize_t *end);
-__DLL__ herr_t H5S_all_select_get_seq_list(unsigned flags, const H5S_t *space,H5S_sel_iter_t *iter,
- size_t elem_size, size_t maxseq, size_t maxbytes,
+__DLL__ htri_t H5S_all_is_valid(const H5S_t *space);
+__DLL__ hssize_t H5S_all_serial_size(const H5S_t *space);
+__DLL__ herr_t H5S_all_serialize(const H5S_t *space, uint8_t *buf);
+__DLL__ herr_t H5S_all_deserialize(H5S_t *space, const uint8_t *buf);
+__DLL__ herr_t H5S_all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
+__DLL__ htri_t H5S_all_is_contiguous(const H5S_t *space);
+__DLL__ htri_t H5S_all_is_single(const H5S_t *space);
+__DLL__ htri_t H5S_all_is_regular(const H5S_t *space);
+__DLL__ herr_t H5S_all_get_seq_list(const H5S_t *space, unsigned flags,
+ H5S_sel_iter_t *iter, size_t elem_size, size_t maxseq, size_t maxbytes,
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
/* Hyperslab selection functions */
-__DLL__ herr_t H5S_hyper_init (const H5S_t *space, size_t elmt_size,
+__DLL__ herr_t H5S_hyper_iter_init (const H5S_t *space, size_t elmt_size,
H5S_sel_iter_t *iter);
-__DLL__ hsize_t H5S_hyper_favail (const H5S_t *space, const H5S_sel_iter_t *iter,
- hsize_t max);
+__DLL__ hsize_t H5S_hyper_iter_nelmts (const H5S_sel_iter_t *iter);
+__DLL__ herr_t H5S_hyper_iter_release(H5S_sel_iter_t *sel_iter);
__DLL__ herr_t H5S_hyper_release(H5S_t *space);
-__DLL__ herr_t H5S_hyper_sel_iter_release(H5S_sel_iter_t *sel_iter);
__DLL__ hsize_t H5S_hyper_npoints(const H5S_t *space);
__DLL__ herr_t H5S_hyper_copy(H5S_t *dst, const H5S_t *src);
-__DLL__ htri_t H5S_hyper_select_valid(const H5S_t *space);
-__DLL__ hssize_t H5S_hyper_select_serial_size(const H5S_t *space);
-__DLL__ herr_t H5S_hyper_select_serialize(const H5S_t *space, uint8_t *buf);
-__DLL__ herr_t H5S_hyper_select_deserialize(H5S_t *space, const uint8_t *buf);
-__DLL__ hssize_t H5S_hyper_span_nblocks(H5S_hyper_span_info_t *spans);
-__DLL__ herr_t H5S_hyper_span_blocklist(H5S_hyper_span_info_t *spans, hssize_t start[], hssize_t end[], hsize_t rank, hsize_t *startblock, hsize_t *numblocks, hsize_t **buf);
-__DLL__ herr_t H5S_hyper_bounds(H5S_t *space, hsize_t *start, hsize_t *end);
-__DLL__ htri_t H5S_hyper_select_contiguous(const H5S_t *space);
-__DLL__ htri_t H5S_hyper_select_single(const H5S_t *space);
-__DLL__ htri_t H5S_hyper_select_regular(const H5S_t *space);
-__DLL__ herr_t H5S_hyper_select_get_seq_list(unsigned flags, const H5S_t *space,H5S_sel_iter_t *iter,
- size_t elem_size, size_t maxseq, size_t maxbytes,
+__DLL__ htri_t H5S_hyper_is_valid(const H5S_t *space);
+__DLL__ hssize_t H5S_hyper_serial_size(const H5S_t *space);
+__DLL__ herr_t H5S_hyper_serialize(const H5S_t *space, uint8_t *buf);
+__DLL__ herr_t H5S_hyper_deserialize(H5S_t *space, const uint8_t *buf);
+__DLL__ herr_t H5S_hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
+__DLL__ htri_t H5S_hyper_is_contiguous(const H5S_t *space);
+__DLL__ htri_t H5S_hyper_is_single(const H5S_t *space);
+__DLL__ htri_t H5S_hyper_is_regular(const H5S_t *space);
+__DLL__ herr_t H5S_hyper_get_seq_list(const H5S_t *space, unsigned flags,
+ H5S_sel_iter_t *iter, size_t elem_size, size_t maxseq, size_t maxbytes,
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
/* "None" selection functions */
+__DLL__ herr_t H5S_none_iter_init (const H5S_t *space, size_t elmt_size,
+ H5S_sel_iter_t *iter);
+__DLL__ hsize_t H5S_none_iter_nelmts (const H5S_sel_iter_t *iter);
+__DLL__ herr_t H5S_none_iter_release(H5S_sel_iter_t *sel_iter);
+__DLL__ herr_t H5S_none_release(H5S_t *space);
+__DLL__ hsize_t H5S_none_npoints(const H5S_t *space);
+__DLL__ htri_t H5S_none_is_valid(const H5S_t *space);
+__DLL__ hssize_t H5S_none_serial_size(const H5S_t *space);
+__DLL__ herr_t H5S_none_serialize(const H5S_t *space, uint8_t *buf);
+__DLL__ herr_t H5S_none_deserialize(H5S_t *space, const uint8_t *buf);
+__DLL__ herr_t H5S_none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
+__DLL__ htri_t H5S_none_is_contiguous(const H5S_t *space);
+__DLL__ htri_t H5S_none_is_single(const H5S_t *space);
+__DLL__ htri_t H5S_none_is_regular(const H5S_t *space);
+__DLL__ herr_t H5S_none_get_seq_list(const H5S_t *space, unsigned flags,
+ H5S_sel_iter_t *iter, size_t elem_size, size_t maxseq, size_t maxbytes,
+ size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
+/* Needed for use in hyperslab code (H5Shyper.c) */
__DLL__ herr_t H5S_select_none(H5S_t *space);
-__DLL__ herr_t H5S_none_select_serialize(const H5S_t *space, uint8_t *buf);
-__DLL__ herr_t H5S_none_select_deserialize(H5S_t *space, const uint8_t *buf);
-__DLL__ herr_t H5S_none_select_iterate(void *buf, hid_t type_id, H5S_t *space,
- H5D_operator_t op, void *operator_data);
#endif
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index e7f32ef..780ba75 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -31,7 +31,7 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t);
/*-------------------------------------------------------------------------
- * Function: H5S_point_init
+ * Function: H5S_point_iter_init
*
* Purpose: Initializes iteration information for point selection.
*
@@ -45,9 +45,9 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t);
*-------------------------------------------------------------------------
*/
herr_t
-H5S_point_init (const H5S_t *space, size_t UNUSED elmt_size, H5S_sel_iter_t *sel_iter)
+H5S_point_iter_init(const H5S_t *space, size_t UNUSED elmt_size, H5S_sel_iter_t *sel_iter)
{
- FUNC_ENTER_NOAPI(H5S_point_init, FAIL);
+ FUNC_ENTER_NOAPI(H5S_point_iter_init, FAIL);
/* Check args */
assert (space && H5S_SEL_POINTS==space->select.type);
@@ -60,7 +60,62 @@ H5S_point_init (const H5S_t *space, size_t UNUSED elmt_size, H5S_sel_iter_t *sel
sel_iter->pnt.curr=space->select.sel_info.pnt_lst->head;
FUNC_LEAVE (SUCCEED);
-}
+} /* H5S_point_iter_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5S_point_iter_nelmts
+ *
+ * Purpose: Return number of elements left to process in iterator
+ *
+ * Return: non-negative number of elements on success, zero on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hsize_t
+H5S_point_iter_nelmts (const H5S_sel_iter_t *sel_iter)
+{
+ FUNC_ENTER_NOAPI(H5S_point_iter_nelmts, 0);
+
+ /* Check args */
+ assert (sel_iter);
+
+ FUNC_LEAVE (sel_iter->pnt.elmt_left);
+} /* H5S_point_iter_nelmts() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_point_iter_release
+ PURPOSE
+ Release point selection iterator information for a dataspace
+ USAGE
+ herr_t H5S_point_iter_release(sel_iter)
+ H5S_sel_iter_t *sel_iter; IN: Pointer to selection iterator
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Releases all information for a dataspace point selection iterator
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_point_iter_release (H5S_sel_iter_t * UNUSED sel_iter)
+{
+ FUNC_ENTER_NOAPI(H5S_point_iter_release, FAIL);
+
+ /* Check args */
+ assert (sel_iter);
+
+ FUNC_LEAVE (SUCCEED);
+} /* H5S_point_iter_release() */
/*--------------------------------------------------------------------------
@@ -82,7 +137,8 @@ H5S_point_init (const H5S_t *space, size_t UNUSED elmt_size, H5S_sel_iter_t *sel
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t **_coord)
+static herr_t
+H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t **_coord)
{
H5S_pnt_node_t *top, *curr, *new_node; /* Point selection nodes */
const hssize_t *coord=(const hssize_t *)_coord; /* Pointer to the actual coordinates */
@@ -149,33 +205,6 @@ herr_t H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hss
done:
FUNC_LEAVE (ret_value);
} /* H5S_point_add() */
-
-/*-------------------------------------------------------------------------
- * Function: H5S_point_favail
- *
- * Purpose: Figure out the optimal number of elements to transfer to/from the file
- *
- * Return: non-negative number of elements on success, zero on failure
- *
- * Programmer: Quincey Koziol
- * Tuesday, June 16, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-hsize_t
-H5S_point_favail (const H5S_t * UNUSED space,
- const H5S_sel_iter_t *sel_iter, hsize_t max)
-{
- FUNC_ENTER_NOAPI(H5S_point_favail, 0);
-
- /* Check args */
- assert (space && H5S_SEL_POINTS==space->select.type);
- assert (sel_iter);
-
- FUNC_LEAVE (MIN(sel_iter->pnt.elmt_left,max));
-} /* H5S_point_favail() */
/*--------------------------------------------------------------------------
@@ -256,6 +285,89 @@ H5S_point_npoints (const H5S_t *space)
/*--------------------------------------------------------------------------
NAME
+ H5S_select_elements
+ PURPOSE
+ Specify a series of elements in the dataspace to select
+ USAGE
+ herr_t H5S_select_elements(dsid, op, num_elem, coord)
+ hid_t dsid; IN: Dataspace ID of selection to modify
+ H5S_seloper_t op; IN: Operation to perform on current selection
+ size_t num_elem; IN: Number of elements in COORD array.
+ const hssize_t **coord; IN: The location of each element selected
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ This function selects array elements to be included in the selection for
+ the dataspace. The COORD array is a 2-D array of size <dataspace rank>
+ by NUM_ELEM (ie. a list of coordinates in the dataspace). The order of
+ the element coordinates in the COORD array specifies the order that the
+ array elements are iterated through when I/O is performed. Duplicate
+ coordinates are not checked for. The selection operator, OP, determines
+ how the new selection is to be combined with the existing selection for
+ the dataspace. Currently, only H5S_SELECT_SET is supported, which replaces
+ the existing selection with the one defined in this call. When operators
+ other than H5S_SELECT_SET are used to combine a new selection with an
+ existing selection, the selection ordering is reset to 'C' array ordering.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem,
+ const hssize_t **coord)
+{
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER_NOINIT(H5S_select_elements);
+
+ /* Check args */
+ assert(space);
+ assert(num_elem);
+ assert(coord);
+ assert(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND);
+
+ /* If we are setting a new selection, remove current selection first */
+ if(op==H5S_SELECT_SET) {
+ if((*space->select.release)(space)<0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release point selection");
+ } /* end if */
+
+ /* Allocate space for the point selection information if necessary */
+ if(space->select.type!=H5S_SEL_POINTS || space->select.sel_info.pnt_lst==NULL) {
+ if((space->select.sel_info.pnt_lst = H5FL_ALLOC(H5S_pnt_list_t,1))==NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate element information");
+ } /* end if */
+
+ /* Add points to selection */
+ if(H5S_point_add(space,op,num_elem,coord)<0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert elements");
+
+ /* Set selection type */
+ space->select.type=H5S_SEL_POINTS;
+
+ /* Set selection methods */
+ space->select.get_seq_list=H5S_point_get_seq_list;
+ space->select.get_npoints=H5S_point_npoints;
+ space->select.release=H5S_point_release;
+ space->select.iter_init=H5S_point_iter_init;
+ space->select.iter_nelmts=H5S_point_iter_nelmts;
+ space->select.iter_release=H5S_point_iter_release;
+ space->select.is_valid=H5S_point_is_valid;
+ space->select.serial_size=H5S_point_serial_size;
+ space->select.serialize=H5S_point_serialize;
+ space->select.bounds=H5S_point_bounds;
+ space->select.is_contiguous=H5S_point_is_contiguous;
+ space->select.is_single=H5S_point_is_single;
+ space->select.is_regular=H5S_point_is_regular;
+
+done:
+ FUNC_LEAVE (ret_value);
+} /* H5S_select_elements() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S_point_copy
PURPOSE
Copy a selection from one dataspace to another
@@ -320,12 +432,12 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_point_select_valid
+ H5S_point_is_valid
PURPOSE
Check whether the selection fits within the extent, with the current
offset defined.
USAGE
- htri_t H5S_point_select_valid(space);
+ htri_t H5S_point_is_valid(space);
H5S_t *space; IN: Dataspace pointer to query
RETURNS
TRUE if the selection fits within the extent, FALSE if it does not and
@@ -339,13 +451,13 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
-H5S_point_select_valid (const H5S_t *space)
+H5S_point_is_valid (const H5S_t *space)
{
H5S_pnt_node_t *curr; /* Point information nodes */
unsigned u; /* Counter */
htri_t ret_value=TRUE; /* return value */
- FUNC_ENTER_NOAPI(H5S_point_select_valid, FAIL);
+ FUNC_ENTER_NOAPI(H5S_point_is_valid, FAIL);
assert(space);
@@ -367,17 +479,87 @@ H5S_point_select_valid (const H5S_t *space)
} /* end while */
FUNC_LEAVE (ret_value);
-} /* end H5S_point_select_valid() */
+} /* end H5S_point_is_valid() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_select_serial_size
+ H5S_get_select_elem_npoints
+ PURPOSE
+ Get the number of points in current element selection
+ USAGE
+ hssize_t H5S_get_select_elem_npoints(space)
+ H5S_t *space; IN: Dataspace ptr of selection to query
+ RETURNS
+ The number of element points in selection on success, negative on failure
+ DESCRIPTION
+ Returns the number of element points in current selection for dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static hssize_t
+H5S_get_select_elem_npoints(H5S_t *space)
+{
+ hssize_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER_NOINIT(H5S_get_select_elem_npoints);
+
+ assert(space);
+
+ ret_value = space->select.num_elem;
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_elem_npoints() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_select_elem_npoints
+ PURPOSE
+ Get the number of points in current element selection
+ USAGE
+ hssize_t H5Sget_select_elem_npoints(dsid)
+ hid_t dsid; IN: Dataspace ID of selection to query
+ RETURNS
+ The number of element points in selection on success, negative on failure
+ DESCRIPTION
+ Returns the number of element points in current selection for dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hssize_t
+H5Sget_select_elem_npoints(hid_t spaceid)
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ hssize_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER_API(H5Sget_select_elem_npoints, FAIL);
+ H5TRACE1("Hs","i",spaceid);
+
+ /* Check args */
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ if(space->select.type!=H5S_SEL_POINTS)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection");
+
+ ret_value = H5S_get_select_elem_npoints(space);
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_elem_npoints() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_point_serial_size
PURPOSE
Determine the number of bytes needed to store the serialized point selection
information.
USAGE
- hssize_t H5S_point_select_serial_size(space)
+ hssize_t H5S_point_serial_size(space)
H5S_t *space; IN: Dataspace pointer to query
RETURNS
The number of bytes required on success, negative on an error.
@@ -390,12 +572,12 @@ H5S_point_select_valid (const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
hssize_t
-H5S_point_select_serial_size (const H5S_t *space)
+H5S_point_serial_size (const H5S_t *space)
{
H5S_pnt_node_t *curr; /* Point information nodes */
hssize_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_point_select_serial_size, FAIL);
+ FUNC_ENTER_NOAPI(H5S_point_serial_size, FAIL);
assert(space);
@@ -414,16 +596,16 @@ H5S_point_select_serial_size (const H5S_t *space)
} /* end while */
FUNC_LEAVE (ret_value);
-} /* end H5S_point_select_serial_size() */
+} /* end H5S_point_serial_size() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_select_serialize
+ H5S_point_serialize
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_point_select_serialize(space, buf)
+ herr_t H5S_point_serialize(space, buf)
H5S_t *space; IN: Dataspace pointer of selection to serialize
uint8 *buf; OUT: Buffer to put serialized selection into
RETURNS
@@ -437,7 +619,7 @@ H5S_point_select_serial_size (const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_point_select_serialize (const H5S_t *space, uint8_t *buf)
+H5S_point_serialize (const H5S_t *space, uint8_t *buf)
{
H5S_pnt_node_t *curr; /* Point information nodes */
uint8_t *lenp; /* pointer to length location for later storage */
@@ -445,7 +627,7 @@ H5S_point_select_serialize (const H5S_t *space, uint8_t *buf)
unsigned u; /* local counting variable */
herr_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_point_select_serialize, FAIL);
+ FUNC_ENTER_NOAPI(H5S_point_serialize, FAIL);
assert(space);
@@ -484,16 +666,16 @@ H5S_point_select_serialize (const H5S_t *space, uint8_t *buf)
ret_value=SUCCEED;
FUNC_LEAVE (ret_value);
-} /* H5S_point_select_serialize() */
+} /* H5S_point_serialize() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_select_deserialize
+ H5S_point_deserialize
PURPOSE
Deserialize the current selection from a user-provided buffer.
USAGE
- herr_t H5S_point_select_deserialize(space, buf)
+ herr_t H5S_point_deserialize(space, buf)
H5S_t *space; IN/OUT: Dataspace pointer to place selection into
uint8 *buf; IN: Buffer to retrieve serialized selection from
RETURNS
@@ -507,7 +689,7 @@ H5S_point_select_serialize (const H5S_t *space, uint8_t *buf)
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_point_select_deserialize (H5S_t *space, const uint8_t *buf)
+H5S_point_deserialize (H5S_t *space, const uint8_t *buf)
{
H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */
uint32_t rank; /* Rank of points */
@@ -516,7 +698,7 @@ H5S_point_select_deserialize (H5S_t *space, const uint8_t *buf)
unsigned i,j; /* local counting variables */
herr_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_point_select_deserialize, FAIL);
+ FUNC_ENTER_NOAPI(H5S_point_deserialize, FAIL);
/* Check args */
assert(space);
@@ -539,9 +721,8 @@ H5S_point_select_deserialize (H5S_t *space, const uint8_t *buf)
UINT32DECODE(buf, *tcoord);
/* Select points */
- if((ret_value=H5S_select_elements(space,op,num_elem,(const hssize_t **)coord))<0) {
+ if((ret_value=H5S_select_elements(space,op,num_elem,(const hssize_t **)coord))<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
- } /* end if */
done:
/* Free the coordinate array if necessary */
@@ -549,7 +730,124 @@ done:
H5MM_xfree(coord);
FUNC_LEAVE (ret_value);
-} /* H5S_point_select_deserialize() */
+} /* H5S_point_deserialize() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_get_select_elem_pointlist
+ PURPOSE
+ Get the list of element points currently selected
+ USAGE
+ herr_t H5S_get_select_elem_pointlist(space, hsize_t *buf)
+ H5S_t *space; IN: Dataspace pointer of selection to query
+ hsize_t startpoint; IN: Element point to start with
+ hsize_t numpoints; IN: Number of element points to get
+ hsize_t *buf; OUT: List of element points selected
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Puts a list of the element points into the user's buffer. The points
+ start with the 'startpoint'th block in the list of points and put
+ 'numpoints' number of points into the user's buffer (or until the end of
+ the list of points, whichever happen first)
+ The point coordinates have the same dimensionality (rank) as the
+ dataspace they are located within. The list of points is formatted as
+ follows: <coordinate> followed by the next coordinate, etc. until all the
+ point information in the selection have been put into the user's buffer.
+ The points are returned in the order they will be interated through
+ when a selection is read/written from/to disk.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf)
+{
+ H5S_pnt_node_t *node; /* Point node */
+ int rank; /* Dataspace rank */
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER_NOINIT(H5S_get_select_elem_pointlist);
+
+ assert(space);
+ assert(buf);
+
+ /* Get the dataspace extent rank */
+ rank=space->extent.u.simple.rank;
+
+ /* Get the head of the point list */
+ node=space->select.sel_info.pnt_lst->head;
+
+ /* Iterate to the first point to return */
+ while(node!=NULL && startpoint>0) {
+ startpoint--;
+ node=node->next;
+ } /* end while */
+
+ /* Iterate through the node, copying each hyperslab's information */
+ while(node!=NULL && numpoints>0) {
+ HDmemcpy(buf,node->pnt,sizeof(hsize_t)*rank);
+ buf+=rank;
+ numpoints--;
+ node=node->next;
+ } /* end while */
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_elem_pointlist() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_select_elem_pointlist
+ PURPOSE
+ Get the list of element points currently selected
+ USAGE
+ herr_t H5Sget_select_elem_pointlist(dsid, hsize_t *buf)
+ hid_t dsid; IN: Dataspace ID of selection to query
+ hsize_t startpoint; IN: Element point to start with
+ hsize_t numpoints; IN: Number of element points to get
+ hsize_t *buf; OUT: List of element points selected
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Puts a list of the element points into the user's buffer. The points
+ start with the 'startpoint'th block in the list of points and put
+ 'numpoints' number of points into the user's buffer (or until the end of
+ the list of points, whichever happen first)
+ The point coordinates have the same dimensionality (rank) as the
+ dataspace they are located within. The list of points is formatted as
+ follows: <coordinate> followed by the next coordinate, etc. until all the
+ point information in the selection have been put into the user's buffer.
+ The points are returned in the order they will be interated through
+ when a selection is read/written from/to disk.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, hsize_t *buf)
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ herr_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER_API(H5Sget_select_elem_pointlist, FAIL);
+ H5TRACE4("e","ihh*h",spaceid,startpoint,numpoints,buf);
+
+ /* Check args */
+ if(buf==NULL)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ if(space->select.type!=H5S_SEL_POINTS)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection");
+
+ ret_value = H5S_get_select_elem_pointlist(space,startpoint,numpoints,buf);
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_elem_pointlist() */
/*--------------------------------------------------------------------------
@@ -579,11 +877,11 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_point_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
+H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
{
H5S_pnt_node_t *node; /* Point node */
- int rank; /* Dataspace rank */
- int i; /* index variable */
+ int rank; /* Dataspace rank */
+ int i; /* index variable */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_NOAPI(H5S_point_bounds, FAIL);
@@ -595,6 +893,12 @@ H5S_point_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
/* Get the dataspace extent rank */
rank=space->extent.u.simple.rank;
+ /* Set the start and end arrays up */
+ for(i=0; i<rank; i++) {
+ start[i]=UINT_MAX;
+ end[i]=0;
+ } /* end for */
+
/* Iterate through the node, checking the bounds on each element */
node=space->select.sel_info.pnt_lst->head;
while(node!=NULL) {
@@ -613,11 +917,11 @@ H5S_point_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
/*--------------------------------------------------------------------------
NAME
- H5S_point_select_contiguous
+ H5S_point_is_contiguous
PURPOSE
Check if a point selection is contiguous within the dataspace extent.
USAGE
- htri_t H5S_point_select_contiguous(space)
+ htri_t H5S_point_is_contiguous(space)
H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -633,11 +937,11 @@ H5S_point_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
-H5S_point_select_contiguous(const H5S_t *space)
+H5S_point_is_contiguous(const H5S_t *space)
{
htri_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_point_select_contiguous, FAIL);
+ FUNC_ENTER_NOAPI(H5S_point_is_contiguous, FAIL);
assert(space);
@@ -648,16 +952,16 @@ H5S_point_select_contiguous(const H5S_t *space)
ret_value=FALSE;
FUNC_LEAVE (ret_value);
-} /* H5S_point_select_contiguous() */
+} /* H5S_point_is_contiguous() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_select_single
+ H5S_point_is_single
PURPOSE
Check if a point selection is single within the dataspace extent.
USAGE
- htri_t H5S_point_select_contiguous(space)
+ htri_t H5S_point_is_single(space)
H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -670,31 +974,31 @@ H5S_point_select_contiguous(const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
-H5S_point_select_single(const H5S_t *space)
+H5S_point_is_single(const H5S_t *space)
{
htri_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_point_select_single, FAIL);
+ FUNC_ENTER_NOAPI(H5S_point_is_single, FAIL);
assert(space);
- /* One point is definitely contiguous */
+ /* One point is definitely 'single' :-) */
if(space->select.num_elem==1)
ret_value=TRUE;
else
ret_value=FALSE;
FUNC_LEAVE (ret_value);
-} /* H5S_point_select_single() */
+} /* H5S_point_is_single() */
/*--------------------------------------------------------------------------
NAME
- H5S_point_select_regular
+ H5S_point_is_regular
PURPOSE
Check if a point selection is "regular"
USAGE
- htri_t H5S_point_select_regular(space)
+ htri_t H5S_point_is_regular(space)
const H5S_t *space; IN: Dataspace pointer to check
RETURNS
TRUE/FALSE/FAIL
@@ -710,11 +1014,11 @@ H5S_point_select_single(const H5S_t *space)
REVISION LOG
--------------------------------------------------------------------------*/
htri_t
-H5S_point_select_regular(const H5S_t *space)
+H5S_point_is_regular(const H5S_t *space)
{
htri_t ret_value=FAIL; /* return value */
- FUNC_ENTER_NOAPI(H5S_point_select_regular, FAIL);
+ FUNC_ENTER_NOAPI(H5S_point_is_regular, FAIL);
/* Check args */
assert(space);
@@ -726,79 +1030,7 @@ H5S_point_select_regular(const H5S_t *space)
ret_value=FALSE;
FUNC_LEAVE (ret_value);
-} /* H5S_point_select_regular() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_select_elements
- PURPOSE
- Specify a series of elements in the dataspace to select
- USAGE
- herr_t H5S_select_elements(dsid, op, num_elem, coord)
- hid_t dsid; IN: Dataspace ID of selection to modify
- H5S_seloper_t op; IN: Operation to perform on current selection
- size_t num_elem; IN: Number of elements in COORD array.
- const hssize_t **coord; IN: The location of each element selected
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- This function selects array elements to be included in the selection for
- the dataspace. The COORD array is a 2-D array of size <dataspace rank>
- by NUM_ELEM (ie. a list of coordinates in the dataspace). The order of
- the element coordinates in the COORD array specifies the order that the
- array elements are iterated through when I/O is performed. Duplicate
- coordinates are not checked for. The selection operator, OP, determines
- how the new selection is to be combined with the existing selection for
- the dataspace. Currently, only H5S_SELECT_SET is supported, which replaces
- the existing selection with the one defined in this call. When operators
- other than H5S_SELECT_SET are used to combine a new selection with an
- existing selection, the selection ordering is reset to 'C' array ordering.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem,
- const hssize_t **coord)
-{
- herr_t ret_value=SUCCEED; /* return value */
-
- FUNC_ENTER_NOAPI(H5S_select_elements, FAIL);
-
- /* Check args */
- assert(space);
- assert(num_elem);
- assert(coord);
- assert(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND);
-
- /* If we are setting a new selection, remove current selection first */
- if(op==H5S_SELECT_SET) {
- if(H5S_select_release(space)<0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL,
- "can't release point selection");
- } /* end if */
- } /* end if */
-
- /* Allocate space for the point selection information if necessary */
- if(space->select.type!=H5S_SEL_POINTS || space->select.sel_info.pnt_lst==NULL) {
- if((space->select.sel_info.pnt_lst = H5FL_ALLOC(H5S_pnt_list_t,1))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "can't allocate element information");
- } /* end if */
-
- /* Add points to selection */
- if(H5S_point_add(space,op,num_elem,coord)<0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL,
- "can't insert elements");
- }
-
- /* Set selection type */
- space->select.type=H5S_SEL_POINTS;
-
-done:
- FUNC_LEAVE (ret_value);
-} /* H5S_select_elements() */
+} /* H5S_point_is_regular() */
/*--------------------------------------------------------------------------
@@ -831,7 +1063,8 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elem,
+herr_t
+H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elem,
const hssize_t **coord)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
@@ -840,22 +1073,16 @@ herr_t H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elem,
FUNC_ENTER_API(H5Sselect_elements, FAIL);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(spaceid) ||
- NULL == (space=H5I_object(spaceid))) {
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- if(coord==NULL || num_elem==0) {
+ if(coord==NULL || num_elem==0)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified");
- } /* end if */
- if(!(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND)) {
- HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL,
- "operations other than H5S_SELECT_SET not supported currently");
- } /* end if */
+ if(!(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND))
+ HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operations other than H5S_SELECT_SET not supported currently");
/* Call the real element selection routine */
- if((ret_value=H5S_select_elements(space,op,num_elem,coord))<0) {
+ if((ret_value=H5S_select_elements(space,op,num_elem,coord))<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't select elements");
- } /* end if */
done:
FUNC_LEAVE (ret_value);
@@ -864,13 +1091,13 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_point_select_get_seq_list
+ H5S_point_get_seq_list
PURPOSE
Create a list of offsets & lengths for a selection
USAGE
- herr_t H5S_point_select_get_seq_list(flags,space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len)
- unsigned flags; IN: Flags for extra information about operation
+ herr_t H5S_point_get_seq_list(space,flags,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len)
H5S_t *space; IN: Dataspace containing selection to use.
+ unsigned flags; IN: Flags for extra information about operation
H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
position of interest in selection.
size_t elem_size; IN: Size of an element
@@ -895,7 +1122,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_point_select_get_seq_list(unsigned flags, const H5S_t *space,H5S_sel_iter_t *iter,
+H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter,
size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
hsize_t *off, size_t *len)
{
@@ -910,7 +1137,7 @@ H5S_point_select_get_seq_list(unsigned flags, const H5S_t *space,H5S_sel_iter_t
int i; /* Local index variable */
herr_t ret_value=SUCCEED; /* return value */
- FUNC_ENTER_NOAPI (H5S_point_select_get_seq_list, FAIL);
+ FUNC_ENTER_NOAPI (H5S_point_get_seq_list, FAIL);
/* Check args */
assert(space);
@@ -1001,4 +1228,5 @@ H5S_point_select_get_seq_list(unsigned flags, const H5S_t *space,H5S_sel_iter_t
done:
FUNC_LEAVE (ret_value);
-} /* end H5S_point_select_get_seq_list() */
+} /* end H5S_point_get_seq_list() */
+
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index 1412ea3..393f6bb 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -40,7 +40,7 @@
#define H5S_CONV_STORAGE_CHUNKED 0x0004 /* i.e. '2' */
#define H5S_CONV_STORAGE_MASK 0x0006
-/* Flags for H5S_select_get_seq_list() */
+/* Flags for "get_seq_list" methods */
#define H5S_GET_SEQ_LIST_SORTED 0x0001
/* Forward references of common typedefs */
@@ -154,38 +154,20 @@ __DLL__ herr_t H5S_modify(struct H5G_entry_t *ent, const H5S_t *space);
__DLL__ H5S_t *H5S_read(struct H5G_entry_t *ent);
__DLL__ int H5S_cmp(const H5S_t *ds1, const H5S_t *ds2);
__DLL__ htri_t H5S_is_simple(const H5S_t *sdim);
-__DLL__ unsigned H5S_nelem(const H5S_t *space);
-__DLL__ int H5S_get_hyperslab(const H5S_t *ds, hssize_t offset[]/*out*/,
- hsize_t size[]/*out*/, hsize_t stride[]/*out*/);
-__DLL__ herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src);
__DLL__ herr_t H5S_extent_release(H5S_t *space);
-__DLL__ herr_t H5S_select_release(H5S_t *space);
-__DLL__ hssize_t H5S_get_select_npoints(const H5S_t *space);
__DLL__ int H5S_extend(H5S_t *space, const hsize_t *size);
__DLL__ herr_t H5S_set_extent(H5S_t *space, const hsize_t *size);
-__DLL__ htri_t H5S_select_valid(const H5S_t *space);
__DLL__ herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream,
int indent, int fwidth);
-__DLL__ hssize_t H5S_select_serial_size(const H5S_t *space);
-__DLL__ herr_t H5S_select_serialize(const H5S_t *space, uint8_t *buf);
+
+/* Operations on selections */
+__DLL__ herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src);
__DLL__ herr_t H5S_select_deserialize(H5S_t *space, const uint8_t *buf);
-__DLL__ htri_t H5S_select_contiguous(const H5S_t *space);
-__DLL__ htri_t H5S_select_single(const H5S_t *space);
-__DLL__ htri_t H5S_select_regular(const H5S_t *space);
__DLL__ htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2);
__DLL__ herr_t H5S_select_iterate(void *buf, hid_t type_id, H5S_t *space,
H5D_operator_t op, void *operator_data);
-__DLL__ herr_t H5S_select_iter_init(const H5S_t *space, size_t elmt_size,
- H5S_sel_iter_t *iter);
-__DLL__ herr_t H5S_sel_iter_release(const H5S_t *space,
- H5S_sel_iter_t *sel_iter);
__DLL__ herr_t H5S_select_fill(void *fill, size_t fill_size,
const H5S_t *space, void *buf);
-__DLL__ herr_t H5S_select_get_seq_list(unsigned flags, const H5S_t *space,H5S_sel_iter_t *iter,
- size_t elem_size, size_t maxseq, size_t maxbytes,
- size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
-__DLL__ hsize_t H5S_select_favail(const H5S_t *space, const H5S_sel_iter_t *iter,
- hsize_t max);
__DLL__ herr_t H5S_select_fscat (H5F_t *f, const struct H5O_layout_t *layout,
H5P_genplist_t *dc_plist, size_t elmt_size, const H5S_t *file_space,
H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id,
@@ -208,7 +190,7 @@ __DLL__ herr_t H5S_select_write(H5F_t *f, const struct H5O_layout_t *layout,
const H5S_t *mem_space, hid_t dxpl_id, const void *buf/*out*/);
/* Needed for internal use of selections in H5Fistore code */
-__DLL__ herr_t H5S_select_all(H5S_t *space);
+__DLL__ herr_t H5S_select_all(H5S_t *space, unsigned rel_prev);
__DLL__ herr_t H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hssize_t start[],
const hsize_t stride[], const hsize_t count[],
const hsize_t block[]);
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index 5fd7448..283096f 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -119,7 +119,7 @@ __DLL__ herr_t H5Sselect_select(hid_t space1_id, H5S_seloper_t op,
hid_t space2_id);
__DLL__ hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op,
hid_t space2_id);
-#endif /* OLD_WAY */
+#endif /* NEW_HYPERSLAB_API */
__DLL__ herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op,
size_t num_elemn,
const hssize_t **coord);
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 705eefb..b37c2b6 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -23,12 +23,6 @@
#define INTERFACE_INIT NULL
static int interface_initialize_g = 0;
-static hssize_t H5S_get_select_hyper_nblocks(H5S_t *space);
-static hssize_t H5S_get_select_elem_npoints(H5S_t *space);
-static herr_t H5S_get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblocks, hsize_t *buf);
-static herr_t H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf);
-static herr_t H5S_get_select_bounds(H5S_t *space, hsize_t *start, hsize_t *end);
-
/* Declare external the free list for hssize_t arrays */
H5FL_ARR_EXTERN(hssize_t);
@@ -81,10 +75,8 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
/* Need to copy order information still */
/* Copy offset information */
- if (NULL==(dst->select.offset = H5FL_ARR_ALLOC(hssize_t,src->extent.u.simple.rank,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(dst->select.offset = H5FL_ARR_ALLOC(hssize_t,src->extent.u.simple.rank,1)))
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
if(src->select.offset!=NULL)
HDmemcpy(dst->select.offset,src->select.offset,(src->extent.u.simple.rank*sizeof(hssize_t)));
@@ -123,64 +115,10 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
default:
assert("unknown data space type" && 0);
break;
- }
+ } /* end switch */
FUNC_LEAVE (ret_value);
} /* H5S_select_copy() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_select_release
- PURPOSE
- Release selection information for a dataspace
- USAGE
- herr_t H5S_select_release(space)
- H5S_t *space; IN: Pointer to dataspace
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Releases all selection information for a dataspace
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S_select_release (H5S_t *space)
-{
- herr_t ret_value=SUCCEED; /* return value */
-
- FUNC_ENTER_NOAPI(H5S_select_release, FAIL);
-
- /* Check args */
- assert (space);
-
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_release(space);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_release(space);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=H5S_all_release(space);
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- /* Reset type of selection to "all" */
- space->select.type=H5S_SEL_ALL;
-
- FUNC_LEAVE (ret_value);
-} /* H5S_select_release() */
/*--------------------------------------------------------------------------
@@ -210,12 +148,10 @@ H5Sget_select_npoints(hid_t spaceid)
H5TRACE1("Hs","i",spaceid);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(spaceid) ||
- NULL == (space=H5I_object(spaceid))) {
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
- }
- ret_value = H5S_get_select_npoints(space);
+ ret_value = (*space->select.get_npoints)(space);
FUNC_LEAVE (ret_value);
} /* H5Sget_select_npoints() */
@@ -223,108 +159,6 @@ H5Sget_select_npoints(hid_t spaceid)
/*--------------------------------------------------------------------------
NAME
- H5S_get_select_npoints
- PURPOSE
- Get the number of elements in current selection
- USAGE
- herr_t H5S_get_select_npoints(ds)
- H5S_t *ds; IN: Dataspace pointer
- RETURNS
- The number of elements in selection on success, 0 on failure
- DESCRIPTION
- Returns the number of elements in current selection for dataspace.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-hssize_t
-H5S_get_select_npoints (const H5S_t *space)
-{
- hssize_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOAPI(H5S_get_select_npoints, FAIL);
-
- assert(space);
-
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_npoints(space);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_npoints(space);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=H5S_all_npoints(space);
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- ret_value=0;
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- FUNC_LEAVE (ret_value);
-} /* H5S_get_select_npoints() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_sel_iter_release
- PURPOSE
- Release selection iterator information for a dataspace
- USAGE
- herr_t H5S_sel_iter_release(sel_iter)
- const H5S_t *space; IN: Pointer to dataspace iterator is for
- H5S_sel_iter_t *sel_iter; IN: Pointer to selection iterator
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Releases all information for a dataspace selection iterator
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S_sel_iter_release (const H5S_t *space, H5S_sel_iter_t *sel_iter)
-{
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5S_sel_iter_release, FAIL);
-
- /* Check args */
- assert (sel_iter);
-
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- case H5S_SEL_ALL: /* Entire extent selected */
- /* no action needed */
- ret_value=SUCCEED;
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_sel_iter_release(sel_iter);
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- FUNC_LEAVE (ret_value);
-} /* H5S_sel_iter_release() */
-
-/*--------------------------------------------------------------------------
- NAME
H5Sselect_valid
PURPOSE
Check whether the selection fits within the extent, with the current
@@ -353,178 +187,14 @@ H5Sselect_valid(hid_t spaceid)
H5TRACE1("b","i",spaceid);
/* Check args */
- if (H5I_DATASPACE != H5I_get_type(spaceid) ||
- NULL == (space=H5I_object(spaceid))) {
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
- }
- ret_value = H5S_select_valid(space);
+ ret_value = (*space->select.is_valid)(space);
FUNC_LEAVE (ret_value);
} /* H5Sselect_valid() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_select_valid
- PURPOSE
- Check whether the selection fits within the extent, with the current
- offset defined.
- USAGE
- htri_t H5Sselect_void(space)
- H5S_t *space; IN: Dataspace pointer to query
- RETURNS
- TRUE if the selection fits within the extent, FALSE if it does not and
- Negative on an error.
- DESCRIPTION
- Determines if the current selection at the current offet fits within the
- extent for the dataspace.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-htri_t
-H5S_select_valid (const H5S_t *space)
-{
- htri_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOAPI(H5S_select_valid, FAIL);
-
- assert(space);
-
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_select_valid(space);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_select_valid(space);
- break;
- case H5S_SEL_ALL: /* Entire extent selected */
- case H5S_SEL_NONE: /* Nothing selected */
- ret_value=TRUE;
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- FUNC_LEAVE (ret_value);
-} /* H5S_select_valid() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_select_serial_size
- PURPOSE
- Determine the number of bytes needed to serialize the current selection
- offset defined.
- USAGE
- hssize_t H5S_select_serial_size(space)
- H5S_t *space; IN: Dataspace pointer to query
- RETURNS
- The number of bytes required on success, negative on an error.
- DESCRIPTION
- Determines the number of bytes required to serialize the current selection
- information for storage on disk. This routine just hands off to the
- appropriate routine for each type of selection.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-hssize_t
-H5S_select_serial_size (const H5S_t *space)
-{
- hssize_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOAPI(H5S_select_serial_size, FAIL);
-
- assert(space);
-
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_select_serial_size(space);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_select_serial_size(space);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- case H5S_SEL_NONE: /* Nothing selected */
- ret_value=16; /* replace with real function call at some point */
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- FUNC_LEAVE (ret_value);
-} /* H5S_select_serial_size() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_select_serialize
- PURPOSE
- Serialize the current selection into a user-provided buffer.
- USAGE
- herr_t H5S_select_serialize(space, buf)
- H5S_t *space; IN: Dataspace pointer of selection to serialize
- uint8 *buf; OUT: Buffer to put serialized selection into
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Serializes the current selection into a buffer. (Primarily for storing
- on disk). This routine just hands off to the appropriate routine for each
- type of selection.
- The serialized information for all types of selections follows this format:
- <type of selection> = uint32
- <version #> = uint32
- <padding, not-used> = 4 bytes
- <length of selection specific information> = uint32
- <selection specific information> = ? bytes (depends on selection type)
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S_select_serialize (const H5S_t *space, uint8_t *buf)
-{
- herr_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOAPI(H5S_select_serialize, FAIL);
-
- assert(space);
-
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_select_serialize(space,buf);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_select_serialize(space,buf);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=H5S_all_select_serialize(space,buf);
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- ret_value=H5S_none_select_serialize(space,buf);
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- FUNC_LEAVE (ret_value);
-} /* H5S_select_serialize() */
/*--------------------------------------------------------------------------
NAME
@@ -563,19 +233,19 @@ H5S_select_deserialize (H5S_t *space, const uint8_t *buf)
UINT32DECODE(tbuf, sel_type);
switch(sel_type) {
case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_select_deserialize(space,buf);
+ ret_value=H5S_point_deserialize(space,buf);
break;
case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_select_deserialize(space,buf);
+ ret_value=H5S_hyper_deserialize(space,buf);
break;
case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=H5S_all_select_deserialize(space,buf);
+ ret_value=H5S_all_deserialize(space,buf);
break;
case H5S_SEL_NONE: /* Nothing selected */
- ret_value=H5S_none_select_deserialize(space,buf);
+ ret_value=H5S_none_deserialize(space,buf);
break;
default:
@@ -588,549 +258,6 @@ H5S_select_deserialize (H5S_t *space, const uint8_t *buf)
/*--------------------------------------------------------------------------
NAME
- H5S_get_select_hyper_nblocks
- PURPOSE
- Get the number of hyperslab blocks in current hyperslab selection
- USAGE
- hssize_t H5S_get_select_hyper_nblocks(space)
- H5S_t *space; IN: Dataspace ptr of selection to query
- RETURNS
- The number of hyperslab blocks in selection on success, negative on failure
- DESCRIPTION
- Returns the number of hyperslab blocks in current selection for dataspace.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static hssize_t
-H5S_get_select_hyper_nblocks(H5S_t *space)
-{
- hssize_t ret_value=FAIL; /* return value */
- unsigned u; /* Counter */
-
- FUNC_ENTER_NOINIT(H5S_get_select_hyper_nblocks);
-
- assert(space);
-
- /* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab.diminfo != NULL) {
- /* Check each dimension */
- for(ret_value=1,u=0; u<space->extent.u.simple.rank; u++)
- ret_value*=space->select.sel_info.hslab.app_diminfo[u].count;
- } /* end if */
- else
- ret_value = H5S_hyper_span_nblocks(space->select.sel_info.hslab.span_lst);
-
- FUNC_LEAVE (ret_value);
-} /* H5S_get_select_hyper_nblocks() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5Sget_select_hyper_nblocks
- PURPOSE
- Get the number of hyperslab blocks in current hyperslab selection
- USAGE
- hssize_t H5Sget_select_hyper_nblocks(dsid)
- hid_t dsid; IN: Dataspace ID of selection to query
- RETURNS
- The number of hyperslab blocks in selection on success, negative on failure
- DESCRIPTION
- Returns the number of hyperslab blocks in current selection for dataspace.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-hssize_t
-H5Sget_select_hyper_nblocks(hid_t spaceid)
-{
- H5S_t *space = NULL; /* Dataspace to modify selection of */
- hssize_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_API(H5Sget_select_hyper_nblocks, FAIL);
- H5TRACE1("Hs","i",spaceid);
-
- /* Check args */
- if (H5I_DATASPACE != H5I_get_type(spaceid) ||
- NULL == (space=H5I_object(spaceid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- if(space->select.type!=H5S_SEL_HYPERSLABS)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
-
- ret_value = H5S_get_select_hyper_nblocks(space);
-
- FUNC_LEAVE (ret_value);
-} /* H5Sget_select_hyper_nblocks() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_get_select_elem_npoints
- PURPOSE
- Get the number of points in current element selection
- USAGE
- hssize_t H5S_get_select_elem_npoints(space)
- H5S_t *space; IN: Dataspace ptr of selection to query
- RETURNS
- The number of element points in selection on success, negative on failure
- DESCRIPTION
- Returns the number of element points in current selection for dataspace.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static hssize_t
-H5S_get_select_elem_npoints(H5S_t *space)
-{
- hssize_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOINIT(H5S_get_select_elem_npoints);
-
- assert(space);
-
- ret_value = space->select.num_elem;
-
- FUNC_LEAVE (ret_value);
-} /* H5Sget_select_elem_npoints() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5Sget_select_elem_npoints
- PURPOSE
- Get the number of points in current element selection
- USAGE
- hssize_t H5Sget_select_elem_npoints(dsid)
- hid_t dsid; IN: Dataspace ID of selection to query
- RETURNS
- The number of element points in selection on success, negative on failure
- DESCRIPTION
- Returns the number of element points in current selection for dataspace.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-hssize_t
-H5Sget_select_elem_npoints(hid_t spaceid)
-{
- H5S_t *space = NULL; /* Dataspace to modify selection of */
- hssize_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_API(H5Sget_select_elem_npoints, FAIL);
- H5TRACE1("Hs","i",spaceid);
-
- /* Check args */
- if (H5I_DATASPACE != H5I_get_type(spaceid) ||
- NULL == (space=H5I_object(spaceid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- if(space->select.type!=H5S_SEL_POINTS)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection");
-
- ret_value = H5S_get_select_elem_npoints(space);
-
- FUNC_LEAVE (ret_value);
-} /* H5Sget_select_elem_npoints() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_get_select_hyper_blocklist
- PURPOSE
- Get the list of hyperslab blocks currently selected
- USAGE
- herr_t H5S_get_select_hyper_blocklist(space, startblock, numblocks, buf)
- H5S_t *space; IN: Dataspace pointer of selection to query
- hsize_t startblock; IN: Hyperslab block to start with
- hsize_t numblocks; IN: Number of hyperslab blocks to get
- hsize_t *buf; OUT: List of hyperslab blocks selected
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Puts a list of the hyperslab blocks into the user's buffer. The blocks
- start with the 'startblock'th block in the list of blocks and put
- 'numblocks' number of blocks into the user's buffer (or until the end of
- the list of blocks, whichever happens first)
- The block coordinates have the same dimensionality (rank) as the
- dataspace they are located within. The list of blocks is formatted as
- follows: <"start" coordinate> immediately followed by <"opposite" corner
- coordinate>, followed by the next "start" and "opposite" coordinate, etc.
- until all the block information requested has been put into the user's
- buffer.
- No guarantee of any order of the blocks is implied.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S_get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblocks, hsize_t *buf)
-{
- H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
- hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */
- hssize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */
- hssize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */
- hssize_t end[H5O_LAYOUT_NDIMS]; /* Location of end of hyperslab */
- hssize_t temp_off; /* Offset in a given dimension */
- int i; /* Counter */
- int fast_dim; /* Rank of the fastest changing dimension for the dataspace */
- int temp_dim; /* Temporary rank holder */
- int ndims; /* Rank of the dataspace */
- int done; /* Whether we are done with the iteration */
- herr_t ret_value=SUCCEED; /* return value */
-
- FUNC_ENTER_NOINIT(H5S_get_select_hyper_blocklist);
-
- assert(space);
- assert(buf);
-
- /* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab.diminfo != NULL) {
- /* Set some convienence values */
- ndims=space->extent.u.simple.rank;
- fast_dim=ndims-1;
- /*
- * Use the "application dimension information" to pass back to the user
- * the blocks they set, not the optimized, internal information.
- */
- diminfo=space->select.sel_info.hslab.app_diminfo;
-
- /* Build the tables of count sizes as well as the initial offset */
- for(i=0; i<ndims; i++) {
- tmp_count[i]=diminfo[i].count;
- offset[i]=diminfo[i].start;
- } /* end for */
-
- /* We're not done with the iteration */
- done=0;
-
- /* Go iterate over the hyperslabs */
- while(done==0 && numblocks>0) {
- /* Iterate over the blocks in the fastest dimension */
- while(tmp_count[fast_dim]>0 && numblocks>0) {
-
- /* Check if we should copy this block information */
- if(startblock==0) {
- /* Copy the starting location */
- HDmemcpy(buf,offset,sizeof(hsize_t)*ndims);
- buf+=ndims;
-
- /* Compute the ending location */
- HDmemcpy(buf,offset,sizeof(hsize_t)*ndims);
- for(i=0; i<ndims; i++)
- buf[i]+=(diminfo[i].block-1);
- buf+=ndims;
-
- /* Decrement the number of blocks to retrieve */
- numblocks--;
- } /* end if */
- else
- startblock--;
-
- /* 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 && numblocks>0) {
- /* Reset the block counts */
- tmp_count[fast_dim]=diminfo[fast_dim].count;
-
- /* Bubble up the decrement to the slower changing dimensions */
- temp_dim=fast_dim-1;
- while(temp_dim>=0 && done==0) {
- /* Decrement the block count */
- tmp_count[temp_dim]--;
-
- /* 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=1;
-
- /* 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 */
-
- /* Re-compute offset array */
- for(i=0; i<ndims; i++) {
- temp_off=diminfo[i].start+diminfo[i].stride*(diminfo[i].count-tmp_count[i]);
- offset[i]=temp_off;
- } /* end for */
- } /* end while */
- } /* end if */
- else {
- ret_value=H5S_hyper_span_blocklist(space->select.sel_info.hslab.span_lst,start,end,(hsize_t)0,&startblock,&numblocks,&buf);
- } /* end else */
-
- FUNC_LEAVE (ret_value);
-} /* H5S_get_select_hyper_blocklist() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5Sget_select_hyper_blocklist
- PURPOSE
- Get the list of hyperslab blocks currently selected
- USAGE
- herr_t H5Sget_select_hyper_blocklist(dsid, startblock, numblocks, buf)
- hid_t dsid; IN: Dataspace ID of selection to query
- hsize_t startblock; IN: Hyperslab block to start with
- hsize_t numblocks; IN: Number of hyperslab blocks to get
- hsize_t *buf; OUT: List of hyperslab blocks selected
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Puts a list of the hyperslab blocks into the user's buffer. The blocks
- start with the 'startblock'th block in the list of blocks and put
- 'numblocks' number of blocks into the user's buffer (or until the end of
- the list of blocks, whichever happen first)
- The block coordinates have the same dimensionality (rank) as the
- dataspace they are located within. The list of blocks is formatted as
- follows: <"start" coordinate> immediately followed by <"opposite" corner
- coordinate>, followed by the next "start" and "opposite" coordinate, etc.
- until all the block information requested has been put into the user's
- buffer.
- No guarantee of any order of the blocks is implied.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, hsize_t *buf)
-{
- H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_API(H5Sget_select_hyper_blocklist, FAIL);
- H5TRACE4("e","ihh*h",spaceid,startblock,numblocks,buf);
-
- /* Check args */
- if(buf==NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
- if (H5I_DATASPACE != H5I_get_type(spaceid) ||
- NULL == (space=H5I_object(spaceid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- if(space->select.type!=H5S_SEL_HYPERSLABS)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
-
- /* Go get the correct number of blocks */
- if(numblocks>0)
- ret_value = H5S_get_select_hyper_blocklist(space,startblock,numblocks,buf);
- else
- ret_value=SUCCEED; /* Successfully got 0 blocks... */
-
- FUNC_LEAVE (ret_value);
-} /* H5Sget_select_hyper_blocklist() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_get_select_elem_pointlist
- PURPOSE
- Get the list of element points currently selected
- USAGE
- herr_t H5S_get_select_elem_pointlist(space, hsize_t *buf)
- H5S_t *space; IN: Dataspace pointer of selection to query
- hsize_t startpoint; IN: Element point to start with
- hsize_t numpoints; IN: Number of element points to get
- hsize_t *buf; OUT: List of element points selected
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Puts a list of the element points into the user's buffer. The points
- start with the 'startpoint'th block in the list of points and put
- 'numpoints' number of points into the user's buffer (or until the end of
- the list of points, whichever happen first)
- The point coordinates have the same dimensionality (rank) as the
- dataspace they are located within. The list of points is formatted as
- follows: <coordinate> followed by the next coordinate, etc. until all the
- point information in the selection have been put into the user's buffer.
- The points are returned in the order they will be interated through
- when a selection is read/written from/to disk.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf)
-{
- H5S_pnt_node_t *node; /* Point node */
- int rank; /* Dataspace rank */
- herr_t ret_value=SUCCEED; /* return value */
-
- FUNC_ENTER_NOINIT(H5S_get_select_elem_pointlist);
-
- assert(space);
- assert(buf);
-
- /* Get the dataspace extent rank */
- rank=space->extent.u.simple.rank;
-
- /* Get the head of the point list */
- node=space->select.sel_info.pnt_lst->head;
-
- /* Iterate to the first point to return */
- while(node!=NULL && startpoint>0) {
- startpoint--;
- node=node->next;
- } /* end while */
-
- /* Iterate through the node, copying each hyperslab's information */
- while(node!=NULL && numpoints>0) {
- HDmemcpy(buf,node->pnt,sizeof(hsize_t)*rank);
- buf+=rank;
- numpoints--;
- node=node->next;
- } /* end while */
-
- FUNC_LEAVE (ret_value);
-} /* H5Sget_select_elem_pointlist() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5Sget_select_elem_pointlist
- PURPOSE
- Get the list of element points currently selected
- USAGE
- herr_t H5Sget_select_elem_pointlist(dsid, hsize_t *buf)
- hid_t dsid; IN: Dataspace ID of selection to query
- hsize_t startpoint; IN: Element point to start with
- hsize_t numpoints; IN: Number of element points to get
- hsize_t *buf; OUT: List of element points selected
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Puts a list of the element points into the user's buffer. The points
- start with the 'startpoint'th block in the list of points and put
- 'numpoints' number of points into the user's buffer (or until the end of
- the list of points, whichever happen first)
- The point coordinates have the same dimensionality (rank) as the
- dataspace they are located within. The list of points is formatted as
- follows: <coordinate> followed by the next coordinate, etc. until all the
- point information in the selection have been put into the user's buffer.
- The points are returned in the order they will be interated through
- when a selection is read/written from/to disk.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, hsize_t *buf)
-{
- H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_API(H5Sget_select_elem_pointlist, FAIL);
- H5TRACE4("e","ihh*h",spaceid,startpoint,numpoints,buf);
-
- /* Check args */
- if(buf==NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
- if (H5I_DATASPACE != H5I_get_type(spaceid) ||
- NULL == (space=H5I_object(spaceid))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- if(space->select.type!=H5S_SEL_POINTS)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection");
-
- ret_value = H5S_get_select_elem_pointlist(space,startpoint,numpoints,buf);
-
- FUNC_LEAVE (ret_value);
-} /* H5Sget_select_elem_pointlist() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_get_select_bounds
- PURPOSE
- Gets the bounding box containing the selection.
- USAGE
- herr_t H5S_get_select_bounds(space, hsize_t *start, hsize_t *end)
- H5S_t *space; IN: Dataspace pointer of selection to query
- hsize_t *start; OUT: Starting coordinate of bounding box
- hsize_t *end; OUT: Opposite coordinate of bounding box
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Retrieves the bounding box containing the current selection and places
- it into the user's buffers. The start and end buffers must be large
- enough to hold the dataspace rank number of coordinates. The bounding box
- exactly contains the selection, ie. if a 2-D element selection is currently
- defined with the following points: (4,5), (6,8) (10,7), the bounding box
- with be (4, 5), (10, 8). Calling this function on a "none" selection
- returns fail.
- The bounding box calculations _does_ include the current offset of the
- selection within the dataspace extent.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S_get_select_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
-{
- int rank; /* Dataspace rank */
- int i; /* index variable */
- herr_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOINIT(H5S_get_select_bounds);
-
- assert(space);
- assert(start);
- assert(end);
-
- /* Set the start and end arrays up */
- rank=space->extent.u.simple.rank;
- for(i=0; i<rank; i++) {
- start[i]=UINT_MAX;
- end[i]=0;
- } /* end for */
-
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_bounds(space,start,end);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_bounds(space,start,end);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=H5S_all_bounds(space,start,end);
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- FUNC_LEAVE (ret_value);
-} /* H5S_get_select_bounds() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5Sget_select_bounds
PURPOSE
Gets the bounding box containing the selection.
@@ -1168,12 +295,10 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end)
/* Check args */
if(start==NULL || end==NULL)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
- if (H5I_DATASPACE != H5I_get_type(spaceid) ||
- NULL == (space=H5I_object(spaceid))) {
+ if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid)))
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- ret_value = H5S_get_select_bounds(space,start,end);
+ ret_value = (*space->select.bounds)(space,start,end);
FUNC_LEAVE (ret_value);
} /* H5Sget_select_bounds() */
@@ -1181,112 +306,6 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end)
/*--------------------------------------------------------------------------
NAME
- H5S_select_contiguous
- PURPOSE
- Check if the selection is contiguous within the dataspace extent.
- USAGE
- htri_t H5S_select_contiguous(space)
- H5S_t *space; IN: Dataspace pointer to check
- RETURNS
- TRUE/FALSE/FAIL
- DESCRIPTION
- Checks to see if the current selection in the dataspace is contiguous.
- This is primarily used for reading the entire selection in one swoop.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-htri_t
-H5S_select_contiguous(const H5S_t *space)
-{
- htri_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOAPI(H5S_select_contiguous, FAIL);
-
- assert(space);
-
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_select_contiguous(space);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_select_contiguous(space);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=TRUE;
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- ret_value=FALSE;
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- FUNC_LEAVE (ret_value);
-} /* H5S_select_contiguous() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_select_iter_init
- PURPOSE
- Construct an iterator for a dataspace & selection
- USAGE
- herr_t H5S_select_iter_init(space, elmt_size, iter)
- H5S_t *space; IN: Dataspace object containing selection to iterate over
- size_t elmt_size; IN: Size of element in dataspace
- H5S_sel_iter_t *iter; OUT: Iterator to initialize
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Genericly initializes an iterator, based on the type of selection in the
- dataspace.
---------------------------------------------------------------------------*/
-herr_t
-H5S_select_iter_init(const H5S_t *space, size_t elmt_size, H5S_sel_iter_t *iter)
-{
- herr_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOINIT(H5S_select_iter_init);
-
- assert(space);
- assert(iter);
-
- /* Initialize iterator */
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_init(space,elmt_size,iter);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_init(space,elmt_size,iter);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=H5S_all_init(space,elmt_size,iter);
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- ret_value=FALSE;
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- FUNC_LEAVE (ret_value);
-} /* end H5S_select_iter_init() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5S_select_iterate
PURPOSE
Iterate over the selected elements in a memory buffer.
@@ -1372,11 +391,11 @@ H5S_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate selection iterator");
/* Initialize iterator */
- if (H5S_select_iter_init(space, elmt_size, iter)<0)
+ if ((*space->select.iter_init)(space, elmt_size, iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator");
/* Get the number of elements in selection */
- if((nelmts = H5S_get_select_npoints(space))<0)
+ if((nelmts = (*space->select.get_npoints)(space))<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected");
/* Get the rank of the dataspace */
@@ -1394,7 +413,7 @@ H5S_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op,
/* Loop, while elements left in selection */
while(max_bytes>0 && user_ret==0) {
/* Get the sequences of bytes */
- if(H5S_select_get_seq_list(0,space,iter,elmt_size,vector_size,max_bytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,0,iter,elmt_size,vector_size,max_bytes,&nseq,&nbytes,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Loop, while sequences left to process */
@@ -1438,7 +457,7 @@ H5S_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op,
done:
/* Release selection iterator */
if(iter!=NULL) {
- if (H5S_sel_iter_release(space, iter)<0)
+ if ((*space->select.iter_release)(iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator");
H5FL_FREE(H5S_sel_iter_t,iter);
} /* end if */
@@ -1486,60 +505,6 @@ H5Sget_select_type(hid_t space_id)
/*--------------------------------------------------------------------------
NAME
- H5S_select_single
- PURPOSE
- Check if the selection is a single block within the dataspace extent.
- USAGE
- htri_t H5S_select_single(space)
- H5S_t *space; IN: Dataspace pointer to check
- RETURNS
- TRUE/FALSE/FAIL
- DESCRIPTION
- Checks to see if the current selection in the dataspace is a single block.
- This is primarily used for reading the entire selection in one swoop.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-htri_t
-H5S_select_single(const H5S_t *space)
-{
- htri_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOAPI(H5S_select_single, FAIL);
-
- /* Check args */
- assert(space);
-
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_select_single(space);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_select_single(space);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=TRUE;
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- ret_value=FALSE;
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- }
-
- FUNC_LEAVE (ret_value);
-} /* H5S_select_single() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5S_select_shape_same
PURPOSE
Check if two selections are the same shape
@@ -1605,6 +570,10 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
elmts1=1;
break;
+ case H5S_SEL_NONE:
+ elmts1=0;
+ break;
+
default:
assert(0 && "Invalid selection type!");
} /* end switch */
@@ -1636,6 +605,10 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
elmts2=1;
break;
+ case H5S_SEL_NONE:
+ elmts2=0;
+ break;
+
default:
assert(0 && "Invalid selection type!");
} /* end switch */
@@ -1652,63 +625,6 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_select_regular
- PURPOSE
- Check if a selection is "regular"
- USAGE
- htri_t H5S_select_regular(space)
- const H5S_t *space; IN: Dataspace pointer to check
- RETURNS
- TRUE/FALSE/FAIL
- DESCRIPTION
- Checks to see if the current selection in a dataspace is the a regular
- pattern.
- This is primarily used for reading the entire selection in one swoop.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-htri_t
-H5S_select_regular(const H5S_t *space)
-{
- htri_t ret_value=FAIL; /* return value */
-
- FUNC_ENTER_NOAPI(H5S_select_regular, FAIL);
-
- /* Check args */
- assert(space);
-
- /* Check for a "regular" selection */
- /* [Defer (mostly) to the selection routines] */
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_select_regular(space);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_select_regular(space);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=TRUE;
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- ret_value=FALSE;
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- break;
- } /* end switch */
-
- FUNC_LEAVE (ret_value);
-} /* H5S_select_regular() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5S_select_fill
PURPOSE
Fill a selection in memory with a value
@@ -1779,11 +695,11 @@ H5S_select_fill(void *_fill, size_t fill_size, const H5S_t *space, void *_buf)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate selection iterator");
/* Initialize iterator */
- if (H5S_select_iter_init(space, fill_size, iter)<0)
+ if ((*space->select.iter_init)(space, fill_size, iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator");
/* Get the number of elements in selection */
- if((nelmts = H5S_get_select_npoints(space))<0)
+ if((nelmts = (*space->select.get_npoints)(space))<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected");
/* Compute the number of bytes to process */
@@ -1793,7 +709,7 @@ H5S_select_fill(void *_fill, size_t fill_size, const H5S_t *space, void *_buf)
/* Loop, while elements left in selection */
while(max_bytes>0) {
/* Get the sequences of bytes */
- if(H5S_select_get_seq_list(0,space,iter,fill_size,vector_size,max_bytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,0,iter,fill_size,vector_size,max_bytes,&nseq,&nbytes,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Loop over sequences */
@@ -1813,7 +729,7 @@ H5S_select_fill(void *_fill, size_t fill_size, const H5S_t *space, void *_buf)
done:
/* Release selection iterator */
if(iter!=NULL) {
- if (H5S_sel_iter_release(space, iter)<0)
+ if ((*space->select.iter_release)(iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator");
H5FL_FREE(H5S_sel_iter_t,iter);
} /* end if */
@@ -1832,151 +748,6 @@ done:
} /* H5S_select_fill() */
-/*--------------------------------------------------------------------------
- NAME
- H5S_select_get_seq_list
- PURPOSE
- Create a list of offsets & lengths for a selection
- USAGE
- herr_t H5S_select_get_file_list(flags,space,iter,flag,elem_size,maxseq,maxbytes,nseq,off,len)
- unsigned flags; IN: Flags for extra information about operation
- H5S_t *space; IN: Dataspace containing selection to use.
- H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last
- position of interest in selection.
- unsigned flag; IN: Flag to indicate whether to update the
- iterator or not.
- size_t elem_size; IN: Size of an element
- size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxbytes; IN: Maximum number of bytes to include in the
- generated sequences
- size_t *nseq; OUT: Actual number of sequences generated
- hsize_t *off; OUT: Array of offsets
- hsize_t *len; OUT: Array of lengths
- RETURNS
- Non-negative on success/Negative on failure.
- DESCRIPTION
- Use the selection in the dataspace to generate a list of byte offsets and
- lengths for the region(s) selected. Start/Restart from the position in the
- ITER parameter. Updating the iterator is controlled with the FLAG
- parameter. The number of sequences generated is limited by the MAXSEQ
- parameter and the number of sequences actually generated is stored in the
- NSEQ parameter.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S_select_get_seq_list(unsigned flags, const H5S_t *space,H5S_sel_iter_t *iter,
- size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
- hsize_t *off, size_t *len)
-{
- herr_t ret_value=SUCCEED; /* return value */
-
- FUNC_ENTER_NOAPI (H5S_select_get_seq_list, FAIL);
-
- /* Check args */
- assert(space);
- assert(iter);
- assert(elem_size>0);
- assert(maxseq>0);
- assert(maxbytes>0);
- assert(nseq);
- assert(off);
- assert(len);
-
- /* Get the list of sequences for each type selection */
- /* [Defer (mostly) to the selection routines] */
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_select_get_seq_list(flags,space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_select_get_seq_list(flags,space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=H5S_all_select_get_seq_list(flags,space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len);
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- *nseq=0; /* Set the number of sequences generated */
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- assert(0 && "Invalid selection type!");
- break;
- } /* end switch */
-
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
-} /* H5S_select_get_seq_list() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5S_select_favail
- *
- * Purpose: Figure out the optimal number of elements to transfer to/from
- * the file.
- *
- * Return: non-negative number of elements on success, zero on
- * failure.
- *
- * Programmer: Quincey Koziol
- * Wednesday, July 24, 2002
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-hsize_t
-H5S_select_favail(const H5S_t *space, const H5S_sel_iter_t *iter, hsize_t max)
-{
- hsize_t ret_value=0; /* Return value */
-
- FUNC_ENTER_NOAPI (H5S_select_favail, 0);
-
- /* Check args */
- assert(space);
- assert(iter);
- assert(max>0);
-
- /* Get the number of elements to transfer for each type of selection */
- /* [Defer (mostly) to the selection routines] */
- switch(space->select.type) {
- case H5S_SEL_POINTS: /* Sequence of points selected */
- ret_value=H5S_point_favail(space,iter,max);
- break;
-
- case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
- ret_value=H5S_hyper_favail(space,iter,max);
- break;
-
- case H5S_SEL_ALL: /* Entire extent selected */
- ret_value=H5S_all_favail(space,iter,max);
- break;
-
- case H5S_SEL_NONE: /* Nothing selected */
- ret_value=0; /* Set the number of elements to transfer */
- break;
-
- case H5S_SEL_ERROR:
- case H5S_SEL_N:
- assert(0 && "Invalid selection type!");
- break;
- } /* end switch */
-
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
-} /* H5S_select_favail() */
-
-
/*-------------------------------------------------------------------------
* Function: H5S_select_fscat
*
@@ -1998,7 +769,7 @@ done:
herr_t
H5S_select_fscat (H5F_t *f, const struct H5O_layout_t *layout,
H5P_genplist_t *dc_plist, size_t elmt_size,
- const H5S_t *file_space, H5S_sel_iter_t *file_iter,
+ const H5S_t *space, H5S_sel_iter_t *iter,
hsize_t nelmts, hid_t dxpl_id, const void *_buf)
{
const uint8_t *buf=_buf; /* Alias for pointer arithmetic */
@@ -2017,8 +788,8 @@ H5S_select_fscat (H5F_t *f, const struct H5O_layout_t *layout,
assert (f);
assert (layout);
assert (elmt_size>0);
- assert (file_space);
- assert (file_iter);
+ assert (space);
+ assert (iter);
assert (nelmts>0);
assert (_buf);
@@ -2040,11 +811,11 @@ H5S_select_fscat (H5F_t *f, const struct H5O_layout_t *layout,
/* Loop until all elements are written */
while(maxbytes>0) {
/* Get list of sequences for selection to write */
- if(H5S_select_get_seq_list(H5S_GET_SEQ_LIST_SORTED,file_space,file_iter,elmt_size,vector_size,maxbytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,H5S_GET_SEQ_LIST_SORTED,iter,elmt_size,vector_size,maxbytes,&nseq,&nbytes,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Write sequence list out */
- if (H5F_seq_writev(f, dxpl_id, layout, dc_plist, file_space, elmt_size, nseq, len, off, buf)<0)
+ if (H5F_seq_writev(f, dxpl_id, layout, dc_plist, space, elmt_size, nseq, len, off, buf)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error");
/* Update buffer */
@@ -2090,8 +861,8 @@ done:
hsize_t
H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout,
H5P_genplist_t *dc_plist,
- size_t elmt_size, const H5S_t *file_space,
- H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id,
+ size_t elmt_size, const H5S_t *space,
+ H5S_sel_iter_t *iter, hsize_t nelmts, hid_t dxpl_id,
void *_buf/*out*/)
{
uint8_t *buf=_buf; /* Alias for pointer arithmetic */
@@ -2110,8 +881,8 @@ H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout,
assert (f);
assert (layout);
assert (elmt_size>0);
- assert (file_space);
- assert (file_iter);
+ assert (space);
+ assert (iter);
assert (nelmts>0);
assert (_buf);
@@ -2133,11 +904,11 @@ H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout,
/* Loop until all elements are written */
while(maxbytes>0) {
/* Get list of sequences for selection to write */
- if(H5S_select_get_seq_list(H5S_GET_SEQ_LIST_SORTED,file_space,file_iter,elmt_size,vector_size,maxbytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,H5S_GET_SEQ_LIST_SORTED,iter,elmt_size,vector_size,maxbytes,&nseq,&nbytes,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed");
/* Read sequence list in */
- if (H5F_seq_readv(f, dxpl_id, layout, dc_plist, file_space, elmt_size, nseq, len, off, buf)<0)
+ if (H5F_seq_readv(f, dxpl_id, layout, dc_plist, space, elmt_size, nseq, len, off, buf)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error");
/* Update buffer */
@@ -2219,7 +990,7 @@ H5S_select_mscat (const void *_tscat_buf, size_t elmt_size, const H5S_t *space,
/* Loop until all elements are written */
while(maxbytes>0) {
/* Get list of sequences for selection to write */
- if(H5S_select_get_seq_list(0,space,iter,elmt_size,vector_size,maxbytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,0,iter,elmt_size,vector_size,maxbytes,&nseq,&nbytes,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed");
/* Loop, while sequences left to process */
@@ -2311,7 +1082,7 @@ H5S_select_mgath (const void *_buf, size_t elmt_size, const H5S_t *space,
/* Loop until all elements are written */
while(maxbytes>0) {
/* Get list of sequences for selection to write */
- if(H5S_select_get_seq_list(0,space,iter,elmt_size,vector_size,maxbytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,0,iter,elmt_size,vector_size,maxbytes,&nseq,&nbytes,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed");
/* Loop, while sequences left to process */
@@ -2404,7 +1175,7 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate selection iterator");
/* Initialize file iterator */
- if (H5S_select_iter_init(file_space, elmt_size, file_iter)<0)
+ if ((*file_space->select.iter_init)(file_space, elmt_size, file_iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator");
/* Allocate memory iterator */
@@ -2412,11 +1183,11 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate selection iterator");
/* Initialize memory iterator */
- if (H5S_select_iter_init(mem_space, elmt_size, mem_iter)<0)
+ if ((*mem_space->select.iter_init)(mem_space, elmt_size, mem_iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator");
/* Get number of bytes in selection */
- maxbytes=H5S_get_select_npoints(file_space)*elmt_size;
+ maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
/* Initialize sequence counts */
curr_mem_seq=curr_file_seq=0;
@@ -2427,7 +1198,7 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
/* Check if more file sequences are needed */
if(curr_file_seq>=file_nseq) {
/* Get sequences for file selection */
- if(H5S_select_get_seq_list(H5S_GET_SEQ_LIST_SORTED,file_space,file_iter,elmt_size,vector_size,maxbytes,&file_nseq,&file_nbytes,file_off,file_len)<0)
+ if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,file_iter,elmt_size,vector_size,maxbytes,&file_nseq,&file_nbytes,file_off,file_len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Start at the beginning of the sequences again */
@@ -2437,7 +1208,7 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
/* Check if more memory sequences are needed */
if(curr_mem_seq>=mem_nseq) {
/* Get sequences for memory selection */
- if(H5S_select_get_seq_list(0,mem_space,mem_iter,elmt_size,vector_size,maxbytes,&mem_nseq,&mem_nbytes,mem_off,mem_len)<0)
+ if((*mem_space->select.get_seq_list)(mem_space,0,mem_iter,elmt_size,vector_size,maxbytes,&mem_nseq,&mem_nbytes,mem_off,mem_len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Start at the beginning of the sequences again */
@@ -2544,14 +1315,14 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
done:
/* Release file selection iterator */
if(file_iter!=NULL) {
- if (H5S_sel_iter_release(file_space, file_iter)<0)
+ if ((*file_space->select.iter_release)(file_iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator");
H5FL_FREE(H5S_sel_iter_t,file_iter);
} /* end if */
/* Release memory selection iterator */
if(mem_iter!=NULL) {
- if (H5S_sel_iter_release(mem_space, mem_iter)<0)
+ if ((*mem_space->select.iter_release)(mem_iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator");
H5FL_FREE(H5S_sel_iter_t,mem_iter);
} /* end if */
@@ -2634,7 +1405,7 @@ H5S_select_write(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate selection iterator");
/* Initialize file iterator */
- if (H5S_select_iter_init(file_space, elmt_size, file_iter)<0)
+ if ((*file_space->select.iter_init)(file_space, elmt_size, file_iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator");
/* Allocate memory iterator */
@@ -2642,11 +1413,11 @@ H5S_select_write(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate selection iterator");
/* Initialize memory iterator */
- if (H5S_select_iter_init(mem_space, elmt_size, mem_iter)<0)
+ if ((*mem_space->select.iter_init)(mem_space, elmt_size, mem_iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator");
/* Get number of bytes in selection */
- maxbytes=H5S_get_select_npoints(file_space)*elmt_size;
+ maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
/* Initialize sequence counts */
curr_mem_seq=curr_file_seq=0;
@@ -2657,7 +1428,7 @@ H5S_select_write(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
/* Check if more file sequences are needed */
if(curr_file_seq>=file_nseq) {
/* Get sequences for file selection */
- if(H5S_select_get_seq_list(H5S_GET_SEQ_LIST_SORTED,file_space,file_iter,elmt_size,vector_size,maxbytes,&file_nseq,&file_nbytes,file_off,file_len)<0)
+ if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,file_iter,elmt_size,vector_size,maxbytes,&file_nseq,&file_nbytes,file_off,file_len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Start at the beginning of the sequences again */
@@ -2667,7 +1438,7 @@ H5S_select_write(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
/* Check if more memory sequences are needed */
if(curr_mem_seq>=mem_nseq) {
/* Get sequences for memory selection */
- if(H5S_select_get_seq_list(0,mem_space,mem_iter,elmt_size,vector_size,maxbytes,&mem_nseq,&mem_nbytes,mem_off,mem_len)<0)
+ if((*mem_space->select.get_seq_list)(mem_space,0,mem_iter,elmt_size,vector_size,maxbytes,&mem_nseq,&mem_nbytes,mem_off,mem_len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Start at the beginning of the sequences again */
@@ -2774,14 +1545,14 @@ H5S_select_write(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
done:
/* Release file selection iterator */
if(file_iter!=NULL) {
- if (H5S_sel_iter_release(file_space, file_iter)<0)
+ if ((*file_space->select.iter_release)(file_iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator");
H5FL_FREE(H5S_sel_iter_t,file_iter);
} /* end if */
/* Release memory selection iterator */
if(mem_iter!=NULL) {
- if (H5S_sel_iter_release(mem_space, mem_iter)<0)
+ if ((*mem_space->select.iter_release)(mem_iter)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator");
H5FL_FREE(H5S_sel_iter_t,mem_iter);
} /* end if */