summaryrefslogtreecommitdiffstats
path: root/src/H5Dchunk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dchunk.c')
-rw-r--r--src/H5Dchunk.c147
1 files changed, 65 insertions, 82 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index c8bad76..05d9fe6 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -179,16 +179,15 @@ typedef struct H5D_chunk_it_ud3_t {
bool do_convert; /* Whether to perform type conversions */
/* needed for converting variable-length data */
- hid_t tid_src; /* Datatype ID for source datatype */
- hid_t tid_dst; /* Datatype ID for destination datatype */
- hid_t tid_mem; /* Datatype ID for memory datatype */
- const H5T_t *dt_src; /* Source datatype */
- H5T_path_t *tpath_src_mem; /* Datatype conversion path from source file to memory */
- H5T_path_t *tpath_mem_dst; /* Datatype conversion path from memory to dest. file */
- void *reclaim_buf; /* Buffer for reclaiming data */
- size_t reclaim_buf_size; /* Reclaim buffer size */
- uint32_t nelmts; /* Number of elements in buffer */
- H5S_t *buf_space; /* Dataspace describing buffer */
+ H5T_t *dt_src; /* Source datatype */
+ H5T_t *dt_dst; /* Destination datatype */
+ H5T_t *dt_mem; /* Memory datatype */
+ H5T_path_t *tpath_src_mem; /* Datatype conversion path from source file to memory */
+ H5T_path_t *tpath_mem_dst; /* Datatype conversion path from memory to dest. file */
+ void *reclaim_buf; /* Buffer for reclaiming data */
+ size_t reclaim_buf_size; /* Reclaim buffer size */
+ uint32_t nelmts; /* Number of elements in buffer */
+ H5S_t *buf_space; /* Dataspace describing buffer */
/* needed for compressed variable-length data */
const H5O_pline_t *pline; /* Filter pipeline */
@@ -297,9 +296,9 @@ static herr_t H5D__create_piece_file_map_all(H5D_dset_io_info_t *di, H5D_io_in
static herr_t H5D__create_piece_file_map_hyper(H5D_dset_io_info_t *di, H5D_io_info_t *io_info);
static herr_t H5D__create_piece_mem_map_1d(const H5D_dset_io_info_t *di);
static herr_t H5D__create_piece_mem_map_hyper(const H5D_dset_io_info_t *di);
-static herr_t H5D__piece_file_cb(void *elem, const H5T_t *type, unsigned ndims, const hsize_t *coords,
+static herr_t H5D__piece_file_cb(void *elem, H5T_t *type, unsigned ndims, const hsize_t *coords,
void *_opdata);
-static herr_t H5D__piece_mem_cb(void *elem, const H5T_t *type, unsigned ndims, const hsize_t *coords,
+static herr_t H5D__piece_mem_cb(void *elem, H5T_t *type, unsigned ndims, const hsize_t *coords,
void *_opdata);
static herr_t H5D__chunk_may_use_select_io(H5D_io_info_t *io_info, const H5D_dset_io_info_t *dset_info);
static unsigned H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled);
@@ -2234,7 +2233,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__piece_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims,
+H5D__piece_file_cb(void H5_ATTR_UNUSED *elem, H5T_t H5_ATTR_UNUSED *type, unsigned ndims,
const hsize_t *coords, void *_opdata)
{
H5D_io_info_wrap_t *opdata = (H5D_io_info_wrap_t *)_opdata;
@@ -2360,7 +2359,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__piece_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims,
+H5D__piece_mem_cb(void H5_ATTR_UNUSED *elem, H5T_t H5_ATTR_UNUSED *type, unsigned ndims,
const hsize_t *coords, void *_opdata)
{
H5D_io_info_wrap_t *opdata = (H5D_io_info_wrap_t *)_opdata;
@@ -4590,8 +4589,8 @@ H5D__chunk_lock(const H5D_io_info_t H5_ATTR_NDEBUG_UNUSED *io_info, const H5D_ds
/* Initialize the fill value buffer */
/* (use the compact dataset storage buffer as the fill value buffer) */
if (H5D__fill_init(&fb_info, chunk, NULL, NULL, NULL, NULL,
- &dset->shared->dcpl_cache.fill, dset->shared->type,
- dset->shared->type_id, (size_t)0, chunk_size) < 0)
+ &dset->shared->dcpl_cache.fill, dset->shared->type, (size_t)0,
+ chunk_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't initialize fill buffer info");
fb_info_init = true;
@@ -5020,8 +5019,8 @@ H5D__chunk_allocate(const H5D_t *dset, bool full_overwrite, const hsize_t old_di
/* Initialize the fill value buffer */
/* (delay allocating fill buffer for VL datatypes until refilling) */
if (H5D__fill_init(&fb_info, NULL, H5D__chunk_mem_alloc, pline, H5D__chunk_mem_free, pline,
- &dset->shared->dcpl_cache.fill, dset->shared->type, dset->shared->type_id,
- (size_t)0, orig_chunk_size) < 0)
+ &dset->shared->dcpl_cache.fill, dset->shared->type, (size_t)0,
+ orig_chunk_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info");
fb_info_init = true;
@@ -5793,8 +5792,7 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, bool new_unfilt_chunk)
if (!udata->fb_info_init) {
H5_CHECK_OVERFLOW(udata->elmts_per_chunk, uint32_t, size_t);
if (H5D__fill_init(&udata->fb_info, NULL, NULL, NULL, NULL, NULL, &dset->shared->dcpl_cache.fill,
- dset->shared->type, dset->shared->type_id, (size_t)udata->elmts_per_chunk,
- chunk_size) < 0)
+ dset->shared->type, (size_t)udata->elmts_per_chunk, chunk_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info");
udata->fb_info_init = true;
} /* end if */
@@ -6576,6 +6574,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
bool need_insert = false; /* Whether the chunk needs to be inserted into the index */
/* General information about chunk copy */
+ H5T_t *dt_src = udata->dt_src;
void *bkg = udata->bkg; /* Background buffer for datatype conversion */
void *buf = udata->buf; /* Chunk buffer for I/O & datatype conversions */
size_t buf_size = udata->buf_size; /* Size of chunk buffer */
@@ -6608,9 +6607,9 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
/* Check parameter for type conversion */
if (udata->do_convert) {
- if (H5T_detect_class(udata->dt_src, H5T_VLEN, false) > 0)
+ if (H5T_detect_class(dt_src, H5T_VLEN, false) > 0)
is_vlen = true;
- else if ((H5T_get_class(udata->dt_src, false) == H5T_REFERENCE) &&
+ else if ((H5T_get_class(dt_src, false) == H5T_REFERENCE) &&
(udata->file_src != udata->idx_info_dst->f))
fix_ref = true;
else
@@ -6704,18 +6703,17 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
if (is_vlen) {
H5T_path_t *tpath_src_mem = udata->tpath_src_mem;
H5T_path_t *tpath_mem_dst = udata->tpath_mem_dst;
+ H5T_t *dt_dst = udata->dt_dst;
+ H5T_t *dt_mem = udata->dt_mem;
H5S_t *buf_space = udata->buf_space;
- hid_t tid_src = udata->tid_src;
- hid_t tid_dst = udata->tid_dst;
- hid_t tid_mem = udata->tid_mem;
void *reclaim_buf = udata->reclaim_buf;
size_t reclaim_buf_size = udata->reclaim_buf_size;
/* Convert from source file to memory */
H5_CHECK_OVERFLOW(udata->nelmts, uint32_t, size_t);
- if (H5T_convert(tpath_src_mem, tid_src, tid_mem, (size_t)udata->nelmts, (size_t)0, (size_t)0, buf,
+ if (H5T_convert(tpath_src_mem, dt_src, dt_mem, (size_t)udata->nelmts, (size_t)0, (size_t)0, buf,
bkg) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, H5_ITER_ERROR, "datatype conversion failed");
/* Copy into another buffer, to reclaim memory later */
H5MM_memcpy(reclaim_buf, buf, reclaim_buf_size);
@@ -6724,20 +6722,20 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
memset(bkg, 0, buf_size);
/* Convert from memory to destination file */
- if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, udata->nelmts, (size_t)0, (size_t)0, buf, bkg) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed");
+ if (H5T_convert(tpath_mem_dst, dt_mem, dt_dst, udata->nelmts, (size_t)0, (size_t)0, buf, bkg) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, H5_ITER_ERROR, "datatype conversion failed");
/* Reclaim space from variable length data */
- if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_BADITER, H5_ITER_ERROR, "unable to reclaim variable-length data");
+ if (H5T_reclaim(dt_mem, buf_space, reclaim_buf) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to reclaim variable-length data");
} /* end if */
else if (fix_ref) {
/* Check for expanding references */
/* (background buffer has already been zeroed out, if not expanding) */
if (udata->cpy_info->expand_ref) {
/* Copy the reference elements */
- if (H5O_copy_expand_ref(udata->file_src, udata->tid_src, udata->dt_src, buf, nbytes,
- udata->idx_info_dst->f, bkg, udata->cpy_info) < 0)
+ if (H5O_copy_expand_ref(udata->file_src, dt_src, buf, nbytes, udata->idx_info_dst->f, bkg,
+ udata->cpy_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy reference attribute");
} /* end if */
@@ -6813,32 +6811,32 @@ done:
*/
herr_t
H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk_t *layout_src, H5F_t *f_dst,
- H5O_storage_chunk_t *storage_dst, const H5S_extent_t *ds_extent_src, const H5T_t *dt_src,
+ H5O_storage_chunk_t *storage_dst, const H5S_extent_t *ds_extent_src, H5T_t *dt_src,
const H5O_pline_t *pline_src, H5O_copy_t *cpy_info)
{
- H5D_chunk_it_ud3_t udata; /* User data for iteration callback */
- H5D_chk_idx_info_t idx_info_dst; /* Dest. chunked index info */
- H5D_chk_idx_info_t idx_info_src; /* Source chunked index info */
- int sndims; /* Rank of dataspace */
- hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */
- hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */
- H5O_pline_t _pline; /* Temporary pipeline info */
- const H5O_pline_t *pline; /* Pointer to pipeline info to use */
- H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */
- hid_t tid_src = -1; /* Datatype ID for source datatype */
- hid_t tid_dst = -1; /* Datatype ID for destination datatype */
- hid_t tid_mem = -1; /* Datatype ID for memory datatype */
- size_t buf_size; /* Size of copy buffer */
- size_t reclaim_buf_size; /* Size of reclaim buffer */
- void *buf = NULL; /* Buffer for copying data */
- void *bkg = NULL; /* Buffer for background during type conversion */
- void *reclaim_buf = NULL; /* Buffer for reclaiming data */
- H5S_t *buf_space = NULL; /* Dataspace describing buffer */
- hid_t sid_buf = -1; /* ID for buffer dataspace */
- uint32_t nelmts = 0; /* Number of elements in buffer */
- bool do_convert = false; /* Indicate that type conversions should be performed */
- bool copy_setup_done = false; /* Indicate that 'copy setup' is done */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5D_chunk_it_ud3_t udata; /* User data for iteration callback */
+ H5D_chk_idx_info_t idx_info_dst; /* Dest. chunked index info */
+ H5D_chk_idx_info_t idx_info_src; /* Source chunked index info */
+ int sndims; /* Rank of dataspace */
+ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */
+ hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */
+ H5O_pline_t _pline; /* Temporary pipeline info */
+ const H5O_pline_t *pline; /* Pointer to pipeline info to use */
+ H5T_path_t *tpath_src_mem = NULL; /* Source datatype conversion path */
+ H5T_path_t *tpath_mem_dst = NULL; /* Memory datatype conversion path */
+ H5T_t *dt_dst = NULL; /* Destination datatype */
+ H5T_t *dt_mem = NULL; /* Memory datatype */
+ size_t buf_size; /* Size of copy buffer */
+ size_t reclaim_buf_size; /* Size of reclaim buffer */
+ void *buf = NULL; /* Buffer for copying data */
+ void *bkg = NULL; /* Buffer for background during type conversion */
+ void *reclaim_buf = NULL; /* Buffer for reclaiming data */
+ H5S_t *buf_space = NULL; /* Dataspace describing buffer */
+ hid_t sid_buf = -1; /* ID for buffer dataspace */
+ uint32_t nelmts = 0; /* Number of elements in buffer */
+ bool do_convert = false; /* Indicate that type conversions should be performed */
+ bool copy_setup_done = false; /* Indicate that 'copy setup' is done */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -6896,14 +6894,8 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk
"unable to set up index-specific chunk copying information");
copy_setup_done = true;
- /* Create datatype ID for src datatype */
- if ((tid_src = H5I_register(H5I_DATATYPE, dt_src, false)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype");
-
/* If there's a VLEN source datatype, set up type conversion information */
if (H5T_detect_class(dt_src, H5T_VLEN, false) > 0) {
- H5T_t *dt_dst; /* Destination datatype */
- H5T_t *dt_mem; /* Memory datatype */
size_t mem_dt_size; /* Memory datatype size */
size_t tmp_dt_size; /* Temp. datatype size */
size_t max_dt_size; /* Max atatype size */
@@ -6913,10 +6905,6 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk
/* create a memory copy of the variable-length datatype */
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, false)) < 0) {
- (void)H5T_close_real(dt_mem);
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype");
- } /* end if */
/* create variable-length datatype at the destination file */
if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
@@ -6925,10 +6913,6 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk
(void)H5T_close_real(dt_dst);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk");
} /* end if */
- if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, false)) < 0) {
- (void)H5T_close_real(dt_dst);
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype");
- } /* end if */
/* Set up the conversion functions */
if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem)))
@@ -7008,10 +6992,9 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk
udata.buf = buf;
udata.bkg = bkg;
udata.buf_size = buf_size;
- udata.tid_src = tid_src;
- udata.tid_mem = tid_mem;
- udata.tid_dst = tid_dst;
udata.dt_src = dt_src;
+ udata.dt_dst = dt_dst;
+ udata.dt_mem = dt_mem;
udata.do_convert = do_convert;
udata.tpath_src_mem = tpath_src_mem;
udata.tpath_mem_dst = tpath_mem_dst;
@@ -7059,12 +7042,13 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk
done:
if (sid_buf > 0 && H5I_dec_ref(sid_buf) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID");
- if (tid_src > 0 && H5I_dec_ref(tid_src) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID");
- if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID");
- if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID");
+ /* Caller expects that source datatype will be freed */
+ if (dt_src && (H5T_close(dt_src) < 0))
+ HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close temporary datatype");
+ if (dt_dst && (H5T_close(dt_dst) < 0))
+ HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close temporary datatype");
+ if (dt_mem && (H5T_close(dt_mem) < 0))
+ HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close temporary datatype");
if (buf)
H5MM_xfree(buf);
if (bkg)
@@ -7342,8 +7326,7 @@ H5D__nonexistent_readvv_cb(hsize_t H5_ATTR_UNUSED dst_off, hsize_t src_off, size
/* Initialize the fill value buffer */
if (H5D__fill_init(&fb_info, (udata->rbuf + src_off), NULL, NULL, NULL, NULL,
- &udata->dset->shared->dcpl_cache.fill, udata->dset->shared->type,
- udata->dset->shared->type_id, (size_t)0, len) < 0)
+ &udata->dset->shared->dcpl_cache.fill, udata->dset->shared->type, (size_t)0, len) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info");
fb_info_init = true;