diff options
author | Songyu Lu <songyulu@hdfgroup.org> | 2019-04-17 21:53:40 (GMT) |
---|---|---|
committer | Songyu Lu <songyulu@hdfgroup.org> | 2019-04-17 21:53:40 (GMT) |
commit | fc47e2e07a252f9421c6d11e88cfd63e5a337183 (patch) | |
tree | 7e5d55c6e22dc6e99439db667a5bfc4ac8679e8e /src | |
parent | b90b5be59bd7f38b92d575c7e6ce380ca15f10f7 (diff) | |
download | hdf5-fc47e2e07a252f9421c6d11e88cfd63e5a337183.zip hdf5-fc47e2e07a252f9421c6d11e88cfd63e5a337183.tar.gz hdf5-fc47e2e07a252f9421c6d11e88cfd63e5a337183.tar.bz2 |
Changing the prefix of external file and VDS from empty string to null for performance improvement.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Defl.c | 20 | ||||
-rw-r--r-- | src/H5Dint.c | 35 |
2 files changed, 30 insertions, 25 deletions
diff --git a/src/H5Defl.c b/src/H5Defl.c index 19f3a00..eef758c 100644 --- a/src/H5Defl.c +++ b/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); diff --git a/src/H5Dint.c b/src/H5Dint.c index 15a2050..736f17c 100644 --- a/src/H5Dint.c +++ b/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) |