diff options
Diffstat (limited to 'src/H5Olayout.c')
-rw-r--r-- | src/H5Olayout.c | 211 |
1 files changed, 3 insertions, 208 deletions
diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 18fd664..be1411d 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -591,9 +591,9 @@ H5O_layout_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg HDassert(f); HDassert(mesg); - ret_value = H5O_layout_meta_size(f, mesg); - if(H5D_COMPACT == mesg->type) - ret_value += mesg->store.u.compact.size;/* data for compact dataset */ + /* Compute serialized size */ + /* (including possibly compact data) */ + ret_value = H5D_layout_meta_size(f, mesg, TRUE); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_layout_size() */ @@ -915,208 +915,3 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_layout_debug() */ - -/*------------------------------------------------------------------------- - * Function: H5O_layout_meta_size - * - * Purpose: Returns the size of the raw message in bytes except raw data - * part for compact dataset. This function doesn't take into - * account message alignment. - * - * Return: Success: Message data size in bytes(except raw data - * for compact dataset) - * Failure: 0 - * - * Programmer: Raymond Lu - * August 14, 2002 - * - *------------------------------------------------------------------------- - */ -size_t -H5O_layout_meta_size(const H5F_t *f, const void *_mesg) -{ - const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - size_t ret_value; - - FUNC_ENTER_NOAPI_NOINIT(H5O_layout_meta_size) - - /* check args */ - HDassert(f); - HDassert(mesg); - - ret_value = 1 + /* Version number */ - 1; /* layout class type */ - - switch(mesg->type) { - case H5D_COMPACT: - /* Size of raw data */ - ret_value += 2; - break; - - case H5D_CONTIGUOUS: - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ - ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ - break; - - case H5D_CHUNKED: - if(mesg->version < H5O_LAYOUT_VERSION_4) { - /* Number of dimensions (1 byte) */ - HDassert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); - ret_value++; - - /* B-tree address */ - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ - - /* Dimension sizes */ - ret_value += mesg->u.chunk.ndims * 4; - } /* end if */ - else { - /* Chunked layout feature flags */ - ret_value++; - - /* Number of dimensions (1 byte) */ - HDassert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); - ret_value++; - - /* Encoded # of bytes for each chunk dimension */ - HDassert(mesg->u.chunk.enc_bytes_per_dim > 0 && mesg->u.chunk.enc_bytes_per_dim <= 8); - ret_value++; - - /* Dimension sizes */ - ret_value += mesg->u.chunk.ndims * mesg->u.chunk.enc_bytes_per_dim; - - /* Type of chunk index */ - ret_value++; - - switch(mesg->u.chunk.idx_type) { - case H5D_CHUNK_IDX_BTREE: /* Remove this when v2 B-tree indices added */ - /* B-tree address */ - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ - break; - - case H5D_CHUNK_IDX_FARRAY: - /* Fixed array creation parameters */ - ret_value += 1; - - /* Fixed array header address */ - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ - break; - - case H5D_CHUNK_IDX_EARRAY: - /* Extensible array creation parameters */ - ret_value += 5; - - /* Extensible array header address */ - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ - break; - - default: - HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid chunk index type") - } /* end switch */ - } /* end else */ - break; - - default: - HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_layout_meta_size() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_layout_set_latest_version - * - * Purpose: Set the encoding for a layout to the latest version. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, January 15, 2009 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_layout_set_latest_version(H5O_layout_t *layout, const H5S_t *space) -{ - int sndims; /* Rank of dataspace */ - unsigned ndims; /* Rank of dataspace */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5O_layout_set_latest_version, FAIL) - - /* Sanity check */ - HDassert(layout); - - /* Set encoding of layout to latest version */ - layout->version = H5O_LAYOUT_VERSION_LATEST; - - /* Query the dimensionality of the dataspace */ - if((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "invalid dataspace rank") - ndims = (unsigned)sndims; - - /* Avoid scalar/null dataspace */ - if(ndims > 0) { - hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Maximum dimension sizes */ - hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */ - unsigned unlim_count; /* Count of unlimited max. dimensions */ - hbool_t fixed = FALSE; /* Fixed dimension or not */ - unsigned u; /* Local index variable */ - - /* Query the dataspace's dimensions */ - if(H5S_get_simple_extent_dims(space, curr_dims, max_dims) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get dataspace max. dimensions") - - /* Spin through the max. dimensions, looking for unlimited dimensions */ - unlim_count = 0; - for(u = 0; u < ndims; u++) - if(max_dims[u] == H5S_UNLIMITED) - unlim_count++; - - /* Check if it is fixed dimension */ - if(0 == unlim_count) { - fixed = TRUE; - for(u = 0; u < ndims; u++) - if(curr_dims[u] != max_dims[u]) { - fixed = FALSE; - break; - } /* end if */ - } /* end if */ - - /* If we have only 1 unlimited dimension, we can use extensible array index */ - if(1 == unlim_count) { - /* Set the chunk index type to an extensible array */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_EARRAY; - - /* Set the extensible array creation parameters */ - /* (use hard-coded defaults for now, until we give applications - * control over this with a property list - QAK) - */ - layout->u.chunk.u.earray.cparam.max_nelmts_bits = H5D_EARRAY_MAX_NELMTS_BITS; - layout->u.chunk.u.earray.cparam.idx_blk_elmts = H5D_EARRAY_IDX_BLK_ELMTS; - layout->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs = H5D_EARRAY_SUP_BLK_MIN_DATA_PTRS; - layout->u.chunk.u.earray.cparam.data_blk_min_elmts = H5D_EARRAY_DATA_BLK_MIN_ELMTS; - layout->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits = H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS; - } /* end if */ - /* Chunked datasets with fixed dimensions */ - else if(layout->type == H5D_CHUNKED && fixed) { - /* Set the chunk index type to a fixed array */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; - - /* Set the fixed array creation parameters */ - /* (use hard-coded defaults for now, until we give applications - * control over this with a property list - QAK) - */ - layout->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS; - } /* end if */ - else { - /* Add setup for v2 B-tree indices here */ - } /* end else */ - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_layout_set_latest_version() */ - |