Merge pull request #605 in HDFFV/hdf5 from ~VCHOI/my_hdf5_fork:hdf5_1_10 to hdf5_1_10

* commit '201af70c24ccdd84e8fba376dab9b2024bf21dc4':
  Fix for HDFFV-7853 H5Ocopy doesn't work with open identifiers Changes made so that raw data for dataset objects are copied from cached info when possible instead of flushing objects to file and read them back in again.
This commit is contained in:
Vailin Choi 2017-07-19 13:18:30 -05:00
commit 45724d8082
6 changed files with 633 additions and 208 deletions

View File

@ -188,6 +188,10 @@ typedef struct H5D_chunk_it_ud3_t {
/* needed for copy object pointed by refs */
H5O_copy_t *cpy_info; /* Copy options */
/* needed for getting raw data from chunk cache */
hbool_t chunk_in_cache;
uint8_t *chunk; /* the unfiltered chunk data */
} H5D_chunk_it_ud3_t;
/* Callback info for iteration to dump index */
@ -5658,11 +5662,22 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
H5Z_cb_t cb_struct; /* Filter failure callback struct */
int ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_STATIC
/* Get 'size_t' local value for number of bytes in chunk */
H5_CHECKED_ASSIGN(nbytes, size_t, chunk_rec->nbytes, uint32_t);
/* Check for filtered chunks */
/* Check for an edge chunk that is not filtered */
if(pline && pline->nused) {
must_filter = TRUE;
if( (udata->common.layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) &&
(H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, udata->common.layout->dim,
chunk_rec->scaled, udata->dset_dims)) )
must_filter = FALSE;
}
/* Check parameter for type conversion */
if(udata->do_convert) {
if(H5T_detect_class(udata->dt_src, H5T_VLEN, FALSE) > 0)
@ -5673,19 +5688,6 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy dataset elements")
} /* end if */
/* Check for filtered chunks */
if((is_vlen || fix_ref) && pline && pline->nused) {
/* Check if we should disable filters on this chunk */
if(udata->common.layout->flags
& H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) {
/* Check if the chunk is an edge chunk, and disable filters if so */
if(!H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, udata->common.layout->dim, chunk_rec->scaled, udata->dset_dims))
must_filter = TRUE;
} /* end if */
else
must_filter = TRUE;
} /* end if */
/* Resize the buf if it is too small to hold the data */
if(nbytes > buf_size) {
void *new_buf; /* New buffer for data */
@ -5708,12 +5710,51 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
udata->buf_size = buf_size = nbytes;
} /* end if */
if(udata->chunk_in_cache && udata->chunk) {
HDassert(!H5F_addr_defined(chunk_rec->chunk_addr));
HDmemcpy(buf, udata->chunk, nbytes);
udata->chunk = NULL;
} else {
H5D_rdcc_ent_t *ent = NULL; /* Cache entry */
unsigned idx; /* Index of chunk in cache, if present */
unsigned u; /* Counter */
H5D_shared_t *shared_fo = udata->cpy_info->shared_fo;
/* See if the written chunk is in the chunk cache */
if(shared_fo && shared_fo->cache.chunk.nslots > 0) {
/* Determine the chunk's location in the hash table */
idx = H5D__chunk_hash_val(shared_fo, chunk_rec->scaled);
/* Get the chunk cache entry for that location */
ent = shared_fo->cache.chunk.slot[idx];
if(ent) {
/* Speculatively set the 'found' flag */
udata->chunk_in_cache = TRUE;
/* Verify that the cache entry is the correct chunk */
for(u = 0; u < shared_fo->ndims; u++)
if(chunk_rec->scaled[u] != ent->scaled[u]) {
udata->chunk_in_cache = FALSE;
break;
} /* end if */
} /* end if */
} /* end if */
if(udata->chunk_in_cache) {
HDassert(H5F_addr_defined(chunk_rec->chunk_addr));
HDassert(H5F_addr_defined(ent->chunk_block.offset));
H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t);
HDmemcpy(buf, ent->chunk, nbytes);
} else {
/* read chunk data from the source file */
if(H5F_block_read(udata->file_src, H5FD_MEM_DRAW, chunk_rec->chunk_addr, nbytes, H5AC_rawdata_dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk")
}
}
/* Need to uncompress variable-length & reference data elements */
if(must_filter) {
/* Need to uncompress filtered variable-length & reference data elements that are not found in chunk cache */
if(must_filter && (is_vlen || fix_ref) && !udata->chunk_in_cache) {
unsigned filter_mask = chunk_rec->filter_mask;
cb_struct.func = NULL; /* no callback function when failed */
@ -5777,8 +5818,8 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
udata_dst.chunk_block.length = chunk_rec->nbytes;
udata_dst.filter_mask = chunk_rec->filter_mask;
/* Need to compress variable-length & reference data elements before writing to file */
if(must_filter) {
/* Need to compress variable-length or reference data elements or a chunk found in cache before writing to file */
if(must_filter && (is_vlen || fix_ref || udata->chunk_in_cache) ) {
if(H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, cb_struct, &nbytes, &buf_size, &buf) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed")
#if H5_SIZEOF_SIZE_T > 4
@ -5791,6 +5832,8 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
udata->buf_size = buf_size;
} /* end if */
udata->chunk_in_cache = FALSE;
udata_dst.chunk_idx = H5VM_array_offset_pre(udata_dst.common.layout->ndims - 1,
udata_dst.common.layout->max_down_chunks, udata_dst.common.scaled);
@ -6047,11 +6090,35 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src,
udata.dset_ndims = (unsigned)sndims;
udata.dset_dims = curr_dims;
udata.cpy_info = cpy_info;
udata.chunk_in_cache = FALSE;
udata.chunk = NULL;
/* Iterate over chunks to copy data */
if((storage_src->ops->iterate)(&idx_info_src, H5D__chunk_copy_cb, &udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to copy data")
/* Iterate over the chunk cache to copy data for chunks with undefined address */
if(udata.cpy_info->shared_fo) {
H5D_rdcc_ent_t *ent, *next;
H5D_chunk_rec_t chunk_rec;
H5D_shared_t *shared_fo = (H5D_shared_t *)udata.cpy_info->shared_fo;
chunk_rec.nbytes = layout_src->size;
chunk_rec.filter_mask = 0;
chunk_rec.chunk_addr = HADDR_UNDEF;
for(ent = shared_fo->cache.chunk.head; ent; ent = next) {
if(!H5F_addr_defined(ent->chunk_block.offset)) {
HDmemcpy(chunk_rec.scaled, ent->scaled, sizeof(chunk_rec.scaled));
udata.chunk = ent->chunk;
udata.chunk_in_cache = TRUE;
if(H5D__chunk_copy_cb(&chunk_rec, &udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy chunk data in cache")
}
next = ent->next;
} /* end for */
}
/* I/O buffers may have been re-allocated */
buf = udata.buf;
bkg = udata.bkg;

View File

@ -420,7 +420,7 @@ H5D__compact_dest(H5D_t *dset, hid_t H5_ATTR_UNUSED dxpl_id)
*-------------------------------------------------------------------------
*/
herr_t
H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst,
H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_dst,
H5O_storage_compact_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info,
hid_t dxpl_id)
{
@ -431,6 +431,8 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst
void *bkg = NULL; /* Temporary buffer for copying data */
void *reclaim_buf = NULL; /* Buffer for reclaiming data */
hid_t buf_sid = -1; /* ID for buffer dataspace */
H5D_shared_t *shared_fo = cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */
H5O_storage_compact_t *storage_src = _storage_src; /* Pointer to storage_src */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@ -443,6 +445,10 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst
HDassert(storage_dst->buf);
HDassert(dt_src);
/* If the dataset is open in the file, point to "layout" in the shared struct */
if(shared_fo != NULL)
storage_src = &(shared_fo->layout.storage.u.compact);
/* Create datatype ID for src datatype, so it gets freed */
if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")

View File

@ -39,6 +39,7 @@
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
#include "H5MFprivate.h" /* File memory management */
#include "H5FOprivate.h" /* File objects */
#include "H5Oprivate.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
#include "H5VMprivate.h" /* Vector and array functions */
@ -1362,6 +1363,10 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
hsize_t buf_dim[1] = {0}; /* Dimension for buffer */
hbool_t is_vlen = FALSE; /* Flag to indicate that VL type conversion should occur */
hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */
H5D_shared_t *shared_fo = cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */
hbool_t try_sieve = FALSE; /* Try to get data from the sieve buffer */
haddr_t sieve_start = HADDR_UNDEF; /* Start location of sieve buffer */
haddr_t sieve_end = HADDR_UNDEF; /* End locations of sieve buffer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@ -1485,6 +1490,16 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
/* Loop over copying data */
addr_src = storage_src->addr;
addr_dst = storage_dst->addr;
/* If data sieving is enabled and the dataset is open in the file,
set up to copy data out of the sieve buffer if deemed possible later */
if(H5F_HAS_FEATURE(f_src, H5FD_FEAT_DATA_SIEVE) &&
shared_fo && shared_fo->cache.contig.sieve_buf) {
try_sieve = TRUE;
sieve_start = shared_fo->cache.contig.sieve_loc;
sieve_end = sieve_start + shared_fo->cache.contig.sieve_size;
}
while(total_src_nbytes > 0) {
/* Check if we should reduce the number of bytes to transfer */
if(total_src_nbytes < src_nbytes) {
@ -1510,6 +1525,12 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
dst_nbytes = mem_nbytes = src_nbytes;
} /* end if */
/* If the entire copy is within the sieve buffer, copy data from the sieve buffer */
if(try_sieve && (addr_src >= sieve_start) && ((addr_src + src_nbytes -1) < sieve_end)) {
unsigned char *base_sieve_buf = shared_fo->cache.contig.sieve_buf + (addr_src - sieve_start);
HDmemcpy(buf, base_sieve_buf, src_nbytes);
} else
/* Read raw data from source file - use raw dxpl because passed in one is metadata */
if(H5F_block_read(f_src, H5FD_MEM_DRAW, addr_src, src_nbytes, H5AC_rawdata_dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read raw data")

View File

@ -347,36 +347,8 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/,
if(NULL == (obj_class = H5O_obj_class(oloc_src, dxpl_id)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type")
/* Check if the object at the address is already open in the file */
if(H5FO_opened(oloc_src->file, oloc_src->addr) != NULL) {
H5G_loc_t tmp_loc; /* Location of object */
H5O_loc_t tmp_oloc; /* Location of object */
H5G_name_t tmp_path; /* Object's path */
void *obj_ptr = NULL; /* Object pointer */
hid_t tmp_id = -1; /* Object ID */
tmp_loc.oloc = &tmp_oloc;
tmp_loc.path = &tmp_path;
tmp_oloc.file = oloc_src->file;
tmp_oloc.addr = oloc_src->addr;
tmp_oloc.holding_file = FALSE;
H5G_name_reset(tmp_loc.path);
/* Get a temporary ID */
if((tmp_id = obj_class->open(&tmp_loc, H5P_DEFAULT, dxpl_id, FALSE)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to open object")
/* Get object pointer */
obj_ptr = H5I_object(tmp_id);
/* Flush the object */
if(obj_class->flush && obj_class->flush(obj_ptr, dxpl_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object")
/* Release the temporary ID */
if(tmp_id != -1 && H5I_dec_app_ref(tmp_id))
HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close temporary ID")
} /* end if */
/* Set the pointer to the shared struct for the object if opened in the file */
cpy_info->shared_fo = H5FO_opened(oloc_src->file, oloc_src->addr);
/* Get source object header */
if(NULL == (oh_src = H5O_protect(oloc_src, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))

View File

@ -174,6 +174,7 @@ typedef struct H5O_copy_t {
H5SL_t *dst_dt_list; /* Skip list to hold committed datatypes in dest file */
hbool_t dst_dt_list_complete; /* Whether the destination datatype list is complete (i.e. not only populated with "suggestions" from H5Padd_merge_committed_dtype_path) */
H5O_t *oh_dst; /* The destination object header */
void *shared_fo; /* The shared pointer for the object */
H5O_mcdt_search_cb_t mcdt_cb; /* The callback to invoke before searching the global list of committed datatypes at destination */
void *mcdt_ud; /* User data passed to callback */
} H5O_copy_t;

View File

@ -2200,6 +2200,9 @@ error:
* Purpose: Create a simple dataset in SRC file and copy it to DST file
* (Note: dataset has no data)
*
* Note: The parameter "test_open" is added to test for H5Ocopy when
* the dataset is open in the file (HDFFV-7853).
*
* Return: Success: 0
* Failure: number of errors
*
@ -2209,7 +2212,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
test_copy_dataset_simple_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
test_copy_dataset_simple_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
@ -2218,7 +2221,11 @@ test_copy_dataset_simple_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
if(test_open) {
TESTING("H5Ocopy(): empty and openend contiguous dataset");
} else {
TESTING("H5Ocopy(): empty contiguous dataset");
}
/* Initialize the filenames */
h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
@ -2246,16 +2253,19 @@ test_copy_dataset_simple_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h
/* attach attributes to the dataset */
if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
if(!test_open) {
/* close the dataset */
if(H5Dclose(did) < 0) TEST_ERROR
/* close the SRC file */
if(H5Fclose(fid_src) < 0) TEST_ERROR
/* open the source file with read-only */
if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
}
/* create destination file */
if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
@ -2265,8 +2275,10 @@ test_copy_dataset_simple_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h
/* copy the dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(!test_open) {
/* open the dataset for copy */
if((did = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
}
/* open the destination dataset */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
@ -3890,6 +3902,9 @@ error:
*
* Purpose: Create a compressed, chunked dataset in SRC file and copy it to DST file
*
* Note: The parameter "test_open" is added to test for H5Ocopy when
* the dataset is open in the file (HDFFV-7853).
*
* Return: Success: 0
* Failure: number of errors
*
@ -3902,7 +3917,7 @@ error:
*/
static int
test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
hid_t dst_fapl)
hid_t dst_fapl, hbool_t test_open)
{
#ifdef H5_HAVE_FILTER_DEFLATE
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
@ -3917,7 +3932,11 @@ test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
char dst_filename[NAME_BUF_SIZE];
#endif /* H5_HAVE_FILTER_DEFLATE */
if(test_open) {
TESTING("H5Ocopy(): compressed and opened dataset with no edge filters");
} else {
TESTING("H5Ocopy(): compressed dataset with no edge filters");
}
#ifndef H5_HAVE_FILTER_DEFLATE
SKIPPED();
@ -3966,6 +3985,8 @@ test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
/* attach attributes to the dataset */
if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
if(!test_open) {
/* close the dataset */
if(H5Dclose(did) < 0) TEST_ERROR
@ -3976,6 +3997,8 @@ test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
/* open the source file with read-only */
if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
}
/* create destination file */
if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
@ -3985,8 +4008,10 @@ test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
/* copy the dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(!test_open) {
/* open the dataset for copy */
if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR
}
/* open the destination dataset */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR
@ -4034,6 +4059,9 @@ error:
*
* Purpose: Create a compact dataset in SRC file and copy it to DST file
*
* Note: The parameter "test_open" is added to test for H5Ocopy when
* the dataset is open in the file (HDFFV-7853).
*
* Return: Success: 0
* Failure: number of errors
*
@ -4043,7 +4071,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
@ -4055,7 +4083,11 @@ test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
if(test_open) {
TESTING("H5Ocopy(): compact and opened dataset");
} else {
TESTING("H5Ocopy(): compact dataset");
}
/* set initial data values */
for (i=0; i<DIM_SIZE_1; i++)
@ -4098,6 +4130,7 @@ test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t
/* attach attributes to the dataset */
if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
if(!test_open) {
/* close the dataset */
if(H5Dclose(did) < 0) TEST_ERROR
@ -4107,6 +4140,7 @@ test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t
/* open the source file with read-only */
if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
}
/* create destination file */
if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
@ -4117,8 +4151,10 @@ test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t
/* copy the dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_COMPACT, fid_dst, NAME_DATASET_COMPACT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(!test_open) {
/* open the dataset for copy */
if((did = H5Dopen2(fid_src, NAME_DATASET_COMPACT, H5P_DEFAULT)) < 0) TEST_ERROR
}
/* open the destination dataset */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_COMPACT, H5P_DEFAULT)) < 0) TEST_ERROR
@ -4686,6 +4722,9 @@ error:
* creates lots of object header chunks in SRC file and copy
* datasets to DST file
*
* Note: The parameter "test_open" is added to test for H5Ocopy when
* the dataset is open in the file (HDFFV-7853).
*
* Return: Success: 0
* Failure: number of errors
*
@ -4695,7 +4734,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
test_copy_dataset_multi_ohdr_chunks(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
test_copy_dataset_multi_ohdr_chunks(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
@ -4707,7 +4746,11 @@ test_copy_dataset_multi_ohdr_chunks(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fa
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
if(test_open) {
TESTING("H5Ocopy(): opened datasets that have multiple ohdr chunks");
} else {
TESTING("H5Ocopy(): datasets that have multiple ohdr chunks");
}
/* set initial data values */
for (i=0; i<DIM_SIZE_1; i++)
@ -4747,25 +4790,28 @@ test_copy_dataset_multi_ohdr_chunks(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fa
/* Add attributes to datasets in a way that creates lots of chunks */
if(test_copy_attach_paired_attributes(did, did2, H5T_NATIVE_INT) < 0) TEST_ERROR
/* close dataspace */
if(H5Sclose(sid) < 0) TEST_ERROR
/* close the first dataset */
if(H5Dclose(did) < 0) TEST_ERROR
if(!test_open) {
/* close the second dataset */
if(H5Dclose(did2) < 0) TEST_ERROR
/* close dataspace */
if(H5Sclose(sid) < 0) TEST_ERROR
/* close group */
if(H5Gclose(gid) < 0) TEST_ERROR
/* close the SRC file */
if(H5Fclose(fid_src) < 0) TEST_ERROR
/* open the source file with read-only */
if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
}
/* create destination file */
if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
@ -4775,6 +4821,11 @@ test_copy_dataset_multi_ohdr_chunks(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fa
/* copy the dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(test_open) {
/* close the second dataset */
if(H5Dclose(did2) < 0) TEST_ERROR
} else
/* open the group for copy */
if((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@ -7008,6 +7059,9 @@ error:
* Purpose: Create a soft link in SRC file and copy it to DST file
* copy a datast pointed by a soft link to DST file
*
* Note: The parameter "test_open" is added to test for H5Ocopy when
* the dataset is open in the file (HDFFV-7853).
*
* Return: Success: 0
* Failure: number of errors
*
@ -7017,7 +7071,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
test_copy_soft_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
test_copy_soft_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
@ -7029,7 +7083,11 @@ test_copy_soft_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fa
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
if(test_open) {
TESTING("H5Ocopy(): openend object through soft link");
} else {
TESTING("H5Ocopy(): object through soft link");
}
/* set initial data values */
for (i=0; i<DIM_SIZE_1; i++)
@ -7066,21 +7124,22 @@ test_copy_soft_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fa
/* close dataspace */
if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
/* close the dataset */
if(H5Dclose(did) < 0) FAIL_STACK_ERROR
/* close the group */
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
/* make a soft link to the dataset */
if(H5Lcreate_soft(NAME_LINK_DATASET, fid_src, NAME_LINK_SOFT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* close the group */
if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
if(!test_open) {
/* close the dataset */
if(H5Dclose(did) < 0) FAIL_STACK_ERROR
/* close the SRC file */
if(H5Fclose(fid_src) < 0) FAIL_STACK_ERROR
/* open the source file with read-only */
if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
}
/* create destination file */
if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
@ -7091,8 +7150,10 @@ test_copy_soft_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fa
/* copy the dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_LINK_SOFT, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(!test_open) {
/* open the dataset through the soft link for copy */
if((did = H5Dopen2(fid_src, NAME_LINK_SOFT, H5P_DEFAULT)) < 0) TEST_ERROR
}
/* open the destination dataset */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
@ -7593,14 +7654,18 @@ error:
*-------------------------------------------------------------------------
*/
static int
test_copy_old_layout(hid_t fcpl_dst, hid_t fapl)
test_copy_old_layout(hid_t fcpl_dst, hid_t fapl, hbool_t test_open)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t did = -1, did2 = -1; /* Dataset IDs */
const char *src_filename = H5_get_srcdir_filename(FILE_OLD_LAYOUT); /* Corrected test file name */
char dst_filename[NAME_BUF_SIZE];
if(test_open) {
TESTING("H5Ocopy(): opened dataset with old layout format");
} else {
TESTING("H5Ocopy(): dataset with old layout format");
}
/* Initialize the destination filename */
h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
@ -7617,11 +7682,18 @@ test_copy_old_layout(hid_t fcpl_dst, hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(test_open) {
/* open the source dataset */
if((did = H5Dopen2(fid_src, NAME_OLD_FORMAT, H5P_DEFAULT)) < 0) TEST_ERROR
}
/* copy the dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_OLD_FORMAT, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(!test_open) {
/* open the source dataset */
if((did = H5Dopen2(fid_src, NAME_OLD_FORMAT, H5P_DEFAULT)) < 0) TEST_ERROR
}
/* open the destination dataset */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
@ -7962,6 +8034,9 @@ error:
* Purpose: Create a dataset that uses a named variable length datatype
* in SRC file and copy it to DST file
*
* Note: The parameter "test_open" is added to test for H5Ocopy when
* the dataset is open in the file (HDFFV-7853).
*
* Return: Success: 0
* Failure: number of errors
*
@ -7971,7 +8046,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t tid = -1, tid_copy=-1; /* Datatype ID */
@ -7986,7 +8061,11 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
if(test_open) {
TESTING("H5Ocopy(): chunked and opened dataset with named VLEN datatype");
} else {
TESTING("H5Ocopy(): chunked dataset with named VLEN datatype");
}
/* set initial data values */
for(i = 0; i < DIM_SIZE_1; i++) {
@ -8037,6 +8116,8 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
/* close the datatype */
if(H5Tclose(tid) < 0) TEST_ERROR
if(!test_open) {
/* close the dataset */
if(H5Dclose(did) < 0) TEST_ERROR
@ -8046,6 +8127,7 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
/* open the source file with read-only */
if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
}
/* create destination file */
if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
@ -8056,8 +8138,10 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
/* copy the dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(!test_open) {
/* open the dataset for copy */
if((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR
}
/* open the destination dataset */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR
@ -8438,6 +8522,9 @@ error:
* Purpose: Create a compact dataset w/nested VLEN datatype
* in SRC file and copy it to DST file
*
* Note: The parameter "test_open" is added to test for H5Ocopy when
* the dataset is open in the file (HDFFV-7853).
*
* Return: Success: 0
* Failure: number of errors
*
@ -8447,7 +8534,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t tid=-1, tid2=-1; /* Datatype ID */
@ -8462,7 +8549,11 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
if(test_open) {
TESTING("H5Ocopy(): contigous and opened dataset with nested VLEN datatype");
} else {
TESTING("H5Ocopy(): contigous dataset with nested VLEN datatype");
}
/* set initial data values */
for(i=0; i<DIM_SIZE_1; i++) {
@ -8519,6 +8610,7 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h
/* close compact plist */
if(H5Pclose(pid) < 0) TEST_ERROR
if(!test_open) {
/* close the dataset */
if(H5Dclose(did) < 0) TEST_ERROR
@ -8528,6 +8620,7 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h
/* open the source file with read-only */
if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
}
/* create destination file */
if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
@ -8538,8 +8631,10 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h
/* copy the dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(!test_open) {
/* open the dataset for copy */
if((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR
}
/* open the destination dataset */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR
@ -8801,6 +8896,9 @@ error:
* Purpose: Create a dataset that uses a named variable length datatype
* in SRC file and copy it to DST file
*
* Note: The parameter "test_open" is added to test for H5Ocopy when
* the dataset is open in the file (HDFFV-7853).
*
* Return: Success: 0
* Failure: number of errors
*
@ -8810,7 +8908,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t tid = -1, tid2=-1; /* Datatype ID */
@ -8826,7 +8924,11 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
if(test_open) {
TESTING("H5Ocopy(): compressed and opened dataset with nested VLEN datatype");
} else {
TESTING("H5Ocopy(): compressed dataset with nested VLEN datatype");
}
/* set initial data values */
for(i=0; i<DIM_SIZE_1; i++) {
@ -8884,6 +8986,8 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
/* close compact plist */
if(H5Pclose(pid) < 0) TEST_ERROR
if(!test_open) {
/* close the dataset */
if(H5Dclose(did) < 0) TEST_ERROR
@ -8893,6 +8997,7 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
/* open the source file with read-only */
if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR
}
/* create destination file */
if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR
@ -8902,8 +9007,10 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
/* copy the dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(!test_open) {
/* open the dataset for copy */
if((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR
}
/* open the destination dataset */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR
@ -9582,6 +9689,189 @@ error:
return 1;
} /* end test_copy_null_ref */
/*-------------------------------------------------------------------------
* Function: test_copy_null_ref_open
*
* Purpose: Creates 2 datasets with references, one with object and
* the other with region references. Copies these datasets
* to a new file without expanding references, causing them
* to become NULL. Next, copies these references to a third
* file with expanding references, to verify that NULL
* references are handled correctly.
*
* Note: this is copied from test_copy_null_ref() with modifications
* to test for opened datasets in the files.
*
* Return: Success: 0
* Failure: number of errors
*
* Programmer: Neil Fortner
* Wednesday, March 31, 2010
*
*-------------------------------------------------------------------------
*/
static int
test_copy_null_ref_open(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl)
{
hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
hid_t pid = -1; /* Object copy property list ID */
hid_t did1 = -1, did2 = -1; /* Dataset IDs */
hid_t did3 = -1, did4 = -1; /* Dataset IDs */
hid_t did5 = -1, did6 = -1; /* Dataset IDs */
hid_t dcpl = -1; /* Dataset creation property list */
hsize_t chunk_dim1d[1] = {2}; /* Chunk dimensions */
hsize_t dim1d[1] = {3}; /* Dataset dimensions */
hobj_ref_t obj_buf[3]; /* Buffer for object refs */
hdset_reg_ref_t reg_buf[3]; /* Buffer for region refs */
char zeros[MAX(sizeof(obj_buf),sizeof(reg_buf))]; /* Array of zeros, for memcmp */
char src_filename[NAME_BUF_SIZE];
char mid_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
TESTING("H5Ocopy(): NULL references for opened datasets");
/* Initialize "zeros" array */
HDmemset(zeros, 0, sizeof(zeros));
/* Initialize the filenames */
h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename);
h5_fixname(FILENAME[1], src_fapl, mid_filename, sizeof mid_filename);
h5_fixname(FILENAME[2], dst_fapl, dst_filename, sizeof dst_filename);
/* Reset file address checking info */
addr_reset();
/* Create source file */
if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0)
TEST_ERROR
/* Create dataspace */
if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR
/* create and set chunk plist */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
if(H5Pset_chunk(dcpl, 1, chunk_dim1d) < 0) TEST_ERROR
if(H5Pset_deflate(dcpl, 9) < 0) TEST_ERROR
if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) TEST_ERROR
/* Create object reference dataset at SRC file */
if((did1 = H5Dcreate2(fid1, "obj_ref_dset", H5T_STD_REF_OBJ, sid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create region reference dataset at SRC file */
if((did2 = H5Dcreate2(fid1, "reg_ref_dset", H5T_STD_REF_DSETREG,
sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create references */
if(H5Rcreate(&obj_buf[0], did1, ".", H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR
if(H5Rcreate(&obj_buf[1], did2, ".", H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR
if(H5Rcreate(&reg_buf[0], did1, ".", H5R_DATASET_REGION, sid) < 0)
TEST_ERROR
if(H5Rcreate(&reg_buf[1], did2, ".", H5R_DATASET_REGION, sid) < 0)
TEST_ERROR
/* Write data into file */
if(H5Dwrite(did1, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf)
< 0) TEST_ERROR
if(H5Dwrite(did2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,
reg_buf) < 0) TEST_ERROR
/* Create middle file */
if((fid2 = H5Fcreate(mid_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0)
TEST_ERROR
/* Copy the source file to the middle file. Note the expand references
* flag is not set. */
if(H5Ocopy(fid1, "/", fid2, "/A", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Close datasets in source file */
if(H5Dclose(did1) < 0) TEST_ERROR
if(H5Dclose(did2) < 0) TEST_ERROR
/* Close source file */
if(H5Fclose(fid1) < 0) TEST_ERROR
/* Open copied datasets */
if((did3 = H5Dopen2(fid2, "/A/obj_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR
if((did4 = H5Dopen2(fid2, "/A/reg_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR
/* Read copied datasets */
if(H5Dread(did3, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf)
< 0) TEST_ERROR
if(H5Dread(did4, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,
reg_buf) < 0) TEST_ERROR
/* Verify that the references contain only "0" bytes */
if(HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) TEST_ERROR
if(HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) TEST_ERROR
/* Create destination file */
if((fid3 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0)
TEST_ERROR
/* Create object copy property list */
if((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR
/* Set the "expand references" flag */
if(H5Pset_copy_object(pid, H5O_COPY_EXPAND_REFERENCE_FLAG) < 0) TEST_ERROR
/* Copy the middle file to the destination file. Note the expand references
* flag *is* set, even though the references are now NULL. */
if(H5Ocopy(fid2, "/", fid3, "/AA", pid, H5P_DEFAULT) < 0) TEST_ERROR
/* Close datasets in middle file */
if(H5Dclose(did3) < 0) TEST_ERROR
if(H5Dclose(did4) < 0) TEST_ERROR
/* Close the middle file */
if(H5Fclose(fid2) < 0) TEST_ERROR
/* Open copied datasets */
if((did5 = H5Dopen2(fid3, "/AA/A/obj_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR
if((did6 = H5Dopen2(fid3, "/AA/A/reg_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR
/* Read copied datasets */
if(H5Dread(did5, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf)
< 0) TEST_ERROR
if(H5Dread(did6, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,
reg_buf) < 0) TEST_ERROR
/* Verify that the references contain only "0" bytes */
if(HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) TEST_ERROR
if(HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) TEST_ERROR
/* Close */
if(H5Pclose(pid) < 0) TEST_ERROR
if(H5Pclose(dcpl) < 0) TEST_ERROR
if(H5Dclose(did5) < 0) TEST_ERROR
if(H5Dclose(did6) < 0) TEST_ERROR
if(H5Fclose(fid3) < 0) TEST_ERROR
if(H5Sclose(sid) < 0) TEST_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Pclose(pid);
H5Pclose(dcpl);
H5Sclose(sid);
H5Dclose(did1);
H5Dclose(did2);
H5Dclose(did3);
H5Dclose(did4);
H5Dclose(did5);
H5Dclose(did6);
H5Fclose(fid1);
H5Fclose(fid2);
H5Fclose(fid3);
} H5E_END_TRY;
return 1;
} /* end test_copy_null_ref_open */
/*-------------------------------------------------------------------------
* Function: test_copy_attr_crt_order
@ -13309,7 +13599,10 @@ test_copy_dataset_open(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst
hid_t sid = -1; /* Dataspace ID */
hid_t tid = -1; /* Datatype ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
hid_t did3 = -1, did4 = -1; /* Dataset IDs */
hid_t gid = -1, gid2 = -1; /* Group IDs */
hid_t pid = -1; /* Dataset creation property list */
hsize_t chunk_dim2d[2] = {CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimension sizes */
int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
int newbuf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
hsize_t dim2d[2]; /* Dataset dimensions */
@ -13352,14 +13645,23 @@ test_copy_dataset_open(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst
/* create 2D dataspace */
if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR
/* create 2D int dataset in SRC file */
/* create and set chunk plist */
if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
if(H5Pset_chunk(pid, 2, chunk_dim2d) < 0) TEST_ERROR
/* create 2D dataset in SRC file */
if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* create 2D chunked dataset in SRC file */
if((did2 = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, H5T_NATIVE_INT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR
/* write data to the dataset */
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR
/* attach attributes to the dataset */
if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR
if(test_copy_attach_attributes(did2, H5T_NATIVE_INT) < 0) TEST_ERROR
/*
* Test case 1
@ -13370,74 +13672,94 @@ test_copy_dataset_open(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst
*/
/* copy the opened dataset to another location in SRC file */
if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_src, NAME_DATASET_SIMPLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* open the copied dataset */
if((did2 = H5Dopen2(fid_src, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR
if((did3 = H5Dopen2(fid_src, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR
if((did4 = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check if the datasets are equal */
if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
if(compare_datasets(did, did3, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
if(compare_datasets(did2, did4, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
/* close the copied dataset */
if(H5Dclose(did2) < 0) TEST_ERROR
if(H5Dclose(did3) < 0) TEST_ERROR
if(H5Dclose(did4) < 0) TEST_ERROR
/*
* Copy to another file
*/
/* copy the opened dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* open the copied dataset in DST file */
if((did2 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
if((did3 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
if((did4 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR
/* Check if the datasets are equal */
if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
if(compare_datasets(did, did3, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
if(compare_datasets(did2, did4, H5P_DEFAULT, buf) != TRUE) TEST_ERROR
/* close the copied dataset in DST file */
if(H5Dclose(did2) < 0) TEST_ERROR
if(H5Dclose(did3) < 0) TEST_ERROR
if(H5Dclose(did4) < 0) TEST_ERROR
/* close the dataset in SRC file */
if(H5Dclose(did) < 0) TEST_ERROR
if(H5Dclose(did2) < 0) TEST_ERROR
/*
* Test case 2
*/
/* reopen the dataset in SRC file */
if((did = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
if((did2 = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR
/* write another set of data to the dataset */
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, newbuf) < 0) TEST_ERROR
if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, newbuf) < 0) TEST_ERROR
/*
* Copy within the same file
*/
/* copy the opened dataset to another location in SRC file */
if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_src, "NEW_DATASET", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_src, "NEW_DATASET_SIMPLE", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_src, "NEW_DATASET_CHUNKED", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* open the copied dataset */
if((did2 = H5Dopen2(fid_src, "NEW_DATASET", H5P_DEFAULT)) < 0) TEST_ERROR
if((did3 = H5Dopen2(fid_src, "NEW_DATASET_SIMPLE", H5P_DEFAULT)) < 0) TEST_ERROR
if((did4 = H5Dopen2(fid_src, "NEW_DATASET_CHUNKED", H5P_DEFAULT)) < 0) TEST_ERROR
/* Check if the datasets are equal */
if(compare_datasets(did, did2, H5P_DEFAULT, newbuf) != TRUE) TEST_ERROR
if(compare_datasets(did, did3, H5P_DEFAULT, newbuf) != TRUE) TEST_ERROR
if(compare_datasets(did2, did4, H5P_DEFAULT, newbuf) != TRUE) TEST_ERROR
/* close the copied dataset in SRC file */
if(H5Dclose(did2) < 0) TEST_ERROR
if(H5Dclose(did3) < 0) TEST_ERROR
if(H5Dclose(did4) < 0) TEST_ERROR
/*
* Copy to another file
*/
/* copy the opened dataset from SRC to DST */
if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, "NEW_DATASET", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, "NEW_DATASET_SIMPLE", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, "NEW_DATASET_CHUNKED", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* open the copied dataset in DST file */
if((did2 = H5Dopen2(fid_dst, "NEW_DATASET", H5P_DEFAULT)) < 0) TEST_ERROR
if((did3 = H5Dopen2(fid_dst, "NEW_DATASET_SIMPLE", H5P_DEFAULT)) < 0) TEST_ERROR
if((did4 = H5Dopen2(fid_dst, "NEW_DATASET_CHUNKED", H5P_DEFAULT)) < 0) TEST_ERROR
/* Check if the datasets are equal */
if(compare_datasets(did, did2, H5P_DEFAULT, newbuf) != TRUE) TEST_ERROR
if(compare_datasets(did, did3, H5P_DEFAULT, newbuf) != TRUE) TEST_ERROR
if(compare_datasets(did2, did4, H5P_DEFAULT, newbuf) != TRUE) TEST_ERROR
/* close the copied dataset in DST file */
if(H5Dclose(did2) < 0) TEST_ERROR
if(H5Dclose(did3) < 0) TEST_ERROR
if(H5Dclose(did4) < 0) TEST_ERROR
/* close the dataset at SRC file */
if(H5Dclose(did) < 0) TEST_ERROR
if(H5Dclose(did2) < 0) TEST_ERROR
/*
* Test case 3
@ -13696,15 +14018,28 @@ main(void)
/* The tests... */
nerrors += test_copy_dataset_simple(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_simple_samefile(fcpl_src, src_fapl);
nerrors += test_copy_dataset_simple_empty(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
/* Test with dataset opened in the file or not */
nerrors += test_copy_dataset_simple_empty(fcpl_src, fcpl_dst, src_fapl, dst_fapl, FALSE);
nerrors += test_copy_dataset_simple_empty(fcpl_src, fcpl_dst, src_fapl, dst_fapl, TRUE);
nerrors += test_copy_dataset_compound(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_chunked(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_chunked_empty(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_chunked_sparse(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_compressed(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_no_edge_filt(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_compact(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_multi_ohdr_chunks(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
/* Test with dataset opened in the file or not */
nerrors += test_copy_dataset_no_edge_filt(fcpl_src, fcpl_dst, src_fapl, dst_fapl, FALSE);
nerrors += test_copy_dataset_no_edge_filt(fcpl_src, fcpl_dst, src_fapl, dst_fapl, TRUE);
/* Test with dataset opened in the file or not */
nerrors += test_copy_dataset_compact(fcpl_src, fcpl_dst, src_fapl, dst_fapl, FALSE);
nerrors += test_copy_dataset_compact(fcpl_src, fcpl_dst, src_fapl, dst_fapl, TRUE);
nerrors += test_copy_dataset_multi_ohdr_chunks(fcpl_src, fcpl_dst, src_fapl, dst_fapl, FALSE);
nerrors += test_copy_dataset_multi_ohdr_chunks(fcpl_src, fcpl_dst, src_fapl, dst_fapl, TRUE);
nerrors += test_copy_dataset_attr_named_dtype(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_group_empty(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
@ -13714,7 +14049,11 @@ main(void)
nerrors += test_copy_group_loop(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_group_wide_loop(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_group_links(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_soft_link(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
/* Test with dataset opened in the file or not */
nerrors += test_copy_soft_link(fcpl_src, fcpl_dst, src_fapl, dst_fapl, FALSE);
nerrors += test_copy_soft_link(fcpl_src, fcpl_dst, src_fapl, dst_fapl, TRUE);
nerrors += test_copy_ext_link(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_exist(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_path(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
@ -13794,19 +14133,38 @@ main(void)
nerrors += test_copy_attribute_compound_vlstr(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_compact_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_contig_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_chunked_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
/* Test with dataset opened in the file or not */
nerrors += test_copy_dataset_chunked_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl, FALSE);
nerrors += test_copy_dataset_chunked_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl, TRUE);
nerrors += test_copy_dataset_compressed_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_compact_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_contig_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
/* Test with dataset opened in the file or not */
nerrors += test_copy_dataset_contig_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl, FALSE);
nerrors += test_copy_dataset_contig_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl, TRUE);
nerrors += test_copy_dataset_chunked_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_compressed_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
/* Test with dataset opened in the file or not */
nerrors += test_copy_dataset_compressed_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl, FALSE);
nerrors += test_copy_dataset_compressed_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl, TRUE);
nerrors += test_copy_dataset_contig_cmpd_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_chunked_cmpd_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_dataset_compact_cmpd_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_same_file_named_datatype(fcpl_src, src_fapl);
nerrors += test_copy_old_layout(fcpl_dst, dst_fapl);
/* Test with dataset opened in the file or not */
nerrors += test_copy_old_layout(fcpl_dst, dst_fapl, FALSE);
nerrors += test_copy_old_layout(fcpl_dst, dst_fapl, TRUE);
/* Test with dataset opened in the file or not */
nerrors += test_copy_null_ref(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_null_ref_open(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
nerrors += test_copy_iterate(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
} /* end if */