diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2018-04-29 08:04:21 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2018-04-29 08:04:21 (GMT) |
commit | 01f196b31a03f072b685f998b0805c1f90322c2b (patch) | |
tree | 6e1cae004705ade1c870e4c6612a76b55be3c331 /src/H5Ddeprec.c | |
parent | da4b69097756158fdbfcbf52b5b552e2034d263d (diff) | |
parent | b3c5284692093953132c6c8227e0980b670bf4ad (diff) | |
download | hdf5-01f196b31a03f072b685f998b0805c1f90322c2b.zip hdf5-01f196b31a03f072b685f998b0805c1f90322c2b.tar.gz hdf5-01f196b31a03f072b685f998b0805c1f90322c2b.tar.bz2 |
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/hdffv/hdf5 into merge_hyperslab_updates
Diffstat (limited to 'src/H5Ddeprec.c')
-rw-r--r-- | src/H5Ddeprec.c | 177 |
1 files changed, 30 insertions, 147 deletions
diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index f4c6797..0f1bfee 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -5,12 +5,10 @@ * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- @@ -38,6 +36,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ @@ -62,10 +61,6 @@ /* Local Prototypes */ /********************/ -#ifndef H5_NO_DEPRECATED_SYMBOLS -static herr_t H5D__extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*********************/ /* Package Variables */ @@ -120,6 +115,7 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, H5G_loc_t loc; /* Object location to insert dataset into */ H5D_t *dset = NULL; /* New dataset's info */ const H5S_t *space; /* Dataspace for dataset */ + hid_t dapl_id = H5P_DEFAULT; /* DAPL used by library */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -140,8 +136,12 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Build and open the new dataset */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, H5P_LINK_CREATE_DEFAULT, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id))) + if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, H5P_LINK_CREATE_DEFAULT, dcpl_id, dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") /* Register the new dataset to get an ID for it */ @@ -179,7 +179,7 @@ H5Dopen1(hid_t loc_id, const char *name) { H5D_t *dset = NULL; H5G_loc_t loc; /* Object location of group */ - hid_t ret_value; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "i*s", loc_id, name); @@ -191,7 +191,7 @@ H5Dopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, H5P_DATASET_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id))) + if(NULL == (dset = H5D__open_name(&loc, name, H5P_DATASET_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") /* Register an atom for the dataset */ @@ -226,8 +226,10 @@ done: herr_t H5Dextend(hid_t dset_id, const hsize_t size[]) { - H5D_t *dset; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset; /* Pointer to dataset to modify */ + hsize_t dset_dims[H5S_MAX_RANK]; /* Current dataset dimensions */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); @@ -238,143 +240,24 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) if(!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") + /* Make certain that the dataset dimensions don't decrease */ + /* (Shrinking dimensions is possible with H5Dset_extent, but not H5Dextend) */ + if(H5S_get_simple_extent_dims(dset->shared->space, dset_dims, NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") + for(u = 0; u < dset->shared->ndims; u++) + if(size[u] > dset_dims[u]) + dset_dims[u] = size[u]; + + /* Set up collective metadata if appropriate */ + if(H5CX_set_loc(dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Increase size */ - if(H5D__extend(dset, size, H5AC_ind_read_dxpl_id) < 0) + if(H5D__set_extent(dset, dset_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset") done: FUNC_LEAVE_API(ret_value) } /* end H5Dextend() */ - - -/*------------------------------------------------------------------------- - * Function: H5D__extend - * - * Purpose: Increases the size of a dataset. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Friday, January 30, 1998 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5D__extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) -{ - htri_t changed; /* Flag to indicate that the dataspace was successfully extended */ - hsize_t old_dims[H5S_MAX_RANK]; /* Current (i.e. old, if changed) dimension sizes */ - H5O_fill_t *fill; /* Dataset's fill value */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check args */ - HDassert(dataset); - HDassert(size); - - /* Check if the filters in the DCPL will need to encode, and if so, can they? */ - if(H5D__check_filters(dataset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't apply filters") - - /* - * NOTE: Restrictions on extensions were checked when the dataset was - * created. All extensions are allowed here since none should be - * able to muck things up. - */ - - /* Retrieve the current dimensions */ - HDcompile_assert(sizeof(old_dims) == sizeof(dataset->shared->curr_dims)); - HDmemcpy(old_dims, dataset->shared->curr_dims, H5S_MAX_RANK * sizeof(old_dims[0])); - - /* Increase the size of the dataspace */ - if((changed = H5S_extend(dataset->shared->space, size)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to increase size of dataspace") - - /* Updated the dataset's info if the dataspace was successfully extended */ - if(changed) { - /* Get the extended dimension sizes */ - /* (Need to retrieve this here, since the 'size' dimensions could - * extend one dimension but be smaller in a different dimension, - * and the dataspace's extent is the larger of the current and - * 'size' dimension values. - QAK) - */ - if(H5S_get_simple_extent_dims(dataset->shared->space, dataset->shared->curr_dims, NULL) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") - - /* Update the index values for the cached chunks for this dataset */ - if(H5D_CHUNKED == dataset->shared->layout.type) { - hbool_t update_chunks = FALSE; /* Flag to indicate chunk cache update is needed */ - - /* Check if we need to track & update scaled dimension information */ - if(dataset->shared->ndims > 1) { - unsigned u; /* Local indicate variable */ - - /* Update scaled chunk information */ - for(u = 0; u < dataset->shared->ndims; u++) { - hsize_t scaled; /* Scaled value */ - - /* Compute the scaled dimension size value */ - scaled = size[u] / dataset->shared->layout.u.chunk.dim[u]; - - /* Check if scaled dimension size changed */ - if(scaled != dataset->shared->cache.chunk.scaled_dims[u]) { - hsize_t scaled_power2up; /* New size value, rounded to next power of 2 */ - - /* Update the scaled dimension size value for the current dimension */ - dataset->shared->cache.chunk.scaled_dims[u] = scaled; - - /* Check if algorithm for computing hash values will change */ - if((scaled > dataset->shared->cache.chunk.nslots && - dataset->shared->cache.chunk.scaled_dims[u] <= dataset->shared->cache.chunk.nslots) - || (scaled <= dataset->shared->cache.chunk.nslots && - dataset->shared->cache.chunk.scaled_dims[u] > dataset->shared->cache.chunk.nslots)) - update_chunks = TRUE; - - /* Check if the number of bits required to encode the scaled size value changed */ - if(dataset->shared->cache.chunk.scaled_power2up[u] != (scaled_power2up = H5VM_power2up(scaled))) { - /* Update the 'power2up' & 'encode_bits' values for the current dimension */ - dataset->shared->cache.chunk.scaled_power2up[u] = scaled_power2up; - dataset->shared->cache.chunk.scaled_encode_bits[u] = H5VM_log2_gen(scaled_power2up); - - /* Indicate that the chunk cache indices should be updated */ - update_chunks = TRUE; - } /* end if */ - } /* end if */ - } /* end for */ - } /* end if */ - - /* Update general information for chunks */ - if(H5D__chunk_set_info(dataset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to update # of chunks") - - /* Check for updating chunk cache indices */ - if(update_chunks) { - /* Update the chunk cache indices */ - if(H5D__chunk_update_cache(dataset, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") - } /* end if */ - } /* end if */ - - /* Allocate space for the new parts of the dataset, if appropriate */ - fill = &dataset->shared->dcpl_cache.fill; - if(fill->alloc_time == H5D_ALLOC_TIME_EARLY) { - H5D_io_info_t io_info; - - io_info.dset = dataset; - io_info.raw_dxpl_id = H5AC_rawdata_dxpl_id; - io_info.md_dxpl_id = dxpl_id; - - if(H5D__alloc_storage(&io_info, H5D_ALLOC_EXTEND, FALSE, old_dims) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") - } - /* Mark the dataspace as dirty, for later writing to the file */ - if(H5D__mark(dataset, dxpl_id, H5D_MARK_SPACE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark dataspace as dirty") - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__extend() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ |