summaryrefslogtreecommitdiffstats
path: root/src/H5Dcompact.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-07-31 03:08:12 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-07-31 03:08:12 (GMT)
commit0eb775f3583f05b41fdab359d53bbc70c9a13db0 (patch)
tree0bb23f0ad2a9e5f6bf620b991d655bd380c979a7 /src/H5Dcompact.c
parent361586a90e00fb4f13fcb85dff669f13ff872b94 (diff)
downloadhdf5-0eb775f3583f05b41fdab359d53bbc70c9a13db0.zip
hdf5-0eb775f3583f05b41fdab359d53bbc70c9a13db0.tar.gz
hdf5-0eb775f3583f05b41fdab359d53bbc70c9a13db0.tar.bz2
[svn-r17281] Description:
Further refactoring of the dataset layout information, to separate the storage information from the layout info. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.7 (amazon) in debug mode Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5Dcompact.c')
-rw-r--r--src/H5Dcompact.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index ae6a72e..831ab13 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -38,6 +38,7 @@
#include "H5FDprivate.h" /* File drivers */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* Object headers */
#include "H5Vprivate.h" /* Vector and array functions */
@@ -58,7 +59,7 @@
/* Layout operation callbacks */
static herr_t H5D_compact_construct(H5F_t *f, H5D_t *dset);
-static hbool_t H5D_compact_is_space_alloc(const H5O_layout_t *layout);
+static hbool_t H5D_compact_is_space_alloc(const H5O_storage_t *storage);
static herr_t H5D_compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space,
H5D_chunk_map_t *cm);
@@ -213,12 +214,12 @@ done:
*-------------------------------------------------------------------------
*/
static hbool_t
-H5D_compact_is_space_alloc(const H5O_layout_t UNUSED *layout)
+H5D_compact_is_space_alloc(const H5O_storage_t UNUSED *storage)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_compact_is_space_alloc)
/* Sanity checks */
- HDassert(layout);
+ HDassert(storage);
/* Compact storage is currently always allocated */
FUNC_LEAVE_NOAPI(TRUE)
@@ -380,8 +381,9 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-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)
+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)
{
hid_t tid_src = -1; /* Datatype ID for source datatype */
hid_t tid_dst = -1; /* Datatype ID for destination datatype */
@@ -395,15 +397,19 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
FUNC_ENTER_NOAPI(H5D_compact_copy, FAIL)
/* Check args */
- HDassert(layout_src && H5D_COMPACT == layout_src->type);
HDassert(f_src);
+ HDassert(storage_src);
HDassert(f_dst);
- HDassert(layout_dst && H5D_COMPACT == layout_dst->type);
+ HDassert(storage_dst);
HDassert(dt_src);
+ /* Allocate space for destination data */
+ if(NULL == (storage_dst->buf = H5MM_malloc(storage_src->size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate memory for compact dataset")
+
/* Create datatype ID for src datatype, so it gets freed */
if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
/* If there's a VLEN source datatype, do type conversion information */
if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
@@ -449,7 +455,7 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
max_dt_size = MAX(max_dt_size, tmp_dt_size);
/* Set number of whole elements that fit in buffer */
- if(0 == (nelmts = layout_src->storage.u.compact.size / src_dt_size))
+ if(0 == (nelmts = storage_src->size / src_dt_size))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "element size too large")
/* Set up number of bytes to copy, and initial buffer size */
@@ -476,7 +482,7 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
if(NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- HDmemcpy(buf, layout_src->storage.u.compact.buf, layout_src->storage.u.compact.size);
+ HDmemcpy(buf, storage_src->buf, storage_src->size);
/* Convert from source file to memory */
if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, NULL, dxpl_id) < 0)
@@ -492,7 +498,7 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
- HDmemcpy(layout_dst->storage.u.compact.buf, buf, layout_dst->storage.u.compact.size);
+ HDmemcpy(storage_dst->buf, buf, storage_dst->size);
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")
@@ -504,24 +510,27 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
size_t ref_count;
/* Determine # of reference elements to copy */
- ref_count = layout_src->storage.u.compact.size / H5T_get_size(dt_src);
+ ref_count = storage_src->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->storage.u.compact.buf, dxpl_id, f_dst,
- layout_dst->storage.u.compact.buf, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0)
+ if(H5O_copy_expand_ref(f_src, storage_src->buf, dxpl_id, f_dst,
+ storage_dst->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->storage.u.compact.buf, 0, layout_src->storage.u.compact.size);
+ HDmemset(storage_dst->buf, 0, storage_src->size);
} /* end if */
else
/* Type conversion not necessary */
- HDmemcpy(layout_dst->storage.u.compact.buf, layout_src->storage.u.compact.buf, layout_src->storage.u.compact.size);
+ HDmemcpy(storage_dst->buf, storage_src->buf, storage_src->size);
} /* end if */
else
/* Type conversion not necessary */
- HDmemcpy(layout_dst->storage.u.compact.buf, layout_src->storage.u.compact.buf, layout_src->storage.u.compact.size);
+ HDmemcpy(storage_dst->buf, storage_src->buf, storage_src->size);
+
+ /* Mark destination buffer as dirty */
+ storage_dst->dirty = TRUE;
done:
if(buf_sid > 0 && H5I_dec_ref(buf_sid, FALSE) < 0)