summaryrefslogtreecommitdiffstats
path: root/src/H5D.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2002-02-07 20:20:40 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2002-02-07 20:20:40 (GMT)
commit472c42233cbd207bb0c3f97b12ee57dd5cec030b (patch)
treec5dfea35d484215d7ad0811cd15184585400b183 /src/H5D.c
parentd8626dd40f82baf616134cfd179b894429fce501 (diff)
downloadhdf5-472c42233cbd207bb0c3f97b12ee57dd5cec030b.zip
hdf5-472c42233cbd207bb0c3f97b12ee57dd5cec030b.tar.gz
hdf5-472c42233cbd207bb0c3f97b12ee57dd5cec030b.tar.bz2
[svn-r4921]
Description: modified the below files to inlude a new public function H5Dset_extend, similar to H5Dextend, but it can lower the dimension this function requires 2 more new private functions: H5D_set_extend H5S_set_extend Platforms tested:
Diffstat (limited to 'src/H5D.c')
-rw-r--r--src/H5D.c137
1 files changed, 137 insertions, 0 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 3b15bae..bb4ba39 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1275,6 +1275,139 @@ H5Dextend(hid_t dset_id, const hsize_t *size)
FUNC_LEAVE (SUCCEED);
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Dset_extend
+ *
+ * Purpose: Modifies the dimensions of a dataset, based on H5Dextend
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 26, 2001
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *
+ *-------------------------------------------------------------------------
+ */
+
+
+herr_t
+H5Dset_extend(hid_t dset_id, const hsize_t *size)
+{
+ H5D_t *dset = NULL;
+
+ FUNC_ENTER (H5Dset_extend, FAIL);
+ H5TRACE2("e","i*h",dset_id,size);
+
+ /* Check args */
+ if (H5I_DATASET!=H5I_get_type(dset_id) ||
+ NULL==(dset=H5I_object(dset_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ }
+ if (!size) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified");
+ }
+
+ /* Increase size */
+ if (H5D_set_extend (dset, size)<0) {
+ HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to extend dataset");
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_set_extend
+ *
+ * Purpose: Same as H5D_extend, allows change to a lower dimension, calls H5S_modify
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 26, 2001
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5D_set_extend (H5D_t *dataset, const hsize_t *size)
+{
+ herr_t changed, ret_value=FAIL;
+ H5S_t *space = NULL;
+ H5O_fill_t fill;
+ H5P_genplist_t *plist; /* Property list */
+
+ FUNC_ENTER (H5D_set_extend, FAIL);
+
+ /* Check args */
+ assert (dataset);
+ assert (size);
+
+ /*
+ * NOTE: Restrictions on extensions were checked when the dataset was
+ * created. All extensions are allowed here since none should be
+ * able to muck things up.
+ */
+
+ /* Increase the size of the data space */
+ if (NULL==(space=H5S_read (&(dataset->ent))))
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data space info from dataset header");
+ if ((changed = H5S_set_extend (space, size))<0)
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to increase size of data space");
+
+ if (changed>0){
+ /* Save the new dataspace in the file if necessary */
+ if (H5S_modify (&(dataset->ent), space)<0)
+ HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace");
+
+ /* Initialize the new parts of the dataset */
+#ifdef LATER
+ if (H5S_select_all(space)<0 ||
+ H5S_select_hyperslab(space, H5S_SELECT_DIFF, zero, NULL, old_dims, NULL)<0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to select new extents for fill value");
+#else
+ /*
+ * We don't have the H5S_SELECT_DIFF operator yet. We really only
+ * need it for contiguous datasets because the chunked datasets will
+ * either fill on demand during I/O or attempt a fill of all chunks.
+ */
+ if (NULL == (plist = H5I_object(dataset->dcpl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list");
+ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value");
+ if(H5D_CONTIGUOUS == dataset->layout.type && fill.buf)
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to select fill value region");
+#endif
+ if (H5D_init_storage(dataset, space)<0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value");
+ } /* end if */
+
+ ret_value = SUCCEED;
+
+done:
+ H5S_close(space);
+ FUNC_LEAVE (ret_value);
+}
+
+
+
+
+
/*-------------------------------------------------------------------------
* Function: H5D_new
@@ -2938,6 +3071,10 @@ done:
H5S_close(space);
FUNC_LEAVE (ret_value);
}
+
+
+
+
/*-------------------------------------------------------------------------