From 8205a888cb60bfa0e62b632ca3f8a828248146f4 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 24 Nov 2010 10:56:09 -0500 Subject: [svn-r19840] Description: Check in Vailin's "implicit" chunk indexing code. Tested on: Mac OS X/32 10.6.5 (amazon) w/debug & production (further testing upcoming shortly) --- src/H5Dchunk.c | 76 ++-- src/H5Dint.c | 4 +- src/H5Dlayout.c | 64 +++- src/H5Dnone.c | 551 +++++++++++++++++++++++++++++ src/H5Dpkg.h | 5 +- src/H5Dpublic.h | 7 +- src/H5Olayout.c | 11 + src/H5Ostorage.c | 24 +- src/Makefile.am | 2 +- src/Makefile.in | 50 +-- test/dsets.c | 251 +++++++++++-- test/objcopy.c | 335 +++++++++++++++++- tools/h5diff/testfiles/h5diff_dset_idx1.h5 | Bin 5974 -> 5974 bytes tools/h5diff/testfiles/h5diff_dset_idx2.h5 | Bin 2206 -> 2206 bytes tools/h5stat/testfiles/h5stat_idx.h5 | Bin 2206 -> 2206 bytes tools/misc/h5debug.c | 2 +- tools/testfiles/tdset_idx.h5 | Bin 10562 -> 10562 bytes 17 files changed, 1258 insertions(+), 124 deletions(-) create mode 100644 src/H5Dnone.c diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index c0ce03d..17775bb 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -493,7 +493,9 @@ H5D_chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id) (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops)); + H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for fapl ID"); @@ -574,7 +576,9 @@ H5D_chunk_is_space_alloc(const H5O_storage_t *storage) (H5D_CHUNK_IDX_BT2 == storage->u.chunk.idx_type && H5D_COPS_BT2 == storage->u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == storage->u.chunk.idx_type && - H5D_COPS_BTREE == storage->u.chunk.ops)); + H5D_COPS_BTREE == storage->u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == storage->u.chunk.idx_type && + H5D_COPS_NONE == storage->u.chunk.ops)); /* Query index layer */ ret_value = (storage->u.chunk.ops->is_space_alloc)(&storage->u.chunk); @@ -2070,7 +2074,9 @@ H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) (H5D_CHUNK_IDX_BT2 == storage->idx_type && H5D_COPS_BT2 == storage->ops) || (H5D_CHUNK_IDX_BTREE == storage->idx_type && - H5D_COPS_BTREE == storage->ops)); + H5D_COPS_BTREE == storage->ops) || + (H5D_CHUNK_IDX_NONE == storage->idx_type && + H5D_COPS_NONE == storage->ops)); /* Reset index structures */ if((storage->ops->reset)(storage, reset_addr) < 0) @@ -2231,7 +2237,9 @@ H5D_chunk_create(H5D_t *dset /*in,out*/, hid_t dxpl_id) (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops)); + H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); #ifndef NDEBUG { unsigned u; /* Local index variable */ @@ -2290,7 +2298,9 @@ H5D_chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *chunk_offset, (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops)); + H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); HDassert(chunk_offset); HDassert(udata); @@ -2386,7 +2396,9 @@ H5D_chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t * (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops)); + H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); HDassert(dxpl_cache); HDassert(ent); HDassert(!ent->locked); @@ -3320,7 +3332,9 @@ H5D_chunk_allocated(H5D_t *dset, hid_t dxpl_id, hsize_t *nbytes) (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops)); + H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); /* Fill the DXPL cache values for later use */ if(H5D_get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) @@ -3421,7 +3435,9 @@ H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, (H5D_CHUNK_IDX_BT2 == layout->storage.u.chunk.idx_type && H5D_COPS_BT2 == layout->storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == layout->storage.u.chunk.idx_type && - H5D_COPS_BTREE == layout->storage.u.chunk.ops)); + H5D_COPS_BTREE == layout->storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == layout->storage.u.chunk.idx_type && + H5D_COPS_NONE == layout->storage.u.chunk.ops)); HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); /* Retrieve the dataset dimensions */ @@ -3637,7 +3653,8 @@ H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") - HDassert(!H5F_addr_defined(udata.addr)); + if(H5D_CHUNK_IDX_NONE != layout->storage.u.chunk.idx_type) + HDassert(!H5F_addr_defined(udata.addr)); } /* end block */ /* Make sure the chunk is really in the dataset and outside the @@ -3871,7 +3888,9 @@ H5D_chunk_update_old_edge_chunks(H5D_t *dset, hid_t dxpl_id, hsize_t old_dim[]) (H5D_CHUNK_IDX_BT2 == layout->storage.u.chunk.idx_type && H5D_COPS_BT2 == layout->storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == layout->storage.u.chunk.idx_type && - H5D_COPS_BTREE == layout->storage.u.chunk.ops)); + H5D_COPS_BTREE == layout->storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == layout->storage.u.chunk.idx_type && + H5D_COPS_NONE == layout->storage.u.chunk.ops)); HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); HDassert(pline->nused > 0); HDassert(layout->u.chunk.flags @@ -4291,7 +4310,9 @@ H5D_chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) (H5D_CHUNK_IDX_BT2 == layout->storage.u.chunk.idx_type && H5D_COPS_BT2 == layout->storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == layout->storage.u.chunk.idx_type && - H5D_COPS_BTREE == layout->storage.u.chunk.ops)); + H5D_COPS_BTREE == layout->storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == layout->storage.u.chunk.idx_type && + H5D_COPS_NONE == layout->storage.u.chunk.ops)); HDassert(dxpl_cache); /* Fill the DXPL cache values for later use */ @@ -4677,7 +4698,9 @@ H5D_chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops)); + H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); HDassert(chunk_addr); /* Set up user data for B-tree callback */ @@ -4741,7 +4764,9 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) (H5D_CHUNK_IDX_BT2 == storage->u.chunk.idx_type && H5D_COPS_BT2 == storage->u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == storage->u.chunk.idx_type && - H5D_COPS_BTREE == storage->u.chunk.ops)); + H5D_COPS_BTREE == storage->u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == storage->u.chunk.idx_type && + H5D_COPS_NONE == storage->u.chunk.ops)); /* Check for I/O pipeline message */ if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) @@ -5129,7 +5154,9 @@ H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, (H5D_CHUNK_IDX_BT2 == storage_src->idx_type && H5D_COPS_BT2 == storage_src->ops) || (H5D_CHUNK_IDX_BTREE == storage_src->idx_type && - H5D_COPS_BTREE == storage_src->ops)); + H5D_COPS_BTREE == storage_src->ops) || + (H5D_CHUNK_IDX_NONE == storage_src->idx_type && + H5D_COPS_NONE == storage_src->ops)); HDassert(layout_src); HDassert(f_dst); HDassert(storage_dst); @@ -5140,7 +5167,9 @@ H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, (H5D_CHUNK_IDX_BT2 == storage_dst->idx_type && H5D_COPS_BT2 == storage_dst->ops) || (H5D_CHUNK_IDX_BTREE == storage_dst->idx_type && - H5D_COPS_BTREE == storage_dst->ops)); + H5D_COPS_BTREE == storage_dst->ops) || + (H5D_CHUNK_IDX_NONE == storage_dst->idx_type && + H5D_COPS_NONE == storage_dst->ops)); HDassert(ds_extent_src); HDassert(dt_src); @@ -5344,7 +5373,7 @@ done: /* Clean up any index information */ if(copy_setup_done) - if((storage_src->ops->copy_shutdown)(storage_src, storage_dst, dxpl_id) < 0) + if(storage_src->ops->copy_shutdown && (storage_src->ops->copy_shutdown)(storage_src, storage_dst, dxpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to shut down index copying info") FUNC_LEAVE_NOAPI(ret_value) @@ -5383,7 +5412,9 @@ H5D_chunk_bh_info(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout, (H5D_CHUNK_IDX_BT2 == layout->storage.u.chunk.idx_type && H5D_COPS_BT2 == layout->storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == layout->storage.u.chunk.idx_type && - H5D_COPS_BTREE == layout->storage.u.chunk.ops)); + H5D_COPS_BTREE == layout->storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == layout->storage.u.chunk.idx_type && + H5D_COPS_NONE == layout->storage.u.chunk.ops)); HDassert(pline); HDassert(index_size); @@ -5479,7 +5510,9 @@ H5D_chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream) (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops)); + H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); /* Only display info if stream is defined */ if(stream) { @@ -5547,7 +5580,9 @@ H5D_chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset) (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops)); + H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); /* Fill the DXPL cache values for later use */ if(H5D_get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) @@ -5577,7 +5612,8 @@ H5D_chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset) idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Free any index structures */ - if((dset->shared->layout.storage.u.chunk.ops->dest)(&idx_info) < 0) + if(dset->shared->layout.storage.u.chunk.ops->dest && + (dset->shared->layout.storage.u.chunk.ops->dest)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") done: diff --git a/src/H5Dint.c b/src/H5Dint.c index 2b2715b..3120b86 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1127,12 +1127,12 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of fill value") /* Set the latest version for the layout message */ - if(H5D_layout_set_latest_version(&new_dset->shared->layout, new_dset->shared->space) < 0) + if(H5D_layout_set_latest_version(&new_dset->shared->layout, new_dset->shared->space, &new_dset->shared->dcpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of layout") } /* end if */ else if(new_dset->shared->layout.version >= H5O_LAYOUT_VERSION_4) { /* Use latest indexing type for layout message version >= 4 */ - if(H5D_layout_set_latest_indexing(&new_dset->shared->layout, new_dset->shared->space) < 0) + if(H5D_layout_set_latest_indexing(&new_dset->shared->layout, new_dset->shared->space, &new_dset->shared->dcpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest indexing") } /* end if */ diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 2c222a9..10fc9c9 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -101,6 +101,10 @@ H5D_layout_set_io_ops(const H5D_t *dataset) dataset->shared->layout.storage.u.chunk.ops = H5D_COPS_BTREE; break; + case H5D_CHUNK_IDX_NONE: + dataset->shared->layout.storage.u.chunk.ops = H5D_COPS_NONE; + break; + case H5D_CHUNK_IDX_FARRAY: dataset->shared->layout.storage.u.chunk.ops = H5D_COPS_FARRAY; break; @@ -213,6 +217,10 @@ H5D_layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include ret_value++; switch(layout->u.chunk.idx_type) { + case H5D_CHUNK_IDX_NONE: + /* nothing */ + break; + case H5D_CHUNK_IDX_FARRAY: /* Fixed array creation parameters */ ret_value += H5D_FARRAY_CREATE_PARAM_SIZE; @@ -260,7 +268,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_layout_set_latest_version(H5O_layout_t *layout, const H5S_t *space) +H5D_layout_set_latest_version(H5O_layout_t *layout, const H5S_t *space, + const H5D_dcpl_cache_t *dcpl_cache) { herr_t ret_value = SUCCEED; /* Return value */ @@ -268,12 +277,14 @@ H5D_layout_set_latest_version(H5O_layout_t *layout, const H5S_t *space) /* Sanity check */ HDassert(layout); + HDassert(space); + HDassert(dcpl_cache); /* Set encoding of layout to latest version */ layout->version = H5O_LAYOUT_VERSION_LATEST; /* Set the latest indexing type for the layout message */ - if(H5D_layout_set_latest_indexing(layout, space) < 0) + if(H5D_layout_set_latest_indexing(layout, space, dcpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest indexing type") done: @@ -295,7 +306,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space) +H5D_layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, + const H5D_dcpl_cache_t *dcpl_cache) { int sndims; /* Rank of dataspace */ unsigned ndims; /* Rank of dataspace */ @@ -305,6 +317,8 @@ H5D_layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space) /* Sanity check */ HDassert(layout); + HDassert(space); + HDassert(dcpl_cache); /* Query the dimensionality of the dataspace */ if((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0) @@ -347,7 +361,8 @@ H5D_layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space) layout->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs = H5D_EARRAY_SUP_BLK_MIN_DATA_PTRS; layout->u.chunk.u.earray.cparam.data_blk_min_elmts = H5D_EARRAY_DATA_BLK_MIN_ELMTS; layout->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits = H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS; - } else { /* Chunked dataset with > 1 unlimited dimensions */ + } /* end if */ + else { /* Chunked dataset with > 1 unlimited dimensions */ /* Set the chunk index type to v2 B-tree */ layout->u.chunk.idx_type = H5D_CHUNK_IDX_BT2; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BT2; @@ -357,20 +372,33 @@ H5D_layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space) layout->u.chunk.u.btree2.cparam.node_size = H5D_BT2_NODE_SIZE; layout->u.chunk.u.btree2.cparam.split_percent = H5D_BT2_SPLIT_PERC; layout->u.chunk.u.btree2.cparam.merge_percent = H5D_BT2_MERGE_PERC; - } - } else if(layout->type == H5D_CHUNKED) { - /* Chunked dataset with fixed dimensions (with or without max. dimension setting) */ - /* Set the chunk index type to Fixed Array */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; - layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; - layout->storage.u.chunk.ops = H5D_COPS_FARRAY; - - /* Set the fixed array creation parameters */ - /* (use hard-coded defaults for now, until we give applications - * control over this with a property list - QAK) - */ - layout->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS; - } /* end if */ + } /* end else */ + } /* end if */ + else + /* Chunked dataset with fixed dimensions */ + if(layout->type == H5D_CHUNKED) { + /* Check for correct condition for using "implicit" chunk index */ + if(!dcpl_cache->pline.nused && + dcpl_cache->fill.alloc_time == H5D_ALLOC_TIME_EARLY) { + + /* Set the chunk index type to Non Index */ + layout->u.chunk.idx_type = H5D_CHUNK_IDX_NONE; + layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_NONE; + layout->storage.u.chunk.ops = H5D_COPS_NONE; + } /* end if */ + else { /* Used Fixed Array */ + /* Set the chunk index type to Fixed Array */ + layout->u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; + layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; + layout->storage.u.chunk.ops = H5D_COPS_FARRAY; + + /* Set the fixed array creation parameters */ + /* (use hard-coded defaults for now, until we give applications + * control over this with a property list - QAK) + */ + layout->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS; + } /* end else */ + } /* end if */ } /* end if */ done: diff --git a/src/H5Dnone.c b/src/H5Dnone.c new file mode 100644 index 0000000..723ab45 --- /dev/null +++ b/src/H5Dnone.c @@ -0,0 +1,551 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Programmer: Vailin Choi + * September 2010 + * + * Purpose: Non Index chunked I/O functions. + * This is used when the dataset is: + * extendible but with fixed max. dims + * with early allocation + * without filter + * The chunk coordinate is mapped into the actual disk addresses + * for the chunk without indexing. + * + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5D_PACKAGE /*suppress error about including H5Dpkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5Vprivate.h" /* Vector functions */ + + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Non Index chunking I/O ops */ +static herr_t H5D_none_create(const H5D_chk_idx_info_t *idx_info); +static hbool_t H5D_none_is_space_alloc(const H5O_storage_chunk_t *storage); +static herr_t H5D_none_insert(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_ud_t *udata); +static herr_t H5D_none_get_addr(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_ud_t *udata); +static int H5D_none_iterate(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); +static herr_t H5D_none_remove(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_common_ud_t *udata); +static herr_t H5D_none_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D_none_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D_none_size(const H5D_chk_idx_info_t *idx_info, + hsize_t *size); +static herr_t H5D_none_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D_none_dump(const H5O_storage_chunk_t *storage, FILE *stream); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Non Index chunk I/O ops */ +const H5D_chunk_ops_t H5D_COPS_NONE[1] = {{ + FALSE, /* Non-indexed chunking don't current support SWMR access */ + NULL, /* init */ + H5D_none_create, /* create */ + H5D_none_is_space_alloc, /* is_space_alloc */ + H5D_none_insert, /* insert */ + H5D_none_get_addr, /* get_addr */ + NULL, /* resize */ + H5D_none_iterate, /* iterate */ + H5D_none_remove, /* remove */ + H5D_none_delete, /* delete */ + H5D_none_copy_setup, /* copy_setup */ + NULL, /* copy_shutdown */ + H5D_none_size, /* size */ + H5D_none_reset, /* reset */ + NULL, /* support */ + NULL, /* unsupport */ + H5D_none_dump, /* dump */ + NULL /* dest */ +}}; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_create + * + * Purpose: Allocate memory for the maximum # of chunks in the dataset. + * + * Return: Non-negative on success + * Negative on failure. + * + * Programmer: Vailin Choi; September 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_none_create(const H5D_chk_idx_info_t *idx_info) +{ + hsize_t nbytes; /* Total size of dataset chunks */ + haddr_t addr; /* The address of dataset chunks */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5D_none_create) + + /* Check args */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->pline->nused == 0); /* Shouldn't have filter defined on entering here */ + HDassert(idx_info->layout); + HDassert(idx_info->storage); + HDassert(idx_info->layout->max_nchunks); + HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); /* address of data shouldn't be defined */ + + /* Calculate size of max dataset chunks */ + nbytes = idx_info->layout->max_nchunks * idx_info->layout->size; + + /* Allocate space for max dataset chunks */ + addr = H5MF_alloc(idx_info->f, H5FD_MEM_DRAW, idx_info->dxpl_id, nbytes); + if(!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "file allocation failed") + + /* This is the address of the dataset chunks */ + idx_info->storage->idx_addr = addr; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_none_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_is_space_alloc + * + * Purpose: Query if space for the dataset chunks is allocated + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; September 2010 + * + *------------------------------------------------------------------------- + */ +static hbool_t +H5D_none_is_space_alloc(const H5O_storage_chunk_t *storage) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_none_is_space_alloc) + + /* Check args */ + HDassert(storage); + + FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) +} /* end H5D_none_is_space_alloc() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_insert + * + * Purpose: Calculate the address of the chunk + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Sept 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_none_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) +{ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5D_none_insert) + + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->pline->nused == 0); + HDassert(idx_info->layout); + HDassert(idx_info->storage); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); + HDassert(udata); + + /* Calculate the index of this chunk */ + if(H5V_chunk_index((idx_info->layout->ndims - 1), udata->common.offset, idx_info->layout->dim, idx_info->layout->max_down_chunks, &idx) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") + + HDassert(!H5F_addr_defined(udata->addr)); + HDassert(udata->nbytes == idx_info->layout->size); + + /* Storage is already allocated, just calculate the file address of the chunk */ + H5_CHECK_OVERFLOW(udata->nbytes, /*From: */uint32_t, /*To: */hsize_t); + udata->addr = idx_info->storage->idx_addr + idx * udata->nbytes; + + HDassert(H5F_addr_defined(udata->addr)); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5D_none_insert() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_get_addr + * + * Purpose: Get the file address of a chunk. + * Save the retrieved information in the udata supplied. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Sept 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_none_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) +{ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5D_none_get_addr) + + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->pline->nused == 0); + HDassert(idx_info->layout); + HDassert(idx_info->storage); + HDassert(udata); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); + + /* Calculate the index of this chunk */ + if(H5V_chunk_index((idx_info->layout->ndims - 1), udata->common.offset, idx_info->layout->dim, idx_info->layout->max_down_chunks, &idx) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") + + /* Calculate the address of the chunk */ + udata->addr = idx_info->storage->idx_addr + idx * idx_info->layout->size; + + /* Update the other (constant) information for the chunk */ + udata->nbytes = idx_info->layout->size; + udata->filter_mask = 0; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5D_none_get_addr() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_iterate + * + * Purpose: Iterate over the chunks in an index, making a callback + * for each one. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; September 2010 + * + *------------------------------------------------------------------------- + */ +static int +H5D_none_iterate(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +{ + H5D_chunk_rec_t chunk_rec; /* generic chunk record */ + hsize_t chunk_offset[H5O_LAYOUT_NDIMS]; /* Offset for the chunk */ + unsigned ndims; /* Rank of chunk */ + unsigned u; /* Local index variable */ + int curr_dim; /* Current rank */ + hsize_t idx; /* Array index of chunk */ + int ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5D_none_iterate) + + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(!idx_info->pline->nused); + HDassert(idx_info->layout); + HDassert(idx_info->storage); + HDassert(chunk_cb); + HDassert(chunk_udata); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); + + /* Initialize generic chunk record */ + HDmemset(&chunk_rec, 0, sizeof(chunk_rec)); + chunk_rec.nbytes = idx_info->layout->size; + chunk_rec.filter_mask = 0; + + HDmemset(&chunk_offset, 0, sizeof(chunk_offset)); + + ndims = idx_info->layout->ndims - 1; + HDassert(ndims > 0); + + /* Iterate over all the chunks in the dataset's dataspace */ + for(u = 0; u < idx_info->layout->nchunks; u++) { + /* Calculate the index of this chunk */ + if(H5V_chunk_index(ndims, chunk_rec.offset, idx_info->layout->dim, idx_info->layout->max_down_chunks, &idx) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") + + /* Calculate the address of the chunk */ + chunk_rec.chunk_addr = idx_info->storage->idx_addr + idx * idx_info->layout->size; + + /* Make "generic chunk" callback */ + if((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) + HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); + + /* Update coordinates of chunk in dataset */ + curr_dim = (int)(ndims - 1); + while(curr_dim >= 0) { + /* Increment coordinate in current dimension */ + chunk_offset[curr_dim]++; + chunk_rec.offset[curr_dim] += idx_info->layout->dim[curr_dim]; + + /* Check if we went off the end of the current dimension */ + if(chunk_offset[curr_dim] >= idx_info->layout->chunks[curr_dim]) { + /* Reset coordinate & move to next faster dimension */ + chunk_offset[curr_dim] = 0; + chunk_rec.offset[curr_dim] = 0; + curr_dim--; + } /* end if */ + else + break; + } /* end while */ + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_none_iterate() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_remove + * + * Purpose: Remove chunk from index. + * + * Note: Chunks can't be removed (or added) to datasets with this + * form of index - all the space for all the chunks is always + * allocated in the file. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Sept 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_none_remove(const H5D_chk_idx_info_t UNUSED *idx_info, H5D_chunk_common_ud_t UNUSED *udata) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_none_remove) + + /* NO OP */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5D_none_remove() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_delete + * + * Purpose: Delete raw data storage for entire dataset (i.e. all chunks) + * + * Return: Success: Non-negative + * Failure: negative + * + * Programmer: Vailin Choi; Sept 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_none_delete(const H5D_chk_idx_info_t *idx_info) +{ + hsize_t nbytes; /* Size of all chunks */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5D_none_delete) + + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(!idx_info->pline->nused); /* Shouldn't have filter defined on entering here */ + HDassert(idx_info->layout); + HDassert(idx_info->storage); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); /* should be defined */ + + /* chunk size * max # of chunks */ + nbytes = idx_info->layout->max_nchunks * idx_info->layout->size; + if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->dxpl_id, idx_info->storage->idx_addr, nbytes) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free dataset chunks") + + idx_info->storage->idx_addr = HADDR_UNDEF; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_none_delete() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_copy_setup + * + * Purpose: Set up any necessary information for copying chunks + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Sept 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_none_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5D_none_copy_setup) + + /* Check args */ + HDassert(idx_info_src); + HDassert(idx_info_src->f); + HDassert(idx_info_src->pline); + HDassert(!idx_info_src->pline->nused); + HDassert(idx_info_src->layout); + HDassert(idx_info_src->storage); + HDassert(H5F_addr_defined(idx_info_src->storage->idx_addr)); + + HDassert(idx_info_dst); + HDassert(idx_info_dst->f); + HDassert(idx_info_dst->pline); + HDassert(!idx_info_dst->pline->nused); + HDassert(idx_info_dst->layout); + HDassert(idx_info_dst->storage); + + /* Set copied metadata tag */ + H5_BEGIN_TAG(idx_info_dst->dxpl_id, H5AC__COPIED_TAG, FAIL); + + /* Allocate dataset chunks in the dest. file */ + if(H5D_none_create(idx_info_dst) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") + + /* Reset metadata tag */ + H5_END_TAG(FAIL); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_none_copy_setup() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_size + * + * Purpose: Retrieve the amount of index storage for chunked dataset + * + * Return: Success: Non-negative + * Failure: negative + * + * Programmer: Vailin Choi; Sept 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_none_size(const H5D_chk_idx_info_t UNUSED *idx_info, hsize_t *index_size) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_none_size) + + /* Check args */ + HDassert(index_size); + + *index_size = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D_none_size() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_reset + * + * Purpose: Reset indexing information. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Sept 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_none_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_none_reset) + + /* Check args */ + HDassert(storage); + + /* Reset index info */ + if(reset_addr) + storage->idx_addr = HADDR_UNDEF; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D_none_reset() */ + + +/*------------------------------------------------------------------------- + * Function: H5D_none_dump + * + * Purpose: Dump + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; September 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_none_dump(const H5O_storage_chunk_t *storage, FILE *stream) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_none_dump) + + /* Check args */ + HDassert(storage); + HDassert(stream); + + HDfprintf(stream, " Address: %a\n", storage->idx_addr); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D_none_dump() */ + diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 673dac3..5dc728f 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -564,6 +564,7 @@ H5_DLLVAR const H5D_layout_ops_t H5D_LOPS_CHUNK[1]; /* Chunked layout operations */ H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_BTREE[1]; +H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_NONE[1]; H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_EARRAY[1]; H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_FARRAY[1]; H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_BT2[1]; @@ -623,9 +624,9 @@ H5_DLL herr_t H5D_layout_set_io_ops(const H5D_t *dataset); H5_DLL size_t H5D_layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data); H5_DLL herr_t H5D_layout_set_latest_version(H5O_layout_t *layout, - const H5S_t *space); + const H5S_t *space, const H5D_dcpl_cache_t *dcpl_cache); H5_DLL herr_t H5D_layout_set_latest_indexing(H5O_layout_t *layout, - const H5S_t *space); + const H5S_t *space, const H5D_dcpl_cache_t *dcpl_cache); H5_DLL herr_t H5D_layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset, hid_t dapl_id); H5_DLL herr_t H5D_layout_oh_read(H5D_t *dset, hid_t dxpl_id, hid_t dapl_id, diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 900046a..a96755a 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -54,9 +54,10 @@ typedef enum H5D_layout_t { /* Types of chunk index data structures */ typedef enum H5D_chunk_index_t { H5D_CHUNK_IDX_BTREE = 0, /* v1 B-tree index (default) */ - H5D_CHUNK_IDX_FARRAY = 1, /* Fixed array (for 0 unlimited dims) */ - H5D_CHUNK_IDX_EARRAY = 2, /* Extensible array (for 1 unlimited dim) */ - H5D_CHUNK_IDX_BT2 = 3, /* v2 B-tree index (for >1 unlimited dims) */ + H5D_CHUNK_IDX_NONE = 1, /* No Index (H5D_ALLOC_TIME_EARLY, non-filtered, fixed dims) */ + H5D_CHUNK_IDX_FARRAY = 2, /* Fixed array (for 0 unlimited dims) */ + H5D_CHUNK_IDX_EARRAY = 3, /* Extensible array (for 1 unlimited dim) */ + H5D_CHUNK_IDX_BT2 = 4, /* v2 B-tree index (for >1 unlimited dims) */ H5D_CHUNK_IDX_NTYPES /*this one must be last! */ } H5D_chunk_index_t; diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 32a9809..aec3c0a 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -306,6 +306,9 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, mesg->storage.u.chunk.idx_type = mesg->u.chunk.idx_type; switch(mesg->u.chunk.idx_type) { + case H5D_CHUNK_IDX_NONE: /* Non Index */ + break; + case H5D_CHUNK_IDX_FARRAY: /* Fixed array creation parameters */ mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = *p++; @@ -482,6 +485,9 @@ H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi *p++ = (uint8_t)mesg->u.chunk.idx_type; switch(mesg->u.chunk.idx_type) { + case H5D_CHUNK_IDX_NONE: /* Non Index */ + break; + case H5D_CHUNK_IDX_FARRAY: /* Fixed array creation parameters */ *p++ = mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits; @@ -931,6 +937,11 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, "Index Type:", "v1 B-tree"); break; + case H5D_CHUNK_IDX_NONE: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index Type:", "None"); + break; + case H5D_CHUNK_IDX_FARRAY: HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Fixed Array"); diff --git a/src/H5Ostorage.c b/src/H5Ostorage.c index 38de1c4..41b16bc 100644 --- a/src/H5Ostorage.c +++ b/src/H5Ostorage.c @@ -170,9 +170,14 @@ H5O_storage_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, /* Check for chunk index */ if(flags & H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX) { - /* Chunk index type */ - mesg->u.chunk.idx_type = (H5D_chunk_index_t)*p++; + /* Chunk index type */ + mesg->u.chunk.idx_type = (H5D_chunk_index_t)*p++; switch(mesg->u.chunk.idx_type) { + case H5D_CHUNK_IDX_NONE: + /* Set the chunk operations */ + mesg->u.chunk.ops = H5D_COPS_NONE; + break; + case H5D_CHUNK_IDX_FARRAY: /* Set the chunk operations */ mesg->u.chunk.ops = H5D_COPS_FARRAY; @@ -272,11 +277,11 @@ H5O_storage_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, case H5D_CHUNKED: { - /* Chunk feature flags */ - *p++ = (uint8_t)H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX; + /* Chunk feature flags */ + *p++ = (uint8_t)H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX; - /* Chunk index type */ - *p++ = (uint8_t)mesg->u.chunk.idx_type; + /* Chunk index type */ + *p++ = (uint8_t)mesg->u.chunk.idx_type; /* Chunk index address */ H5F_addr_encode(f, &p, mesg->u.chunk.idx_addr); @@ -634,6 +639,11 @@ H5O_storage_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, "Index Type:", "v1 B-tree"); break; + case H5D_CHUNK_IDX_NONE: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index Type:", "None"); + break; + case H5D_CHUNK_IDX_FARRAY: HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Fixed Array"); @@ -730,7 +740,7 @@ H5O_storage_meta_size(const H5F_t *f, const H5O_storage_t *storage, case H5D_CHUNKED: ret_value += 1 + /* Chunk feature flags */ 1; /* Chunk index type */ - ret_value += H5F_SIZEOF_ADDR(f); /* Chunk index address */ + ret_value += H5F_SIZEOF_ADDR(f); /* Chunk index address or data address */ break; default: diff --git a/src/Makefile.am b/src/Makefile.am index b55c6eb..b6acdd6 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,7 +48,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5C.c H5CS.c \ H5D.c H5Dbtree.c H5Dbtree2.c H5Dchunk.c H5Dcompact.c H5Dcontig.c H5Ddbg.c \ H5Ddeprec.c H5Dearray.c H5Defl.c H5Dfarray.c H5Dfill.c H5Dint.c \ - H5Dio.c H5Dlayout.c H5Dmpio.c H5Doh.c H5Dproxy.c H5Dscatgath.c \ + H5Dio.c H5Dlayout.c H5Dmpio.c H5Dnone.c H5Doh.c H5Dproxy.c H5Dscatgath.c \ H5Dselect.c H5Dtest.c \ H5E.c H5Edeprec.c H5Eint.c \ H5EA.c H5EAcache.c H5EAdbg.c H5EAdblkpage.c H5EAdblock.c H5EAhdr.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 74f5927..1c757d3 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -104,29 +104,30 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Dcontig.lo H5Ddbg.lo H5Ddeprec.lo H5Dearray.lo H5Defl.lo \ H5Dfarray.lo H5Dfill.lo H5Dint.lo H5Dio.lo H5Dlayout.lo \ H5Dmpio.lo H5Doh.lo H5Dproxy.lo H5Dscatgath.lo H5Dselect.lo \ - H5Dtest.lo H5E.lo H5Edeprec.lo H5Eint.lo H5EA.lo H5EAcache.lo \ - H5EAdbg.lo H5EAdblkpage.lo H5EAdblock.lo H5EAhdr.lo \ - H5EAiblock.lo H5EAint.lo H5EAsblock.lo H5EAstat.lo H5EAtest.lo \ - H5F.lo H5Faccum.lo H5Fdbg.lo H5Fdeprec.lo H5Ffake.lo H5Fio.lo \ - H5Fmount.lo H5Fmpi.lo H5Fquery.lo H5Fsfile.lo H5Fsuper.lo \ - H5Fsuper_cache.lo H5Ftest.lo H5FA.lo H5FAcache.lo H5FAdbg.lo \ - H5FAdblock.lo H5FAdblkpage.lo H5FAhdr.lo H5FAstat.lo \ - H5FAtest.lo H5FD.lo H5FDcore.lo H5FDdirect.lo H5FDfamily.lo \ - H5FDint.lo H5FDlog.lo H5FDmpi.lo H5FDmpio.lo H5FDmpiposix.lo \ - H5FDmulti.lo H5FDsec2.lo H5FDspace.lo H5FDstdio.lo H5FL.lo \ - H5FO.lo H5FS.lo H5FScache.lo H5FSdbg.lo H5FSsection.lo \ - H5FSstat.lo H5FStest.lo H5G.lo H5Gbtree2.lo H5Gcache.lo \ - H5Gcompact.lo H5Gdense.lo H5Gdeprec.lo H5Gent.lo H5Gint.lo \ - H5Glink.lo H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo \ - H5Groot.lo H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HF.lo \ - H5HFbtree2.lo H5HFcache.lo H5HFdbg.lo H5HFdblock.lo \ - H5HFdtable.lo H5HFhdr.lo H5HFhuge.lo H5HFiblock.lo H5HFiter.lo \ - H5HFman.lo H5HFsection.lo H5HFspace.lo H5HFstat.lo H5HFtest.lo \ - H5HFtiny.lo H5HG.lo H5HGcache.lo H5HGdbg.lo H5HL.lo \ - H5HLcache.lo H5HLdbg.lo H5HLint.lo H5HP.lo H5I.lo H5Itest.lo \ - H5L.lo H5Lexternal.lo H5lib_settings.lo H5MF.lo H5MFaggr.lo \ - H5MFdbg.lo H5MFsection.lo H5MM.lo H5MP.lo H5MPtest.lo H5O.lo \ - H5Oainfo.lo H5Oalloc.lo H5Oattr.lo H5Oattribute.lo H5Obogus.lo \ + H5Dtest.lo H5Dnone.lo H5E.lo H5Edeprec.lo H5Eint.lo H5EA.lo \ + H5EAcache.lo H5EAdbg.lo H5EAdblkpage.lo H5EAdblock.lo \ + H5EAhdr.lo H5EAiblock.lo H5EAint.lo H5EAsblock.lo H5EAstat.lo \ + H5EAtest.lo H5F.lo H5Faccum.lo H5Fdbg.lo H5Fdeprec.lo \ + H5Ffake.lo H5Fio.lo H5Fmount.lo H5Fmpi.lo H5Fquery.lo \ + H5Fsfile.lo H5Fsuper.lo H5Fsuper_cache.lo H5Ftest.lo H5FA.lo \ + H5FAcache.lo H5FAdbg.lo H5FAdblock.lo H5FAdblkpage.lo \ + H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5FD.lo H5FDcore.lo \ + H5FDdirect.lo H5FDfamily.lo H5FDint.lo H5FDlog.lo H5FDmpi.lo \ + H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo H5FDsec2.lo \ + H5FDspace.lo H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo H5FScache.lo \ + H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo H5G.lo \ + H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \ + H5Gdeprec.lo H5Gent.lo H5Gint.lo H5Glink.lo H5Gloc.lo \ + H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo H5Groot.lo H5Gstab.lo \ + H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFbtree2.lo H5HFcache.lo \ + H5HFdbg.lo H5HFdblock.lo H5HFdtable.lo H5HFhdr.lo H5HFhuge.lo \ + H5HFiblock.lo H5HFiter.lo H5HFman.lo H5HFsection.lo \ + H5HFspace.lo H5HFstat.lo H5HFtest.lo H5HFtiny.lo H5HG.lo \ + H5HGcache.lo H5HGdbg.lo H5HL.lo H5HLcache.lo H5HLdbg.lo \ + H5HLint.lo H5HP.lo H5I.lo H5Itest.lo H5L.lo H5Lexternal.lo \ + H5lib_settings.lo H5MF.lo H5MFaggr.lo H5MFdbg.lo \ + H5MFsection.lo H5MM.lo H5MP.lo H5MPtest.lo H5O.lo H5Oainfo.lo \ + H5Oalloc.lo H5Oattr.lo H5Oattribute.lo H5Obogus.lo \ H5Obtreek.lo H5Ocache.lo H5Ochunk.lo H5Ocont.lo H5Ocopy.lo \ H5Odbg.lo H5Odrvinfo.lo H5Odtype.lo H5Oefl.lo H5Ofill.lo \ H5Oflush.lo H5Ofsinfo.lo H5Oginfo.lo H5Olayout.lo H5Olinfo.lo \ @@ -481,7 +482,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5D.c H5Dbtree.c H5Dbtree2.c H5Dchunk.c H5Dcompact.c H5Dcontig.c H5Ddbg.c \ H5Ddeprec.c H5Dearray.c H5Defl.c H5Dfarray.c H5Dfill.c H5Dint.c \ H5Dio.c H5Dlayout.c H5Dmpio.c H5Doh.c H5Dproxy.c H5Dscatgath.c \ - H5Dselect.c H5Dtest.c \ + H5Dselect.c H5Dtest.c H5Dnone.c \ H5E.c H5Edeprec.c H5Eint.c \ H5EA.c H5EAcache.c H5EAdbg.c H5EAdblkpage.c H5EAdblock.c H5EAhdr.c \ H5EAiblock.c H5EAint.c H5EAsblock.c H5EAstat.c H5EAtest.c \ @@ -718,6 +719,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dlayout.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dmpio.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dnone.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Doh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dproxy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dscatgath.Plo@am__quote@ diff --git a/test/dsets.c b/test/dsets.c index de4443e..74abdb5 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -6338,8 +6338,8 @@ test_zero_dims(hid_t file) { hid_t s = -1, d = -1, dcpl = -1; hid_t s2 = -1, d2 = -1, dcpl2 = -1; - hsize_t dsize = 0, dmax = H5S_UNLIMITED, csize = 5; - hsize_t dsize2[2] = {0, 0}; + hsize_t dzero = 0, dmax = H5S_UNLIMITED, csize = 5; + hsize_t dzero2[2] = {0, 0}; hsize_t dmax2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; hsize_t csize2[2] = {5, 5}; hid_t fapl; /* File access property list */ @@ -6358,7 +6358,7 @@ test_zero_dims(hid_t file) /* * One-dimensional dataset */ - if((s = H5Screate_simple(1, &dsize, &dmax)) < 0) FAIL_STACK_ERROR + if((s = H5Screate_simple(1, &dzero, &dmax)) < 0) FAIL_STACK_ERROR /* Try creating chunked dataset with undefined chunk dimensions */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR @@ -6374,7 +6374,7 @@ test_zero_dims(hid_t file) /* Try creating chunked dataset with zero-sized chunk dimensions */ H5E_BEGIN_TRY { - ret = H5Pset_chunk(dcpl, 1, &dsize); + ret = H5Pset_chunk(dcpl, 1, &dzero); } H5E_END_TRY; if(ret > 0) FAIL_PUTS_ERROR("set zero-sized chunk dimensions") @@ -6406,7 +6406,7 @@ test_zero_dims(hid_t file) /* * Two-dimensional dataset */ - if((s2 = H5Screate_simple(2, dsize2, dmax2)) < 0) FAIL_STACK_ERROR + if((s2 = H5Screate_simple(2, dzero2, dmax2)) < 0) FAIL_STACK_ERROR /* Try creating chunked dataset with undefined chunk dimensions */ if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR @@ -6422,7 +6422,7 @@ test_zero_dims(hid_t file) /* Try creating chunked dataset with zero-sized chunk dimensions */ H5E_BEGIN_TRY { - ret = H5Pset_chunk(dcpl2, 2, dsize2); + ret = H5Pset_chunk(dcpl2, 2, dzero2); } H5E_END_TRY; if(ret > 0) FAIL_PUTS_ERROR("set zero-sized chunk dimensions") @@ -6488,8 +6488,9 @@ error: static herr_t test_missing_chunk(hid_t file) { - hid_t d = -1, did2 = -1, dcpl=-1, dcpl2 = -1; /* Dataset & dataset creation property IDs */ - hid_t s = -1, sid2 = -1; /* Dataspace ID */ + hid_t d = -1, did2 = -1; /* Dataset IDs */ + hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property IDs */ + hid_t s = -1, sid2 = -1; /* Dataspace ID */ hsize_t hs_start[1], hs_stride[1], hs_count[1], hs_block[1]; /* Hyperslab setting */ hsize_t hs_start2[2], hs_stride2[2], hs_count2[2], hs_block2[2];/* Hyperslab setting */ @@ -6657,11 +6658,9 @@ error: /*------------------------------------------------------------------------- - * Function: test_random_chunks + * Function: test_random_chunks_real * - * Purpose: Tests that write/read on randomly selected chunks in 2 datasets. - * One dataset has fixed dimensions, and the other has unlimited - * dimensions which are extended before write/read operations. + * Purpose: Tests that write/read on randomly selected chunks * * * Return: Success: 0 @@ -6673,7 +6672,7 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_random_chunks(hid_t fapl) +test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) { char filename[FILENAME_BUF_SIZE]; hid_t s=-1, m=-1, d=-1, dcpl=-1, file=-1; @@ -6682,6 +6681,7 @@ test_random_chunks(hid_t fapl) check2[20][20]; hsize_t coord[NPOINTS][2]; hsize_t dsize[2]={100,100}, dmax[2]={H5S_UNLIMITED, H5S_UNLIMITED}, csize[2]={10,10}, nsize[2]={200,200}; + hsize_t fixed_dmax[2] = {1000, 1000}; hsize_t msize[1]={NPOINTS}; const char dname[]="dataset"; int chunk_row, chunk_col; @@ -6690,12 +6690,14 @@ test_random_chunks(hid_t fapl) H5F_libver_t low; /* File format low bound */ - TESTING("Write/read on randomly selected chunks"); + TESTING(testname); assert(NPOINTS < 100); h5_fixname(FILENAME[6], fapl, filename, sizeof filename); + if(H5Pget_libver_bounds(fapl, &low, NULL) < 0) TEST_ERROR; + /* Create file for first test */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; @@ -6708,8 +6710,9 @@ test_random_chunks(hid_t fapl) /* Set chunked layout */ if(H5Pset_chunk(dcpl, 2, csize) < 0) TEST_ERROR; - /* Set early allocation time */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR; + /* Set early allocation time for one dataset; the other dataset is using default alloc time */ + if(early_alloc) + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR; /* Create dataset */ if((d = H5Dcreate2(file, dname, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -6747,12 +6750,28 @@ test_random_chunks(hid_t fapl) if(H5Dclose(d) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; - /* Open file again */ + /* Open first file again */ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Open dataset */ if((d = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) TEST_ERROR; + /* Get the chunk index type */ + if(H5D_layout_idx_type_test(d, &idx_type) < 0) TEST_ERROR; + + /* Verify index type */ + if(low == H5F_LIBVER_LATEST) { + if(early_alloc) { + if(idx_type != H5D_CHUNK_IDX_NONE) + FAIL_PUTS_ERROR("should be using Non-Index as index"); + } /* end if */ + else { + if(idx_type != H5D_CHUNK_IDX_FARRAY) + FAIL_PUTS_ERROR("should be using Fixed Array as index"); + } /* end else */ + } else if(idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + /* Get dataset dataspace */ if((s = H5Dget_space(d)) < 0) TEST_ERROR; @@ -6780,9 +6799,7 @@ test_random_chunks(hid_t fapl) if(H5Fclose(file) < 0) TEST_ERROR; - /* Create file for second test */ - if(H5Pget_libver_bounds(fapl, &low, NULL) < 0) TEST_ERROR; - + /* Create second file */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; /* Create dataspace with unlimited maximum dimensions */ @@ -6794,8 +6811,9 @@ test_random_chunks(hid_t fapl) /* Set chunked layout */ if(H5Pset_chunk(dcpl, 2, csize) < 0) TEST_ERROR; - /* Set allocation time to early */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR; + /* Set early allocation time for one dataset; the other dataset is using default alloc time */ + if(early_alloc) + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR; /* Create dataset */ if((d = H5Dcreate2(file, dname, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -6849,7 +6867,7 @@ test_random_chunks(hid_t fapl) if(H5Dclose(d) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; - /* Open file again */ + /* Open second file again */ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Open dataset */ @@ -6880,6 +6898,112 @@ test_random_chunks(hid_t fapl) if(H5Dclose(d) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; + + /* Create third file */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; + + /* Create dataspace with fixed maximum dimensions */ + if((s = H5Screate_simple(2, dsize, fixed_dmax)) < 0) TEST_ERROR; + + /* Create dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + + /* Set chunked layout */ + if(H5Pset_chunk(dcpl, 2, csize) < 0) TEST_ERROR; + + /* Set early allocation time for one dataset; the other dataset is using default alloc time */ + if(early_alloc) + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR; + + /* Create dataset */ + if((d = H5Dcreate2(file, dname, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR; + + /* Get the chunk index type */ + if(H5D_layout_idx_type_test(d, &idx_type) < 0) TEST_ERROR; + + /* Verify index type */ + if(low == H5F_LIBVER_LATEST) { + if(early_alloc) { + if(idx_type != H5D_CHUNK_IDX_NONE) + FAIL_PUTS_ERROR("should be using Non-Index as index"); + } /* end if */ + else { + if(idx_type != H5D_CHUNK_IDX_FARRAY) + FAIL_PUTS_ERROR("should be using Fixed Array as index"); + } /* end else */ + } else if(idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + + /* Extend both dimensions of the dataset */ + if(H5Dset_extent(d, nsize) < 0) TEST_ERROR; + + /* Reset the dataset dataspace to new dimensions */ + if(H5Sset_extent_simple(s, 2, nsize, dmax) < 0) TEST_ERROR; + + /* Initialize check buffer for repeated coordinates */ + for(i = 0; i < nsize[0]/csize[0]; i++) + for(j = 0; j < nsize[1] / csize[1]; j++) + check2[i][j] = 0; + + /* Generate random point coordinates. Only one point is selected per chunk */ + for(i = 0; i < NPOINTS; i++){ + do { + chunk_row = (int)HDrandom() % (int)(nsize[0] / csize[0]); + chunk_col = (int)HDrandom() % (int)(nsize[1] / csize[1]); + } while (check2[chunk_row][chunk_col]); + + wbuf[i] = check2[chunk_row][chunk_col] = chunk_row + chunk_col + 1; + coord[i][0] = (hsize_t)chunk_row * csize[0]; + coord[i][1] = (hsize_t)chunk_col * csize[1]; + } + + /* Create dataspace for write buffer */ + if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; + + /* Select the random points for writing */ + if(H5Sselect_elements(s, H5S_SELECT_SET, (size_t)NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; + + /* Write into dataset */ + if(H5Dwrite(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; + + /* Close resources */ + if(H5Sclose(s) < 0) TEST_ERROR; + if(H5Sclose(m) < 0) TEST_ERROR; + if(H5Pclose(dcpl) < 0) TEST_ERROR; + if(H5Dclose(d) < 0) TEST_ERROR; + if(H5Fclose(file) < 0) TEST_ERROR; + + /* Open third file again */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; + + /* Open dataset */ + if((d = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) TEST_ERROR; + + /* Get dataset dataspace */ + if((s = H5Dget_space(d)) < 0) TEST_ERROR; + + /* Create dataspace for read buffer */ + if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; + + /* Select the random points for reading */ + if(H5Sselect_elements (s, H5S_SELECT_SET, (size_t)NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; + + /* Read from dataset */ + if(H5Dread(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; + + /* Verify that written and read data are the same */ + for(i = 0; i < NPOINTS; i++) + if(rbuf[i] != wbuf[i]){ + printf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n",__LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); + TEST_ERROR; + } /* end if */ + + /* Close resources */ + if(H5Sclose(s) < 0) TEST_ERROR; + if(H5Sclose(m) < 0) TEST_ERROR; + if(H5Dclose(d) < 0) TEST_ERROR; + if(H5Fclose(file) < 0) TEST_ERROR; + PASSED(); return 0; @@ -6892,6 +7016,43 @@ error: H5Fclose(file); } H5E_END_TRY; return -1; +} /* end test_random_chunks_real() */ + + +/*------------------------------------------------------------------------- + * Function: test_random_chunks + * + * Purpose: Tests that write/read on randomly selected chunks + * First file: + * One dataset has fixed dimensions without max. dims & H5D_ALLOC_TIME_EARLY + * One dataset has fixed dimensions without max. dims & default alloc time + * Second file: + * One extendible dataset with unlimited max. dims & H5D_ALLOC_TIME_EARLY + * One extendible dataset with unlimited max. dims & default alloc time + * third file: + * one extendible dataset with fixed max. dims & H5D_ALLOC_TIME_EARLY + * one extendible dataset with fixed max. dims & default alloc time + * + * All the datasets in second & third files are extended before write/read operations + * + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Christian Chilan + * Monday, March 26, 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_random_chunks(hid_t fapl) +{ + int nerrors = 0; /* Errors in sub-tests */ + + nerrors += test_random_chunks_real("Write/read on randomly selected chunks w/non-implicit index", FALSE, fapl); + nerrors += test_random_chunks_real("Write/read on randomly selected chunks w/implicit index", TRUE, fapl); + + return nerrors;; } /* end test_random_chunks() */ #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -8624,20 +8785,25 @@ error: /*------------------------------------------------------------------------- * Function: test_fixed_array * - * Purpose: Tests support for Fixed Array Indexing + * Purpose: Tests support for Fixed Array and Non-Index Indexing + * + * Create the following 3 datasets: + * 1) extendible chunked dataset with fixed max. dims + * 2) extendible chunked dataset with NULL max. dims + * 3) extendible chunked dataset with same max. dims + * (Note that the third dataset is created with bigger size for curr & max. dims + * so that Fixed Array Indexing with paging is exercised) + * * Repeat the following test with/without compression filter * Repeat the following test with H5D_ALLOC_TIME_EARLY/H5D_ALLOC_TIME_LATE/H5D_ALLOC_TIME_INCR - * For the old format, verify that v1 btree indexing type is used for all - * following datasets - * For the new format, verify that Fixed Array indexing type is used when - * the dataset is created with the following dimension setting: - * (cur dim, max dim) (but not H5S_UNLIMITED) - * (cur dim, max dim = NULL) - * (cur dim, max dim = curr dim) - * Write elements to each dataset - * Read from the dataset and verify the elements read are correct - * Note that the third dataset is created with fixed dimensions but with bigger size - * so that Fixed Array Indexing with paging is involved + * For the old format, + * verify that v1 btree indexing type is used for + * all 3 datasets with all settings + * For the new format: + * Verify that Non-Index type is used for + * all 3 datasets when ALLOC_TIME_EARLY and compression are true + * Verify Fixed Array indexing type is used for + * all 3 datasets with the other settings * * Return: Success: 0 * Failure: -1 @@ -8773,7 +8939,10 @@ test_fixed_array(hid_t fapl) /* Chunk index type depends on whether we are using the latest version of the format */ if(low == H5F_LIBVER_LATEST) { - if(idx_type != H5D_CHUNK_IDX_FARRAY) + if(alloc_time == H5D_ALLOC_TIME_EARLY && !compress) { + if(idx_type != H5D_CHUNK_IDX_NONE) + FAIL_PUTS_ERROR("should be using Non Index as index"); + } else if (idx_type != H5D_CHUNK_IDX_FARRAY) FAIL_PUTS_ERROR("should be using Fixed Array as index"); } /* end if */ else { @@ -8808,7 +8977,10 @@ test_fixed_array(hid_t fapl) /* Chunk index type depends on whether we are using the latest version of the format */ if(low == H5F_LIBVER_LATEST) { - if(idx_type != H5D_CHUNK_IDX_FARRAY) + if(alloc_time == H5D_ALLOC_TIME_EARLY && !compress) { + if(idx_type != H5D_CHUNK_IDX_NONE) + FAIL_PUTS_ERROR("should be using Non Index as index"); + } else if(idx_type != H5D_CHUNK_IDX_FARRAY) FAIL_PUTS_ERROR("should be using Fixed Array as index"); } else { if(idx_type != H5D_CHUNK_IDX_BTREE) @@ -8841,7 +9013,10 @@ test_fixed_array(hid_t fapl) /* Chunk index type depends on whether we are using the latest version of the format */ if(low == H5F_LIBVER_LATEST) { - if(idx_type != H5D_CHUNK_IDX_FARRAY) + if(alloc_time == H5D_ALLOC_TIME_EARLY && !compress) { + if(idx_type != H5D_CHUNK_IDX_NONE) + FAIL_PUTS_ERROR("should be using Non Index as index"); + } else if(idx_type != H5D_CHUNK_IDX_FARRAY) FAIL_PUTS_ERROR("should be using Fixed Array as index"); } /* end if */ else { diff --git a/test/objcopy.c b/test/objcopy.c index 941d113..56e2c5b 100755 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -81,6 +81,8 @@ const char *FILENAME[] = { #define NAME_DATASET_COMPOUND "dataset_compound" #define NAME_DATASET_CHUNKED "dataset_chunked" #define NAME_DATASET_CHUNKED2 "dataset_chunked2" +#define NAME_DATASET_CHUNKED3 "dataset_chunked3" +#define NAME_DATASET_CHUNKED4 "dataset_chunked4" #define NAME_DATASET_COMPACT "dataset_compact" #define NAME_DATASET_EXTERNAL "dataset_ext" #define NAME_DATASET_NAMED_DTYPE "dataset_named_dtype" @@ -88,7 +90,9 @@ const char *FILENAME[] = { #define NAME_DATASET_MULTI_OHDR "dataset_multi_ohdr" #define NAME_DATASET_MULTI_OHDR2 "dataset_multi_ohdr2" #define NAME_DATASET_VL "dataset_vl" +#define NAME_DATASET_VL2 "dataset_vl2" #define NAME_DATASET_VL_VL "dataset_vl_vl" +#define NAME_DATASET_VL_VL2 "dataset_vl_vl2" #define NAME_DATASET_CMPD_VL "dataset_cmpd_vl" #define NAME_DATASET_SUB_SUB "/g0/g00/g000/dataset_simple" #define NAME_GROUP_UNCOPIED "/uncopied" @@ -121,6 +125,8 @@ const char *FILENAME[] = { #define ATTR_NAME_LEN 80 #define DIM_SIZE_1 12 #define DIM_SIZE_2 6 +#define MAX_DIM_SIZE_1 100 +#define MAX_DIM_SIZE_2 80 #define CHUNK_SIZE_1 5 /* Not an even fraction of dimension sizes, so we test copying partial chunks */ #define CHUNK_SIZE_2 5 #define NUM_SUB_GROUPS 20 @@ -2346,6 +2352,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* Set 2-D dataspace dimensions */ dim2d[0] = DIM_SIZE_1; dim2d[1] = DIM_SIZE_2; @@ -2360,6 +2367,22 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* create dataset */ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED2, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* write data into file */ + if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2d) < 0) TEST_ERROR + + /* attach attributes to the dataset */ + if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR + + /* close the dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* Set allocation time to early */ + if(H5Pset_alloc_time(pid, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + + /* create dataset */ + if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED3, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* close chunk plist */ if(H5Pclose(pid) < 0) TEST_ERROR @@ -2375,6 +2398,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -2391,6 +2415,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* copy the datasets from SRC to DST */ if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED2, fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED3, fid_dst, NAME_DATASET_CHUNKED3, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2411,6 +2436,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* open the 2-D dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2430,6 +2456,27 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + + /* open the 2-D dataset for copy */ + if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED3, H5P_DEFAULT)) < 0) TEST_ERROR + + /* open the destination dataset */ + if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED3, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Check if the array index type is correct */ + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + + /* Check if the datasets are equal */ + if(compare_datasets(did, did2, H5P_DEFAULT, buf2d) != TRUE) TEST_ERROR + + /* close the destination dataset */ + if(H5Dclose(did2) < 0) TEST_ERROR + + /* close the source dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -2519,6 +2566,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* Set 2-D dataspace dimensions */ dim2d[0] = DIM_SIZE_1; dim2d[1] = DIM_SIZE_2; @@ -2533,6 +2581,19 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* create dataset */ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED2, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* attach attributes to the dataset */ + if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR + + /* close the dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* Set allocation time to early */ + if(H5Pset_alloc_time(pid, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + + /* create dataset */ + if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED3, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* close chunk plist */ if(H5Pclose(pid) < 0) TEST_ERROR @@ -2561,6 +2622,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* copy the datasets from SRC to DST */ if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED2, fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED3, fid_dst, NAME_DATASET_CHUNKED3, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2581,6 +2643,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2600,6 +2663,27 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + + /* open the third dataset for copy */ + if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED3, H5P_DEFAULT)) < 0) TEST_ERROR + + /* open the destination dataset */ + if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED3, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Check if the array index type is correct */ + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + + /* Check if the datasets are equal */ + if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR + + /* close the destination dataset */ + if(H5Dclose(did2) < 0) TEST_ERROR + + /* close the source dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -2690,6 +2774,38 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* create dataset */ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* write data into file */ + if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1d) < 0) TEST_ERROR + + /* close dataspace */ + if(H5Sclose(sid) < 0) TEST_ERROR + + /* Set extended dataset dimensions */ + new_dim1d[0] = DIM_SIZE_1 * 2; + + /* Extend dataset's dimensions */ + if(H5Dset_extent(did, new_dim1d) < 0) TEST_ERROR + + /* attach attributes to the dataset */ + if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR + + /* close the dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* Change 1-D dataspace dimensions */ + dim1d[0] = DIM_SIZE_1; + max_dim1d[0] = MAX_DIM_SIZE_1; + + /* create 1-D dataspace */ + if((sid = H5Screate_simple(1, dim1d, max_dim1d)) < 0) TEST_ERROR + + /* Set allocation time to early */ + if(H5Pset_alloc_time(pid, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + + /* create dataset */ + if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED3, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* close chunk plist */ if(H5Pclose(pid) < 0) TEST_ERROR @@ -2711,6 +2827,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* Set 2-D dataspace dimensions */ dim2d[0]=DIM_SIZE_1; dim2d[1]=DIM_SIZE_2; @@ -2727,6 +2844,41 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* create dataset */ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED2, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* write data into file */ + if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2d) < 0) TEST_ERROR + + /* close dataspace */ + if(H5Sclose(sid) < 0) TEST_ERROR + + /* Set extended dataset dimensions */ + new_dim2d[0] = DIM_SIZE_1 * 2; + new_dim2d[1] = DIM_SIZE_2 * 2; + + /* Extend dataset's dimensions */ + if(H5Dset_extent(did, new_dim2d) < 0) TEST_ERROR + + /* attach attributes to the dataset */ + if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR + + /* close the dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* Change 2-D dataspace dimensions */ + dim2d[0] = DIM_SIZE_1; + dim2d[1] = DIM_SIZE_2; + max_dim2d[0] = MAX_DIM_SIZE_1; + max_dim2d[1] = MAX_DIM_SIZE_2; + + /* create 2-D dataspace */ + if((sid = H5Screate_simple(2, dim2d, max_dim2d)) < 0) TEST_ERROR + + /* Set allocation time to early */ + if(H5Pset_alloc_time(pid, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + + /* create dataset */ + if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED4, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* close chunk plist */ if(H5Pclose(pid) < 0) TEST_ERROR @@ -2749,6 +2901,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -2765,6 +2918,8 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* copy the datasets from SRC to DST */ if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED2, fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED3, fid_dst, NAME_DATASET_CHUNKED3, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED4, fid_dst, NAME_DATASET_CHUNKED4, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2772,6 +2927,10 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR + /* Check if the array index type is correct */ + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_EARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + /* Check if the datasets are equal */ if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR @@ -2781,12 +2940,57 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR + /* Check if the array index type is correct */ + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_BT2, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + + /* Check if the datasets are equal */ + if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR + + /* close the destination dataset */ + if(H5Dclose(did2) < 0) TEST_ERROR + + /* close the source dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* open the dataset for copy */ + if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED3, H5P_DEFAULT)) < 0) TEST_ERROR + + /* open the destination dataset */ + if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED3, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Check if the array index type is correct */ + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + + /* Check if the datasets are equal */ + if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR + + /* close the destination dataset */ + if(H5Dclose(did2) < 0) TEST_ERROR + + /* close the source dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* open the dataset for copy */ + if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED4, H5P_DEFAULT)) < 0) TEST_ERROR + + /* open the destination dataset */ + if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED4, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Check if the array index type is correct */ + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + /* Check if the datasets are equal */ if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR @@ -2796,6 +3000,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -2869,8 +3074,8 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ - dim2d[0]=DIM_SIZE_1; - dim2d[1]=DIM_SIZE_2; + dim2d[0] = DIM_SIZE_1; + dim2d[1] = DIM_SIZE_2; /* create dataspace */ if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR @@ -2883,6 +3088,22 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* create dataset */ if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* write data into file */ + if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + + /* attach attributes to the dataset */ + if(test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR + + /* close the dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* Set allocation time to early */ + if(H5Pset_alloc_time(pid, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + + /* create dataset */ + if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED2, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* close chunk plist */ if(H5Pclose(pid) < 0) TEST_ERROR @@ -2898,6 +3119,7 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -2913,6 +3135,7 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* copy the dataset from SRC to DST */ if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED2, fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2932,6 +3155,26 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + + /* open the dataset for copy */ + if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR + + /* open the destination dataset */ + if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR + + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + + /* Check if the datasets are equal */ + if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR + + /* close the destination dataset */ + if(H5Dclose(did2) < 0) TEST_ERROR + + /* close the source dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -4220,6 +4463,19 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* create dataset at SRC file */ if((did = H5Dcreate2(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* write data into file */ + if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + + /* close the dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* Set allocation time to early */ + if(H5Pset_alloc_time(pid, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + + /* create dataset at SRC file */ + if((did = H5Dcreate2(fid_src, NAME_DATASET_VL2, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + /* close chunk plist */ if(H5Pclose(pid) < 0) TEST_ERROR @@ -4229,6 +4485,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -4244,6 +4501,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* copy the dataset from SRC to DST */ if(H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Ocopy(fid_src, NAME_DATASET_VL2, fid_dst, NAME_DATASET_VL2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4251,6 +4509,28 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + + /* Check if the datasets are equal */ + if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + + /* close the destination dataset */ + if(H5Dclose(did2) < 0) TEST_ERROR + + /* close the source dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* open the dataset for copy */ + if((did = H5Dopen2(fid_src, NAME_DATASET_VL2, H5P_DEFAULT)) < 0) TEST_ERROR + + /* open the destination dataset */ + if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL2, H5P_DEFAULT)) < 0) TEST_ERROR + + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + /* Check if the datasets are equal */ if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR @@ -4260,6 +4540,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -7266,7 +7547,7 @@ static int test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid2=-1; /* Datatype ID */ + hid_t tid = -1, tid2=-1; /* Datatype ID */ hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ @@ -7322,7 +7603,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* create nested VL datatype */ if((tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR - /* create and set chunk plist */ + /* create and set chunk plist */ if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR @@ -7332,12 +7613,26 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* write data into file */ if(H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR - /* close compact plist */ + /* close the dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + + /* Set allocation time to early */ + if(H5Pset_alloc_time(pid, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + + /* create dataset at SRC file */ + if((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL2, tid2, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + + /* write data into file */ + if(H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + + /* close plist */ if(H5Pclose(pid) < 0) TEST_ERROR /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -7352,6 +7647,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* copy the dataset from SRC to DST */ if(H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Ocopy(fid_src, NAME_DATASET_VL_VL2, fid_dst, NAME_DATASET_VL_VL2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR @@ -7359,6 +7655,9 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + /* Check if the datasets are equal */ if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR @@ -7368,6 +7667,26 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + + /* open the dataset for copy */ + if((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL2, H5P_DEFAULT)) < 0) TEST_ERROR + + /* open the destination dataset */ + if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL2, H5P_DEFAULT)) < 0) TEST_ERROR + + if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + TEST_ERROR + + /* Check if the datasets are equal */ + if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + + /* close the destination dataset */ + if(H5Dclose(did2) < 0) TEST_ERROR + + /* close the source dataset */ + if(H5Dclose(did) < 0) TEST_ERROR + + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -7603,7 +7922,7 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* set initial data values */ for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].a = i * (i - 1); + buf[i].a = (int)(i * (i - 1)); buf[i].b.len = i+1; buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int)); for(j = 0; j < buf[i].b.len; j++) @@ -7742,7 +8061,7 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* set initial data values */ for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].a = i * (i - 1); + buf[i].a = (int)(i * (i - 1)); buf[i].b.len = i+1; buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int)); for(j = 0; j < buf[i].b.len; j++) @@ -7887,7 +8206,7 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* set initial data values */ for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].a = i * (i - 1); + buf[i].a = (int)(i * (i - 1)); buf[i].b.len = i+1; buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int)); for(j = 0; j < buf[i].b.len; j++) diff --git a/tools/h5diff/testfiles/h5diff_dset_idx1.h5 b/tools/h5diff/testfiles/h5diff_dset_idx1.h5 index 1af4e5a..9f71b42 100644 Binary files a/tools/h5diff/testfiles/h5diff_dset_idx1.h5 and b/tools/h5diff/testfiles/h5diff_dset_idx1.h5 differ diff --git a/tools/h5diff/testfiles/h5diff_dset_idx2.h5 b/tools/h5diff/testfiles/h5diff_dset_idx2.h5 index 64c9330..3069fff 100644 Binary files a/tools/h5diff/testfiles/h5diff_dset_idx2.h5 and b/tools/h5diff/testfiles/h5diff_dset_idx2.h5 differ diff --git a/tools/h5stat/testfiles/h5stat_idx.h5 b/tools/h5stat/testfiles/h5stat_idx.h5 index 8b7655a..c6c8006 100644 Binary files a/tools/h5stat/testfiles/h5stat_idx.h5 and b/tools/h5stat/testfiles/h5stat_idx.h5 differ diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c index 44aaa7c..2b3b85d 100644 --- a/tools/misc/h5debug.c +++ b/tools/misc/h5debug.c @@ -244,7 +244,7 @@ main(int argc, char *argv[]) { hid_t fid, fapl, dxpl; H5F_t *f; - haddr_t addr = 1, extra = 0, extra2 = 0, extra3 = 0, extra4 = 0; + haddr_t addr = 0, extra = 0, extra2 = 0, extra3 = 0, extra4 = 0; uint8_t sig[H5F_SIGNATURE_LEN]; size_t u; herr_t status = SUCCEED; diff --git a/tools/testfiles/tdset_idx.h5 b/tools/testfiles/tdset_idx.h5 index d1d910b..3884789 100644 Binary files a/tools/testfiles/tdset_idx.h5 and b/tools/testfiles/tdset_idx.h5 differ -- cgit v0.12