summaryrefslogtreecommitdiffstats
path: root/src/H5Sselect.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1998-11-25 00:29:09 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1998-11-25 00:29:09 (GMT)
commit5d0938aba6d4b99640f57abc41441e7af68a1c2c (patch)
tree813480254a0f728a6eb75ac1478320af1524de00 /src/H5Sselect.c
parent0dfd13d13b2587cbdc3388a205159c25eb83588f (diff)
downloadhdf5-5d0938aba6d4b99640f57abc41441e7af68a1c2c.zip
hdf5-5d0938aba6d4b99640f57abc41441e7af68a1c2c.tar.gz
hdf5-5d0938aba6d4b99640f57abc41441e7af68a1c2c.tar.bz2
[svn-r947] Lots of patches to enable dataset region references. The testing for these
need to be finished and checked in still.
Diffstat (limited to 'src/H5Sselect.c')
-rw-r--r--src/H5Sselect.c279
1 files changed, 209 insertions, 70 deletions
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index c97a350..bfbe27f 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -335,7 +335,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab lo bound information");
} /* end if */
-#ifndef OLD_WAY
/* Generate list of blocks to add/remove based on selection operation */
switch(op) {
case H5S_SELECT_SET:
@@ -421,40 +420,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
#ifdef QAK
printf("%s: check 3.0\n",FUNC);
#endif /* QAK */
-#else /* OLD_WAY */
- /* Add hyperslab to selection */
- if(contig) { /* Check for trivial case */
-
- /* Account for strides & blocks being equal, but larger than one */
- /* (Why someone would torture us this way, I don't know... -QAK :-) */
- for(i=0; i<space->extent.u.simple.rank; i++)
- slab[i]=count[i]*stride[i];
-
- /* Add the contiguous hyperslab to the selection */
- if(H5S_hyper_add(space,start,(const hsize_t *)slab)<0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab");
- }
- } else {
- /* Build the slice sizes for each dimension */
- for(i=0, acc=1; i<space->extent.u.simple.rank; i++) {
- slice[i]=acc;
- acc*=count[i];
- } /* end for */
-
- /* Step through all the blocks to add */
- /* (reuse the count in ACC above) */
- for(i=0; i<(int)acc; i++) {
- /* Build the location of the block */
- for(j=0; j<space->extent.u.simple.rank; j++)
- slab[j]=start[j]+((i/slice[j])%count[j])*stride[j];
-
- /* Add the block to the list of hyperslab selections */
- if(H5S_hyper_add(space,(const hssize_t *)slab, (const hsize_t *)block)<0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab");
- } /* end if */
- } /* end for */
- } /* end if */
-#endif /* OLD_WAY */
/* Set selection type */
space->select.type=H5S_SEL_HYPERSLABS;
@@ -468,15 +433,14 @@ done:
if(_block!=NULL) H5TB_release_buf(block_id);
FUNC_LEAVE (ret_value);
}
-
/*--------------------------------------------------------------------------
NAME
- H5Sselect_elements
+ H5S_select_elements
PURPOSE
Specify a series of elements in the dataspace to select
USAGE
- herr_t H5Sselect_elements(dsid, op, num_elem, coord)
+ 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.
@@ -500,26 +464,18 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elem,
+herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem,
const hssize_t **coord)
{
- H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* return value */
- FUNC_ENTER (H5Sselect_elements, FAIL);
+ FUNC_ENTER (H5S_select_elements, 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(coord==NULL || num_elem==0) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified");
- } /* end if */
- if(op!=H5S_SELECT_SET) {
- HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL,
- "operations other than H5S_SELECT_SET not supported currently");
- } /* end if */
+ assert(space);
+ assert(num_elem);
+ assert(coord);
+ assert(op==H5S_SELECT_SET);
#ifdef QAK
printf("%s: check 1.0\n",FUNC);
@@ -553,7 +509,6 @@ herr_t H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elem,
/* Set selection type */
space->select.type=H5S_SEL_POINTS;
- ret_value=SUCCEED;
#ifdef QAK
printf("%s: check 4.0\n",FUNC);
#endif /* QAK */
@@ -564,11 +519,109 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5Sselect_elements
+ PURPOSE
+ Specify a series of elements in the dataspace to select
+ USAGE
+ herr_t H5Sselect_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 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 */
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER (H5Sselect_elements, 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(coord==NULL || num_elem==0) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified");
+ } /* end if */
+ if(op!=H5S_SELECT_SET) {
+ HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL,
+ "operations other than H5S_SELECT_SET not supported currently");
+ } /* end if */
+
+ /* Call the real element selection routine */
+ 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);
+} /* H5Sselect_elements() */
+
+/*--------------------------------------------------------------------------
+ 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
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ This function selects the entire extent for a dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t H5S_select_all (H5S_t *space)
+{
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER (H5S_select_all, FAIL);
+
+ /* Check args */
+ 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 */
+
+ /* Set selection type */
+ space->select.type=H5S_SEL_ALL;
+
+done:
+ FUNC_LEAVE (ret_value);
+} /* H5S_select_all() */
+
+/*--------------------------------------------------------------------------
+ NAME
H5Sselect_all
PURPOSE
Specify the the entire extent is selected
USAGE
- herr_t H5Sselect_elements(dsid)
+ herr_t H5Sselect_all(dsid)
hid_t dsid; IN: Dataspace ID of selection to modify
RETURNS
Non-negative on success/Negative on failure
@@ -582,29 +635,62 @@ done:
herr_t H5Sselect_all (hid_t spaceid)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER (H5Sselect_all, 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");
}
/* Remove current selection first */
+ if((ret_value=H5S_select_all(space))<0) {
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
+ } /* end if */
+
+done:
+ FUNC_LEAVE (ret_value);
+} /* H5Sselect_all() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_select_none
+ PURPOSE
+ Specify that nothing is selected in the extent
+ USAGE
+ herr_t H5S_select_none(dsid)
+ hid_t dsid; IN: Dataspace ID of selection to modify
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ This function de-selects the entire extent for a dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t H5S_select_none (H5S_t *space)
+{
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER (H5S_select_none, FAIL);
+
+ /* Check args */
+ 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 */
/* Set selection type */
- space->select.type=H5S_SEL_ALL;
- ret_value=SUCCEED;
+ space->select.type=H5S_SEL_NONE;
done:
FUNC_LEAVE (ret_value);
-} /* H5Sselect_all() */
+} /* H5S_select_none() */
/*--------------------------------------------------------------------------
NAME
@@ -612,7 +698,7 @@ done:
PURPOSE
Specify that nothing is selected in the extent
USAGE
- herr_t H5Sselect_elements(dsid)
+ herr_t H5Sselect_none(dsid)
hid_t dsid; IN: Dataspace ID of selection to modify
RETURNS
Non-negative on success/Negative on failure
@@ -636,16 +722,11 @@ herr_t H5Sselect_none (hid_t spaceid)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
}
- /* Remove current selection first */
- if(H5S_select_release(space)<0) {
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL,
- "can't release hyperslab");
+ /* 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 */
- /* Set selection type */
- space->select.type=H5S_SEL_NONE;
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5Sselect_none() */
@@ -989,3 +1070,61 @@ H5S_select_serialize (const H5S_t *space, uint8_t *buf)
FUNC_LEAVE (ret_value);
} /* H5S_select_serialize() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_select_deserialize
+ PURPOSE
+ Deserialize the current selection from a user-provided buffer into a real
+ selection in the dataspace.
+ USAGE
+ herr_t H5S_select_deserialize(space, buf)
+ H5S_t *space; IN/OUT: Dataspace pointer to place selection into
+ uint8 *buf; IN: Buffer to retrieve serialized selection from
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Deserializes the current selection into a buffer. (Primarily for retrieving
+ from disk). This routine just hands off to the appropriate routine for each
+ type of selection. The format of the serialized information is shown in
+ the H5S_select_serialize() header.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_select_deserialize (H5S_t *space, const uint8_t *buf)
+{
+ const uint32_t *sel_type; /* Pointer to the selection type */
+ herr_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5S_select_deserialize, FAIL);
+
+ assert(space);
+
+ sel_type=(const uint32_t *)buf;
+ switch(*sel_type) {
+ case H5S_SEL_POINTS: /* Sequence of points selected */
+ ret_value=H5S_point_select_deserialize(space,buf);
+ break;
+
+ case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
+ ret_value=H5S_hyper_select_deserialize(space,buf);
+ break;
+
+ case H5S_SEL_ALL: /* Entire extent selected */
+ ret_value=H5S_all_select_deserialize(space,buf);
+ break;
+
+ case H5S_SEL_NONE: /* Nothing selected */
+ ret_value=H5S_none_select_deserialize(space,buf);
+ break;
+
+ case H5S_SEL_ERROR:
+ case H5S_SEL_N:
+ break;
+ }
+
+ FUNC_LEAVE (ret_value);
+} /* H5S_select_deserialize() */