summaryrefslogtreecommitdiffstats
path: root/src/H5Dearray.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dearray.c')
-rw-r--r--src/H5Dearray.c298
1 files changed, 26 insertions, 272 deletions
diff --git a/src/H5Dearray.c b/src/H5Dearray.c
index b78f58c..fd57390 100644
--- a/src/H5Dearray.c
+++ b/src/H5Dearray.c
@@ -110,7 +110,7 @@ static herr_t H5D_earray_idx_init(const H5D_chk_idx_info_t *idx_info,
const H5S_t *space, haddr_t dset_ohdr_addr);
static herr_t H5D_earray_idx_create(const H5D_chk_idx_info_t *idx_info);
static hbool_t H5D_earray_idx_is_space_alloc(const H5O_storage_chunk_t *storage);
-static herr_t H5D_earray_idx_insert(const H5D_chk_idx_info_t *idx_info,
+static herr_t H5D_earray_idx_insert_addr(const H5D_chk_idx_info_t *idx_info,
H5D_chunk_ud_t *udata);
static herr_t H5D_earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info,
H5D_chunk_ud_t *udata);
@@ -127,10 +127,6 @@ static herr_t H5D_earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src,
static herr_t H5D_earray_idx_size(const H5D_chk_idx_info_t *idx_info,
hsize_t *size);
static herr_t H5D_earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr);
-static herr_t H5D_earray_idx_support(const H5D_chk_idx_info_t *idx_info,
- H5D_chunk_ud_t *udata, H5AC_info_t *child_entry);
-static herr_t H5D_earray_idx_unsupport(const H5D_chk_idx_info_t *idx_info,
- H5D_chunk_ud_t *udata, H5AC_info_t *child_entry);
static herr_t H5D_earray_idx_dump(const H5O_storage_chunk_t *storage,
FILE *stream);
static herr_t H5D_earray_idx_dest(const H5D_chk_idx_info_t *idx_info);
@@ -146,7 +142,7 @@ const H5D_chunk_ops_t H5D_COPS_EARRAY[1] = {{
H5D_earray_idx_init,
H5D_earray_idx_create,
H5D_earray_idx_is_space_alloc,
- H5D_earray_idx_insert,
+ H5D_earray_idx_insert_addr,
H5D_earray_idx_get_addr,
H5D_earray_idx_resize,
H5D_earray_idx_iterate,
@@ -156,8 +152,6 @@ const H5D_chunk_ops_t H5D_COPS_EARRAY[1] = {{
H5D_earray_idx_copy_shutdown,
H5D_earray_idx_size,
H5D_earray_idx_reset,
- H5D_earray_idx_support,
- H5D_earray_idx_unsupport,
H5D_earray_idx_dump,
H5D_earray_idx_dest
}};
@@ -1058,23 +1052,20 @@ H5D_earray_idx_is_space_alloc(const H5O_storage_chunk_t *storage)
/*-------------------------------------------------------------------------
- * Function: H5D_earray_idx_insert
+ * Function: H5D_earray_idx_insert_addr
*
- * Purpose: Create the chunk it if it doesn't exist, or reallocate the
- * chunk if its size changed.
+ * Purpose: Insert chunk address into the indexing structure.
*
* Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
- * Thursday, January 29, 2009
+ * Programmer: Vailin Choi; May 2014
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata)
+H5D_earray_idx_insert_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata)
{
H5EA_t *ea; /* Pointer to extensible array structure */
- hsize_t idx; /* Array index of chunk */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1086,6 +1077,7 @@ H5D_earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata)
HDassert(idx_info->storage);
HDassert(H5F_addr_defined(idx_info->storage->idx_addr));
HDassert(udata);
+ HDassert(udata->need_insert);
/* Check if the extensible array is open yet */
if(NULL == idx_info->storage->u.earray.ea) {
@@ -1097,129 +1089,30 @@ H5D_earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata)
/* Set convenience pointer to extensible array structure */
ea = idx_info->storage->u.earray.ea;
- /* Check for unlimited dim. not being the slowest-changing dim. */
- if(idx_info->layout->u.earray.unlim_dim > 0) {
- hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */
- unsigned ndims = (idx_info->layout->ndims - 1); /* Number of dimensions */
-
- /* Set up the swizzled chunk coordinates */
- HDmemcpy(swizzled_coords, udata->common.offset, ndims * sizeof(udata->common.offset[0]));
- H5VM_swizzle_coords(hsize_t, swizzled_coords, idx_info->layout->u.earray.unlim_dim);
-
- /* Calculate the index of this chunk */
- if(H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, idx_info->layout->u.earray.swizzled_down_chunks, &idx) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
- } /* end if */
- else {
- /* Calculate the index of this chunk */
- if(H5VM_chunk_index((idx_info->layout->ndims - 1), udata->common.offset, idx_info->layout->dim, idx_info->layout->down_chunks, &idx) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
- } /* end else */
+ if(!H5F_addr_defined(udata->addr))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "The chunk should have allocated already")
+ if(udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk index must be less than 2^32")
- /* Check for filters on chunks */
if(idx_info->pline->nused > 0) {
- H5D_earray_filt_elmt_t elmt; /* Extensible array element */
- unsigned allow_chunk_size_len; /* Allowed size of encoded chunk size */
- unsigned new_chunk_size_len; /* Size of encoded chunk size */
- hbool_t alloc_chunk = FALSE; /* Whether to allocate chunk */
-
- /* Compute the size required for encoding the size of a chunk, allowing
- * for an extra byte, in case the filter makes the chunk larger.
- */
- allow_chunk_size_len = 1 + ((H5VM_log2_gen(idx_info->layout->size) + 8) / 8);
- if(allow_chunk_size_len > 8)
- allow_chunk_size_len = 8;
-
- /* Compute encoded size of chunk */
- new_chunk_size_len = (H5VM_log2_gen(udata->nbytes) + 8) / 8;
- if(new_chunk_size_len > 8)
- HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "encoded chunk size is more than 8 bytes?!?")
-
- /* Check if the chunk became too large to be encoded */
- if(new_chunk_size_len > allow_chunk_size_len)
- HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk size can't be encoded")
-
- /* Get the information for the chunk */
- if(H5EA_get(ea, idx_info->dxpl_id, idx, &elmt) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info")
-
- /* Check for previous chunk */
- if(H5F_addr_defined(elmt.addr)) {
- /* Sanity check */
- HDassert(!H5F_addr_defined(udata->addr) || H5F_addr_eq(udata->addr, elmt.addr));
-
- /* Check for chunk being same size */
- if(udata->nbytes != elmt.nbytes) {
- /* Release previous chunk */
- /* Only free the old location if not doing SWMR writes - otherwise
- * we must keep the old chunk around in case a reader has an
- * outdated version of the b-tree node */
- if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) {
- H5_CHECK_OVERFLOW(elmt.nbytes, uint32_t, hsize_t);
- if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->dxpl_id, elmt.addr, (hsize_t)elmt.nbytes) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk")
- } /* end if */
- elmt.addr = HADDR_UNDEF;
- alloc_chunk = TRUE;
- } /* end if */
- else {
- /* Don't need to reallocate chunk, but send its address back up */
- if(!H5F_addr_defined(udata->addr))
- udata->addr = elmt.addr;
- } /* end else */
- } /* end if */
- else
- alloc_chunk = TRUE;
-
- /* Check if we need to allocate the chunk */
- if(alloc_chunk) {
- H5_CHECK_OVERFLOW(udata->nbytes, uint32_t, hsize_t);
- udata->addr = H5MF_alloc(idx_info->f, H5FD_MEM_DRAW, idx_info->dxpl_id, (hsize_t)udata->nbytes);
- if(!H5F_addr_defined(udata->addr))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk")
-
- /* Update the element information */
- elmt.addr = udata->addr;
- elmt.nbytes = udata->nbytes;
- elmt.filter_mask = udata->filter_mask;
-
- /* Set the info for the chunk */
- if(H5EA_set(ea, idx_info->dxpl_id, idx, &elmt) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info")
- } /* end if */
- } /* end if */
- else {
- HDassert(!H5F_addr_defined(udata->addr));
- HDassert(udata->nbytes == idx_info->layout->size);
+ H5D_earray_filt_elmt_t elmt; /* Extensible array element */
-#ifndef NDEBUG
-{
- haddr_t addr = HADDR_UNDEF; /* Address of chunk in file */
+ elmt.addr = udata->addr;
+ elmt.nbytes = udata->nbytes;
+ elmt.filter_mask = udata->filter_mask;
- /* Get the address for the chunk */
- if(H5EA_get(ea, idx_info->dxpl_id, idx, &addr) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address")
- HDassert(!H5F_addr_defined(addr));
-}
-#endif /* NDEBUG */
-
- /*
- * Allocate storage for the new chunk
- */
- H5_CHECK_OVERFLOW(udata->nbytes, /*From: */uint32_t, /*To: */hsize_t);
- udata->addr = H5MF_alloc(idx_info->f, H5FD_MEM_DRAW, idx_info->dxpl_id, (hsize_t)udata->nbytes);
- if(!H5F_addr_defined(udata->addr))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "file allocation failed")
-
- /* Set the address for the chunk */
- if(H5EA_set(ea, idx_info->dxpl_id, idx, &udata->addr) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk address")
- } /* end else */
- HDassert(H5F_addr_defined(udata->addr));
+ /* Set the info for the chunk */
+ if(H5EA_set(ea, idx_info->dxpl_id, udata->chunk_idx, &elmt) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info")
+ } else {
+ /* Set the address for the chunk */
+ if(H5EA_set(ea, idx_info->dxpl_id, udata->chunk_idx, &udata->addr) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk address")
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5D_earray_idx_insert() */
+} /* H5D_earray_idx_insert_addr() */
/*-------------------------------------------------------------------------
@@ -1282,6 +1175,8 @@ H5D_earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udat
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
} /* end else */
+ udata->chunk_idx = idx;
+
/* Check for filters on chunks */
if(idx_info->pline->nused > 0) {
H5D_earray_filt_elmt_t elmt; /* Extensible array element */
@@ -1872,147 +1767,6 @@ H5D_earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr)
/*-------------------------------------------------------------------------
- * Function: H5D_earray_idx_support
- *
- * Purpose: Create a dependency between a chunk [proxy] and the index
- * metadata that contains the record for the chunk.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Thursday, May 21, 2009
- *
- *-------------------------------------------------------------------------
- */
-static htri_t
-H5D_earray_idx_support(const H5D_chk_idx_info_t *idx_info,
- H5D_chunk_ud_t *udata, H5AC_info_t *child_entry)
-{
- H5EA_t *ea; /* Pointer to extensible array structure */
- hsize_t idx; /* Array index of chunk */
- herr_t ret_value = TRUE; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check args */
- HDassert(idx_info);
- HDassert(idx_info->layout);
- HDassert(idx_info->storage);
- HDassert(udata);
- HDassert(child_entry);
-
- /* Check if the extensible array is open yet */
- if(NULL == idx_info->storage->u.earray.ea) {
- /* Open the extensible array in file */
- if(H5D_earray_idx_open(idx_info) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array")
- } /* end if */
-
- /* Set convenience pointer to extensible array structure */
- ea = idx_info->storage->u.earray.ea;
-
- /* Check for unlimited dim. not being the slowest-changing dim. */
- if(idx_info->layout->u.earray.unlim_dim > 0) {
- hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */
- unsigned ndims = (idx_info->layout->ndims - 1); /* Number of dimensions */
-
- /* Set up the swizzled chunk coordinates */
- HDmemcpy(swizzled_coords, udata->common.offset, ndims * sizeof(udata->common.offset[0]));
- H5VM_swizzle_coords(hsize_t, swizzled_coords, idx_info->layout->u.earray.unlim_dim);
-
- /* Calculate the index of this chunk */
- if(H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, idx_info->layout->u.earray.swizzled_down_chunks, &idx) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
- } /* end if */
- else {
- /* Calculate the index of this chunk */
- if(H5VM_chunk_index((idx_info->layout->ndims - 1), udata->common.offset, idx_info->layout->dim, idx_info->layout->down_chunks, &idx) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
- } /* end else */
-
- /* Create flush dependency between the child_entry and the piece of metadata
- * in the extensible array that contains the entry for this chunk.
- */
- if(H5EA_support(ea, idx_info->dxpl_id, idx, child_entry) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on extensible array metadata")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_earray_idx_support() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5D_earray_idx_unsupport
- *
- * Purpose: Remove a dependency between a chunk [proxy] and the index
- * metadata that contains the record for the chunk.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Thursday, May 21, 2009
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5D_earray_idx_unsupport(const H5D_chk_idx_info_t *idx_info,
- H5D_chunk_ud_t *udata, H5AC_info_t *child_entry)
-{
- H5EA_t *ea; /* Pointer to extensible array structure */
- hsize_t idx; /* Array index of chunk */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check args */
- HDassert(idx_info);
- HDassert(idx_info->layout);
- HDassert(idx_info->storage);
- HDassert(udata);
- HDassert(child_entry);
-
- /* Check if the extensible array is open yet */
- if(NULL == idx_info->storage->u.earray.ea) {
- /* Open the extensible array in file */
- if(H5D_earray_idx_open(idx_info) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array")
- } /* end if */
-
- /* Set convenience pointer to extensible array structure */
- ea = idx_info->storage->u.earray.ea;
-
- /* Check for unlimited dim. not being the slowest-changing dim. */
- if(idx_info->layout->u.earray.unlim_dim > 0) {
- hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */
- unsigned ndims = (idx_info->layout->ndims - 1); /* Number of dimensions */
-
- /* Set up the swizzled chunk coordinates */
- HDmemcpy(swizzled_coords, udata->common.offset, ndims * sizeof(udata->common.offset[0]));
- H5VM_swizzle_coords(hsize_t, swizzled_coords, idx_info->layout->u.earray.unlim_dim);
-
-
- /* Calculate the index of this chunk */
- if(H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, idx_info->layout->u.earray.swizzled_down_chunks, &idx) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
- } /* end if */
- else {
- /* Calculate the index of this chunk */
- if(H5VM_chunk_index((idx_info->layout->ndims - 1), udata->common.offset, idx_info->layout->dim, idx_info->layout->down_chunks, &idx) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
- } /* end else */
-
- /* Remove flush dependency between the child_entry and the piece of metadata
- * in the extensible array that contains the entry for this chunk.
- */
- if(H5EA_unsupport(ea, idx_info->dxpl_id, idx, child_entry) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTUNDEPEND, FAIL, "unable to remove flush dependency on extensible array metadata")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_earray_idx_unsupport() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5D_earray_idx_dump
*
* Purpose: Dump indexing information to a stream.