mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
Changing the prefix of external file and VDS from empty string to null for performance improvement.
This commit is contained in:
parent
b90b5be59b
commit
fc47e2e07a
20
src/H5Defl.c
20
src/H5Defl.c
@ -287,8 +287,13 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size
|
||||
HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "read past logical end of file")
|
||||
if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip))
|
||||
HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed")
|
||||
if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0)
|
||||
HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name")
|
||||
if(dset->shared->extfile_prefix) {
|
||||
if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0)
|
||||
HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name")
|
||||
} else {
|
||||
if(H5_combine_path("", efl->slot[u].name, &full_name) < 0)
|
||||
HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name")
|
||||
}
|
||||
if((fd = HDopen(full_name, O_RDONLY)) < 0)
|
||||
HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file")
|
||||
if(HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0)
|
||||
@ -379,8 +384,13 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz
|
||||
HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file")
|
||||
if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip))
|
||||
HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed")
|
||||
if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0)
|
||||
HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name")
|
||||
if(dset->shared->extfile_prefix) {
|
||||
if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0)
|
||||
HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name")
|
||||
} else {
|
||||
if(H5_combine_path("", efl->slot[u].name, &full_name) < 0)
|
||||
HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name")
|
||||
}
|
||||
if((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_CREATE_MODE_RW)) < 0) {
|
||||
if(HDaccess(full_name, F_OK) < 0)
|
||||
HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist")
|
||||
@ -477,7 +487,6 @@ H5D__efl_readvv(const H5D_io_info_t *io_info,
|
||||
HDassert(io_info->u.rbuf);
|
||||
HDassert(io_info->dset);
|
||||
HDassert(io_info->dset->shared);
|
||||
HDassert(io_info->dset->shared->extfile_prefix);
|
||||
HDassert(dset_curr_seq);
|
||||
HDassert(dset_len_arr);
|
||||
HDassert(dset_off_arr);
|
||||
@ -561,7 +570,6 @@ H5D__efl_writevv(const H5D_io_info_t *io_info,
|
||||
HDassert(io_info->u.wbuf);
|
||||
HDassert(io_info->dset);
|
||||
HDassert(io_info->dset->shared);
|
||||
HDassert(io_info->dset->shared->extfile_prefix);
|
||||
HDassert(dset_curr_seq);
|
||||
HDassert(dset_len_arr);
|
||||
HDassert(dset_off_arr);
|
||||
|
35
src/H5Dint.c
35
src/H5Dint.c
@ -1133,7 +1133,7 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **
|
||||
/* filename is interpreted as relative to the current directory,
|
||||
* does not need to be expanded
|
||||
*/
|
||||
*file_prefix = "";
|
||||
*file_prefix = NULL;
|
||||
} /* end if */
|
||||
else {
|
||||
if(HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) {
|
||||
@ -1382,10 +1382,8 @@ done:
|
||||
} /* end if */
|
||||
if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0)
|
||||
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list")
|
||||
if(new_dset->shared->extfile_prefix && new_dset->shared->extfile_prefix[0] != '\0')
|
||||
new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix);
|
||||
if(new_dset->shared->vds_prefix && new_dset->shared->vds_prefix[0] != '\0')
|
||||
new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix);
|
||||
new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix);
|
||||
new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix);
|
||||
new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared);
|
||||
} /* end if */
|
||||
new_dset->oloc.file = NULL;
|
||||
@ -1540,8 +1538,13 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id)
|
||||
/* Check whether the external file prefix of the already open dataset
|
||||
* matches the new external file prefix
|
||||
*/
|
||||
if(HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset")
|
||||
if(extfile_prefix && dataset->shared->extfile_prefix) {
|
||||
if(HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset")
|
||||
} else {
|
||||
if(extfile_prefix || dataset->shared->extfile_prefix)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset")
|
||||
}
|
||||
|
||||
/* Check if the object has been opened through the top file yet */
|
||||
if(H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) {
|
||||
@ -1559,19 +1562,15 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id)
|
||||
ret_value = dataset;
|
||||
|
||||
done:
|
||||
if(extfile_prefix && extfile_prefix[0] != '\0')
|
||||
extfile_prefix = (char *)H5MM_xfree(extfile_prefix);
|
||||
if(vds_prefix && vds_prefix[0] != '\0')
|
||||
vds_prefix = (char *)H5MM_xfree(vds_prefix);
|
||||
extfile_prefix = (char *)H5MM_xfree(extfile_prefix);
|
||||
vds_prefix = (char *)H5MM_xfree(vds_prefix);
|
||||
|
||||
if(ret_value == NULL) {
|
||||
/* Free the location--casting away const*/
|
||||
if(dataset) {
|
||||
if(shared_fo == NULL && dataset->shared) { /* Need to free shared fo */
|
||||
if(dataset->shared->extfile_prefix && dataset->shared->extfile_prefix[0] != '\0')
|
||||
dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix);
|
||||
if(dataset->shared->vds_prefix && dataset->shared->vds_prefix[0] != '\0')
|
||||
dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix);
|
||||
dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix);
|
||||
dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix);
|
||||
dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared);
|
||||
}
|
||||
|
||||
@ -1950,12 +1949,10 @@ H5D_close(H5D_t *dataset)
|
||||
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info")
|
||||
|
||||
/* Free the external file prefix */
|
||||
if(dataset->shared->extfile_prefix && dataset->shared->extfile_prefix[0] != '\0')
|
||||
dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix);
|
||||
dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix);
|
||||
|
||||
/* Free the vds file prefix */
|
||||
if(dataset->shared->vds_prefix && dataset->shared->vds_prefix[0] != '\0')
|
||||
dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix);
|
||||
dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix);
|
||||
|
||||
/* Release layout, fill-value, efl & pipeline messages */
|
||||
if(dataset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT)
|
||||
|
Loading…
Reference in New Issue
Block a user