mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-30 16:10:44 +08:00
Merge pull request #2056 from gsjaardema/WIP-attribute-creation-order-tracking-option
Attribute creation order on/off
This commit is contained in:
commit
4086bbd887
@ -301,6 +301,7 @@ typedef struct NC_FILE_INFO
|
||||
int cmode; /**< Create mode used to create the file. */
|
||||
nc_bool_t parallel; /**< True if file is open for parallel access */
|
||||
nc_bool_t redef; /**< True if redefining an existing file */
|
||||
nc_bool_t no_attr_create_order; /**< True if the creation order tracking of attributes is disabled (netcdf-4 only) */
|
||||
int fill_mode; /**< Fill mode for vars - Unused internally currently */
|
||||
nc_bool_t no_write; /**< true if nc_open has mode NC_NOWRITE. */
|
||||
NC_GRP_INFO_T *root_grp; /**< Pointer to root group. */
|
||||
|
@ -161,6 +161,8 @@ Use this in mode flags for both nc_create() and nc_open(). */
|
||||
#define NC_PERSIST 0x4000 /**< Save diskless contents to disk. Mode flag for nc_open() or nc_create() */
|
||||
#define NC_INMEMORY 0x8000 /**< Read from memory. Mode flag for nc_open() or nc_create() */
|
||||
|
||||
#define NC_NOATTCREORD 0x20000 /**< Disable the netcdf-4 (hdf5) attribute creation order tracking */
|
||||
|
||||
#define NC_MAX_MAGIC_NUMBER_LEN 8 /**< Max len of user-defined format magic number. */
|
||||
|
||||
/** Format specifier for nc_set_default_format() and returned
|
||||
|
@ -192,10 +192,15 @@ nc4_create_file(const char *path, int cmode, size_t initialsz,
|
||||
if (H5Pset_link_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED |
|
||||
H5P_CRT_ORDER_INDEXED)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (H5Pset_attr_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED |
|
||||
H5P_CRT_ORDER_INDEXED)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
if (cmode & NC_NOATTCREORD) {
|
||||
nc4_info->no_attr_create_order = NC_TRUE;
|
||||
}
|
||||
else {
|
||||
if (H5Pset_attr_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED |
|
||||
H5P_CRT_ORDER_INDEXED)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
#ifdef HDF5_HAS_COLL_METADATA_OPS
|
||||
/* If HDF5 supports collective metadata operations, turn them
|
||||
* on. This is only relevant for parallel I/O builds of HDF5. */
|
||||
|
@ -756,6 +756,10 @@ nc4_open_file(const char *path, int mode, void* parameters, int ncid)
|
||||
if ((mode & NC_WRITE) == 0)
|
||||
nc4_info->no_write = NC_TRUE;
|
||||
|
||||
if ((mode & NC_WRITE) && (mode & NC_NOATTCREORD)) {
|
||||
nc4_info->no_attr_create_order = NC_TRUE;
|
||||
}
|
||||
|
||||
if(nc4_info->mem.inmemory && nc4_info->mem.diskless)
|
||||
BAIL(NC_EINTERNAL);
|
||||
|
||||
@ -900,6 +904,19 @@ nc4_open_file(const char *path, int mode, void* parameters, int ncid)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
|
||||
/* Get the file creation property list to check for attribute ordering */
|
||||
{
|
||||
hid_t pid;
|
||||
unsigned int crt_order_flags;
|
||||
if ((pid = H5Fget_create_plist(h5->hdfid)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (H5Pget_attr_creation_order(pid, &crt_order_flags) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (!(crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
|
||||
nc4_info->no_attr_create_order = NC_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now read in all the metadata. Some types and dimscale
|
||||
* information may be difficult to resolve here, if, for example, a
|
||||
* dataset of user-defined type is encountered before the
|
||||
|
@ -969,9 +969,11 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
|
||||
}
|
||||
|
||||
/* Turn on creation order tracking. */
|
||||
if (H5Pset_attr_creation_order(plistid, H5P_CRT_ORDER_TRACKED|
|
||||
H5P_CRT_ORDER_INDEXED) < 0)
|
||||
if (!grp->nc4_info->no_attr_create_order) {
|
||||
if (H5Pset_attr_creation_order(plistid, H5P_CRT_ORDER_TRACKED|
|
||||
H5P_CRT_ORDER_INDEXED) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
|
||||
/* Set per-var chunk cache, for chunked datasets. */
|
||||
if (var->storage == NC_CHUNKED && var->chunk_cache_size)
|
||||
@ -1336,8 +1338,10 @@ create_group(NC_GRP_INFO_T *grp)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
/* Tell HDF5 to keep track of attributes in creation order. */
|
||||
if (H5Pset_attr_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED|H5P_CRT_ORDER_INDEXED) < 0)
|
||||
if (!grp->nc4_info->no_attr_create_order) {
|
||||
if (H5Pset_attr_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED|H5P_CRT_ORDER_INDEXED) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
|
||||
/* Create the group. */
|
||||
if ((hdf5_grp->hdf_grpid = H5Gcreate2(parent_hdf5_grp->hdf_grpid, grp->hdr.name,
|
||||
@ -1761,10 +1765,11 @@ nc4_create_dim_wo_var(NC_DIM_INFO_T *dim)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
/* Turn on creation-order tracking. */
|
||||
if (H5Pset_attr_creation_order(create_propid, H5P_CRT_ORDER_TRACKED|
|
||||
H5P_CRT_ORDER_INDEXED) < 0)
|
||||
if (!dim->container->nc4_info->no_attr_create_order) {
|
||||
if (H5Pset_attr_creation_order(create_propid, H5P_CRT_ORDER_TRACKED|
|
||||
H5P_CRT_ORDER_INDEXED) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
}
|
||||
/* Create the dataset that will be the dimension scale. */
|
||||
LOG((4, "%s: about to H5Dcreate1 a dimscale dataset %s", __func__,
|
||||
dim->hdr.name));
|
||||
|
Loading…
Reference in New Issue
Block a user