summaryrefslogtreecommitdiffstats
path: root/src/H5Dcompact.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dcompact.c')
-rw-r--r--src/H5Dcompact.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index 842ad9c..2d17a57 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -140,6 +140,7 @@ H5D_compact_writevv(const H5D_io_info_t *io_info,
if((ret_value=H5V_memcpyvv(io_info->dset->shared->layout.u.compact.buf,dset_max_nseq,dset_curr_seq,dset_size_arr,dset_offset_arr,buf,mem_max_nseq,mem_curr_seq,mem_size_arr,mem_offset_arr))<0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed")
+ /* Mark the compact dataset's buffer as dirty */
io_info->dset->shared->layout.u.compact.dirty = TRUE;
done:
@@ -160,8 +161,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D_compact_copy(const H5O_layout_t *layout_src, H5F_t *f_dst, H5O_layout_t *layout_dst,
- H5T_t *dt_src, hid_t dxpl_id)
+H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
+ H5O_layout_t *layout_dst, H5T_t *dt_src, H5O_copy_t *cpy_info, hid_t dxpl_id)
{
hid_t tid_src = -1; /* Datatype ID for source datatype */
hid_t tid_dst = -1; /* Datatype ID for destination datatype */
@@ -176,14 +177,32 @@ H5D_compact_copy(const H5O_layout_t *layout_src, H5F_t *f_dst, H5O_layout_t *la
/* Check args */
HDassert(layout_src && H5D_COMPACT == layout_src->type);
+ HDassert(f_src);
HDassert(f_dst);
HDassert(layout_dst && H5D_COMPACT == layout_dst->type);
/* If there's a source datatype, set up type conversion information */
- if (!dt_src)
+ if(!dt_src)
/* Type conversion not necessary */
HDmemcpy(layout_dst->u.compact.buf, layout_src->u.compact.buf, layout_src->u.compact.size);
- else {
+ else if(dt_src && (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) && (f_src != f_dst)) {
+ /* Check for expanding references */
+ if(cpy_info->expand_ref) {
+ size_t ref_count;
+
+ /* Determine # of reference elements to copy */
+ ref_count = layout_src->u.compact.size / H5T_get_size(dt_src);
+
+ /* Copy objects referenced in source buffer to destination file and set destination elements */
+ if(H5O_copy_expand_ref(f_src, layout_src->u.compact.buf, dxpl_id, f_dst,
+ layout_dst->u.compact.buf, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
+ } /* end if */
+ else
+ /* Reset value to zero */
+ HDmemset(layout_dst->u.compact.buf, 0, layout_src->u.compact.size);
+ } /* end if */
+ else if(dt_src && (H5T_detect_class(dt_src, H5T_VLEN) > 0) ) {
H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */
H5T_t *dt_dst; /* Destination datatype */
H5T_t *dt_mem; /* Memory datatype */
@@ -203,7 +222,7 @@ H5D_compact_copy(const H5O_layout_t *layout_src, H5F_t *f_dst, H5O_layout_t *la
if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem)) < 0)
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
/* create variable-length datatype at the destinaton file */
if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
@@ -278,6 +297,8 @@ H5D_compact_copy(const H5O_layout_t *layout_src, H5F_t *f_dst, H5O_layout_t *la
if(H5D_vlen_reclaim(tid_mem, buf_space, H5P_DATASET_XFER_DEFAULT, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data")
} /* end if */
+ else
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy dataset elements")
done:
if(buf_sid > 0)