From f7aff7d5cf0f1c9cd056ebc0274ad8d0683890a2 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 18 Apr 2016 23:21:12 -0500 Subject: [svn-r29738] Description: Bring "single" chunk index from revise_chunks branch to trunk. Tested on: MacOSX/64 10.11.4 (amazon) w/serial, parallel & production (w/check-vfd) (h5committest forthcoming) --- MANIFEST | 1 + src/H5Dchunk.c | 5 +- src/H5Dlayout.c | 67 +++++-- src/H5Dpkg.h | 1 + src/H5Dpublic.h | 1 + src/H5Dsingle.c | 556 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/H5Olayout.c | 23 +++ src/H5Oprivate.h | 9 + src/H5trace.c | 4 + src/Makefile.am | 3 +- test/Makefile.am | 2 +- test/dsets.c | 248 ++++++++++++++++++++++++- test/objcopy.c | 22 +-- 13 files changed, 909 insertions(+), 33 deletions(-) create mode 100644 src/H5Dsingle.c diff --git a/MANIFEST b/MANIFEST index 57ce23d..117bfae 100644 --- a/MANIFEST +++ b/MANIFEST @@ -518,6 +518,7 @@ ./src/H5Dpublic.h ./src/H5Dscatgath.c ./src/H5Dselect.c +./src/H5Dsingle.c ./src/H5Dtest.c ./src/H5Dvirtual.c ./src/H5E.c diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 0acb385..08c671b 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -78,7 +78,8 @@ HDassert((H5D_CHUNK_IDX_EARRAY == storage->idx_type && H5D_COPS_EARRAY == storage->ops) || \ (H5D_CHUNK_IDX_FARRAY == storage->idx_type && H5D_COPS_FARRAY == storage->ops) || \ (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_CHUNK_IDX_BTREE == storage->idx_type && H5D_COPS_BTREE == storage->ops) || \ + (H5D_CHUNK_IDX_SINGLE == storage->idx_type && H5D_COPS_SINGLE == storage->ops)); /* * Feature: If this constant is defined then every cache preemption and load @@ -6232,7 +6233,6 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old HDassert(idx_info->pline); HDassert(idx_info->layout); HDassert(idx_info->storage); - HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); HDassert(new_chunk); HDassert(need_insert); @@ -6297,6 +6297,7 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old case H5D_CHUNK_IDX_FARRAY: case H5D_CHUNK_IDX_BT2: case H5D_CHUNK_IDX_BTREE: + case H5D_CHUNK_IDX_SINGLE: HDassert(new_chunk->length > 0); H5_CHECK_OVERFLOW(new_chunk->length, /*From: */uint32_t, /*To: */hsize_t); new_chunk->offset = H5MF_alloc(idx_info->f, H5FD_MEM_DRAW, idx_info->dxpl_id, (hsize_t)new_chunk->length); diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index bf99b9d..991ad95 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_SINGLE: + dataset->shared->layout.storage.u.chunk.ops = H5D_COPS_SINGLE; + break; + case H5D_CHUNK_IDX_FARRAY: dataset->shared->layout.storage.u.chunk.ops = H5D_COPS_FARRAY; break; @@ -217,6 +221,14 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ case H5D_CHUNK_IDX_BTREE: HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, 0, "v1 B-tree index type found for layout message >v3") + case H5D_CHUNK_IDX_SINGLE: + /* Possible filter information */ + if(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + ret_value += H5F_SIZEOF_SIZE(f); /* Size of chunk (in file) */ + ret_value += 4; /* Filter mask for chunk */ + } /* end if */ + break; + case H5D_CHUNK_IDX_FARRAY: /* Fixed array creation parameters */ ret_value += H5D_FARRAY_CREATE_PARAM_SIZE; @@ -338,6 +350,7 @@ H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Maximum dimension sizes */ hsize_t cur_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */ unsigned unlim_count = 0; /* Count of unlimited max. dimensions */ + hbool_t single = TRUE; /* Fulfill single chunk indexing */ unsigned u; /* Local index variable */ /* Query the dataspace's dimensions */ @@ -348,6 +361,8 @@ H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, for(u = 0; u < ndims; u++) { if(max_dims[u] == H5S_UNLIMITED) unlim_count++; + if(cur_dims[u] != max_dims[u] || cur_dims[u] != layout->u.chunk.dim[u]) + single = FALSE; } /* end for */ /* Chunked datasets with unlimited dimension(s) */ @@ -383,17 +398,25 @@ H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, layout->u.chunk.u.btree2.cparam.merge_percent = H5D_BT2_MERGE_PERC; } /* end else */ } /* end if */ - else { - /* 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; + else { /* Chunked dataset with fixed dimensions */ + /* Check for correct condition for using "single chunk" chunk index */ + if(single) { + layout->u.chunk.idx_type = H5D_CHUNK_IDX_SINGLE; + layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_SINGLE; + layout->storage.u.chunk.ops = H5D_COPS_SINGLE; + } /* end if */ + else { + /* 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 else */ } /* end if */ } /* end if */ @@ -422,6 +445,7 @@ H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset, { H5O_layout_t *layout; /* Dataset's layout information */ const H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ + unsigned layout_mesg_flags; /* Flags for inserting layout message */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ herr_t ret_value = SUCCEED; /* Return value */ @@ -516,9 +540,14 @@ H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset, } /* end if */ /* Create layout message */ - /* (Don't make layout message constant unless allocation time is early, since space may not be allocated) */ + /* (Don't make layout message constant unless allocation time is early and non-filtered, since space may not be allocated) */ /* (Note: this is relying on H5D__alloc_storage not calling H5O_msg_write during dataset creation) */ - if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_LAYOUT_ID, ((fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type) ? H5O_MSG_FLAG_CONSTANT : 0), 0, layout) < 0) + if(fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type + && !dset->shared->dcpl_cache.pline.nused) + layout_mesg_flags = H5O_MSG_FLAG_CONSTANT; + else + layout_mesg_flags = 0; + if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_LAYOUT_ID, layout_mesg_flags, 0, layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout") done: @@ -636,6 +665,7 @@ done: herr_t H5D__layout_oh_write(H5D_t *dataset, hid_t dxpl_id, H5O_t *oh, unsigned update_flags) { + htri_t msg_exists; /* Whether the layout message exists */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -644,9 +674,14 @@ H5D__layout_oh_write(H5D_t *dataset, hid_t dxpl_id, H5O_t *oh, unsigned update_f HDassert(dataset); HDassert(oh); - /* Write the layout message to the dataset's header */ - if(H5O_msg_write_oh(dataset->oloc.file, dxpl_id, oh, H5O_LAYOUT_ID, H5O_MSG_FLAG_CONSTANT, update_flags, &dataset->shared->layout) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout message") + /* Check if the layout message has been added to the dataset's header */ + if((msg_exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to check if layout message exists") + if(msg_exists) { + /* Write the layout message to the dataset's header */ + if(H5O_msg_write_oh(dataset->oloc.file, dxpl_id, oh, H5O_LAYOUT_ID, 0, update_flags, &dataset->shared->layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout message") + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 2609412..0fb0d12 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -541,6 +541,7 @@ H5_DLLVAR const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1]; /* Chunked layout operations */ H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_BTREE[1]; +H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_SINGLE[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]; diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 07f8dbe..361174a 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -61,6 +61,7 @@ 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_SINGLE = 1, /* Single Chunk index (cur dims[]=max dims[]=chunk dims[]; filtered & non-filtered) */ H5D_CHUNK_IDX_FARRAY = 3, /* Fixed array (for 0 unlimited dims) */ H5D_CHUNK_IDX_EARRAY = 4, /* Extensible array (for 1 unlimited dim) */ H5D_CHUNK_IDX_BT2 = 5, /* v2 B-tree index (for >1 unlimited dims) */ diff --git a/src/H5Dsingle.c b/src/H5Dsingle.c new file mode 100644 index 0000000..e09a5cf --- /dev/null +++ b/src/H5Dsingle.c @@ -0,0 +1,556 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 + * May 2011; updated 10/2015 + * + * Purpose: Single Chunk I/O functions. + * This is used when the dataset has only 1 chunk (with or without filter): + * cur_dims[] is equal to max_dims[] is equal to the chunk dims[] + * non-filter chunk record: [address of the chunk] + * filtered chunk record: [address of the chunk, chunk size, filter mask] + * + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ + + +/***********/ +/* 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 "H5VMprivate.h" /* Vector functions */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Single Chunk Index chunking I/O ops */ +static herr_t H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, + const H5S_t *space, haddr_t dset_ohdr_addr); +static herr_t H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info); +static hbool_t H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage); +static herr_t H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_ud_t *udata, const H5D_t *dset); +static herr_t H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_ud_t *udata); +static int H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); +static herr_t H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_common_ud_t *udata); +static herr_t H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__single_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__single_idx_size(const H5D_chk_idx_info_t *idx_info, + hsize_t *size); +static herr_t H5D__single_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Non Index chunk I/O ops */ +const H5D_chunk_ops_t H5D_COPS_SINGLE[1] = {{ + H5D__single_idx_init, /* init */ + H5D__single_idx_create, /* create */ + H5D__single_idx_is_space_alloc, /* is_space_alloc */ + H5D__single_idx_insert, /* insert */ + H5D__single_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__single_idx_iterate, /* iterate */ + H5D__single_idx_remove, /* remove */ + H5D__single_idx_delete, /* delete */ + H5D__single_idx_copy_setup, /* copy_setup */ + NULL, /* copy_shutdown */ + H5D__single_idx_size, /* size */ + H5D__single_idx_reset, /* reset */ + H5D__single_idx_dump, /* dump */ + NULL /* destroy */ +}}; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_init + * + * Purpose: Initialize the indexing information for a dataset. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi + * July, 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, + const H5S_t H5_ATTR_UNUSED *space, haddr_t H5_ATTR_UNUSED dset_ohdr_addr) +{ + FUNC_ENTER_STATIC_NOERR + + /* Check args */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->layout); + HDassert(idx_info->storage); + + if(idx_info->pline->nused) + idx_info->layout->flags |= H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER; + else + idx_info->layout->flags = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D__single_idx_init() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_create + * + * Purpose: Set up Single Chunk Index: filtered or non-filtered + * + * Return: Non-negative on success + * Negative on failure. + * + * Programmer: Vailin Choi; July 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info) +{ + FUNC_ENTER_STATIC_NOERR + + /* Check args */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->layout); + HDassert(idx_info->storage); + HDassert(idx_info->layout->max_nchunks == idx_info->layout->nchunks); + HDassert(idx_info->layout->nchunks == 1); + HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); + + if(idx_info->pline->nused) + HDassert(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER); + else + HDassert(!(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER)); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D__single_idx_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_is_space_alloc + * + * Purpose: Query if space is allocated for the single chunk + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; July 2011 + * + *------------------------------------------------------------------------- + */ +static hbool_t +H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage) +{ + FUNC_ENTER_STATIC_NOERR + + /* Check args */ + HDassert(storage); + + FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) +} /* end H5D__single_idx_is_space_alloc() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_insert + * + * Purpose: Allocate space for the single chunk + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; July 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->layout); + HDassert(idx_info->storage); + HDassert(idx_info->layout->nchunks == 1); + HDassert(idx_info->layout->max_nchunks == 1); + HDassert(udata); + + /* Set the address for the chunk */ + HDassert(H5F_addr_defined(udata->chunk_block.offset)); + idx_info->storage->idx_addr = udata->chunk_block.offset; + + if(idx_info->pline->nused > 0) { + H5_CHECKED_ASSIGN(idx_info->storage->u.single.nbytes, uint32_t, udata->chunk_block.length, hsize_t); + idx_info->storage->u.single.filter_mask = udata->filter_mask; + } /* end if */ + + if(dset) { + if(dset->shared->dcpl_cache.fill.alloc_time != H5D_ALLOC_TIME_EARLY || idx_info->pline->nused > 0) { + /* Mark the layout dirty so that the address of the single chunk will be flushed later */ + if(H5D__mark(dset, idx_info->dxpl_id, H5D_MARK_LAYOUT) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark layout as dirty") + } /* end if */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5D__single_idx_insert() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_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; July 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->layout); + HDassert(idx_info->storage); + HDassert(idx_info->layout->nchunks == 1); + HDassert(idx_info->layout->max_nchunks == 1); + HDassert(udata); + + udata->chunk_block.offset = idx_info->storage->idx_addr; + if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + udata->chunk_block.length = idx_info->storage->u.single.nbytes; + udata->filter_mask = idx_info->storage->u.single.filter_mask; + } /* end if */ + else { + udata->chunk_block.length = idx_info->layout->size; + udata->filter_mask = 0; + } /* end else */ + if(!H5F_addr_defined(udata->chunk_block.offset)) + udata->chunk_block.length = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5D__single_idx_get_addr() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_iterate + * + * Purpose: Make callback for the single chunk + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; July 2010 + * + *------------------------------------------------------------------------- + */ +static int +H5D__single_idx_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 */ + int ret_value = -1; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + 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.chunk_addr = idx_info->storage->idx_addr; + + if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + chunk_rec.nbytes = idx_info->storage->u.single.nbytes; + chunk_rec.filter_mask = idx_info->storage->u.single.filter_mask; + } /* end if */ + else { + chunk_rec.nbytes = idx_info->layout->size; + chunk_rec.filter_mask = 0; + } /* end else */ + + /* 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"); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__single_idx_iterate() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_remove + * + * Purpose: Remove the single chunk + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; July 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) +{ + hsize_t nbytes; /* Size of all chunks */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->layout); + HDassert(idx_info->storage); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); + + if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) + nbytes = idx_info->storage->u.single.nbytes; + else + nbytes = 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) +} /* H5D__single_idx_remove() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_delete + * + * Purpose: Delete raw data storage for entire dataset (i.e. the only chunk) + * + * Return: Success: Non-negative + * Failure: negative + * + * Programmer: Vailin Choi; Sept 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->layout); + HDassert(idx_info->storage); + + if(H5F_addr_defined(idx_info->storage->idx_addr)) + ret_value = H5D__single_idx_remove(idx_info, NULL); + else + HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__single_idx_delete() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_copy_setup + * + * Purpose: Set up any necessary information for copying the single chunk + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Sept 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_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_STATIC + + /* Check args */ + HDassert(idx_info_src); + HDassert(idx_info_src->f); + HDassert(idx_info_src->pline); + 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->layout); + HDassert(idx_info_dst->storage); + + /* Set copied metadata tag */ + H5_BEGIN_TAG(idx_info_dst->dxpl_id, H5AC__COPIED_TAG, FAIL); + + /* Set up information at the destination file */ + if(H5D__single_idx_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__single_idx_copy_setup() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_size + * + * Purpose: Retrieve the amount of index storage for the chunked dataset + * + * Return: Success: Non-negative + * Failure: negative + * + * Programmer: Vailin Choi; Sept 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_size(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, hsize_t *index_size) +{ + FUNC_ENTER_STATIC_NOERR + + /* Check args */ + HDassert(index_size); + + *index_size = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D__single_idx_size() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_reset + * + * Purpose: Reset indexing information. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Sept 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) +{ + FUNC_ENTER_STATIC_NOERR + + /* Check args */ + HDassert(storage); + + /* Reset index info */ + if(reset_addr) + storage->idx_addr = HADDR_UNDEF; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D__single_idx_reset() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__single_idx_dump + * + * Purpose: Dump the address of the single chunk + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; September 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) +{ + FUNC_ENTER_STATIC_NOERR + + /* Check args */ + HDassert(storage); + HDassert(stream); + + HDfprintf(stream, " Address: %a\n", storage->idx_addr); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D__single_idx_dump() */ + diff --git a/src/H5Olayout.c b/src/H5Olayout.c index bc1ebc6..299a43e 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -298,6 +298,16 @@ H5O__layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "v1 B-tree index type should never be in a v4 layout message") break; + case H5D_CHUNK_IDX_SINGLE: /* Single Chunk Index */ + if(mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + H5F_DECODE_LENGTH(f, p, mesg->storage.u.chunk.u.single.nbytes); + UINT32DECODE(p, mesg->storage.u.chunk.u.single.filter_mask); + } /* end if */ + + /* Set the chunk operations */ + mesg->storage.u.chunk.ops = H5D_COPS_SINGLE; + break; + case H5D_CHUNK_IDX_FARRAY: /* Fixed array creation parameters */ mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = *p++; @@ -618,6 +628,14 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "v1 B-tree index type should never be in a v4 layout message") break; + case H5D_CHUNK_IDX_SINGLE: /* Single Chunk */ + /* Filter information */ + if(mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + H5F_ENCODE_LENGTH(f, p, mesg->storage.u.chunk.u.single.nbytes); + UINT32ENCODE(p, mesg->storage.u.chunk.u.single.filter_mask); + } /* end if */ + break; + case H5D_CHUNK_IDX_FARRAY: /* Fixed array creation parameters */ *p++ = mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits; @@ -1174,6 +1192,11 @@ H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const v "Index Type:", "v1 B-tree"); break; + case H5D_CHUNK_IDX_SINGLE: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index Type:", "Single Chunk"); + break; + case H5D_CHUNK_IDX_FARRAY: HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Fixed Array"); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 46845a3..17ab665 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -369,8 +369,10 @@ typedef struct H5O_efl_t { /* Flags for chunked layout feature encoding */ #define H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS 0x01 +#define H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER 0x02 #define H5O_LAYOUT_ALL_CHUNK_FLAGS ( \ H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS \ + | H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER \ ) /* Initial version of the layout information. Used when space is allocated */ @@ -432,6 +434,12 @@ typedef struct H5O_storage_chunk_earray_t { struct H5EA_t *ea; /* Pointer to extensible index array struct */ } H5O_storage_chunk_earray_t; +/* Filtered info for single chunk index */ +typedef struct H5O_storage_chunk_single_filt_t { + uint32_t nbytes; /* Size of chunk (in file) */ + uint32_t filter_mask; /* Excluded filters for chunk */ +} H5O_storage_chunk_single_filt_t; + /* Forward declaration of structs used below */ struct H5B2_t; /* Defined in H5B2pkg.h */ @@ -449,6 +457,7 @@ typedef struct H5O_storage_chunk_t { H5O_storage_chunk_bt2_t btree2; /* Information for v2 B-tree index */ H5O_storage_chunk_earray_t earray; /* Information for extensible array index */ H5O_storage_chunk_farray_t farray; /* Information for fixed array index */ + H5O_storage_chunk_single_filt_t single; /* Information for single chunk w/ filters index */ } u; } H5O_storage_chunk_t; diff --git a/src/H5trace.c b/src/H5trace.c index a2ca7e2..92d3d20 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -522,6 +522,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) fprintf(out, "H5D_CHUNK_IDX_BT2"); break; + case H5D_CHUNK_IDX_SINGLE: + fprintf(out, "H5D_CHUNK_IDX_SINGLE"); + break; + case H5D_CHUNK_IDX_NTYPES: fprintf(out, "ERROR: H5D_CHUNK_IDX_NTYPES (invalid value)"); break; diff --git a/src/Makefile.am b/src/Makefile.am index ec8c007..f376969 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,7 +50,8 @@ 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 \ - H5Doh.c H5Dscatgath.c H5Dselect.c H5Dtest.c H5Dvirtual.c \ + H5Doh.c H5Dscatgath.c H5Dselect.c \ + H5Dsingle.c H5Dtest.c H5Dvirtual.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 \ diff --git a/test/Makefile.am b/test/Makefile.am index a99f11d..7e3a385 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -128,7 +128,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_fast.h5 chunk_expand.h5 \ chunk_fixed.h5 copy_dcpl_newfile.h5 partial_chunks.h5 layout_extend.h5 \ - zero_chunk.h5 dls_01_strings.h5 storage_size.h5 \ + zero_chunk.h5 chunk_single.h5 storage_size.h5 dls_01_strings.h5 \ extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ sys_file1 tfile[1-7].h5 th5s[1-4].h5 lheap.h5 fheap.h5 ohdr.h5 \ stab.h5 extern_[1-5].h5 extern_[1-4][rw].raw gheap[0-4].h5 \ diff --git a/test/dsets.c b/test/dsets.c index bd683d1..e095875 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -51,8 +51,9 @@ const char *FILENAME[] = { "partial_chunks", /* 14 */ "layout_extend", /* 15 */ "zero_chunk", /* 16 */ - "dls_01_strings", /* 17 */ + "chunk_single", /* 17 */ "storage_size", /* 18 */ + "dls_01_strings", /* 19 */ NULL }; #define FILENAME_BUF_SIZE 1024 @@ -126,6 +127,10 @@ const char *FILENAME[] = { #define POINTS 72 #define POINTS_BIG 2500 +/* Dataset names for testing Implicit Indexing */ +#define DSET_SINGLE_MAX "DSET_SINGLE_MAX" +#define DSET_SINGLE_NOMAX "DSET_SINGLE_NOMAX" + #define USER_BLOCK 1024 #define SIXTY_FOUR_KB 65536 @@ -9462,6 +9467,244 @@ error: } /* end test_fixed_array() */ +/*------------------------------------------------------------------------- + * Function: test_single_chunk + * + * Purpose: Tests support for Single Chunk indexing type + * + * Create the following 2 datasets: + * 1) chunked dataset with NULL max dims and cur_dims = chunk_dims + * 2) chunked dataset with cur_dims = max_dims = chunk_dims + * + * 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 datasets with all settings + * For the new format: + * Verify that Single Chunk indexing type is used for + * all datasets with all settings + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Vailin Choi; July 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_single_chunk(hid_t fapl) +{ + char filename[FILENAME_BUF_SIZE]; /* File name */ + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t t_dcpl = -1; /* Dataset creation property list ID */ + + hid_t sid = -1, sid_max = -1; /* Dataspace ID for dataset with fixed dimensions */ + hid_t did = -1, did_max = -1; /* Dataset ID for dataset with fixed dimensions */ + hsize_t dim2[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */ + hsize_t t_dim2[2] = {50, 100}; /* Dataset dimensions */ + int wbuf[DSET_DIM1*DSET_DIM2]; /* write buffer */ + int t_wbuf[50*100]; /* write buffer */ + int rbuf[DSET_DIM1*DSET_DIM2]; /* read buffer */ + int t_rbuf[50*100]; /* read buffer */ + + H5D_chunk_index_t idx_type; /* Dataset chunk index type */ + H5F_libver_t low, high; /* File format bounds */ + H5D_alloc_time_t alloc_time; /* Storage allocation time */ + +#ifdef H5_HAVE_FILTER_DEFLATE + unsigned compress; /* Whether chunks should be compressed */ +#endif /* H5_HAVE_FILTER_DEFLATE */ + + size_t n, i; /* local index variables */ + herr_t ret; /* Generic return value */ + h5_stat_size_t empty_size; /* Size of an empty file */ + h5_stat_size_t file_size; /* Size of each file created */ + + TESTING("datasets w/Single Chunk indexing"); + + h5_fixname(FILENAME[17], fapl, filename, sizeof filename); + + /* Check if we are using the latest version of the format */ + if(H5Pget_libver_bounds(fapl, &low, &high) < 0) FAIL_STACK_ERROR + + /* Create and close the file to get the file size */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + STACK_ERROR + if(H5Fclose(fid) < 0) + STACK_ERROR + + /* Get the size of the empty file */ + if((empty_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR + + for(i = n = 0; i < (DSET_DIM1 * DSET_DIM2); i++) + wbuf[i] = n++; + + for(i = n = 0; i < (50* 100); i++) + t_wbuf[i] = n++; + +#ifdef H5_HAVE_FILTER_DEFLATE + /* Loop over compressing chunks */ + for(compress = FALSE; compress <= TRUE; compress++) { +#endif /* H5_HAVE_FILTER_DEFLATE */ + + /* Loop over storage allocation time */ + for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + /* Create file */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + + /* Create dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if((t_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + + /* Set chunking */ + if((ret = H5Pset_chunk(dcpl, 2, dim2)) < 0) + FAIL_PUTS_ERROR(" Problem with setting chunk.") + + if((ret = H5Pset_chunk(t_dcpl, 2, t_dim2)) < 0) + FAIL_PUTS_ERROR(" Problem with setting chunk.") + +#ifdef H5_HAVE_FILTER_DEFLATE + /* Check if we should compress the chunks */ + if(compress) { + if(H5Pset_deflate(dcpl, 9) < 0) FAIL_STACK_ERROR + if(H5Pset_deflate(t_dcpl, 9) < 0) FAIL_STACK_ERROR + } +#endif /* H5_HAVE_FILTER_DEFLATE */ + + /* Set fill time */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR + if(H5Pset_fill_time(t_dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR + + /* Set allocation time */ + if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR + if(H5Pset_alloc_time(t_dcpl, alloc_time) < 0) FAIL_STACK_ERROR + + /* Create first dataset with cur and max dimensions */ + if((sid_max = H5Screate_simple(2, dim2, dim2)) < 0) FAIL_STACK_ERROR + did_max = H5Dcreate2(fid, DSET_SINGLE_MAX, H5T_NATIVE_INT, sid_max, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if(did_max < 0) + FAIL_PUTS_ERROR(" Creating Chunked Dataset with maximum dimensions.") + + /* Get the chunk index type */ + if(H5D__layout_idx_type_test(did_max, &idx_type) < 0) FAIL_STACK_ERROR + + /* 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_SINGLE) + FAIL_PUTS_ERROR("should be using Single Chunk indexing"); + } /* end if */ + else { + if(idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + } /* end else */ + + /* Write into dataset */ + if(H5Dwrite(did_max, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; + + /* Closing */ + if(H5Dclose(did_max) < 0) FAIL_STACK_ERROR + if(H5Sclose(sid_max) < 0) FAIL_STACK_ERROR + + /* Create second dataset with curr dim but NULL max dim */ + if((sid = H5Screate_simple(2, t_dim2, NULL)) < 0) FAIL_STACK_ERROR + did = H5Dcreate2(fid, DSET_SINGLE_NOMAX, H5T_NATIVE_INT, sid, H5P_DEFAULT, t_dcpl, H5P_DEFAULT); + if(did < 0) + FAIL_PUTS_ERROR(" Creating Chunked Dataset.") + + /* Get the chunk index type */ + if(H5D__layout_idx_type_test(did, &idx_type) < 0) FAIL_STACK_ERROR + + /* 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_SINGLE) + FAIL_PUTS_ERROR("should be using Single Chunk indexing"); + } else { + if(idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + } /* end else */ + + /* Write into dataset */ + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, t_wbuf) < 0) TEST_ERROR; + + /* Closing */ + if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + + /* Open the first dataset */ + if((did_max = H5Dopen2(fid, DSET_SINGLE_MAX, H5P_DEFAULT)) < 0) TEST_ERROR; + + /* Read from dataset */ + if(H5Dread(did_max, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; + + /* Verify that written and read data are the same */ + for(i = 0; i < (DSET_DIM1 * DSET_DIM2); 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 */ + + /* Closing */ + if(H5Dclose(did_max) < 0) FAIL_STACK_ERROR + + /* Open the second dataset */ + if((did = H5Dopen2(fid, DSET_SINGLE_NOMAX, H5P_DEFAULT)) < 0) TEST_ERROR; + + HDmemset(rbuf, 0, sizeof(rbuf)); + + /* Read from dataset */ + if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, t_rbuf) < 0) TEST_ERROR; + + /* Verify that written and read data are the same */ + for(i = 0; i < (50* 100); i++) + if(t_rbuf[i] != t_wbuf[i]){ + printf(" Line %d: Incorrect value, t_wbuf[%u]=%d, t_rbuf[%u]=%d\n", + __LINE__,(unsigned)i,t_wbuf[i],(unsigned)i,t_rbuf[i]); + TEST_ERROR; + } /* end if */ + + /* Closing */ + if(H5Dclose(did) < 0) FAIL_STACK_ERROR + + /* Delete datasets */ + if(H5Ldelete(fid, DSET_SINGLE_NOMAX, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Ldelete(fid, DSET_SINGLE_MAX, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + + /* Close everything */ + if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + + /* Get the size of the file */ + if((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR + + /* Verify the file is correct size */ + if(file_size != empty_size) + TEST_ERROR + + } /* end for */ +#ifdef H5_HAVE_FILTER_DEFLATE + } /* end for */ +#endif /* H5_HAVE_FILTER_DEFLATE */ + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Pclose(t_dcpl); + H5Dclose(did); + H5Dclose(did_max); + H5Sclose(sid); + H5Sclose(sid_max); + H5Fclose(fid); + } H5E_END_TRY; + return -1; +} /* end test_single_chunk() */ + /*------------------------------------------------------------------------- * @@ -11493,7 +11736,7 @@ dls_01_main( void ) { TESTING("Testing DLS bugfix 1"); - if ( NULL == h5_fixname(FILENAME[17], H5P_DEFAULT, filename, + if ( NULL == h5_fixname(FILENAME[19], H5P_DEFAULT, filename, sizeof(filename)) ) TEST_ERROR @@ -11685,6 +11928,7 @@ main(void) nerrors += (test_fixed_array(my_fapl) < 0 ? 1 : 0); nerrors += (test_idx_compatible() < 0 ? 1 : 0); nerrors += (test_unfiltered_edge_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_single_chunk(my_fapl) < 0 ? 1 : 0); nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); nerrors += (test_storage_size(my_fapl) < 0 ? 1 : 0); diff --git a/test/objcopy.c b/test/objcopy.c index 19caa52..229284d 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -2712,7 +2712,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2770,7 +2770,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2789,7 +2789,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED3_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2808,7 +2808,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED4_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3108,7 +3108,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3146,7 +3146,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3186,7 +3186,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED3_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3205,7 +3205,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED4_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3807,7 +3807,7 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* open the copied dataset NAME_DATASET_CHUNKED2_SINGLE at destination */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3825,7 +3825,7 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* open the copied dataset NAME_DATASET_CHUNKED3_SINGLE at destination */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED3_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3843,7 +3843,7 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* open the copied dataset NAME_DATASET_CHUNKED4_SINGLE at destination */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED4_SINGLE, H5P_DEFAULT)) < 0) TEST_ERROR - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_SINGLE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ -- cgit v0.12