summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2007-12-18 21:55:19 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2007-12-18 21:55:19 (GMT)
commite27b64fc6a20e69eb13bef964497056eeac8b5ea (patch)
tree2e037e96dc74652718547f7e7360c25ea7fdb5e8
parenta3fb4efb4dc0194c0d072716f7fb80cdf875805e (diff)
downloadhdf5-e27b64fc6a20e69eb13bef964497056eeac8b5ea.zip
hdf5-e27b64fc6a20e69eb13bef964497056eeac8b5ea.tar.gz
hdf5-e27b64fc6a20e69eb13bef964497056eeac8b5ea.tar.bz2
[svn-r14351] Some modification of the code for the filter of modifying dataset's datatype.
Tested on smirom, kagiso, and linew.
-rw-r--r--src/H5Dcompact.c1
-rw-r--r--src/H5Dcontig.c3
-rw-r--r--src/H5Dio.c230
-rw-r--r--src/H5Distore.c31
-rw-r--r--src/H5T.c30
-rw-r--r--src/H5Tvlen.c8
-rw-r--r--test/change_dtypes.c4
7 files changed, 96 insertions, 211 deletions
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index 2ffeb1e..2764f2d 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -492,6 +492,7 @@ H5D_compact_copy_conv(const H5D_t *dset_src, const H5D_t *dset_dst,
/* Copy the data from the conversion buffer to the destination */
dset_dst->shared->layout.u.compact.size = total_dst_nbytes;
+ H5MM_xfree(dset_dst->shared->layout.u.compact.buf);
dset_dst->shared->layout.u.compact.buf = (void*)H5MM_malloc((size_t)total_dst_nbytes);
HDmemcpy(dset_dst->shared->layout.u.compact.buf, buf, (size_t)total_dst_nbytes);
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index 065450f..913aa13 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -1256,7 +1256,6 @@ H5D_contig_copy_conv(H5F_t *file, const H5D_t *dset_src, const H5D_t *dset_dst,
size_t target_size; /* Desired buffer size */
void *buf = NULL; /* Buffer for copying data */
void *bkg = NULL; /* Temporary buffer for copying data */
- void *reclaim_buf = NULL; /* Buffer for reclaiming data */
H5S_t *buf_space = NULL; /* Dataspace describing buffer */
hsize_t buf_dim; /* Dimension for buffer */
hbool_t is_vlen = FALSE; /* Flag to indicate VL type */
@@ -1387,8 +1386,6 @@ H5D_contig_copy_conv(H5F_t *file, const H5D_t *dset_src, const H5D_t *dset_dst,
done:
if(buf)
H5FL_BLK_FREE(type_conv, buf);
- if(reclaim_buf)
- H5FL_BLK_FREE(type_conv, reclaim_buf);
if(bkg)
H5FL_BLK_FREE(type_conv, bkg);
if(is_vlen && buf_space) {
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 137f161..e05836d 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -89,10 +89,6 @@ static herr_t H5D_compound_opt_read(size_t nelmts, const H5S_t *mem_space,
void *user_buf/*out*/);
static herr_t H5D_compound_opt_write(size_t nelmts, hid_t src_id, hid_t dst_id,
void *data_buf);
-static herr_t H5D_modify_dtype_with_filter(H5F_t *file, H5D_t *dataset,
- hid_t type_id, H5T_t *type, hid_t dxpl_id);
-static herr_t H5D_modify_dtype_without_filter(H5F_t *file, H5D_t *dataset,
- hid_t type_id, H5T_t *type, hid_t dxpl_id);
static herr_t H5D_modify_dtype_update_fill(H5F_t *file, H5D_t *dataset, struct H5O_t *oh,
hid_t dxpl_id);
@@ -2404,7 +2400,6 @@ H5Dmodify_dtype(hid_t dset_id, hid_t new_type_id)
/* If the new type is the same as the current, simply finish it */
if(0 == H5T_cmp(dset->shared->type, new_type, FALSE))
HGOTO_DONE(SUCCEED)
- /*HGOTO_ERROR(H5E_DATASET, H5E_CANTMODIFY, FAIL, "new datatype is the same as the datatype of the dataset")*/
/* Check if the datatype is valid for this operation */
if(TRUE != H5T_dtype_is_valid(dset->shared->type, new_type))
@@ -2424,6 +2419,12 @@ done:
*
* Purpose: Private function for H5Dmodify_dtype. It handles the
* dataset differently depending on the situation.
+ * For chunked dataset with the filter of dtype modification
+ * disabled or contiguous or compact dataset, this function
+ * modifies the data type of the dataset and converts the
+ * data according to the new data type.
+ * For chunked dataset with the filter of dtype modification
+ * enabled. It only modifies the data type of the dataset.
*
* Return: Success: Non-negative
*
@@ -2431,14 +2432,21 @@ done:
*
* Programmer: Raymond Lu
* Tuesday, 25 Sept. 2007
- *
*-------------------------------------------------------------------------
*/
herr_t
H5D_modify_dtype(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_t *type, hid_t dxpl_id)
{
+ hid_t fid = -1; /* File ID for filters */
hbool_t filter_enabled = FALSE; /* Flag for the datatype modification filter */
H5P_genplist_t *plist; /* Property list pointer */
+ H5D_t *new_dset;
+ H5O_fill_t *fill_prop; /* Fill value property */
+ H5O_copy_t cp_info;
+ struct H5O_t *oh = NULL; /* Pointer to dataset's object header */
+ hbool_t has_data = TRUE; /* The flag to indicate data exists in dset */
+ hbool_t link_adjacent = FALSE;
+ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
herr_t ret = SUCCEED; /* Return value */
@@ -2457,7 +2465,6 @@ H5D_modify_dtype(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_t *type, hid_t
HGOTO_ERROR(H5E_DATASET, H5E_BADATOM, FAIL, "can't find object for ID")
H5E_BEGIN_TRY {
- /*ret = H5Pget_filter_by_id(dataset->shared->dcpl_id, H5Z_FILTER_DTYPE_MODIFY, NULL, NULL, NULL, (size_t)0, NULL, NULL);*/
ret = H5P_get_filter_by_id(plist, H5Z_FILTER_DTYPE_MODIFY, NULL, NULL, NULL, (size_t)0, NULL, NULL);
} H5E_END_TRY;
@@ -2465,63 +2472,16 @@ H5D_modify_dtype(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_t *type, hid_t
filter_enabled = TRUE;
} /* end if */
- if(filter_enabled) {
- /* For chunked dataset when the filter of datatype modification is enabled */
- if(H5D_modify_dtype_with_filter(file, dataset, type_id, type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't modify datatype")
- } else {
- /* For chunked dataset when the filter is NOT enabled or for contiguous or
- * compact dataset */
- if(H5D_modify_dtype_without_filter(file, dataset, type_id, type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't modify datatype")
- }
-
-done:
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_modify_dtype() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5D_modify_dtype_without_filter
- *
- * Purpose: For chunked dataset with the filter of dtype modification
- * disabled or contiguous or compact dataset, this function
- * modifies the data type of the dataset and converts the
- * data according to the new data type.
- *
- * Return: Success: Non-negative
- *
- * Failure: Negative
- *
- * Programmer: Raymond Lu
- * Tuesday, 25 Sept. 2007
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5D_modify_dtype_without_filter(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_t *type,
- hid_t dxpl_id)
-{
- H5D_t *new_dset;
- H5O_fill_t *fill_prop; /* Fill value property */
- H5O_copy_t cp_info;
- struct H5O_t *oh = NULL; /* Pointer to dataset's object header */
- hbool_t has_data = TRUE; /* The flag to indicate data exists in dset */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5D_modify_dtype_without_filter, FAIL)
-
/* If space hasn't been allocated and not using external storage,
* set the flag HAS_DATA to FALSE. If the dataset is compact,
* the flag is always TRUE.
*/
- if(dataset->shared->dcpl_cache.efl.nused == 0 &&
+ if(!filter_enabled && dataset->shared->dcpl_cache.efl.nused == 0 &&
((dataset->shared->layout.type == H5D_CONTIGUOUS && !H5F_addr_defined(dataset->shared->layout.u.contig.addr))
|| (dataset->shared->layout.type == H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr))))
has_data = FALSE;
- if(has_data) {
+ if(!filter_enabled && has_data) {
/*
* Create a bogus dataset with the same properties as the current one, to read,
* convert the data, and write it in this bogus dataset. Then assign the ownership
@@ -2568,6 +2528,10 @@ H5D_modify_dtype_without_filter(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_
}
}
+ /* Get a file ID for the file */
+ if((fid = H5F_get_id(file)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get file ID")
+
/* Copy & initialize datatype for the dataset struct */
if(H5D_init_type(file, dataset, type_id, type) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't copy datatype")
@@ -2602,11 +2566,17 @@ H5D_modify_dtype_without_filter(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_
if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT, 0, dataset->shared->type) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update datatype header message")
- /* Delete the old layout message. If it's contiguous dataset, link the adjacent space. */
- if(H5O_msg_remove(&(dataset->oloc), H5O_LAYOUT_ID, 0, TRUE, dxpl_id) < 0)
+ /* Delete the old layout message. If it isn't chunked dataset with filter enabled,
+ *link the adjacent space. */
+ if(!filter_enabled)
+ link_adjacent = TRUE;
+ else
+ link_adjacent = FALSE;
+
+ if(H5O_msg_remove(&(dataset->oloc), H5O_LAYOUT_ID, 0, link_adjacent, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete old dtype message")
- if(has_data) {
+ if(!filter_enabled && has_data) {
/* Assign the ownership of the new data to the original dataset */
if(H5D_CONTIGUOUS == dataset->shared->layout.type) {
dataset->shared->layout.u.contig.addr = new_dset->shared->layout.u.contig.addr;
@@ -2619,7 +2589,16 @@ H5D_modify_dtype_without_filter(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_
} else {
dataset->shared->layout.u.chunk.addr = new_dset->shared->layout.u.chunk.addr;
dataset->shared->layout.u.chunk.size = new_dset->shared->layout.u.chunk.size;
+ dataset->shared->layout.u.chunk.dim[dataset->shared->layout.u.chunk.ndims-1] =
+ H5T_get_size(dataset->shared->type);
}
+ } else if(filter_enabled) {
+ /* Update the layout info */
+ dataset->shared->layout.u.chunk.dim[dataset->shared->layout.u.chunk.ndims-1] = H5T_get_size(dataset->shared->type);
+
+ /* Compute the new total size of chunk */
+ for(u = 1, dataset->shared->layout.u.chunk.size = dataset->shared->layout.u.chunk.dim[0]; u < dataset->shared->layout.u.chunk.ndims; u++)
+ dataset->shared->layout.u.chunk.size *= dataset->shared->layout.u.chunk.dim[u];
}
/*
@@ -2648,7 +2627,7 @@ H5D_modify_dtype_without_filter(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_
if(H5O_close(&(dataset->oloc)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close dataset object header")
- if(has_data) {
+ if(!filter_enabled && has_data) {
/* Update and delete the object header of the new dataset */
if(H5O_open(&(new_dset->oloc)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open dataset object header")
@@ -2685,132 +2664,25 @@ H5D_modify_dtype_without_filter(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_
/* Close the bogus dataset. It'll be removed, too, because it's unnamed. */
if(H5D_close(new_dset) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close dataset")
- }
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_modify_dtype_without_filter() */
+ } else if(filter_enabled) {
+ /* Make the "reset local" filter callbacks for this dataset */
+ if(H5Z_reset_local(dataset->shared->dcpl_id, dataset->shared->type_id, fid) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set local filter parameters")
-
-/*-------------------------------------------------------------------------
- * Function: H5D_modify_dtype_with_filter
- *
- * Purpose: For chunked dataset with the filter of dtype modification
- * enabled. It only modifies the data type of the dataset.
- *
- * Return: Success: Non-negative
- *
- * Failure: Negative
- *
- * Programmer: Raymond Lu
- * Tuesday, 25 Sept. 2007
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5D_modify_dtype_with_filter(H5F_t *file, H5D_t *dataset, hid_t type_id, H5T_t *type,
- hid_t dxpl_id)
-{
- hid_t fid = -1; /* File ID for filters */
- H5O_fill_t *fill;
- struct H5O_t *oh = NULL; /* Pointer to dataset's object header */
- unsigned u; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5D_modify_dtype_with_filter, FAIL)
-
- /* Get a file ID for the file */
- if((fid = H5F_get_id(file)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get file ID")
-
- /* Copy & initialize datatype for the dataset struct */
- if(H5D_init_type(file, dataset, type_id, type) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't copy datatype")
-
- /* Check if the datatype should be (or are already) shared in the SOHM table */
- if(H5SM_try_share(file, dxpl_id, NULL, H5O_DTYPE_ID, dataset->shared->type, NULL) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_BADMESG, FAIL, "trying to share datatype failed")
-
- /*
- * Check whether datatype is committed & increment ref count. (to maintain
- * ref. count incr/decr similarity with "shared message" type of datatype sharing)
- */
- if(H5T_committed(dataset->shared->type)) {
- /* Increment the reference count on the shared datatype */
- if(H5T_link(dataset->shared->type, 1, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
- } /* end if */
-
- /* Update the layout info */
- dataset->shared->layout.u.chunk.dim[dataset->shared->layout.u.chunk.ndims-1] = H5T_get_size(dataset->shared->type);
-
- /* Compute the new total size of chunk */
- for(u = 1, dataset->shared->layout.u.chunk.size = dataset->shared->layout.u.chunk.dim[0]; u < dataset->shared->layout.u.chunk.ndims; u++)
- dataset->shared->layout.u.chunk.size *= dataset->shared->layout.u.chunk.dim[u];
-
- /* Open the object header of the dataset for updating datatype and layout */
- if(H5O_open(&(dataset->oloc)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open dataset object header")
-
- /* Get a pointer to the object header itself */
- if((oh = H5O_protect(&(dataset->oloc), dxpl_id)) == NULL)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to protect dataset object header")
-
- /* Delete the old datatype message */
- if(H5O_msg_remove(&(dataset->oloc), H5O_DTYPE_ID, 0, FALSE, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete old dtype message")
-
- /* Add the new datatype message */
- if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT, 0, dataset->shared->type) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update datatype header message")
-
- /* Delete the old layout message */
- if(H5O_msg_remove(&(dataset->oloc), H5O_LAYOUT_ID, 0, FALSE, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete old dtype message")
-
- /*
- * Create a new layout message. (Don't make layout message constant unless
- * allocation time is early, since space may not be allocated)
- */
- fill = &(dataset->shared->dcpl_cache.fill);
- if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_LAYOUT_ID, ((fill->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != dataset->shared->layout.type) ? H5O_MSG_FLAG_CONSTANT : 0), 0, &(dataset->shared->layout)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout")
-
- /*
- * Create a new fill value message if it's defined.
- */
-/* if(H5D_modify_dtype_update_fill(file, dataset, oh, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value message")*/
-
- /* Add a modification time message. */
- if(H5O_touch_oh(file, dxpl_id, oh, TRUE) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time message")
-
- /* Release pointer to object header itself */
- if(H5O_unprotect(&(dataset->oloc), oh) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to unprotect dataset object header")
-
- /* Close the object header for the dataset */
- if(H5O_close(&(dataset->oloc)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close dataset object header")
-
- /* Make the "reset local" filter callbacks for this dataset */
- if(H5Z_reset_local(dataset->shared->dcpl_id, dataset->shared->type_id, fid) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set local filter parameters")
-
- /* Release the file ID */
- if(H5I_dec_ref(fid) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "can't close file")
+ /* Release the file ID */
+ if(H5I_dec_ref(fid) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "can't close file")
- fid = -1;
-
+ fid = -1;
+ }
+
done:
- /* Release the file ID */
+ /* Release the file ID */
if(fid>=0 && H5I_dec_ref(fid) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close file ID")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_modify_dtype_with_filter() */
+} /* end H5D_modify_dtype() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 1b7fca0..2d47a5a 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -168,6 +168,7 @@ typedef struct H5D_istore_it_ud4_t {
void *bkg; /* Buffer for background information during type conversion */
size_t buf_size; /* Buffer size */
hbool_t do_convert; /* Whether to perform type conversions */
+ hbool_t is_compressed; /* Whether the filters are enabled */
/* needed for converting variable-length data */
hid_t tid_src; /* Datatype ID for source datatype */
@@ -1008,10 +1009,8 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
} /* end if */
/* Check for filtered chunks */
- if(pline && pline->nused) {
- is_compressed = TRUE;
- cb_struct.func = NULL; /* no callback function when failed */
- } /* end if */
+ is_compressed = udata->is_compressed;
+ cb_struct.func = NULL; /* no callback function when failed */
/* Resize the buf if it is too small to hold the data */
if(nbytes > buf_size) {
@@ -1148,9 +1147,6 @@ H5D_istore_iter_copy_conv(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
H5D_istore_it_ud4_t *udata = (H5D_istore_it_ud4_t *)_udata;
const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key;
H5D_istore_ud1_t udata_dst; /* User data about new destination chunk */
- hbool_t is_vlen = FALSE;
- hbool_t fix_ref = FALSE;
- hbool_t other_conversion = FALSE;
/* General information about chunk copy */
void *bkg = udata->bkg;
@@ -1166,7 +1162,6 @@ H5D_istore_iter_copy_conv(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
H5Z_cb_t cb_struct;
H5T_path_t *tpath = udata->tpath_src_mem;
- H5S_t *buf_space = udata->buf_space;
hid_t tid_src = udata->tid_src;
hid_t tid_dst = udata->tid_dst;
size_t nelmts = udata->nelmts;
@@ -1175,15 +1170,9 @@ H5D_istore_iter_copy_conv(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
FUNC_ENTER_NOAPI_NOINIT(H5D_istore_iter_copy_conv)
- /* Check parameter for type conversion */
- if(H5T_detect_class(udata->dt_src, H5T_VLEN) > 0)
- is_vlen = TRUE;
-
/* Check for filtered chunks */
- if(pline && pline->nused) {
- is_compressed = TRUE;
- cb_struct.func = NULL; /* no callback function when failed */
- } /* end if */
+ is_compressed = udata->is_compressed;
+ cb_struct.func = NULL; /* no callback function when failed */
/* Resize the buf if it is too small to hold the data */
if(nbytes > buf_size) {
@@ -4102,6 +4091,10 @@ H5D_istore_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
udata.buf_space = buf_space;
udata.nelmts = nelmts;
udata.pline = pline;
+ if(udata.pline && udata.pline->nused) {
+ udata.is_compressed = TRUE;
+ } else
+ udata.is_compressed = FALSE;
udata.file_dst = f_dst;
udata.cpy_info = cpy_info;
@@ -4178,7 +4171,7 @@ H5D_istore_copy_conv(H5F_t *file, const H5D_t *dset_src, const H5D_t *dset_dst,
void *bkg = NULL; /* Buffer for background during type conversion */
H5S_t *buf_space = NULL; /* Dataspace describing buffer */
hsize_t buf_dim; /* Dimension for buffer */
- hbool_t is_vlen = FALSE; /* Flag to indicate VL type */
+ htri_t is_vlen = FALSE; /* Flag to indicate VL type */
hbool_t vlen_conv = TRUE; /* Transfer property to indicate no conversion for vlen */
unsigned u;
herr_t ret_value = SUCCEED; /* Return value */
@@ -4267,6 +4260,10 @@ H5D_istore_copy_conv(H5F_t *file, const H5D_t *dset_src, const H5D_t *dset_dst,
udata.buf_space = buf_space;
udata.nelmts = nelmts;
udata.pline = &(dset_src->shared->dcpl_cache.pline);
+ if(udata.pline && udata.pline->nused) {
+ udata.is_compressed = TRUE;
+ } else
+ udata.is_compressed = FALSE;
udata.file_dst = file;
udata.cpy_info = cpy_info;
diff --git a/src/H5T.c b/src/H5T.c
index ae96807..ce72a59 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -5483,8 +5483,8 @@ H5T_dtype_is_valid(H5T_t *dtype, H5T_t *new_type)
H5T_sort_name(new_type, NULL);
/*
- * Build a mapping from source member number to destination member
- * number. If some source member is not a destination member then that
+ * Build a mapping from current type member number to new type member
+ * number. If some current type member is not a new type member then that
* mapping element will be negative. Also verify if each member is valid.
*/
src2dst=H5MM_malloc(dtype_nmembs * sizeof(int));
@@ -5517,6 +5517,8 @@ H5T_dtype_is_valid(H5T_t *dtype, H5T_t *new_type)
case H5T_ENUM:
{
int cur_nmemb, new_nmemb;
+ int *src2dst = NULL;
+ int i, j;
if(new_class != H5T_ENUM)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FALSE, "new type must be an enum type")
@@ -5529,6 +5531,30 @@ H5T_dtype_is_valid(H5T_t *dtype, H5T_t *new_type)
if(new_nmemb < cur_nmemb)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FALSE, "new enum's members can't be less than current enum")
+
+ H5T_sort_name(dtype, NULL);
+ H5T_sort_name(new_type, NULL);
+
+ /*
+ * Build a mapping from current type member number to new type member
+ * number. If some current type member is not a new type member then that
+ * mapping element will be negative. Also verify if each member is valid.
+ */
+ src2dst=H5MM_malloc(cur_nmemb * sizeof(int));
+
+ for (i=0; i<cur_nmemb; i++) {
+ src2dst[i] = -1;
+ for (j=0; j<new_nmemb; j++) {
+ if (!HDstrcmp(dtype->shared->u.enumer.name[i],
+ new_type->shared->u.enumer.name[j])) {
+ src2dst[i] = j;
+ break;
+ }
+ }
+
+ if(src2dst[i] < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FALSE, "no enum member should be deleted")
+ }
}
break;
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c
index 6e2c8a7..bbc698f 100644
--- a/src/H5Tvlen.c
+++ b/src/H5Tvlen.c
@@ -230,9 +230,6 @@ H5T_vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc)
/* Mark this type as being stored in memory */
dt->shared->u.vlen.loc=H5T_LOC_MEMORY;
- /* Turn on the force conversion */
- /*dt->shared->force_conv = TRUE;*/
-
if(dt->shared->u.vlen.type==H5T_VLEN_SEQUENCE) {
/* size in memory, disk size is different */
dt->shared->size = sizeof(hvl_t);
@@ -269,11 +266,6 @@ H5T_vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc)
/* Mark this type as being stored on disk */
dt->shared->u.vlen.loc=H5T_LOC_DISK;
- /* Turn off force conversion for the case of disk to disk copying.
- * Simply copy VL data without conversion. It's mainly used by
- * H5Dmodify_dtype function. */
- /*dt->shared->force_conv = FALSE;*/
-
/*
* Size of element on disk is 4 bytes for the length, plus the size
* of an address in this file, plus 4 bytes for the size of a heap
diff --git a/test/change_dtypes.c b/test/change_dtypes.c
index 1873316..0da2bb6 100644
--- a/test/change_dtypes.c
+++ b/test/change_dtypes.c
@@ -574,9 +574,9 @@ test_enum(hid_t file)
/* Create an enum type with more members type and try to change the type to it.
* It should succeed. */
if ((new_type = H5Tcreate(H5T_ENUM, sizeof(short)))<0) TEST_ERROR;
- if (H5Tenum_insert(new_type, "RED", CPTR(val3, 107))<0) TEST_ERROR;
+ if (H5Tenum_insert(new_type, "BLUE", CPTR(val3, 107))<0) TEST_ERROR;
if (H5Tenum_insert(new_type, "GREEN", CPTR(val3, 106))<0) TEST_ERROR;
- if (H5Tenum_insert(new_type, "BLUE", CPTR(val3, 105))<0) TEST_ERROR;
+ if (H5Tenum_insert(new_type, "RED", CPTR(val3, 105))<0) TEST_ERROR;
if (H5Tenum_insert(new_type, "WHITE", CPTR(val3, 104))<0) TEST_ERROR;
if (H5Tenum_insert(new_type, "BLACK", CPTR(val3, 103))<0) TEST_ERROR;
if (H5Tenum_insert(new_type, "YELLOW", CPTR(val3, 102))<0) TEST_ERROR;