diff options
Diffstat (limited to 'src/H5FA.c')
-rw-r--r-- | src/H5FA.c | 168 |
1 files changed, 83 insertions, 85 deletions
@@ -15,12 +15,12 @@ /*------------------------------------------------------------------------- * - * Created: H5FA.c - * April 2009 - * Vailin Choi <vchoi@hdfgroup.org> + * Created: H5FA.c + * April 2009 + * Vailin Choi <vchoi@hdfgroup.org> * - * Purpose: Implements a Fixed Array for storing elements - * of datasets with fixed dimensions + * Purpose: Implements a Fixed Array for storing elements + * of datasets with fixed dimensions. * *------------------------------------------------------------------------- */ @@ -39,11 +39,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Vprivate.h" /* Vector functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Vprivate.h" /* Vector functions */ /****************/ @@ -76,9 +76,9 @@ * client class.. */ const H5FA_class_t *const H5FA_client_class_g[] = { - H5FA_CLS_CHUNK, /* 0 - H5FA_CLS_CHUNK_ID */ - H5FA_CLS_FILT_CHUNK, /* 1 - H5FA_CLS_FILT_CHUNK_ID */ - H5FA_CLS_TEST, /* ? - H5FA_CLS_TEST_ID */ + H5FA_CLS_CHUNK, /* 0 - H5FA_CLS_CHUNK_ID */ + H5FA_CLS_FILT_CHUNK, /* 1 - H5FA_CLS_FILT_CHUNK_ID */ + H5FA_CLS_TEST, /* ? - H5FA_CLS_TEST_ID */ }; @@ -100,14 +100,14 @@ H5FL_BLK_DEFINE(native_elmt); /*------------------------------------------------------------------------- - * Function: H5FA_create + * Function: H5FA_create * - * Purpose: Creates a new fixed array (header) in the file. + * Purpose: Creates a new fixed array (header) in the file. * - * Return: Pointer to fixed array wrapper on success + * Return: Pointer to fixed array wrapper on success * NULL on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -136,24 +136,24 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Create fixed array header */ if(HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, dxpl_id, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create fixed array header") + H5E_THROW(H5E_CANTINIT, "can't create fixed array header") /* Allocate fixed array wrapper */ if(NULL == (fa = H5FL_MALLOC(H5FA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") /* Lock the array header into memory */ if(NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FARRAY_HDR, fa_addr, ctx_udata, H5AC_WRITE))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") /* Point fixed array wrapper at header and bump it's ref count */ fa->hdr = hdr; if(H5FA__hdr_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") /* Increment # of files using this array header */ if(H5FA__hdr_fuse_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") + H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ fa->f = f; @@ -164,7 +164,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); CATCH if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FARRAY_HDR, fa_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") if(!ret_value) if(fa && H5FA_close(fa, dxpl_id) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") @@ -173,14 +173,14 @@ END_FUNC(PRIV) /* end H5FA_create() */ /*------------------------------------------------------------------------- - * Function: H5FA_open + * Function: H5FA_open * - * Purpose: Opens an existing fixed array in the file. + * Purpose: Opens an existing fixed array in the file. * - * Return: Pointer to array wrapper on success + * Return: Pointer to array wrapper on success * NULL on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -241,13 +241,13 @@ END_FUNC(PRIV) /* end H5FA_open() */ /*------------------------------------------------------------------------- - * Function: H5FA_get_nelmts + * Function: H5FA_get_nelmts * - * Purpose: Query the current number of elements in array + * Purpose: Query the current number of elements in array * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -275,13 +275,13 @@ END_FUNC(PRIV) /* end H5FA_get_nelmts() */ /*------------------------------------------------------------------------- - * Function: H5FA_get_addr + * Function: H5FA_get_addr * - * Purpose: Query the address of the array + * Purpose: Query the address of the array * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -310,13 +310,13 @@ END_FUNC(PRIV) /* end H5FA_get_addr() */ /*------------------------------------------------------------------------- - * Function: H5FA_set + * Function: H5FA_set * - * Purpose: Set an element of a fixed array + * Purpose: Set an element of a fixed array * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -362,13 +362,13 @@ HDfprintf(stderr, "%s: fixed array data block address not defined!\n", FUNC, idx /* Protect data block */ if(NULL == (dblock = H5FA__dblock_protect(hdr, dxpl_id, hdr->dblk_addr, hdr->stats.nelmts, H5AC_WRITE))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)hdr->dblk_addr) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)hdr->dblk_addr) /* Check for paging data block */ if(!dblock->npages) { - /* Set element in data block */ - HDmemcpy(((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, hdr->cparam.cls->nat_elmt_size); - dblock_cache_flags |= H5AC__DIRTIED_FLAG; + /* Set element in data block */ + HDmemcpy(((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, hdr->cparam.cls->nat_elmt_size); + dblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else { /* paging */ size_t page_idx; /* Index of page within data block */ @@ -381,33 +381,33 @@ HDfprintf(stderr, "%s: fixed array data block address not defined!\n", FUNC, idx elmt_idx = (size_t)(idx % dblock->dblk_page_nelmts); /* Get the address of the data block page */ - dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + + dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + ((hsize_t)page_idx * dblock->dblk_page_size); /* Check for using last page, to set the number of elements on the page */ - if((page_idx + 1) == dblock->npages) - dblk_page_nelmts = dblock->last_page_nelmts; - else - dblk_page_nelmts = dblock->dblk_page_nelmts; + if((page_idx + 1) == dblock->npages) + dblk_page_nelmts = dblock->last_page_nelmts; + else + dblk_page_nelmts = dblock->dblk_page_nelmts; /* Check if the page has been created yet */ if(!H5V_bit_get(dblock->dblk_page_init, page_idx)) { - /* Create the data block page */ - if(H5FA__dblk_page_create(hdr, dxpl_id, dblk_page_addr, dblk_page_nelmts) < 0) - H5E_THROW(H5E_CANTCREATE, "unable to create data block page") + /* Create the data block page */ + if(H5FA__dblk_page_create(hdr, dxpl_id, dblk_page_addr, dblk_page_nelmts) < 0) + H5E_THROW(H5E_CANTCREATE, "unable to create data block page") - /* Mark data block page as initialized in data block */ - H5V_bit_set(dblock->dblk_page_init, page_idx, TRUE); - dblock_cache_flags |= H5AC__DIRTIED_FLAG; - } /* end if */ + /* Mark data block page as initialized in data block */ + H5V_bit_set(dblock->dblk_page_init, page_idx, TRUE); + dblock_cache_flags |= H5AC__DIRTIED_FLAG; + } /* end if */ /* Protect the data block page */ - if(NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dxpl_id, dblk_page_addr, dblk_page_nelmts, H5AC_WRITE))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", (unsigned long long)dblk_page_addr) + if(NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dxpl_id, dblk_page_addr, dblk_page_nelmts, H5AC_WRITE))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", (unsigned long long)dblk_page_addr) /* Set the element in the data block page */ - HDmemcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size); - dblk_page_cache_flags |= H5AC__DIRTIED_FLAG; + HDmemcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size); + dblk_page_cache_flags |= H5AC__DIRTIED_FLAG; } /* end else */ CATCH @@ -426,13 +426,13 @@ END_FUNC(PRIV) /* end H5FA_set() */ /*------------------------------------------------------------------------- - * Function: H5FA_get + * Function: H5FA_get * - * Purpose: Get an element of a fixed array + * Purpose: Get an element of a fixed array * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -528,13 +528,13 @@ END_FUNC(PRIV) /* end H5FA_get() */ /*------------------------------------------------------------------------- - * Function: H5FA_close + * Function: H5FA_close * - * Purpose: Close a fixed array + * Purpose: Close a fixed array * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -629,13 +629,13 @@ END_FUNC(PRIV) /* end H5FA_close() */ /*------------------------------------------------------------------------- - * Function: H5FA_delete + * Function: H5FA_delete * - * Purpose: Delete a fixed array + * Purpose: Delete a fixed array * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -683,16 +683,16 @@ END_FUNC(PRIV) /* end H5FA_delete() */ /*------------------------------------------------------------------------- - * Function: H5FA_iterate + * Function: H5FA_iterate * - * Purpose: Iterate over the elements of a fixed array + * Purpose: Iterate over the elements of a fixed array * - * Note: This is not very efficient, we should be iterating directly - * over the fixed array's direct block [pages]. + * Note: This is not very efficient, we should be iterating directly + * over the fixed array's direct block [pages]. * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -702,8 +702,8 @@ herr_t, SUCCEED, FAIL, H5FA_iterate(H5FA_t *fa, hid_t dxpl_id, H5FA_operator_t op, void *udata)) /* Local variables */ - uint8_t *elmt = NULL; - hsize_t u; + uint8_t *elmt = NULL; + hsize_t u; /* * Check arguments. @@ -714,7 +714,7 @@ H5FA_iterate(H5FA_t *fa, hid_t dxpl_id, H5FA_operator_t op, void *udata)) /* Allocate space for a native array element */ if(NULL == (elmt = H5FL_BLK_MALLOC(native_elmt, fa->hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array element") + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array element") /* Iterate over all elements in array */ for(u = 0; u < fa->hdr->stats.nelmts; u++) { @@ -734,7 +734,7 @@ H5FA_iterate(H5FA_t *fa, hid_t dxpl_id, H5FA_operator_t op, void *udata)) CATCH if(elmt) - elmt = H5FL_BLK_FREE(native_elmt, elmt); + elmt = H5FL_BLK_FREE(native_elmt, elmt); END_FUNC(PRIV) /* end H5FA_iterate() */ @@ -748,7 +748,6 @@ END_FUNC(PRIV) /* end H5FA_iterate() */ * Return: SUCCEED/FAIL * * Programmer: Dana Robinson - * derobins@hdfgroup.org * Fall 2012 * *------------------------------------------------------------------------- @@ -773,7 +772,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Set the shared array header's file context for this operation */ hdr->f = fa->f; - /* Set up flush dependency between parent entry and extensible array header */ + /* Set up flush dependency between parent entry and fixed array header */ if(H5FA__create_flush_depend(parent_entry, (H5AC_info_t *)hdr) < 0) H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency on file metadata") @@ -791,7 +790,6 @@ END_FUNC(PRIV) /* end H5FA_depend() */ * Return: SUCCEED/FAIL * * Programmer: Dana Robinson - * derobins@hdfgroup.org * Fall 2012 * *------------------------------------------------------------------------- @@ -816,7 +814,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Set the shared array header's file context for this operation */ hdr->f = fa->f; - /* Remove flush dependency between parent entry and extensible array header */ + /* Remove flush dependency between parent entry and fixed array header */ if(H5FA__destroy_flush_depend(parent_entry, (H5AC_info_t *)hdr) < 0) H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency on file metadata") |