diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 14:04:36 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 14:04:36 (GMT) |
commit | f1ba03cea5b82699a984c80bd2deac14fdc8df18 (patch) | |
tree | ebe777c3e0b83f4c4cec9212731da9ebe0a0cfd3 /src/H5Dbtree2.c | |
parent | 10343c197906415388f2a4c8d292e21d25cf7381 (diff) | |
download | hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.zip hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.gz hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.bz2 |
Source formatted
Diffstat (limited to 'src/H5Dbtree2.c')
-rw-r--r-- | src/H5Dbtree2.c | 641 |
1 files changed, 301 insertions, 340 deletions
diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index d233ce5..51380e4 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -22,64 +22,60 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for creating callback context */ typedef struct H5D_bt2_ctx_ud_t { - const H5F_t *f; /* Pointer to file info */ - uint32_t chunk_size; /* Size of chunk (bytes; for filtered object) */ - unsigned ndims; /* Number of dimensions */ - uint32_t *dim; /* Size of chunk in elements */ + const H5F_t *f; /* Pointer to file info */ + uint32_t chunk_size; /* Size of chunk (bytes; for filtered object) */ + unsigned ndims; /* Number of dimensions */ + uint32_t * dim; /* Size of chunk in elements */ } H5D_bt2_ctx_ud_t; /* The callback context */ typedef struct H5D_bt2_ctx_t { - uint32_t chunk_size; /* Size of chunk (bytes; constant for unfiltered object) */ - size_t sizeof_addr; /* Size of file addresses in the file (bytes) */ - size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ - unsigned ndims; /* Number of dimensions in chunk */ - uint32_t *dim; /* Size of chunk in elements */ + uint32_t chunk_size; /* Size of chunk (bytes; constant for unfiltered object) */ + size_t sizeof_addr; /* Size of file addresses in the file (bytes) */ + size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ + unsigned ndims; /* Number of dimensions in chunk */ + uint32_t *dim; /* Size of chunk in elements */ } H5D_bt2_ctx_t; /* Callback info for iteration over chunks in v2 B-tree */ typedef struct H5D_bt2_it_ud_t { - H5D_chunk_cb_func_t cb; /* Callback routine for the chunk */ - void *udata; /* User data for the chunk's callback routine */ + H5D_chunk_cb_func_t cb; /* Callback routine for the chunk */ + void * udata; /* User data for the chunk's callback routine */ } H5D_bt2_it_ud_t; /* User data for compare callback */ typedef struct H5D_bt2_ud_t { - H5D_chunk_rec_t rec; /* The record to search for */ - unsigned ndims; /* Number of dimensions for the chunked dataset */ + H5D_chunk_rec_t rec; /* The record to search for */ + unsigned ndims; /* Number of dimensions for the chunked dataset */ } H5D_bt2_ud_t; - /********************/ /* Local Prototypes */ /********************/ /* Shared v2 B-tree methods for indexing filtered and non-filtered chunked datasets */ -static void *H5D__bt2_crt_context(void *udata); +static void * H5D__bt2_crt_context(void *udata); static herr_t H5D__bt2_dst_context(void *ctx); static herr_t H5D__bt2_store(void *native, const void *udata); static herr_t H5D__bt2_compare(const void *rec1, const void *rec2, int *result); @@ -87,14 +83,14 @@ static herr_t H5D__bt2_compare(const void *rec1, const void *rec2, int *result); /* v2 B-tree class for indexing non-filtered chunked datasets */ static herr_t H5D__bt2_unfilt_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5D__bt2_unfilt_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *u_ctx); +static herr_t H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *u_ctx); /* v2 B-tree class for indexing filtered chunked datasets */ static herr_t H5D__bt2_filt_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5D__bt2_filt_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *u_ctx); +static herr_t H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *u_ctx); /* Helper routine */ static herr_t H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info); @@ -116,29 +112,24 @@ static herr_t H5D__bt2_remove_cb(const void *nrecord, void *_udata); static herr_t H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed); /* Chunked layout indexing callbacks for v2 B-tree indexing */ -static herr_t H5D__bt2_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__bt2_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); -static herr_t H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, - FILE *stream); -static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info); - +static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst); +static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); +static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info); /*********************/ /* Package Variables */ @@ -146,58 +137,58 @@ static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Chunked dataset I/O ops for v2 B-tree indexing */ const H5D_chunk_ops_t H5D_COPS_BT2[1] = {{ - TRUE, /* Fixed array indices support SWMR access */ - H5D__bt2_idx_init, /* init */ - H5D__bt2_idx_create, /* create */ - H5D__bt2_idx_is_space_alloc, /* is_space_alloc */ - H5D__bt2_idx_insert, /* insert */ - H5D__bt2_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__bt2_idx_iterate, /* iterate */ - H5D__bt2_idx_remove, /* remove */ - H5D__bt2_idx_delete, /* delete */ - H5D__bt2_idx_copy_setup, /* copy_setup */ - H5D__bt2_idx_copy_shutdown, /* copy_shutdown */ - H5D__bt2_idx_size, /* size */ - H5D__bt2_idx_reset, /* reset */ - H5D__bt2_idx_dump, /* dump */ - H5D__bt2_idx_dest /* destroy */ + TRUE, /* Fixed array indices support SWMR access */ + H5D__bt2_idx_init, /* init */ + H5D__bt2_idx_create, /* create */ + H5D__bt2_idx_is_space_alloc, /* is_space_alloc */ + H5D__bt2_idx_insert, /* insert */ + H5D__bt2_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__bt2_idx_iterate, /* iterate */ + H5D__bt2_idx_remove, /* remove */ + H5D__bt2_idx_delete, /* delete */ + H5D__bt2_idx_copy_setup, /* copy_setup */ + H5D__bt2_idx_copy_shutdown, /* copy_shutdown */ + H5D__bt2_idx_size, /* size */ + H5D__bt2_idx_reset, /* reset */ + H5D__bt2_idx_dump, /* dump */ + H5D__bt2_idx_dest /* destroy */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ /* v2 B-tree class for indexing non-filtered chunked datasets */ -const H5B2_class_t H5D_BT2[1] = {{ /* B-tree class information */ - H5B2_CDSET_ID, /* Type of B-tree */ - "H5B2_CDSET_ID", /* Name of B-tree class */ - sizeof(H5D_chunk_rec_t), /* Size of native record */ - H5D__bt2_crt_context, /* Create client callback context */ - H5D__bt2_dst_context, /* Destroy client callback context */ - H5D__bt2_store, /* Record storage callback */ - H5D__bt2_compare, /* Record comparison callback */ - H5D__bt2_unfilt_encode, /* Record encoding callback */ - H5D__bt2_unfilt_decode, /* Record decoding callback */ - H5D__bt2_unfilt_debug /* Record debugging callback */ +const H5B2_class_t H5D_BT2[1] = {{ + /* B-tree class information */ + H5B2_CDSET_ID, /* Type of B-tree */ + "H5B2_CDSET_ID", /* Name of B-tree class */ + sizeof(H5D_chunk_rec_t), /* Size of native record */ + H5D__bt2_crt_context, /* Create client callback context */ + H5D__bt2_dst_context, /* Destroy client callback context */ + H5D__bt2_store, /* Record storage callback */ + H5D__bt2_compare, /* Record comparison callback */ + H5D__bt2_unfilt_encode, /* Record encoding callback */ + H5D__bt2_unfilt_decode, /* Record decoding callback */ + H5D__bt2_unfilt_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing filtered chunked datasets */ -const H5B2_class_t H5D_BT2_FILT[1] = {{ /* B-tree class information */ - H5B2_CDSET_FILT_ID, /* Type of B-tree */ - "H5B2_CDSET_FILT_ID", /* Name of B-tree class */ - sizeof(H5D_chunk_rec_t), /* Size of native record */ - H5D__bt2_crt_context, /* Create client callback context */ - H5D__bt2_dst_context, /* Destroy client callback context */ - H5D__bt2_store, /* Record storage callback */ - H5D__bt2_compare, /* Record comparison callback */ - H5D__bt2_filt_encode, /* Record encoding callback */ - H5D__bt2_filt_decode, /* Record decoding callback */ - H5D__bt2_filt_debug /* Record debugging callback */ +const H5B2_class_t H5D_BT2_FILT[1] = {{ + /* B-tree class information */ + H5B2_CDSET_FILT_ID, /* Type of B-tree */ + "H5B2_CDSET_FILT_ID", /* Name of B-tree class */ + sizeof(H5D_chunk_rec_t), /* Size of native record */ + H5D__bt2_crt_context, /* Create client callback context */ + H5D__bt2_dst_context, /* Destroy client callback context */ + H5D__bt2_store, /* Record storage callback */ + H5D__bt2_compare, /* Record comparison callback */ + H5D__bt2_filt_encode, /* Record encoding callback */ + H5D__bt2_filt_decode, /* Record decoding callback */ + H5D__bt2_filt_debug /* Record debugging callback */ }}; - /*******************/ /* Local Variables */ /*******************/ @@ -208,8 +199,6 @@ H5FL_DEFINE_STATIC(H5D_bt2_ctx_t); /* Declare a free list to manage the page elements */ H5FL_ARR_DEFINE_STATIC(uint32_t, H5O_LAYOUT_NDIMS); - - /*------------------------------------------------------------------------- * Function: H5D__bt2_crt_context * @@ -226,9 +215,9 @@ static void * H5D__bt2_crt_context(void *_udata) { H5D_bt2_ctx_ud_t *udata = (H5D_bt2_ctx_ud_t *)_udata; /* User data for building callback context */ - H5D_bt2_ctx_t *ctx; /* Callback context structure */ - uint32_t *my_dim = NULL; /* Pointer to copy of chunk dimension size */ - void *ret_value = NULL; /* Return value */ + H5D_bt2_ctx_t * ctx; /* Callback context structure */ + uint32_t * my_dim = NULL; /* Pointer to copy of chunk dimension size */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -238,16 +227,16 @@ H5D__bt2_crt_context(void *_udata) HDassert(udata->ndims > 0 && udata->ndims < H5O_LAYOUT_NDIMS); /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5D_bt2_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5D_bt2_ctx_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate callback context") /* Determine the size of addresses and set the chunk size and # of dimensions for the dataset */ ctx->sizeof_addr = H5F_SIZEOF_ADDR(udata->f); - ctx->chunk_size = udata->chunk_size; - ctx->ndims = udata->ndims; + ctx->chunk_size = udata->chunk_size; + ctx->ndims = udata->ndims; /* Set up the "local" information for this dataset's chunk dimension sizes */ - if(NULL == (my_dim = (uint32_t *)H5FL_ARR_MALLOC(uint32_t, H5O_LAYOUT_NDIMS))) + if (NULL == (my_dim = (uint32_t *)H5FL_ARR_MALLOC(uint32_t, H5O_LAYOUT_NDIMS))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate chunk dims") H5MM_memcpy(my_dim, udata->dim, H5O_LAYOUT_NDIMS * sizeof(uint32_t)); ctx->dim = my_dim; @@ -257,7 +246,7 @@ H5D__bt2_crt_context(void *_udata) * allowing for an extra byte, in case the filter makes the chunk larger. */ ctx->chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)udata->chunk_size) + 8) / 8); - if(ctx->chunk_size_len > 8) + if (ctx->chunk_size_len > 8) ctx->chunk_size_len = 8; /* Set return value */ @@ -267,7 +256,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_dst_context * @@ -283,7 +271,7 @@ done: static herr_t H5D__bt2_dst_context(void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -291,7 +279,7 @@ H5D__bt2_dst_context(void *_ctx) HDassert(ctx); /* Free array for chunk dimension sizes */ - if(ctx->dim) + if (ctx->dim) H5FL_ARR_FREE(uint32_t, ctx->dim); /* Release callback context */ ctx = H5FL_FREE(H5D_bt2_ctx_t, ctx); @@ -299,7 +287,6 @@ H5D__bt2_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_store * @@ -316,7 +303,7 @@ H5D__bt2_dst_context(void *_ctx) static herr_t H5D__bt2_store(void *record, const void *_udata) { - const H5D_bt2_ud_t *udata = (const H5D_bt2_ud_t *)_udata; /* User data */ + const H5D_bt2_ud_t *udata = (const H5D_bt2_ud_t *)_udata; /* User data */ FUNC_ENTER_STATIC_NOERR @@ -325,7 +312,6 @@ H5D__bt2_store(void *record, const void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_store() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_compare * @@ -343,10 +329,10 @@ H5D__bt2_store(void *record, const void *_udata) static herr_t H5D__bt2_compare(const void *_udata, const void *_rec2, int *result) { - const H5D_bt2_ud_t *udata = (const H5D_bt2_ud_t *)_udata; /* User data */ - const H5D_chunk_rec_t *rec1 = &(udata->rec); /* The search record */ - const H5D_chunk_rec_t *rec2 = (const H5D_chunk_rec_t *)_rec2; /* The native record */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_bt2_ud_t * udata = (const H5D_bt2_ud_t *)_udata; /* User data */ + const H5D_chunk_rec_t *rec1 = &(udata->rec); /* The search record */ + const H5D_chunk_rec_t *rec2 = (const H5D_chunk_rec_t *)_rec2; /* The native record */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -360,7 +346,6 @@ H5D__bt2_compare(const void *_udata, const void *_rec2, int *result) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_compare() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_unfilt_encode * @@ -377,9 +362,9 @@ H5D__bt2_compare(const void *_udata, const void *_rec2, int *result) static herr_t H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -389,13 +374,12 @@ H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) /* Encode the record's fields */ H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); /* (Don't encode the chunk size & filter mask for non-filtered B-tree records) */ - for(u = 0; u < ctx->ndims; u++) - UINT64ENCODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64ENCODE(raw, record->scaled[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_unfilt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_unfilt_decode * @@ -412,9 +396,9 @@ H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) static herr_t H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ - H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -423,15 +407,14 @@ H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) /* Decode the record's fields */ H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); - record->nbytes = ctx->chunk_size; + record->nbytes = ctx->chunk_size; record->filter_mask = 0; - for(u = 0; u < ctx->ndims; u++) - UINT64DECODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64DECODE(raw, record->scaled[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_unfilt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_unfilt_debug * @@ -445,12 +428,11 @@ H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, - const void *_record, const void *_ctx) +H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, const void *_record, const void *_ctx) { const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - const H5D_bt2_ctx_t *ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ - unsigned u; /* Local index variable */ + const H5D_bt2_ctx_t * ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -462,14 +444,13 @@ H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Chunk address:", record->chunk_addr); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for(u = 0; u < ctx->ndims; u++) - HDfprintf(stream, "%s%Hd", u?", ":"", record->scaled[u] * ctx->dim[u]); + for (u = 0; u < ctx->ndims; u++) + HDfprintf(stream, "%s%Hd", u ? ", " : "", record->scaled[u] * ctx->dim[u]); HDfputs("}\n", stream); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_unfilt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_filt_encode * @@ -486,9 +467,9 @@ H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, static herr_t H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -502,13 +483,12 @@ H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); UINT64ENCODE_VAR(raw, record->nbytes, ctx->chunk_size_len); UINT32ENCODE(raw, record->filter_mask); - for(u = 0; u < ctx->ndims; u++) - UINT64ENCODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64ENCODE(raw, record->scaled[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_filt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_filt_decode * @@ -525,9 +505,9 @@ H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) static herr_t H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ - H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -539,8 +519,8 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); UINT64DECODE_VAR(raw, record->nbytes, ctx->chunk_size_len); UINT32DECODE(raw, record->filter_mask); - for(u = 0; u < ctx->ndims; u++) - UINT64DECODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64DECODE(raw, record->scaled[u]); /* Sanity checks */ HDassert(H5F_addr_defined(record->chunk_addr)); @@ -549,7 +529,6 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_filt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_filt_debug * @@ -563,12 +542,11 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, - const void *_record, const void *_ctx) +H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, const void *_record, const void *_ctx) { - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - const H5D_bt2_ctx_t *ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ - unsigned u; /* Local index variable */ + const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ + const H5D_bt2_ctx_t * ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -582,14 +560,13 @@ H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "Filter mask:", record->filter_mask); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for(u = 0; u < ctx->ndims; u++) - HDfprintf(stream, "%s%Hd", u?", ":"", record->scaled[u] * ctx->dim[u]); + for (u = 0; u < ctx->ndims; u++) + HDfprintf(stream, "%s%Hd", u ? ", " : "", record->scaled[u] * ctx->dim[u]); HDfputs("}\n", stream); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_filt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_init * @@ -603,8 +580,8 @@ H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, - const H5S_t H5_ATTR_UNUSED *space, haddr_t dset_ohdr_addr) +H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, const H5S_t H5_ATTR_UNUSED *space, + haddr_t dset_ohdr_addr) { FUNC_ENTER_STATIC_NOERR @@ -616,7 +593,6 @@ H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__btree2_idx_depend * @@ -634,10 +610,10 @@ H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, static herr_t H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) { - H5O_t *oh = NULL; /* Object header */ - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5O_loc_t oloc; /* Temporary object header location for dataset */ + H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -659,26 +635,26 @@ H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; /* Get header */ - if(NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) + if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Retrieve the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_get_proxy(oh))) + if (NULL == (oh_proxy = H5O_get_proxy(oh))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataset object header proxy") /* Make the v2 B-tree a child flush dependency of the dataset's object header proxy */ - if(H5B2_depend(idx_info->storage->u.btree2.bt2, oh_proxy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header proxy") + if (H5B2_depend(idx_info->storage->u.btree2.bt2, oh_proxy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header proxy") done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree2_idx_depend() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_open() * @@ -699,8 +675,8 @@ done: static herr_t H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info) { - H5D_bt2_ctx_ud_t u_ctx; /* user data for creating context */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_bt2_ctx_ud_t u_ctx; /* user data for creating context */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -715,25 +691,26 @@ H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info) HDassert(NULL == idx_info->storage->u.btree2.bt2); /* Set up the user data */ - u_ctx.f = idx_info->f; - u_ctx.ndims = idx_info->layout->ndims - 1; + u_ctx.f = idx_info->f; + u_ctx.ndims = idx_info->layout->ndims - 1; u_ctx.chunk_size = idx_info->layout->size; - u_ctx.dim = idx_info->layout->dim; + u_ctx.dim = idx_info->layout->dim; /* Open v2 B-tree for the chunk index */ - if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_open(idx_info->f, idx_info->storage->idx_addr, &u_ctx))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open v2 B-tree for tracking chunked dataset") + if (NULL == + (idx_info->storage->u.btree2.bt2 = H5B2_open(idx_info->f, idx_info->storage->idx_addr, &u_ctx))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open v2 B-tree for tracking chunked dataset") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__btree2_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__btree2_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_open() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_create * @@ -748,9 +725,9 @@ done: static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ + H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -762,54 +739,55 @@ H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); - bt2_cparam.rrec_size = H5F_SIZEOF_ADDR(idx_info->f) /* Address of chunk */ - + (idx_info->layout->ndims - 1) * 8; /* # of dimensions x 64-bit chunk offsets */ + bt2_cparam.rrec_size = H5F_SIZEOF_ADDR(idx_info->f) /* Address of chunk */ + + (idx_info->layout->ndims - 1) * 8; /* # of dimensions x 64-bit chunk offsets */ /* General parameters */ - if(idx_info->pline->nused > 0) { - unsigned chunk_size_len; /* Size of encoded chunk size */ + if (idx_info->pline->nused > 0) { + unsigned chunk_size_len; /* Size of encoded chunk size */ /* - * Compute the size required for encoding the size of a 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. */ chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)idx_info->layout->size) + 8) / 8); - if(chunk_size_len > 8) + if (chunk_size_len > 8) chunk_size_len = 8; - bt2_cparam.rrec_size += chunk_size_len + 4; /* Size of encoded chunk size & filter mask */ - bt2_cparam.cls = H5D_BT2_FILT; + bt2_cparam.rrec_size += chunk_size_len + 4; /* Size of encoded chunk size & filter mask */ + bt2_cparam.cls = H5D_BT2_FILT; } /* end if */ else - bt2_cparam.cls = H5D_BT2; + bt2_cparam.cls = H5D_BT2; - bt2_cparam.node_size = idx_info->layout->u.btree2.cparam.node_size; + bt2_cparam.node_size = idx_info->layout->u.btree2.cparam.node_size; bt2_cparam.split_percent = idx_info->layout->u.btree2.cparam.split_percent; bt2_cparam.merge_percent = idx_info->layout->u.btree2.cparam.merge_percent; - u_ctx.f = idx_info->f; - u_ctx.ndims = idx_info->layout->ndims - 1; + u_ctx.f = idx_info->f; + u_ctx.ndims = idx_info->layout->ndims - 1; u_ctx.chunk_size = idx_info->layout->size; - u_ctx.dim = idx_info->layout->dim; + u_ctx.dim = idx_info->layout->dim; /* Create the v2 B-tree for the chunked dataset */ - if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, &bt2_cparam, &u_ctx))) + if (NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, &bt2_cparam, &u_ctx))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking chunked dataset") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(idx_info->storage->u.btree2.bt2, &(idx_info->storage->idx_addr)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get v2 B-tree address for tracking chunked dataset") + if (H5B2_get_addr(idx_info->storage->u.btree2.bt2, &(idx_info->storage->idx_addr)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't get v2 B-tree address for tracking chunked dataset") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__btree2_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__btree2_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_is_space_alloc * @@ -832,7 +810,6 @@ H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__bt2_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_mod_cb * @@ -850,19 +827,19 @@ H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage) static herr_t H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed) { - H5D_bt2_ud_t *op_data = (H5D_bt2_ud_t *)_op_data; /* User data for v2 B-tree calls */ - H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* Chunk record */ + H5D_bt2_ud_t * op_data = (H5D_bt2_ud_t *)_op_data; /* User data for v2 B-tree calls */ + H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* Chunk record */ FUNC_ENTER_STATIC_NOERR /* Sanity check */ #ifndef NDEBUG -{ - unsigned u; /* Local index variable */ + { + unsigned u; /* Local index variable */ - for(u = 0; u < op_data->ndims; u++) - HDassert(record->scaled[u] == op_data->rec.scaled[u]); -} + for (u = 0; u < op_data->ndims; u++) + HDassert(record->scaled[u] == op_data->rec.scaled[u]); + } #endif /* NDEBUG */ /* Modify record */ @@ -874,7 +851,6 @@ H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_mod_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_insert * @@ -895,12 +871,12 @@ H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed) */ static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t H5_ATTR_UNUSED *dset) + const H5D_t H5_ATTR_UNUSED *dset) { - H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ - H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -915,41 +891,40 @@ H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, HDassert(H5F_addr_defined(udata->chunk_block.offset)); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* end if */ - else /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + } /* end if */ + else /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; /* Set up callback info */ - bt2_udata.ndims = idx_info->layout->ndims - 1; + bt2_udata.ndims = idx_info->layout->ndims - 1; bt2_udata.rec.chunk_addr = udata->chunk_block.offset; - if(idx_info->pline->nused > 0) { /* filtered chunk */ + if (idx_info->pline->nused > 0) { /* filtered chunk */ H5_CHECKED_ASSIGN(bt2_udata.rec.nbytes, uint32_t, udata->chunk_block.length, hsize_t); bt2_udata.rec.filter_mask = udata->filter_mask; - } /* end if */ + } /* end if */ else { /* non-filtered chunk */ - bt2_udata.rec.nbytes = idx_info->layout->size; + bt2_udata.rec.nbytes = idx_info->layout->size; bt2_udata.rec.filter_mask = 0; } /* end else */ - for(u = 0; u < (idx_info->layout->ndims - 1); u++) + for (u = 0; u < (idx_info->layout->ndims - 1); u++) bt2_udata.rec.scaled[u] = udata->common.scaled[u]; /* Update record for v2 B-tree (could be insert or modify) */ - if(H5B2_update(bt2, &bt2_udata, H5D__bt2_mod_cb, &bt2_udata) < 0) + if (H5B2_update(bt2, &bt2_udata, H5D__bt2_mod_cb, &bt2_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTUPDATE, FAIL, "unable to update record in v2 B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_found_cb * @@ -974,7 +949,6 @@ H5D__bt2_found_cb(const void *nrecord, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_found_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_get_addr * @@ -991,11 +965,11 @@ H5D__bt2_found_cb(const void *nrecord, void *op_data) static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ - H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ - H5D_chunk_rec_t found_rec; /* Record found from searching for object */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ + H5D_chunk_rec_t found_rec; /* Record found from searching for object */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1010,63 +984,62 @@ H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) HDassert(udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* end if */ - else /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + } /* end if */ + else /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; /* Clear the found record */ - found_rec.chunk_addr = HADDR_UNDEF; - found_rec.nbytes = 0; + found_rec.chunk_addr = HADDR_UNDEF; + found_rec.nbytes = 0; found_rec.filter_mask = 0; /* Prepare user data for compare callback */ bt2_udata.rec.chunk_addr = HADDR_UNDEF; - bt2_udata.ndims = idx_info->layout->ndims - 1; + bt2_udata.ndims = idx_info->layout->ndims - 1; /* Set the chunk offset to be searched for */ - for(u = 0; u < (idx_info->layout->ndims - 1); u++) + for (u = 0; u < (idx_info->layout->ndims - 1); u++) bt2_udata.rec.scaled[u] = udata->common.scaled[u]; /* Go get chunk information from v2 B-tree */ - if(H5B2_find(bt2, &bt2_udata, H5D__bt2_found_cb, &found_rec) < 0) + if (H5B2_find(bt2, &bt2_udata, H5D__bt2_found_cb, &found_rec) < 0) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in v2 B-tree") /* Set common info for the chunk */ udata->chunk_block.offset = found_rec.chunk_addr; /* Check for setting other info */ - if(H5F_addr_defined(udata->chunk_block.offset)) { + if (H5F_addr_defined(udata->chunk_block.offset)) { /* Sanity check */ HDassert(0 != found_rec.nbytes); /* Set other info for the chunk */ - if(idx_info->pline->nused > 0) { /* filtered chunk */ + if (idx_info->pline->nused > 0) { /* filtered chunk */ udata->chunk_block.length = found_rec.nbytes; - udata->filter_mask = found_rec.filter_mask; - } /* end if */ + udata->filter_mask = found_rec.filter_mask; + } /* end if */ else { /* non-filtered chunk */ udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ - } /* end if */ + } /* end if */ else { udata->chunk_block.length = 0; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_iterate_cb * @@ -1086,20 +1059,19 @@ done: static int H5D__bt2_idx_iterate_cb(const void *_record, void *_udata) { - H5D_bt2_it_ud_t *udata = (H5D_bt2_it_ud_t *)_udata; /* User data */ - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* Native record */ - int ret_value = -1; /* Return value */ + H5D_bt2_it_ud_t * udata = (H5D_bt2_it_ud_t *)_udata; /* User data */ + const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* Native record */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Make "generic chunk" callback */ - if((ret_value = (udata->cb)(record, udata->udata)) < 0) + if ((ret_value = (udata->cb)(record, udata->udata)) < 0) HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_iterate * @@ -1113,12 +1085,11 @@ H5D__bt2_idx_iterate_cb(const void *_record, void *_udata) *------------------------------------------------------------------------- */ static int -H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ - H5D_bt2_it_ud_t udata; /* User data for B-tree iterator callback */ - int ret_value = FAIL; /* Return value */ + H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5D_bt2_it_ud_t udata; /* User data for B-tree iterator callback */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC @@ -1133,31 +1104,30 @@ H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* end if */ - else /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + } /* end if */ + else /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; /* Prepare user data for iterate callback */ - udata.cb = chunk_cb; + udata.cb = chunk_cb; udata.udata = chunk_udata; /* Iterate over the records in the v2 B-tree */ - if((ret_value = H5B2_iterate(bt2, H5D__bt2_idx_iterate_cb, &udata)) < 0) + if ((ret_value = H5B2_iterate(bt2, H5D__bt2_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk v2 B-tree"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_remove_cb() * @@ -1176,9 +1146,9 @@ done: static herr_t H5D__bt2_remove_cb(const void *_record, void *_udata) { - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - H5F_t *f = (H5F_t *)_udata; /* User data for removal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ + H5F_t * f = (H5F_t *)_udata; /* User data for removal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1187,14 +1157,13 @@ H5D__bt2_remove_cb(const void *_record, void *_udata) /* Free the space in the file for the object being removed */ H5_CHECK_OVERFLOW(record->nbytes, uint32_t, hsize_t); - if(H5MF_xfree(f, H5FD_MEM_DRAW, record->chunk_addr, (hsize_t)record->nbytes) < 0) + if (H5MF_xfree(f, H5FD_MEM_DRAW, record->chunk_addr, (hsize_t)record->nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_remove_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_remove * @@ -1209,10 +1178,10 @@ done: static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ - H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree find call */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree find call */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1226,14 +1195,14 @@ H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *u HDassert(udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* end if */ - else /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + } /* end if */ + else /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; @@ -1242,19 +1211,20 @@ H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *u bt2_udata.ndims = idx_info->layout->ndims - 1; /* Initialize the record to search for */ - for(u = 0; u < (idx_info->layout->ndims - 1); u++) + for (u = 0; u < (idx_info->layout->ndims - 1); u++) bt2_udata.rec.scaled[u] = udata->scaled[u]; /* Remove the record for the "dataset chunk" object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(bt2, &bt2_udata, (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) ? NULL : H5D__bt2_remove_cb, idx_info->f) < 0) + if (H5B2_remove(bt2, &bt2_udata, + (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) ? NULL : H5D__bt2_remove_cb, + idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_delete * @@ -1271,9 +1241,9 @@ done: static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) { - H5B2_remove_t remove_op; /* The removal callback */ - H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_remove_t remove_op; /* The removal callback */ + H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1285,32 +1255,31 @@ H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->storage->idx_addr)) { - /* Set up user data for creating context */ - u_ctx.f = idx_info->f; - u_ctx.ndims = idx_info->layout->ndims - 1; - u_ctx.chunk_size = idx_info->layout->size; - u_ctx.dim = idx_info->layout->dim; - - /* Set remove operation. Do not remove chunks in SWMR_WRITE mode */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5F_addr_defined(idx_info->storage->idx_addr)) { + /* Set up user data for creating context */ + u_ctx.f = idx_info->f; + u_ctx.ndims = idx_info->layout->ndims - 1; + u_ctx.chunk_size = idx_info->layout->size; + u_ctx.dim = idx_info->layout->dim; + + /* Set remove operation. Do not remove chunks in SWMR_WRITE mode */ + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) remove_op = NULL; else remove_op = H5D__bt2_remove_cb; - /* Delete the v2 B-tree */ - /*(space in the file for each object is freed in the 'remove' callback) */ - if(H5B2_delete(idx_info->f, idx_info->storage->idx_addr, &u_ctx, remove_op, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") + /* Delete the v2 B-tree */ + /*(space in the file for each object is freed in the 'remove' callback) */ + if (H5B2_delete(idx_info->f, idx_info->storage->idx_addr, &u_ctx, remove_op, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") - idx_info->storage->idx_addr = HADDR_UNDEF; + idx_info->storage->idx_addr = HADDR_UNDEF; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_copy_setup * @@ -1323,10 +1292,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) +H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1346,15 +1314,15 @@ H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Check if the source v2 B-tree is open yet */ - if(NULL == idx_info_src->storage->u.btree2.bt2) - if(H5D__bt2_idx_open(idx_info_src) < 0) + if (NULL == idx_info_src->storage->u.btree2.bt2) + if (H5D__bt2_idx_open(idx_info_src) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Create v2 B-tree that describes the chunked dataset in the destination file */ - if(H5D__bt2_idx_create(idx_info_dst) < 0) + if (H5D__bt2_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); @@ -1365,7 +1333,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_copy_shutdown * @@ -1378,10 +1345,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst) +H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1392,12 +1358,12 @@ H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, HDassert(storage_dst->u.btree2.bt2); /* Close v2 B-tree for source file */ - if(H5B2_close(storage_src->u.btree2.bt2) < 0) + if (H5B2_close(storage_src->u.btree2.bt2) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close v2 B-tree") storage_src->u.btree2.bt2 = NULL; /* Close v2 B-tree for destination file */ - if(H5B2_close(storage_dst->u.btree2.bt2) < 0) + if (H5B2_close(storage_dst->u.btree2.bt2) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close v2 B-tree") storage_dst->u.btree2.bt2 = NULL; @@ -1405,7 +1371,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_copy_shutdown() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_size * @@ -1421,8 +1386,8 @@ done: static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5B2_t *bt2_cdset = NULL; /* Pointer to v2 B-tree structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t *bt2_cdset = NULL; /* Pointer to v2 B-tree structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1436,26 +1401,25 @@ H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) HDassert(index_size); /* Open v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") + if (H5D__bt2_idx_open(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") /* Set convenience pointer to v2 B-tree structure */ bt2_cdset = idx_info->storage->u.btree2.bt2; /* Get v2 B-tree size for indexing chunked dataset */ - if(H5B2_size(bt2_cdset, index_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve v2 B-tree storage info for chunked dataset") + if (H5B2_size(bt2_cdset, index_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve v2 B-tree storage info for chunked dataset") done: /* Close v2 B-tree index */ - if(bt2_cdset && H5B2_close(bt2_cdset) < 0) + if (bt2_cdset && H5B2_close(bt2_cdset) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for tracking chunked dataset") idx_info->storage->u.btree2.bt2 = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_reset * @@ -1476,14 +1440,13 @@ H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) + storage->idx_addr = HADDR_UNDEF; storage->u.btree2.bt2 = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_dump * @@ -1509,7 +1472,6 @@ H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_idx_dump() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_dest * @@ -1524,7 +1486,7 @@ H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1534,14 +1496,14 @@ H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the v2-btree is open */ - if(idx_info->storage->u.btree2.bt2) { + if (idx_info->storage->u.btree2.bt2) { - /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Close v2 B-tree */ - if(H5B2_close(idx_info->storage->u.btree2.bt2) < 0) + if (H5B2_close(idx_info->storage->u.btree2.bt2) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree") idx_info->storage->u.btree2.bt2 = NULL; } /* end if */ @@ -1549,4 +1511,3 @@ H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_dest() */ - |