summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-04-18 20:10:05 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-04-18 20:10:05 (GMT)
commit40117dd3849be65d039ca6aa02bb6d6a338c7f7b (patch)
treeb589fe0fa3486826e63600f57a02f6bedba22e55
parentfa3c25fbf0dafa1d5bd9817eb208a0db72f57232 (diff)
downloadhdf5-40117dd3849be65d039ca6aa02bb6d6a338c7f7b.zip
hdf5-40117dd3849be65d039ca6aa02bb6d6a338c7f7b.tar.gz
hdf5-40117dd3849be65d039ca6aa02bb6d6a338c7f7b.tar.bz2
[svn-r5203] Purpose:
Code cleanup Description: Re-indented new code to match coding style of rest of library. Platforms tested: FreeBSD 4.5 (sleipnir)
-rw-r--r--src/H5B.c223
-rw-r--r--src/H5D.c342
-rw-r--r--src/H5Distore.c736
-rw-r--r--src/H5Fistore.c736
-rw-r--r--src/H5S.c57
5 files changed, 1031 insertions, 1063 deletions
diff --git a/src/H5B.c b/src/H5B.c
index 04993a1..b1edd37 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -2153,6 +2153,119 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B_prune_by_extent
+ *
+ * Purpose: Search for chunks that are no longer necessary in the B-tree.
+ * The function iterates through the B-tree and calls an operator
+ * function prune_extent
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: March 26, 2002
+ *
+ * Comments: Private function
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B_prune_by_extent(H5F_t *f, const H5B_class_t *type, haddr_t addr,
+ void *udata, hsize_t *size)
+{
+ H5B_t *bt = NULL;
+ haddr_t next_addr;
+ haddr_t cur_addr = HADDR_UNDEF;
+ uint8_t *key = NULL;
+ int i, nchildren;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER(H5B_prune_by_extent, FAIL);
+
+/*
+ * Check arguments.
+ */
+ assert(f);
+ assert(type);
+ assert(type->prune_extent);
+ assert(H5F_addr_defined(addr));
+ assert(udata);
+
+ if(NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load B-tree node");
+ }
+
+ if(bt->level > 0) {
+ /* Keep following the left-most child until we reach a leaf node. */
+ if((ret_value =
+ H5B_prune_by_extent(f, type, bt->child[0], udata,
+ size)) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL,
+ "unable to list B-tree node");
+ }
+ }
+ else {
+
+/*
+ * We've reached the left-most leaf. Now follow the right-sibling
+ * pointer from leaf to leaf until we've processed all leaves.
+ */
+
+ if(NULL == (key =
+ H5MM_malloc((2 * H5B_Kvalue(f,
+ type) + 1) * type->sizeof_nkey))) {
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+
+ for(cur_addr = addr, ret_value = 0;
+ H5F_addr_defined(cur_addr) && !ret_value;
+ cur_addr = next_addr) {
+
+ /*
+ * Save all the native keys since we can't leave the B-tree node protected during an application callback.
+ */
+
+ if(NULL == (bt = H5AC_find(f, H5AC_BT, cur_addr, type, udata))) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node");
+ }
+
+ for(i = 0; i < bt->nchildren + 1; i++) {
+ if(!bt->key[i].nkey)
+ H5B_decode_key(f, bt, i);
+ HDmemcpy(key + i * type->sizeof_nkey, bt->key[i].nkey,
+ type->sizeof_nkey);
+ }
+
+ next_addr = bt->right;
+ nchildren = bt->nchildren;
+ bt = NULL;
+
+ /* Figure out what chunks are no longer in use for the specified extent and release them */
+
+ for(i = 0, ret_value = 0; i < nchildren && !ret_value; i++) {
+ ret_value =
+ (type->prune_extent) (f, key + i * type->sizeof_nkey,
+ addr, udata, size);
+ if(ret_value < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
+ "iterator function failed");
+ }
+ } /*i */
+ } /*addr */
+ } /*level */
+
+done:
+ if(key != NULL)
+ H5MM_xfree(key);
+ FUNC_LEAVE(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5B_debug
*
* Purpose: Prints debugging info about a B-tree.
@@ -2367,113 +2480,3 @@ H5B_assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata)
FUNC_LEAVE(SUCCEED);
}
#endif /* H5B_DEBUG */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5B_prune_by_extent
- *
- * Purpose: Search for chunks that are no longer necessary in the B-tree.
- * The function iterates trough the B-tree and calls an operator function prune_extent
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 26, 2002
- *
- * Comments: Private function
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-
-herr_t H5B_prune_by_extent( H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata,
- hsize_t *size )
-{
- H5B_t *bt = NULL;
- haddr_t next_addr;
- haddr_t cur_addr = HADDR_UNDEF;
- uint8_t *key = NULL;
- int i, nchildren;
- herr_t ret_value = FAIL;
-
- FUNC_ENTER( H5B_prune_by_extent, FAIL);
-
-/*
- * Check arguments.
- */
- assert( f );
- assert( type );
- assert( type->prune_extent);
- assert( H5F_addr_defined( addr ) );
- assert( udata );
-
- if ( NULL == ( bt = H5AC_find( f, H5AC_BT, addr, type, udata )))
- {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node" );
- }
-
- if ( bt->level > 0 )
- {
- /* Keep following the left-most child until we reach a leaf node. */
- if (( ret_value = H5B_prune_by_extent(f, type, bt->child[0], udata, size )) < 0 )
- {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node");
- }
- }
- else
- {
-
-/*
- * We've reached the left-most leaf. Now follow the right-sibling
- * pointer from leaf to leaf until we've processed all leaves.
- */
-
- if ( NULL== ( key = H5MM_malloc((2*H5B_Kvalue(f, type)+1)*type->sizeof_nkey )))
- {
- HGOTO_ERROR( H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed" );
- }
-
- for ( cur_addr = addr, ret_value = 0; H5F_addr_defined(cur_addr) && !ret_value; cur_addr = next_addr)
- {
-
- /*
- * Save all the native keys since we can't leave the B-tree node protected during an application callback.
- */
-
- if ( NULL == ( bt = H5AC_find( f, H5AC_BT, cur_addr, type, udata )))
- {
- HGOTO_ERROR( H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node" );
- }
-
- for ( i = 0; i < bt->nchildren+1; i++ )
- {
- if ( !bt->key[i].nkey )
- H5B_decode_key(f, bt, i);
- HDmemcpy( key+i*type->sizeof_nkey, bt->key[i].nkey, type->sizeof_nkey );
- }
-
- next_addr = bt->right;
- nchildren = bt->nchildren;
- bt = NULL;
-
- /* Figure out what chunks are no longer in use for the specified extent and release them */
-
- for ( i = 0, ret_value = 0; i < nchildren && !ret_value; i++ )
- {
- ret_value = ( type->prune_extent )( f, key+i*type->sizeof_nkey, addr, udata, size );
- if ( ret_value < 0 )
- {
- HGOTO_ERROR( H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed" );
- }
- } /*i*/
- } /*addr*/
- } /*level*/
-
-done:
- if( key != NULL )
- H5MM_xfree( key );
- FUNC_LEAVE( ret_value );
-}
-
diff --git a/src/H5D.c b/src/H5D.c
index bf46af4..eb52354 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -3994,96 +3994,51 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Ddebug
+ * Function: H5Dset_extent
*
- * Purpose: Prints various information about a dataset. This function is
- * not to be documented in the API at this time.
+ * Purpose: Modifies the dimensions of a dataset, based on H5Dextend.
+ * Can change to a lower dimension.
*
- * Return: Success: Non-negative
+ * Return: Success: 0, Failure: -1
*
- * Failure: Negative
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Robb Matzke
*
- * Programmer: Robb Matzke
- * Wednesday, April 28, 1999
+ * Date: April 9, 2002
+ *
+ * Comments: Public function, calls private H5D_set_extent
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5Ddebug(hid_t dset_id, unsigned UNUSED flags)
+H5Dset_extent(hid_t dset_id, const hsize_t *size)
{
- H5D_t *dset=NULL;
+ H5D_t *dset = NULL;
- FUNC_ENTER(H5Ddebug, FAIL);
- H5TRACE2("e","iIu",dset_id,flags);
+ FUNC_ENTER(H5Dset_extent, FAIL);
/* Check args */
- if (H5I_DATASET!=H5I_get_type(dset_id) ||
- NULL==(dset=H5I_object(dset_id))) {
+ if(H5I_DATASET != H5I_get_type(dset_id)
+ || NULL == (dset = H5I_object(dset_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
+ if(!size) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified");
+ }
- /* Print B-tree information */
- if (H5D_CHUNKED==dset->layout.type) {
- H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims,
- dset->layout.addr);
- } else if (H5D_CONTIGUOUS==dset->layout.type) {
- HDfprintf(stdout, " %-10s %a\n", "Address:",
- dset->layout.addr);
+ /* Private function */
+ if(H5D_set_extent(dset, size) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to set extend dataset");
}
-
+
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
- * Function: H5Dset_extent
- *
- * Purpose: Modifies the dimensions of a dataset, based on H5Dextend.
- * Can change to a lower dimension.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- * Robb Matzke
- *
- * Date: April 9, 2002
- *
- * Comments: Public function, calls private H5D_set_extent
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-
-
-herr_t H5Dset_extent( hid_t dset_id, const hsize_t *size )
-{
- H5D_t *dset = NULL;
-
- FUNC_ENTER( H5Dset_extent, FAIL );
-
- /* Check args */
- if ( H5I_DATASET != H5I_get_type( dset_id ) || NULL == ( dset = H5I_object( dset_id )))
- {
- HRETURN_ERROR( H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset" );
- }
- if ( !size )
- {
- HRETURN_ERROR( H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified" );
- }
-
- /* Private function */
- if ( H5D_set_extent ( dset, size ) < 0 )
- {
- HRETURN_ERROR( H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset");
- }
-
- FUNC_LEAVE (SUCCEED);
-}
-
-/*-------------------------------------------------------------------------
* Function: H5D_set_extent
*
* Purpose: Based in H5D_extend, allows change to a lower dimension,
@@ -4102,135 +4057,180 @@ herr_t H5Dset_extent( hid_t dset_id, const hsize_t *size )
*
*-------------------------------------------------------------------------
*/
-
-herr_t H5D_set_extent( H5D_t *dset, const hsize_t *size )
+herr_t
+H5D_set_extent(H5D_t *dset, const hsize_t *size)
{
- hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */
- int rank; /* Dataspace # of dimensions */
- herr_t changed;
- herr_t ret_value = FAIL;
- H5S_t *space = NULL;
- H5P_genplist_t *plist;
- H5O_fill_t fill;
- H5O_pline_t pline;
- int u;
- int shrink = 0;
-
- FUNC_ENTER( H5D_set_extent, FAIL );
-
- /* Check args */
- assert( dset );
- assert( size );
-
+ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */
+ int rank; /* Dataspace # of dimensions */
+ herr_t changed;
+ herr_t ret_value = FAIL;
+ H5S_t *space = NULL;
+ H5P_genplist_t *plist;
+ H5O_fill_t fill;
+ H5O_pline_t pline;
+ int u;
+ int shrink = 0;
+
+ FUNC_ENTER(H5D_set_extent, FAIL);
+
+ /* Check args */
+ assert(dset);
+ assert(size);
+
/*-------------------------------------------------------------------------
* Get the data space
*-------------------------------------------------------------------------
- */
-
- if ( NULL == ( space = H5S_read (&(dset->ent))))
- {
- HGOTO_ERROR( H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data space info from dset header");
- }
-
+ */
+
+ if(NULL == (space = H5S_read(&(dset->ent)))) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to read data space info from dset header");
+ }
+
/*-------------------------------------------------------------------------
* Check if we are shrinking in any of the dimensions
*-------------------------------------------------------------------------
*/
- if((rank=H5S_get_simple_extent_dims(space, curr_dims, NULL))<0)
- HGOTO_ERROR( H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
-
- for ( u = 0; u < rank; u++ )
- {
- if ( size[u] < curr_dims[u] )
- {
- shrink = 1;
- break;
- }
- }
-
+ if((rank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL,
+ "can't get dataset dimensions");
+
+ for(u = 0; u < rank; u++) {
+ if(size[u] < curr_dims[u]) {
+ shrink = 1;
+ break;
+ }
+ }
+
/*-------------------------------------------------------------------------
* Modify the size of the data space
*-------------------------------------------------------------------------
*/
-
- if ( ( changed = H5S_set_extent( space, size )) < 0 )
- {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of data space");
- }
-
+
+ if((changed = H5S_set_extent(space, size)) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to modify size of data space");
+ }
+
/*-------------------------------------------------------------------------
* Modify the dataset storage if changed space
*-------------------------------------------------------------------------
*/
-
- if ( changed > 0 )
- {
- /* Save the new dataspace in the file if necessary */
- if ( H5S_modify ( &(dset->ent ), space ) < 0 )
- {
- HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace");
- }
-
- /* Initialize the new parts of the dset */
- if ( NULL == ( plist = H5I_object( dset->dcpl_id )))
- {
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dset creation property list");
- }
- if( H5P_get( plist, H5D_CRT_FILL_VALUE_NAME, &fill ) < 0 )
- {
- HGOTO_ERROR( H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value" );
- }
- if( H5D_CONTIGUOUS == dset->layout.type && fill.buf )
- {
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to select fill value region");
- }
- if ( H5D_init_storage( dset, space ) < 0 )
- {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dset with fill value");
- }
-
- } /* end if changed */
-
-
+
+ if(changed > 0) {
+ /* Save the new dataspace in the file if necessary */
+ if(H5S_modify(&(dset->ent), space) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL,
+ "unable to update file with new dataspace");
+ }
+
+ /* Initialize the new parts of the dset */
+ if(NULL == (plist = H5I_object(dset->dcpl_id))) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dset creation property list");
+ }
+ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL,
+ "can't get fill value");
+ }
+ if(H5D_CONTIGUOUS == dset->layout.type && fill.buf) {
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "unable to select fill value region");
+ }
+ if(H5D_init_storage(dset, space) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to initialize dset with fill value");
+ }
+
+ } /* end if changed */
+
+
/*-------------------------------------------------------------------------
* Remove chunk information in the case of chunked datasets
* This removal takes place only in case we are shrinking the dateset
*-------------------------------------------------------------------------
*/
-
- if ( changed > 0 && shrink && H5D_CHUNKED == dset->layout.type )
- {
-
+
+ if(changed > 0 && shrink && H5D_CHUNKED == dset->layout.type) {
+
#if defined (PVN)
- H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims, dset->layout.addr);
+ H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims,
+ dset->layout.addr);
#endif
- if ( H5F_istore_prune_by_extent( dset->ent.file, &dset->layout, space ) < 0 )
- {
- HRETURN_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks ");
- }
-
+ if(H5F_istore_prune_by_extent(dset->ent.file, &dset->layout,
+ space) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL,
+ "unable to remove chunks ");
+ }
+
#if defined (PVN)
- H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims, dset->layout.addr);
-#endif
-
- if( H5P_get( plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
- {
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get pipeline");
- }
-
+ H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims,
+ dset->layout.addr);
+#endif
+
+ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get pipeline");
+ }
+
+
+ if(H5F_istore_initialize_by_extent(dset->ent.file, &dset->layout,
+ &pline, &fill, space) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL,
+ "unable to initialize chunks ");
+ }
+
+ }
+
+ ret_value = SUCCEED;
- if ( H5F_istore_initialize_by_extent( dset->ent.file, &dset->layout, &pline, &fill, space ) < 0 )
- {
- HRETURN_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to initialize chunks ");
- }
-
- }
-
- ret_value = SUCCEED;
-
done:
- if(space)
- H5S_close( space );
- FUNC_LEAVE( ret_value );
+ if(space)
+ H5S_close(space);
+ FUNC_LEAVE(ret_value);
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Ddebug
+ *
+ * Purpose: Prints various information about a dataset. This function is
+ * not to be documented in the API at this time.
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, April 28, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Ddebug(hid_t dset_id, unsigned UNUSED flags)
+{
+ H5D_t *dset=NULL;
+
+ FUNC_ENTER(H5Ddebug, FAIL);
+ H5TRACE2("e","iIu",dset_id,flags);
+
+ /* Check args */
+ if (H5I_DATASET!=H5I_get_type(dset_id) ||
+ NULL==(dset=H5I_object(dset_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ }
+
+ /* Print B-tree information */
+ if (H5D_CHUNKED==dset->layout.type) {
+ H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims,
+ dset->layout.addr);
+ } else if (H5D_CONTIGUOUS==dset->layout.type) {
+ HDfprintf(stdout, " %-10s %a\n", "Address:",
+ dset->layout.addr);
+ }
+
+ FUNC_LEAVE(SUCCEED);
+}
+
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 328f791..da816af 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -1053,6 +1053,7 @@ done:
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_preempt
*
@@ -1064,71 +1065,70 @@ done:
* Programmer: Robb Matzke
* Thursday, May 21, 1998
*
- * Modifications: Pedro Vicente, March 28, 2002
- * Added flush parameter that switches the call to H5F_istore_flush_entry
- * The call with FALSE is used by the H5F_istore_prune_by_extent function
+ * Modifications:
+ * Pedro Vicente, March 28, 2002
+ * Added flush parameter that switches the call to H5F_istore_flush_entry
+ * The call with FALSE is used by the H5F_istore_prune_by_extent function
*
*-------------------------------------------------------------------------
*/
-
- static herr_t
- H5F_istore_preempt (H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t flush )
- {
- H5F_rdcc_t *rdcc = &(f->shared->rdcc);
-
- FUNC_ENTER (H5F_istore_preempt, FAIL);
-
- assert(f);
- assert(ent);
- assert(!ent->locked);
- assert(ent->idx<rdcc->nslots);
-
- if ( flush )
- {
-
- /* Flush */
- if (H5F_istore_flush_entry(f, ent, TRUE)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "cannot flush indexed storage buffer");
- }
- }
-
- else
- {
-
- /* Reset, but do not free or remove from list */
- ent->layout = H5O_free(H5O_LAYOUT, ent->layout);
- ent->pline = H5O_free(H5O_PLINE, ent->pline);
- if(ent->chunk!=NULL)
- ent->chunk = H5F_istore_chunk_free(ent->chunk);
-
- }
-
- /* Unlink from list */
- if (ent->prev) {
- ent->prev->next = ent->next;
- } else {
- rdcc->head = ent->next;
- }
- if (ent->next) {
- ent->next->prev = ent->prev;
- } else {
- rdcc->tail = ent->prev;
- }
- ent->prev = ent->next = NULL;
-
- /* Remove from cache */
- rdcc->slot[ent->idx] = NULL;
- ent->idx = UINT_MAX;
- rdcc->nbytes -= ent->chunk_size;
- --rdcc->nused;
-
- /* Free */
- H5FL_FREE(H5F_rdcc_ent_t, ent);
-
- FUNC_LEAVE (SUCCEED);
- }
+static herr_t
+H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush)
+{
+ H5F_rdcc_t *rdcc = &(f->shared->rdcc);
+
+ FUNC_ENTER(H5F_istore_preempt, FAIL);
+
+ assert(f);
+ assert(ent);
+ assert(!ent->locked);
+ assert(ent->idx < rdcc->nslots);
+ if(flush) {
+
+ /* Flush */
+ if(H5F_istore_flush_entry(f, ent, TRUE) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "cannot flush indexed storage buffer");
+ }
+ }
+
+ else {
+
+ /* Reset, but do not free or remove from list */
+ ent->layout = H5O_free(H5O_LAYOUT, ent->layout);
+ ent->pline = H5O_free(H5O_PLINE, ent->pline);
+ if(ent->chunk != NULL)
+ ent->chunk = H5F_istore_chunk_free(ent->chunk);
+
+ }
+
+ /* Unlink from list */
+ if(ent->prev) {
+ ent->prev->next = ent->next;
+ }
+ else {
+ rdcc->head = ent->next;
+ }
+ if(ent->next) {
+ ent->next->prev = ent->prev;
+ }
+ else {
+ rdcc->tail = ent->prev;
+ }
+ ent->prev = ent->next = NULL;
+
+ /* Remove from cache */
+ rdcc->slot[ent->idx] = NULL;
+ ent->idx = UINT_MAX;
+ rdcc->nbytes -= ent->chunk_size;
+ --rdcc->nused;
+
+ /* Free */
+ H5FL_FREE(H5F_rdcc_ent_t, ent);
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
@@ -1143,8 +1143,8 @@ done:
* Thursday, May 21, 1998
*
* Modifications:
- * Pedro Vicente, March 28, 2002
- * Added TRUE parameter to the call to H5F_istore_preempt
+ * Pedro Vicente, March 28, 2002
+ * Added TRUE parameter to the call to H5F_istore_preempt
*
*-------------------------------------------------------------------------
*/
@@ -1190,8 +1190,8 @@ H5F_istore_flush (H5F_t *f, hbool_t preempt)
* Thursday, May 21, 1998
*
* Modifications:
- * Pedro Vicente, March 28, 2002
- * Added TRUE parameter to the call to H5F_istore_preempt
+ * Pedro Vicente, March 28, 2002
+ * Added TRUE parameter to the call to H5F_istore_preempt
*
*-------------------------------------------------------------------------
*/
@@ -1238,8 +1238,8 @@ H5F_istore_dest (H5F_t *f)
* Thursday, May 21, 1998
*
* Modifications:
- * Pedro Vicente, March 28, 2002
- * Added TRUE parameter to the call to H5F_istore_preempt
+ * Pedro Vicente, March 28, 2002
+ * TRUE parameter to the call to H5F_istore_preempt
*
*-------------------------------------------------------------------------
*/
@@ -1364,8 +1364,8 @@ H5F_istore_prune (H5F_t *f, size_t size)
* The split ratios are passed in as part of the data transfer
* property list.
*
- * Pedro Vicente, March 28, 2002
- * Added TRUE parameter to the call to H5F_istore_preempt
+ * Pedro Vicente, March 28, 2002
+ * TRUE parameter to the call to H5F_istore_preempt
*-------------------------------------------------------------------------
*/
static void *
@@ -2498,8 +2498,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
FUNC_LEAVE(SUCCEED);
}
-
-
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_prune_by_extent
*
@@ -2600,94 +2599,91 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
*
*-------------------------------------------------------------------------
*/
-
-herr_t H5F_istore_prune_by_extent( H5F_t *f, H5O_layout_t *layout, H5S_t *space )
+herr_t
+H5F_istore_prune_by_extent(H5F_t *f, H5O_layout_t *layout, H5S_t * space)
{
- H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache*/
- H5F_rdcc_ent_t *ent = NULL, *next = NULL; /*cache entry */
- unsigned u; /*counters */
- int found = 0; /*remove this entry */
- H5F_istore_ud1_t udata; /*B-tree pass-through */
- hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
-
- FUNC_ENTER( H5F_istore_prune_by_extent, FAIL );
-
- /* Check args */
- assert(f);
- assert(layout && H5D_CHUNKED==layout->type);
- assert(layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert(H5F_addr_defined(layout->addr));
- assert(space);
-
- /* Go get the rank & dimensions */
- if(H5S_get_simple_extent_dims(space, curr_dims, NULL)<0)
- HRETURN_ERROR( H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
-
-
+ H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache */
+ H5F_rdcc_ent_t *ent = NULL, *next = NULL; /*cache entry */
+ unsigned u; /*counters */
+ int found = 0; /*remove this entry */
+ H5F_istore_ud1_t udata; /*B-tree pass-through */
+ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
+
+ FUNC_ENTER(H5F_istore_prune_by_extent, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(H5F_addr_defined(layout->addr));
+ assert(space);
+
+ /* Go get the rank & dimensions */
+ if(H5S_get_simple_extent_dims(space, curr_dims, NULL) < 0)
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTGET, FAIL,
+ "can't get dataset dimensions");
+
+
/*-------------------------------------------------------------------------
* Figure out what chunks are no longer in use for the specified extent
* and release them from the linked list raw data cache
*-------------------------------------------------------------------------
*/
-
- for ( ent = rdcc->head; ent; ent=next )
- {
- next = ent->next;
-
- found = 0;
- for ( u = 0; u < ent->layout->ndims-1; u++ )
- {
- if ( (hsize_t)ent->offset[u] > curr_dims[u] )
- {
- found = 1;
- break;
- }
- }
-
- if ( found )
- {
+
+ for(ent = rdcc->head; ent; ent = next) {
+ next = ent->next;
+
+ found = 0;
+ for(u = 0; u < ent->layout->ndims - 1; u++) {
+ if((hsize_t)ent->offset[u] > curr_dims[u]) {
+ found = 1;
+ break;
+ }
+ }
+
+ if(found) {
#if defined (H5F_ISTORE_DEBUG)
- HDfputs("cache:remove:[", stdout);
- for ( u = 0; u < ent->layout->ndims-1; u++)
- {
- HDfprintf( stdout, "%s%Hd", u?", ":"", ent->offset[u]);
- }
- HDfputs("]\n", stdout );
+ HDfputs("cache:remove:[", stdout);
+ for(u = 0; u < ent->layout->ndims - 1; u++) {
+ HDfprintf(stdout, "%s%Hd", u ? ", " : "", ent->offset[u]);
+ }
+ HDfputs("]\n", stdout);
#endif
-
- /* Preempt the entry from the cache, but do not flush it to disk */
- if ( H5F_istore_preempt( f, ent, FALSE ) < 0 )
- {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to preempt chunk");
- }
-
- }
-
- }
-
+
+ /* Preempt the entry from the cache, but do not flush it to disk */
+ if(H5F_istore_preempt(f, ent, FALSE) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
+ "unable to preempt chunk");
+ }
+
+ }
+
+ }
+
/*-------------------------------------------------------------------------
* Check if there are any chunks on the B-tree
*-------------------------------------------------------------------------
*/
-
- HDmemset(&udata, 0, sizeof udata);
- udata.stream = stdout;
- udata.mesg.addr = layout->addr;
- udata.mesg.ndims = layout->ndims;
- for ( u = 0; u < udata.mesg.ndims; u++ )
- {
- udata.mesg.dim[u] = layout->dim[u];
- }
-
- if ( H5B_prune_by_extent( f, H5B_ISTORE, layout->addr, &udata, curr_dims ) < 0 )
- {
- HRETURN_ERROR( H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree" );
- }
-
- FUNC_LEAVE( SUCCEED );
-
+
+ HDmemset(&udata, 0, sizeof udata);
+ udata.stream = stdout;
+ udata.mesg.addr = layout->addr;
+ udata.mesg.ndims = layout->ndims;
+ for(u = 0; u < udata.mesg.ndims; u++) {
+ udata.mesg.dim[u] = layout->dim[u];
+ }
+
+ if(H5B_prune_by_extent(f, H5B_ISTORE, layout->addr, &udata,
+ curr_dims) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
+ "unable to iterate over B-tree");
+ }
+
+ FUNC_LEAVE(SUCCEED);
+
}
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_prune_extent
*
@@ -2705,60 +2701,57 @@ herr_t H5F_istore_prune_by_extent( H5F_t *f, H5O_layout_t *layout, H5S_t *space
*
*-------------------------------------------------------------------------
*/
-
-static herr_t H5F_istore_prune_extent( H5F_t *f, void *_lt_key, haddr_t addr, void *_udata,
- hsize_t *size )
+static herr_t
+H5F_istore_prune_extent(H5F_t *f, void *_lt_key, haddr_t addr, void *_udata,
+ hsize_t *size)
{
- H5F_istore_ud1_t *bt_udata = (H5F_istore_ud1_t *)_udata;
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- unsigned u;
- int found = 0;
- H5F_istore_ud1_t udata;
-
- /* The LT_KEY is the left key (the onethat describes the chunk). It points to a chunk of
- storage that contains the beginning of the logical address space represented by UDATA.
- */
-
- FUNC_ENTER( H5F_istore_prune_extent, FAIL );
-
- /* Figure out what chunks are no longer in use for the specified extent and release them */
-
- for ( u = 0; u < bt_udata->mesg.ndims-1; u++ )
- {
- if ( (hsize_t)lt_key->offset[u] > size[u] )
- {
- found = 1;
- break;
- }
- }
-
- if ( found )
- {
-
+ H5F_istore_ud1_t *bt_udata = (H5F_istore_ud1_t *)_udata;
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
+ unsigned u;
+ int found = 0;
+ H5F_istore_ud1_t udata;
+
+ /* The LT_KEY is the left key (the onethat describes the chunk). It points to a chunk of
+ * storage that contains the beginning of the logical address space represented by UDATA.
+ */
+
+ FUNC_ENTER(H5F_istore_prune_extent, FAIL);
+
+ /* Figure out what chunks are no longer in use for the specified extent and release them */
+
+ for(u = 0; u < bt_udata->mesg.ndims - 1; u++) {
+ if((hsize_t)lt_key->offset[u] > size[u]) {
+ found = 1;
+ break;
+ }
+ }
+
+ if(found) {
+
#if defined (H5F_ISTORE_DEBUG)
- HDfputs("b-tree:remove:[", bt_udata->stream);
- for ( u = 0; u < bt_udata->mesg.ndims-1; u++)
- {
- HDfprintf(bt_udata->stream, "%s%Hd", u?", ":"", lt_key->offset[u]);
- }
- HDfputs("]\n", bt_udata->stream);
+ HDfputs("b-tree:remove:[", bt_udata->stream);
+ for(u = 0; u < bt_udata->mesg.ndims - 1; u++) {
+ HDfprintf(bt_udata->stream, "%s%Hd", u ? ", " : "",
+ lt_key->offset[u]);
+ }
+ HDfputs("]\n", bt_udata->stream);
#endif
-
- HDmemset( &udata, 0, sizeof udata );
- udata.key = *lt_key;
- udata.mesg = bt_udata->mesg;
-
- /* Remove */
- if ( H5B_remove( f, H5B_ISTORE, addr, &udata ) < 0 )
- {
- HRETURN_ERROR( H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry" );
- }
- }
-
- FUNC_LEAVE( SUCCEED );
-}
+ HDmemset(&udata, 0, sizeof udata);
+ udata.key = *lt_key;
+ udata.mesg = bt_udata->mesg;
+
+ /* Remove */
+ if(H5B_remove(f, H5B_ISTORE, addr, &udata) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "unable to remove entry");
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
+}
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_remove
*
@@ -2777,24 +2770,22 @@ static herr_t H5F_istore_prune_extent( H5F_t *f, void *_lt_key, haddr_t addr, vo
*
*-------------------------------------------------------------------------
*/
-
-static H5B_ins_t H5F_istore_remove( H5F_t *f,
- haddr_t addr,
- void *_lt_key /*in,out*/,
- hbool_t *lt_key_changed /*out*/,
- void UNUSED *_udata /*in,out*/,
- void UNUSED *_rt_key /*in,out*/,
- hbool_t *rt_key_changed /*out*/)
+static H5B_ins_t
+H5F_istore_remove(H5F_t *f, haddr_t addr, void *_lt_key /*in,out */ ,
+ hbool_t *lt_key_changed /*out */ ,
+ void UNUSED * _udata /*in,out */ ,
+ void UNUSED * _rt_key /*in,out */ ,
+ hbool_t *rt_key_changed /*out */ )
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t*)_lt_key;
- H5FD_free(f->shared->lf, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes);
- *lt_key_changed = FALSE;
- *rt_key_changed = FALSE;
- return H5B_INS_REMOVE;
-}
-
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
+ H5FD_free(f->shared->lf, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes);
+ *lt_key_changed = FALSE;
+ *rt_key_changed = FALSE;
+ return H5B_INS_REMOVE;
+}
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_initialize_by_extent
*
@@ -2819,178 +2810,175 @@ static H5B_ins_t H5F_istore_remove( H5F_t *f,
*
*-------------------------------------------------------------------------
*/
+herr_t
+H5F_istore_initialize_by_extent(H5F_t *f, H5O_layout_t *layout,
+ H5O_pline_t * pline, H5O_fill_t * fill, H5S_t * space)
+{
+ hid_t dxpl_id; /*dataset transfer property list */
+ uint8_t *chunk = NULL; /*the file chunk */
+ unsigned idx_hint = 0; /*input value for H5F_istore_lock */
+ hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; /*logical location of the chunks */
+ hsize_t idx_cur[H5O_LAYOUT_NDIMS]; /*multi-dimensional counters */
+ hsize_t idx_min[H5O_LAYOUT_NDIMS];
+ hsize_t idx_max[H5O_LAYOUT_NDIMS];
+ hsize_t sub_size[H5O_LAYOUT_NDIMS];
+ hsize_t naccessed; /*bytes accessed in chunk */
+ hsize_t elm_size; /*size of an element in bytes */
+ hsize_t end_chunk; /*chunk position counter */
+ hssize_t start[H5O_LAYOUT_NDIMS]; /*starting location of hyperslab */
+ hsize_t count[H5O_LAYOUT_NDIMS]; /*element count of hyperslab */
+ hsize_t size[H5O_LAYOUT_NDIMS]; /*current size of dimensions */
+ H5S_t *space_chunk = NULL; /*dataspace for a chunk */
+ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
+ int rank; /*current # of dimensions */
+ int i, carry; /*counters */
+ unsigned u;
+ int found = 0; /*initialize this entry */
+
+ FUNC_ENTER(H5F_istore_initialize_by_extent, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(H5F_addr_defined(layout->addr));
+ assert(space);
+ assert(pline);
+ assert(fill);
+ HDmemset(start, 0, sizeof(start));
+ HDmemset(count, 0, sizeof(count));
+
+ /* Go get the rank & dimensions */
+ if((rank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0)
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTGET, FAIL,
+ "can't get dataset dimensions");
+
+ for(i = 0; i < rank; i++) {
+ size[i] = curr_dims[i];
+ }
+ size[i] = layout->dim[i];
+ elm_size = size[i];
+
+ /* Default dataset transfer property list */
+ dxpl_id = H5P_DATASET_XFER_DEFAULT;
+
+ /* Create a data space for a chunk & set the extent */
+ if(NULL == (space_chunk = H5S_create(H5S_SIMPLE))) {
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL,
+ "can't create simple dataspace");
+ }
+ if(H5S_set_extent_simple(space_chunk, (unsigned)rank, layout->dim,
+ NULL) < 0) {
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
+ "can't set dimensions");
+ }
-herr_t H5F_istore_initialize_by_extent( H5F_t *f, H5O_layout_t *layout, H5O_pline_t *pline,
- H5O_fill_t *fill, H5S_t *space )
-{
- hid_t dxpl_id; /*dataset transfer property list*/
- uint8_t *chunk = NULL; /*the file chunk */
- unsigned idx_hint = 0; /*input value for H5F_istore_lock*/
- hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; /*logical location of the chunks */
- hsize_t idx_cur[H5O_LAYOUT_NDIMS]; /*multi-dimensional counters */
- hsize_t idx_min[H5O_LAYOUT_NDIMS];
- hsize_t idx_max[H5O_LAYOUT_NDIMS];
- hsize_t sub_size[H5O_LAYOUT_NDIMS];
- hsize_t naccessed; /*bytes accessed in chunk */
- hsize_t elm_size; /*size of an element in bytes */
- hsize_t end_chunk; /*chunk position counter */
- hssize_t start[H5O_LAYOUT_NDIMS]; /*starting location of hyperslab */
- hsize_t count[H5O_LAYOUT_NDIMS]; /*element count of hyperslab */
- hsize_t size[H5O_LAYOUT_NDIMS]; /*current size of dimensions */
- H5S_t *space_chunk=NULL; /*dataspace for a chunk */
- hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
- int rank; /*current # of dimensions */
- int i, carry; /*counters */
- unsigned u;
- int found = 0; /*initialize this entry */
-
- FUNC_ENTER( H5F_istore_initialize_by_extent, FAIL );
-
- /* Check args */
- assert(f);
- assert(layout && H5D_CHUNKED==layout->type);
- assert(layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert(H5F_addr_defined(layout->addr));
- assert(space);
- assert(pline);
- assert(fill);
-
- HDmemset( start, 0, sizeof(start) );
- HDmemset( count, 0, sizeof(count) );
-
- /* Go get the rank & dimensions */
- if((rank=H5S_get_simple_extent_dims(space, curr_dims, NULL))<0)
- HRETURN_ERROR( H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
-
- for ( i = 0; i < rank; i++ )
- {
- size[i] = curr_dims[i];
- }
- size[i] = layout->dim[i];
- elm_size = size[i];
-
- /* Default dataset transfer property list */
- dxpl_id = H5P_DATASET_XFER_DEFAULT;
-
- /* Create a data space for a chunk & set the extent */
- if(NULL==(space_chunk=H5S_create(H5S_SIMPLE))) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL,
- "can't create simple dataspace");
- }
- if(H5S_set_extent_simple(space_chunk,(unsigned)rank,layout->dim,NULL)<0) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "can't set dimensions");
- }
-
/*
* Set up multi-dimensional counters (idx_min, idx_max, and idx_cur) and
* loop through the chunks copying each chunk from the application to the
* chunk cache.
*/
- for ( u = 0; u < layout->ndims; u++)
- {
- idx_min[u] = 0;
- idx_max[u] = (size[u]-1) / layout->dim[u] + 1;
- idx_cur[u] = idx_min[u];
- }
-
- /* Loop over all chunks */
- while ( 1 )
- {
-
- for ( u = 0, naccessed=1; u < layout->ndims; u++ )
- {
- /* The location and size of the chunk being accessed */
- chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]);
- sub_size[u] = MIN((idx_cur[u]+1)*layout->dim[u],size[u]) - chunk_offset[u];
- naccessed *= sub_size[u];
- }
-
- /*
- Figure out what chunks have to be initialized. These are the chunks where the database
- extent boundary is within the chunk
- */
-
- for ( u = 0, found = 0; u < layout->ndims-1; u++ )
- {
- end_chunk = chunk_offset[u] + layout->dim[u];
- if ( end_chunk > size[u] )
- {
- found = 1;
- break;
- }
- }
-
- if ( found )
- {
-
- if (NULL==(chunk=H5F_istore_lock( f, dxpl_id, layout, pline, fill, chunk_offset, FALSE, &idx_hint)))
- {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk");
- }
-
- if ( H5S_select_all( space_chunk ) < 0 )
- {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to select space");
- }
-
- for ( i = 0; i < rank; i++ )
- {
- count[i] = MIN( (idx_cur[i]+1)*layout->dim[i], size[i]-chunk_offset[i] );
- }
-
+ for(u = 0; u < layout->ndims; u++) {
+ idx_min[u] = 0;
+ idx_max[u] = (size[u] - 1) / layout->dim[u] + 1;
+ idx_cur[u] = idx_min[u];
+ }
+
+ /* Loop over all chunks */
+ while(1) {
+
+ for(u = 0, naccessed = 1; u < layout->ndims; u++) {
+ /* The location and size of the chunk being accessed */
+ chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]);
+ sub_size[u] =
+ MIN((idx_cur[u] + 1) * layout->dim[u],
+ size[u]) - chunk_offset[u];
+ naccessed *= sub_size[u];
+ }
+
+ /*
+ * Figure out what chunks have to be initialized. These are the chunks where the database
+ * extent boundary is within the chunk
+ */
+
+ for(u = 0, found = 0; u < layout->ndims - 1; u++) {
+ end_chunk = chunk_offset[u] + layout->dim[u];
+ if(end_chunk > size[u]) {
+ found = 1;
+ break;
+ }
+ }
+
+ if(found) {
+
+ if(NULL == (chunk =
+ H5F_istore_lock(f, dxpl_id, layout, pline, fill,
+ chunk_offset, FALSE, &idx_hint))) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to read raw data chunk");
+ }
+
+ if(H5S_select_all(space_chunk) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to select space");
+ }
+
+ for(i = 0; i < rank; i++) {
+ count[i] =
+ MIN((idx_cur[i] + 1) * layout->dim[i],
+ size[i] - chunk_offset[i]);
+ }
+
#if defined (H5F_ISTORE_DEBUG)
- HDfputs("cache:initialize:offset:[", stdout);
- for ( u = 0; u < layout->ndims-1; u++)
- {
- HDfprintf( stdout, "%s%Hd", u?", ":"", chunk_offset[u]);
- }
- HDfputs("]", stdout );
- HDfputs(":count:[", stdout);
- for ( u = 0; u < layout->ndims-1; u++)
- {
- HDfprintf( stdout, "%s%Hd", u?", ":"", count[u]);
- }
- HDfputs("]\n", stdout );
+ HDfputs("cache:initialize:offset:[", stdout);
+ for(u = 0; u < layout->ndims - 1; u++) {
+ HDfprintf(stdout, "%s%Hd", u ? ", " : "", chunk_offset[u]);
+ }
+ HDfputs("]", stdout);
+ HDfputs(":count:[", stdout);
+ for(u = 0; u < layout->ndims - 1; u++) {
+ HDfprintf(stdout, "%s%Hd", u ? ", " : "", count[u]);
+ }
+ HDfputs("]\n", stdout);
#endif
-
- if ( H5S_select_hyperslab( space_chunk, H5S_SELECT_NOTB, start, NULL, count, NULL)<0)
- {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to select hyperslab");
- }
-
- /* Fill the selection in the memory buffer */
- if ( H5S_select_fill( fill->buf, fill->size, space_chunk, chunk ) < 0 )
- {
- HRETURN_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed");
- }
-
- if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, chunk_offset, &idx_hint, chunk, (size_t)naccessed)<0)
- {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk");
- }
-
- } /*found*/
-
-
- /* Increment indices */
- for ( i = layout->ndims-1, carry=1; i >= 0 && carry; --i)
- {
- if (++idx_cur[i] >= idx_max[i])
- idx_cur[i] = idx_min[i];
- else
- carry = 0;
- }
- if (carry)
- break;
-
- }
-
-
- if(space_chunk)
- H5S_close( space_chunk);
-
- FUNC_LEAVE( SUCCEED );
-}
+ if(H5S_select_hyperslab(space_chunk, H5S_SELECT_NOTB, start, NULL,
+ count, NULL) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to select hyperslab");
+ }
+
+ /* Fill the selection in the memory buffer */
+ if(H5S_select_fill(fill->buf, fill->size, space_chunk, chunk) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL,
+ "filling selection failed");
+ }
+
+ if(H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE,
+ chunk_offset, &idx_hint, chunk,
+ (size_t)naccessed) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to unlock raw data chunk");
+ }
+
+ } /*found */
+
+
+ /* Increment indices */
+ for(i = layout->ndims - 1, carry = 1; i >= 0 && carry; --i) {
+ if(++idx_cur[i] >= idx_max[i])
+ idx_cur[i] = idx_min[i];
+ else
+ carry = 0;
+ }
+ if(carry)
+ break;
+
+ }
+
+ if(space_chunk)
+ H5S_close(space_chunk);
+
+ FUNC_LEAVE(SUCCEED);
+}
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index 328f791..da816af 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -1053,6 +1053,7 @@ done:
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_preempt
*
@@ -1064,71 +1065,70 @@ done:
* Programmer: Robb Matzke
* Thursday, May 21, 1998
*
- * Modifications: Pedro Vicente, March 28, 2002
- * Added flush parameter that switches the call to H5F_istore_flush_entry
- * The call with FALSE is used by the H5F_istore_prune_by_extent function
+ * Modifications:
+ * Pedro Vicente, March 28, 2002
+ * Added flush parameter that switches the call to H5F_istore_flush_entry
+ * The call with FALSE is used by the H5F_istore_prune_by_extent function
*
*-------------------------------------------------------------------------
*/
-
- static herr_t
- H5F_istore_preempt (H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t flush )
- {
- H5F_rdcc_t *rdcc = &(f->shared->rdcc);
-
- FUNC_ENTER (H5F_istore_preempt, FAIL);
-
- assert(f);
- assert(ent);
- assert(!ent->locked);
- assert(ent->idx<rdcc->nslots);
-
- if ( flush )
- {
-
- /* Flush */
- if (H5F_istore_flush_entry(f, ent, TRUE)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "cannot flush indexed storage buffer");
- }
- }
-
- else
- {
-
- /* Reset, but do not free or remove from list */
- ent->layout = H5O_free(H5O_LAYOUT, ent->layout);
- ent->pline = H5O_free(H5O_PLINE, ent->pline);
- if(ent->chunk!=NULL)
- ent->chunk = H5F_istore_chunk_free(ent->chunk);
-
- }
-
- /* Unlink from list */
- if (ent->prev) {
- ent->prev->next = ent->next;
- } else {
- rdcc->head = ent->next;
- }
- if (ent->next) {
- ent->next->prev = ent->prev;
- } else {
- rdcc->tail = ent->prev;
- }
- ent->prev = ent->next = NULL;
-
- /* Remove from cache */
- rdcc->slot[ent->idx] = NULL;
- ent->idx = UINT_MAX;
- rdcc->nbytes -= ent->chunk_size;
- --rdcc->nused;
-
- /* Free */
- H5FL_FREE(H5F_rdcc_ent_t, ent);
-
- FUNC_LEAVE (SUCCEED);
- }
+static herr_t
+H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush)
+{
+ H5F_rdcc_t *rdcc = &(f->shared->rdcc);
+
+ FUNC_ENTER(H5F_istore_preempt, FAIL);
+
+ assert(f);
+ assert(ent);
+ assert(!ent->locked);
+ assert(ent->idx < rdcc->nslots);
+ if(flush) {
+
+ /* Flush */
+ if(H5F_istore_flush_entry(f, ent, TRUE) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "cannot flush indexed storage buffer");
+ }
+ }
+
+ else {
+
+ /* Reset, but do not free or remove from list */
+ ent->layout = H5O_free(H5O_LAYOUT, ent->layout);
+ ent->pline = H5O_free(H5O_PLINE, ent->pline);
+ if(ent->chunk != NULL)
+ ent->chunk = H5F_istore_chunk_free(ent->chunk);
+
+ }
+
+ /* Unlink from list */
+ if(ent->prev) {
+ ent->prev->next = ent->next;
+ }
+ else {
+ rdcc->head = ent->next;
+ }
+ if(ent->next) {
+ ent->next->prev = ent->prev;
+ }
+ else {
+ rdcc->tail = ent->prev;
+ }
+ ent->prev = ent->next = NULL;
+
+ /* Remove from cache */
+ rdcc->slot[ent->idx] = NULL;
+ ent->idx = UINT_MAX;
+ rdcc->nbytes -= ent->chunk_size;
+ --rdcc->nused;
+
+ /* Free */
+ H5FL_FREE(H5F_rdcc_ent_t, ent);
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
@@ -1143,8 +1143,8 @@ done:
* Thursday, May 21, 1998
*
* Modifications:
- * Pedro Vicente, March 28, 2002
- * Added TRUE parameter to the call to H5F_istore_preempt
+ * Pedro Vicente, March 28, 2002
+ * Added TRUE parameter to the call to H5F_istore_preempt
*
*-------------------------------------------------------------------------
*/
@@ -1190,8 +1190,8 @@ H5F_istore_flush (H5F_t *f, hbool_t preempt)
* Thursday, May 21, 1998
*
* Modifications:
- * Pedro Vicente, March 28, 2002
- * Added TRUE parameter to the call to H5F_istore_preempt
+ * Pedro Vicente, March 28, 2002
+ * Added TRUE parameter to the call to H5F_istore_preempt
*
*-------------------------------------------------------------------------
*/
@@ -1238,8 +1238,8 @@ H5F_istore_dest (H5F_t *f)
* Thursday, May 21, 1998
*
* Modifications:
- * Pedro Vicente, March 28, 2002
- * Added TRUE parameter to the call to H5F_istore_preempt
+ * Pedro Vicente, March 28, 2002
+ * TRUE parameter to the call to H5F_istore_preempt
*
*-------------------------------------------------------------------------
*/
@@ -1364,8 +1364,8 @@ H5F_istore_prune (H5F_t *f, size_t size)
* The split ratios are passed in as part of the data transfer
* property list.
*
- * Pedro Vicente, March 28, 2002
- * Added TRUE parameter to the call to H5F_istore_preempt
+ * Pedro Vicente, March 28, 2002
+ * TRUE parameter to the call to H5F_istore_preempt
*-------------------------------------------------------------------------
*/
static void *
@@ -2498,8 +2498,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
FUNC_LEAVE(SUCCEED);
}
-
-
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_prune_by_extent
*
@@ -2600,94 +2599,91 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
*
*-------------------------------------------------------------------------
*/
-
-herr_t H5F_istore_prune_by_extent( H5F_t *f, H5O_layout_t *layout, H5S_t *space )
+herr_t
+H5F_istore_prune_by_extent(H5F_t *f, H5O_layout_t *layout, H5S_t * space)
{
- H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache*/
- H5F_rdcc_ent_t *ent = NULL, *next = NULL; /*cache entry */
- unsigned u; /*counters */
- int found = 0; /*remove this entry */
- H5F_istore_ud1_t udata; /*B-tree pass-through */
- hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
-
- FUNC_ENTER( H5F_istore_prune_by_extent, FAIL );
-
- /* Check args */
- assert(f);
- assert(layout && H5D_CHUNKED==layout->type);
- assert(layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert(H5F_addr_defined(layout->addr));
- assert(space);
-
- /* Go get the rank & dimensions */
- if(H5S_get_simple_extent_dims(space, curr_dims, NULL)<0)
- HRETURN_ERROR( H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
-
-
+ H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache */
+ H5F_rdcc_ent_t *ent = NULL, *next = NULL; /*cache entry */
+ unsigned u; /*counters */
+ int found = 0; /*remove this entry */
+ H5F_istore_ud1_t udata; /*B-tree pass-through */
+ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
+
+ FUNC_ENTER(H5F_istore_prune_by_extent, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(H5F_addr_defined(layout->addr));
+ assert(space);
+
+ /* Go get the rank & dimensions */
+ if(H5S_get_simple_extent_dims(space, curr_dims, NULL) < 0)
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTGET, FAIL,
+ "can't get dataset dimensions");
+
+
/*-------------------------------------------------------------------------
* Figure out what chunks are no longer in use for the specified extent
* and release them from the linked list raw data cache
*-------------------------------------------------------------------------
*/
-
- for ( ent = rdcc->head; ent; ent=next )
- {
- next = ent->next;
-
- found = 0;
- for ( u = 0; u < ent->layout->ndims-1; u++ )
- {
- if ( (hsize_t)ent->offset[u] > curr_dims[u] )
- {
- found = 1;
- break;
- }
- }
-
- if ( found )
- {
+
+ for(ent = rdcc->head; ent; ent = next) {
+ next = ent->next;
+
+ found = 0;
+ for(u = 0; u < ent->layout->ndims - 1; u++) {
+ if((hsize_t)ent->offset[u] > curr_dims[u]) {
+ found = 1;
+ break;
+ }
+ }
+
+ if(found) {
#if defined (H5F_ISTORE_DEBUG)
- HDfputs("cache:remove:[", stdout);
- for ( u = 0; u < ent->layout->ndims-1; u++)
- {
- HDfprintf( stdout, "%s%Hd", u?", ":"", ent->offset[u]);
- }
- HDfputs("]\n", stdout );
+ HDfputs("cache:remove:[", stdout);
+ for(u = 0; u < ent->layout->ndims - 1; u++) {
+ HDfprintf(stdout, "%s%Hd", u ? ", " : "", ent->offset[u]);
+ }
+ HDfputs("]\n", stdout);
#endif
-
- /* Preempt the entry from the cache, but do not flush it to disk */
- if ( H5F_istore_preempt( f, ent, FALSE ) < 0 )
- {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to preempt chunk");
- }
-
- }
-
- }
-
+
+ /* Preempt the entry from the cache, but do not flush it to disk */
+ if(H5F_istore_preempt(f, ent, FALSE) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
+ "unable to preempt chunk");
+ }
+
+ }
+
+ }
+
/*-------------------------------------------------------------------------
* Check if there are any chunks on the B-tree
*-------------------------------------------------------------------------
*/
-
- HDmemset(&udata, 0, sizeof udata);
- udata.stream = stdout;
- udata.mesg.addr = layout->addr;
- udata.mesg.ndims = layout->ndims;
- for ( u = 0; u < udata.mesg.ndims; u++ )
- {
- udata.mesg.dim[u] = layout->dim[u];
- }
-
- if ( H5B_prune_by_extent( f, H5B_ISTORE, layout->addr, &udata, curr_dims ) < 0 )
- {
- HRETURN_ERROR( H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree" );
- }
-
- FUNC_LEAVE( SUCCEED );
-
+
+ HDmemset(&udata, 0, sizeof udata);
+ udata.stream = stdout;
+ udata.mesg.addr = layout->addr;
+ udata.mesg.ndims = layout->ndims;
+ for(u = 0; u < udata.mesg.ndims; u++) {
+ udata.mesg.dim[u] = layout->dim[u];
+ }
+
+ if(H5B_prune_by_extent(f, H5B_ISTORE, layout->addr, &udata,
+ curr_dims) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
+ "unable to iterate over B-tree");
+ }
+
+ FUNC_LEAVE(SUCCEED);
+
}
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_prune_extent
*
@@ -2705,60 +2701,57 @@ herr_t H5F_istore_prune_by_extent( H5F_t *f, H5O_layout_t *layout, H5S_t *space
*
*-------------------------------------------------------------------------
*/
-
-static herr_t H5F_istore_prune_extent( H5F_t *f, void *_lt_key, haddr_t addr, void *_udata,
- hsize_t *size )
+static herr_t
+H5F_istore_prune_extent(H5F_t *f, void *_lt_key, haddr_t addr, void *_udata,
+ hsize_t *size)
{
- H5F_istore_ud1_t *bt_udata = (H5F_istore_ud1_t *)_udata;
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- unsigned u;
- int found = 0;
- H5F_istore_ud1_t udata;
-
- /* The LT_KEY is the left key (the onethat describes the chunk). It points to a chunk of
- storage that contains the beginning of the logical address space represented by UDATA.
- */
-
- FUNC_ENTER( H5F_istore_prune_extent, FAIL );
-
- /* Figure out what chunks are no longer in use for the specified extent and release them */
-
- for ( u = 0; u < bt_udata->mesg.ndims-1; u++ )
- {
- if ( (hsize_t)lt_key->offset[u] > size[u] )
- {
- found = 1;
- break;
- }
- }
-
- if ( found )
- {
-
+ H5F_istore_ud1_t *bt_udata = (H5F_istore_ud1_t *)_udata;
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
+ unsigned u;
+ int found = 0;
+ H5F_istore_ud1_t udata;
+
+ /* The LT_KEY is the left key (the onethat describes the chunk). It points to a chunk of
+ * storage that contains the beginning of the logical address space represented by UDATA.
+ */
+
+ FUNC_ENTER(H5F_istore_prune_extent, FAIL);
+
+ /* Figure out what chunks are no longer in use for the specified extent and release them */
+
+ for(u = 0; u < bt_udata->mesg.ndims - 1; u++) {
+ if((hsize_t)lt_key->offset[u] > size[u]) {
+ found = 1;
+ break;
+ }
+ }
+
+ if(found) {
+
#if defined (H5F_ISTORE_DEBUG)
- HDfputs("b-tree:remove:[", bt_udata->stream);
- for ( u = 0; u < bt_udata->mesg.ndims-1; u++)
- {
- HDfprintf(bt_udata->stream, "%s%Hd", u?", ":"", lt_key->offset[u]);
- }
- HDfputs("]\n", bt_udata->stream);
+ HDfputs("b-tree:remove:[", bt_udata->stream);
+ for(u = 0; u < bt_udata->mesg.ndims - 1; u++) {
+ HDfprintf(bt_udata->stream, "%s%Hd", u ? ", " : "",
+ lt_key->offset[u]);
+ }
+ HDfputs("]\n", bt_udata->stream);
#endif
-
- HDmemset( &udata, 0, sizeof udata );
- udata.key = *lt_key;
- udata.mesg = bt_udata->mesg;
-
- /* Remove */
- if ( H5B_remove( f, H5B_ISTORE, addr, &udata ) < 0 )
- {
- HRETURN_ERROR( H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry" );
- }
- }
-
- FUNC_LEAVE( SUCCEED );
-}
+ HDmemset(&udata, 0, sizeof udata);
+ udata.key = *lt_key;
+ udata.mesg = bt_udata->mesg;
+
+ /* Remove */
+ if(H5B_remove(f, H5B_ISTORE, addr, &udata) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "unable to remove entry");
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
+}
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_remove
*
@@ -2777,24 +2770,22 @@ static herr_t H5F_istore_prune_extent( H5F_t *f, void *_lt_key, haddr_t addr, vo
*
*-------------------------------------------------------------------------
*/
-
-static H5B_ins_t H5F_istore_remove( H5F_t *f,
- haddr_t addr,
- void *_lt_key /*in,out*/,
- hbool_t *lt_key_changed /*out*/,
- void UNUSED *_udata /*in,out*/,
- void UNUSED *_rt_key /*in,out*/,
- hbool_t *rt_key_changed /*out*/)
+static H5B_ins_t
+H5F_istore_remove(H5F_t *f, haddr_t addr, void *_lt_key /*in,out */ ,
+ hbool_t *lt_key_changed /*out */ ,
+ void UNUSED * _udata /*in,out */ ,
+ void UNUSED * _rt_key /*in,out */ ,
+ hbool_t *rt_key_changed /*out */ )
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t*)_lt_key;
- H5FD_free(f->shared->lf, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes);
- *lt_key_changed = FALSE;
- *rt_key_changed = FALSE;
- return H5B_INS_REMOVE;
-}
-
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
+ H5FD_free(f->shared->lf, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes);
+ *lt_key_changed = FALSE;
+ *rt_key_changed = FALSE;
+ return H5B_INS_REMOVE;
+}
+
/*-------------------------------------------------------------------------
* Function: H5F_istore_initialize_by_extent
*
@@ -2819,178 +2810,175 @@ static H5B_ins_t H5F_istore_remove( H5F_t *f,
*
*-------------------------------------------------------------------------
*/
+herr_t
+H5F_istore_initialize_by_extent(H5F_t *f, H5O_layout_t *layout,
+ H5O_pline_t * pline, H5O_fill_t * fill, H5S_t * space)
+{
+ hid_t dxpl_id; /*dataset transfer property list */
+ uint8_t *chunk = NULL; /*the file chunk */
+ unsigned idx_hint = 0; /*input value for H5F_istore_lock */
+ hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; /*logical location of the chunks */
+ hsize_t idx_cur[H5O_LAYOUT_NDIMS]; /*multi-dimensional counters */
+ hsize_t idx_min[H5O_LAYOUT_NDIMS];
+ hsize_t idx_max[H5O_LAYOUT_NDIMS];
+ hsize_t sub_size[H5O_LAYOUT_NDIMS];
+ hsize_t naccessed; /*bytes accessed in chunk */
+ hsize_t elm_size; /*size of an element in bytes */
+ hsize_t end_chunk; /*chunk position counter */
+ hssize_t start[H5O_LAYOUT_NDIMS]; /*starting location of hyperslab */
+ hsize_t count[H5O_LAYOUT_NDIMS]; /*element count of hyperslab */
+ hsize_t size[H5O_LAYOUT_NDIMS]; /*current size of dimensions */
+ H5S_t *space_chunk = NULL; /*dataspace for a chunk */
+ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
+ int rank; /*current # of dimensions */
+ int i, carry; /*counters */
+ unsigned u;
+ int found = 0; /*initialize this entry */
+
+ FUNC_ENTER(H5F_istore_initialize_by_extent, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(H5F_addr_defined(layout->addr));
+ assert(space);
+ assert(pline);
+ assert(fill);
+ HDmemset(start, 0, sizeof(start));
+ HDmemset(count, 0, sizeof(count));
+
+ /* Go get the rank & dimensions */
+ if((rank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0)
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTGET, FAIL,
+ "can't get dataset dimensions");
+
+ for(i = 0; i < rank; i++) {
+ size[i] = curr_dims[i];
+ }
+ size[i] = layout->dim[i];
+ elm_size = size[i];
+
+ /* Default dataset transfer property list */
+ dxpl_id = H5P_DATASET_XFER_DEFAULT;
+
+ /* Create a data space for a chunk & set the extent */
+ if(NULL == (space_chunk = H5S_create(H5S_SIMPLE))) {
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL,
+ "can't create simple dataspace");
+ }
+ if(H5S_set_extent_simple(space_chunk, (unsigned)rank, layout->dim,
+ NULL) < 0) {
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
+ "can't set dimensions");
+ }
-herr_t H5F_istore_initialize_by_extent( H5F_t *f, H5O_layout_t *layout, H5O_pline_t *pline,
- H5O_fill_t *fill, H5S_t *space )
-{
- hid_t dxpl_id; /*dataset transfer property list*/
- uint8_t *chunk = NULL; /*the file chunk */
- unsigned idx_hint = 0; /*input value for H5F_istore_lock*/
- hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; /*logical location of the chunks */
- hsize_t idx_cur[H5O_LAYOUT_NDIMS]; /*multi-dimensional counters */
- hsize_t idx_min[H5O_LAYOUT_NDIMS];
- hsize_t idx_max[H5O_LAYOUT_NDIMS];
- hsize_t sub_size[H5O_LAYOUT_NDIMS];
- hsize_t naccessed; /*bytes accessed in chunk */
- hsize_t elm_size; /*size of an element in bytes */
- hsize_t end_chunk; /*chunk position counter */
- hssize_t start[H5O_LAYOUT_NDIMS]; /*starting location of hyperslab */
- hsize_t count[H5O_LAYOUT_NDIMS]; /*element count of hyperslab */
- hsize_t size[H5O_LAYOUT_NDIMS]; /*current size of dimensions */
- H5S_t *space_chunk=NULL; /*dataspace for a chunk */
- hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
- int rank; /*current # of dimensions */
- int i, carry; /*counters */
- unsigned u;
- int found = 0; /*initialize this entry */
-
- FUNC_ENTER( H5F_istore_initialize_by_extent, FAIL );
-
- /* Check args */
- assert(f);
- assert(layout && H5D_CHUNKED==layout->type);
- assert(layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert(H5F_addr_defined(layout->addr));
- assert(space);
- assert(pline);
- assert(fill);
-
- HDmemset( start, 0, sizeof(start) );
- HDmemset( count, 0, sizeof(count) );
-
- /* Go get the rank & dimensions */
- if((rank=H5S_get_simple_extent_dims(space, curr_dims, NULL))<0)
- HRETURN_ERROR( H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
-
- for ( i = 0; i < rank; i++ )
- {
- size[i] = curr_dims[i];
- }
- size[i] = layout->dim[i];
- elm_size = size[i];
-
- /* Default dataset transfer property list */
- dxpl_id = H5P_DATASET_XFER_DEFAULT;
-
- /* Create a data space for a chunk & set the extent */
- if(NULL==(space_chunk=H5S_create(H5S_SIMPLE))) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL,
- "can't create simple dataspace");
- }
- if(H5S_set_extent_simple(space_chunk,(unsigned)rank,layout->dim,NULL)<0) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "can't set dimensions");
- }
-
/*
* Set up multi-dimensional counters (idx_min, idx_max, and idx_cur) and
* loop through the chunks copying each chunk from the application to the
* chunk cache.
*/
- for ( u = 0; u < layout->ndims; u++)
- {
- idx_min[u] = 0;
- idx_max[u] = (size[u]-1) / layout->dim[u] + 1;
- idx_cur[u] = idx_min[u];
- }
-
- /* Loop over all chunks */
- while ( 1 )
- {
-
- for ( u = 0, naccessed=1; u < layout->ndims; u++ )
- {
- /* The location and size of the chunk being accessed */
- chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]);
- sub_size[u] = MIN((idx_cur[u]+1)*layout->dim[u],size[u]) - chunk_offset[u];
- naccessed *= sub_size[u];
- }
-
- /*
- Figure out what chunks have to be initialized. These are the chunks where the database
- extent boundary is within the chunk
- */
-
- for ( u = 0, found = 0; u < layout->ndims-1; u++ )
- {
- end_chunk = chunk_offset[u] + layout->dim[u];
- if ( end_chunk > size[u] )
- {
- found = 1;
- break;
- }
- }
-
- if ( found )
- {
-
- if (NULL==(chunk=H5F_istore_lock( f, dxpl_id, layout, pline, fill, chunk_offset, FALSE, &idx_hint)))
- {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk");
- }
-
- if ( H5S_select_all( space_chunk ) < 0 )
- {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to select space");
- }
-
- for ( i = 0; i < rank; i++ )
- {
- count[i] = MIN( (idx_cur[i]+1)*layout->dim[i], size[i]-chunk_offset[i] );
- }
-
+ for(u = 0; u < layout->ndims; u++) {
+ idx_min[u] = 0;
+ idx_max[u] = (size[u] - 1) / layout->dim[u] + 1;
+ idx_cur[u] = idx_min[u];
+ }
+
+ /* Loop over all chunks */
+ while(1) {
+
+ for(u = 0, naccessed = 1; u < layout->ndims; u++) {
+ /* The location and size of the chunk being accessed */
+ chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]);
+ sub_size[u] =
+ MIN((idx_cur[u] + 1) * layout->dim[u],
+ size[u]) - chunk_offset[u];
+ naccessed *= sub_size[u];
+ }
+
+ /*
+ * Figure out what chunks have to be initialized. These are the chunks where the database
+ * extent boundary is within the chunk
+ */
+
+ for(u = 0, found = 0; u < layout->ndims - 1; u++) {
+ end_chunk = chunk_offset[u] + layout->dim[u];
+ if(end_chunk > size[u]) {
+ found = 1;
+ break;
+ }
+ }
+
+ if(found) {
+
+ if(NULL == (chunk =
+ H5F_istore_lock(f, dxpl_id, layout, pline, fill,
+ chunk_offset, FALSE, &idx_hint))) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to read raw data chunk");
+ }
+
+ if(H5S_select_all(space_chunk) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to select space");
+ }
+
+ for(i = 0; i < rank; i++) {
+ count[i] =
+ MIN((idx_cur[i] + 1) * layout->dim[i],
+ size[i] - chunk_offset[i]);
+ }
+
#if defined (H5F_ISTORE_DEBUG)
- HDfputs("cache:initialize:offset:[", stdout);
- for ( u = 0; u < layout->ndims-1; u++)
- {
- HDfprintf( stdout, "%s%Hd", u?", ":"", chunk_offset[u]);
- }
- HDfputs("]", stdout );
- HDfputs(":count:[", stdout);
- for ( u = 0; u < layout->ndims-1; u++)
- {
- HDfprintf( stdout, "%s%Hd", u?", ":"", count[u]);
- }
- HDfputs("]\n", stdout );
+ HDfputs("cache:initialize:offset:[", stdout);
+ for(u = 0; u < layout->ndims - 1; u++) {
+ HDfprintf(stdout, "%s%Hd", u ? ", " : "", chunk_offset[u]);
+ }
+ HDfputs("]", stdout);
+ HDfputs(":count:[", stdout);
+ for(u = 0; u < layout->ndims - 1; u++) {
+ HDfprintf(stdout, "%s%Hd", u ? ", " : "", count[u]);
+ }
+ HDfputs("]\n", stdout);
#endif
-
- if ( H5S_select_hyperslab( space_chunk, H5S_SELECT_NOTB, start, NULL, count, NULL)<0)
- {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to select hyperslab");
- }
-
- /* Fill the selection in the memory buffer */
- if ( H5S_select_fill( fill->buf, fill->size, space_chunk, chunk ) < 0 )
- {
- HRETURN_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed");
- }
-
- if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, chunk_offset, &idx_hint, chunk, (size_t)naccessed)<0)
- {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk");
- }
-
- } /*found*/
-
-
- /* Increment indices */
- for ( i = layout->ndims-1, carry=1; i >= 0 && carry; --i)
- {
- if (++idx_cur[i] >= idx_max[i])
- idx_cur[i] = idx_min[i];
- else
- carry = 0;
- }
- if (carry)
- break;
-
- }
-
-
- if(space_chunk)
- H5S_close( space_chunk);
-
- FUNC_LEAVE( SUCCEED );
-}
+ if(H5S_select_hyperslab(space_chunk, H5S_SELECT_NOTB, start, NULL,
+ count, NULL) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to select hyperslab");
+ }
+
+ /* Fill the selection in the memory buffer */
+ if(H5S_select_fill(fill->buf, fill->size, space_chunk, chunk) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL,
+ "filling selection failed");
+ }
+
+ if(H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE,
+ chunk_offset, &idx_hint, chunk,
+ (size_t)naccessed) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to unlock raw data chunk");
+ }
+
+ } /*found */
+
+
+ /* Increment indices */
+ for(i = layout->ndims - 1, carry = 1; i >= 0 && carry; --i) {
+ if(++idx_cur[i] >= idx_max[i])
+ idx_cur[i] = idx_min[i];
+ else
+ carry = 0;
+ }
+ if(carry)
+ break;
+
+ }
+
+ if(space_chunk)
+ H5S_close(space_chunk);
+
+ FUNC_LEAVE(SUCCEED);
+}
diff --git a/src/H5S.c b/src/H5S.c
index f681615..076155f 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -1973,9 +1973,7 @@ H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth)
FUNC_LEAVE(SUCCEED);
}
-
-
-
+
/*-------------------------------------------------------------------------
* Function: H5S_set_extent
*
@@ -1991,39 +1989,30 @@ H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth)
*
*-------------------------------------------------------------------------
*/
-
int H5S_set_extent( H5S_t *space, const hsize_t *size )
{
- int ret_value = 0;
- unsigned u;
-
- FUNC_ENTER( H5S_set_extent, FAIL );
-
- /* Check args */
- assert( space && H5S_SIMPLE==space->extent.type );
- assert( size);
-
- for ( u = 0; u < space->extent.u.simple.rank; u++ )
- {
- if ( space->extent.u.simple.max &&
- H5S_UNLIMITED != space->extent.u.simple.max[u] &&
- space->extent.u.simple.max[u]<size[u] )
- {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,"dimension cannot be modified");
- }
-
- ret_value++;
- }
-
- /* Update */
- if ( ret_value )
- {
- for ( u = 0; u < space->extent.u.simple.rank; u++ )
- {
- space->extent.u.simple.size[u] = size[u];
- }
- }
+ int ret_value;
+ unsigned u;
+
+ FUNC_ENTER( H5S_set_extent, FAIL );
+
+ /* Check args */
+ assert( space && H5S_SIMPLE==space->extent.type );
+ assert( size);
+
+ for ( u = 0; u < space->extent.u.simple.rank; u++ )
+ if ( space->extent.u.simple.max &&
+ H5S_UNLIMITED != space->extent.u.simple.max[u] &&
+ space->extent.u.simple.max[u]<size[u] )
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,"dimension cannot be modified");
+
+ /* Update dimensions with new values */
+ for ( u = 0; u < space->extent.u.simple.rank; u++ )
+ space->extent.u.simple.size[u] = size[u];
+
+ /* Set return value */
+ ret_value=space->extent.u.simple.rank;
- FUNC_LEAVE( ret_value );
+ FUNC_LEAVE( ret_value );
}