diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/H5Dchunk.c | 33 | ||||
-rw-r--r-- | src/H5Dlayout.c | 16 | ||||
-rw-r--r-- | src/H5Dnone.c | 496 | ||||
-rw-r--r-- | src/H5Dpkg.h | 1 | ||||
-rw-r--r-- | src/H5Dpublic.h | 1 | ||||
-rw-r--r-- | src/H5Olayout.c | 12 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | test/dsets.c | 20 | ||||
-rw-r--r-- | test/objcopy.c | 12 |
11 files changed, 579 insertions, 16 deletions
@@ -512,6 +512,7 @@ ./src/H5Dlayout.c ./src/H5Dmodule.h ./src/H5Dmpio.c +./src/H5Dnone.c ./src/H5Doh.c ./src/H5Dpkg.h ./src/H5Dprivate.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9845194..4e425b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -117,6 +117,7 @@ set (H5D_SRCS ${HDF5_SRC_DIR}/H5Dio.c ${HDF5_SRC_DIR}/H5Dlayout.c ${HDF5_SRC_DIR}/H5Dmpio.c + ${HDF5_SRC_DIR}/H5Dnone.c ${HDF5_SRC_DIR}/H5Doh.c ${HDF5_SRC_DIR}/H5Dscatgath.c ${HDF5_SRC_DIR}/H5Dselect.c diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 08c671b..da6a717 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -79,7 +79,8 @@ (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_SINGLE == storage->idx_type && H5D_COPS_SINGLE == storage->ops)); + (H5D_CHUNK_IDX_SINGLE == storage->idx_type && H5D_COPS_SINGLE == storage->ops) || \ + (H5D_CHUNK_IDX_NONE == storage->idx_type && H5D_COPS_NONE == storage->ops)); /* * Feature: If this constant is defined then every cache preemption and load @@ -287,7 +288,8 @@ static herr_t H5D__chunk_cache_prune(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *dxpl_cache, size_t size); static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk); static herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, - const H5F_block_t *old_chunk, H5F_block_t *new_chunk, hbool_t *need_insert); + const H5F_block_t *old_chunk, H5F_block_t *new_chunk, hbool_t *need_insert, + hsize_t scaled[]); #ifdef H5_HAVE_PARALLEL static herr_t H5D__chunk_collective_fill(const H5D_t *dset, hid_t dxpl_id, H5D_chunk_coll_info_t *chunk_info, size_t chunk_size, const void *fill_buf); @@ -433,7 +435,7 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, /* Create the chunk it if it doesn't exist, or reallocate the chunk * if its size changed. */ - if(H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert, scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") /* Make sure the address of the chunk is returned. */ @@ -2190,7 +2192,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, udata.chunk_block.length = io_info->dset->shared->layout.u.chunk.size; /* Allocate the chunk */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, chunk_info->scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Make sure the address of the chunk is returned. */ @@ -2894,7 +2896,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t /* Create the chunk it if it doesn't exist, or reallocate the chunk * if its size changed. */ - if(H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert, ent->scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Update the chunk entry's info, in case it was allocated or relocated */ @@ -3998,6 +4000,8 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") #ifndef NDEBUG /* None of the chunks should be allocated */ + if(H5D_CHUNK_IDX_NONE != layout->storage.u.chunk.idx_type) + HDassert(!H5F_addr_defined(udata.chunk_block.offset)); /* Make sure the chunk is really in the dataset and outside the * original dimensions */ @@ -4068,7 +4072,7 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ udata.filter_mask = filter_mask; /* Allocate the chunk (with all processes) */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") HDassert(H5F_addr_defined(udata.chunk_block.offset)); @@ -5527,7 +5531,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) udata_dst.common.layout->max_down_chunks, udata_dst.common.scaled); /* Allocate chunk in the file */ - if(H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert, udata_dst.common.scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Write chunk data to destination file */ @@ -6220,7 +6224,7 @@ done: */ static herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk, - H5F_block_t *new_chunk, hbool_t *need_insert) + H5F_block_t *new_chunk, hbool_t *need_insert, hsize_t scaled[]) { hbool_t alloc_chunk = FALSE; /* Whether to allocate chunk */ herr_t ret_value = SUCCEED; /* Return value */ @@ -6241,6 +6245,7 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old /* Check for filters on chunks */ if(idx_info->pline->nused > 0) { /* Sanity/error checking block */ + HDassert(idx_info->storage->idx_type != H5D_CHUNK_IDX_NONE); { unsigned allow_chunk_size_len; /* Allowed size of encoded chunk size */ unsigned new_chunk_size_len; /* Size of encoded chunk size */ @@ -6293,6 +6298,18 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old /* Actually allocate space for the chunk in the file */ if(alloc_chunk) { switch(idx_info->storage->idx_type) { + case H5D_CHUNK_IDX_NONE: + { + H5D_chunk_ud_t udata; + + udata.common.scaled = scaled; + if((idx_info->storage->ops->get_addr)(idx_info, &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query chunk address") + new_chunk->offset = udata.chunk_block.offset; + HDassert(new_chunk->length == udata.chunk_block.length); + break; + } + case H5D_CHUNK_IDX_EARRAY: case H5D_CHUNK_IDX_FARRAY: case H5D_CHUNK_IDX_BT2: diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 991ad95..cb2eca2 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_SINGLE: dataset->shared->layout.storage.u.chunk.ops = H5D_COPS_SINGLE; break; @@ -221,6 +225,10 @@ 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_NONE: + /* nothing */ + break; + case H5D_CHUNK_IDX_SINGLE: /* Possible filter information */ if(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { @@ -405,6 +413,14 @@ H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_SINGLE; layout->storage.u.chunk.ops = H5D_COPS_SINGLE; } /* end if */ + else if(!dcpl_cache->pline.nused && + dcpl_cache->fill.alloc_time == H5D_ALLOC_TIME_EARLY) { + + /* Set the chunk index type to "none" 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 else-if */ else { /* Set the chunk index type to Fixed Array */ layout->u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; diff --git a/src/H5Dnone.c b/src/H5Dnone.c new file mode 100644 index 0000000..677ca67 --- /dev/null +++ b/src/H5Dnone.c @@ -0,0 +1,496 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 <vchoi@hdfgroup.org> + * September 2010 + * + * Purpose: Implicit (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 */ +/****************/ + +#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 */ +/********************/ + +/* Non Index chunking I/O ops */ +static herr_t H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info); +static hbool_t H5D__none_idx_is_space_alloc(const H5O_storage_chunk_t *storage); +static herr_t H5D__none_idx_get_addr(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_ud_t *udata); +static int H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); +static herr_t H5D__none_idx_remove(const H5D_chk_idx_info_t *idx_info, + H5D_chunk_common_ud_t *udata); +static herr_t H5D__none_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__none_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__none_idx_size(const H5D_chk_idx_info_t *idx_info, + hsize_t *size); +static herr_t H5D__none_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__none_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_NONE[1] = {{ + NULL, /* init */ + H5D__none_idx_create, /* create */ + H5D__none_idx_is_space_alloc, /* is_space_alloc */ + NULL, /* insert */ + H5D__none_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__none_idx_iterate, /* iterate */ + H5D__none_idx_remove, /* remove */ + H5D__none_idx_delete, /* delete */ + H5D__none_idx_copy_setup, /* copy_setup */ + NULL, /* copy_shutdown */ + H5D__none_idx_size, /* size */ + H5D__none_idx_reset, /* reset */ + H5D__none_idx_dump, /* dump */ + NULL /* dest */ +}}; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5D__none_idx_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_idx_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_STATIC + + /* 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_idx_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__none_idx_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_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__none_idx_is_space_alloc() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__none_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; Sept 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__none_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->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 */ + udata->chunk_idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->common.scaled); + + /* Calculate the address of the chunk */ + udata->chunk_block.offset = idx_info->storage->idx_addr + udata->chunk_idx * idx_info->layout->size; + + /* Update the other (constant) information for the chunk */ + udata->chunk_block.length = idx_info->layout->size; + udata->filter_mask = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5D__none_idx_get_addr() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__none_idx_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_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 */ + 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 = -1; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + 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; + + 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 */ + idx = H5VM_array_offset_pre(ndims, idx_info->layout->max_down_chunks, chunk_rec.scaled); + + /* 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_rec.scaled[curr_dim]++; + + /* Check if we went off the end of the current dimension */ + if(chunk_rec.scaled[curr_dim] >= idx_info->layout->chunks[curr_dim]) { + /* Reset coordinate & move to next faster dimension */ + chunk_rec.scaled[curr_dim] = 0; + curr_dim--; + } /* end if */ + else + break; + } /* end while */ + } /* end for */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__none_idx_iterate() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__none_idx_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_idx_remove(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) +{ + FUNC_ENTER_STATIC_NOERR + + /* NO OP */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5D__none_idx_remove() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__none_idx_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_idx_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_STATIC + + /* Sanity checks */ + 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_idx_delete() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__none_idx_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_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->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_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__none_idx_copy_setup() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__none_idx_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_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__none_idx_size() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__none_idx_reset + * + * Purpose: Reset indexing information. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; Sept 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__none_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__none_idx_reset() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__none_idx_dump + * + * Purpose: Dump + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; September 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__none_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__none_idx_dump() */ + diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 0fb0d12..f582367 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_NONE[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]; diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 361174a..0b6540c 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -62,6 +62,7 @@ typedef enum H5D_layout_t { 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_NONE = 2, /* Implicit: No Index (H5D_ALLOC_TIME_EARLY, non-filtered, fixed dims) */ 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/H5Olayout.c b/src/H5Olayout.c index 299a43e..b7a2584 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -298,6 +298,10 @@ 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_NONE: /* Implicit Index */ + mesg->storage.u.chunk.ops = H5D_COPS_NONE; + 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); @@ -628,6 +632,9 @@ 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_NONE: /* Implicit */ + break; + case H5D_CHUNK_IDX_SINGLE: /* Single Chunk */ /* Filter information */ if(mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { @@ -1192,6 +1199,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_NONE: + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index Type:", "Implicit"); + break; + case H5D_CHUNK_IDX_SINGLE: HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Single Chunk"); diff --git a/src/Makefile.am b/src/Makefile.am index f376969..5d72fc5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,7 +49,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.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 \ + H5Dio.c H5Dlayout.c H5Dnone.c \ H5Doh.c H5Dscatgath.c H5Dselect.c \ H5Dsingle.c H5Dtest.c H5Dvirtual.c \ H5E.c H5Edeprec.c H5Eint.c \ diff --git a/test/dsets.c b/test/dsets.c index 2ff8dda..2bc162c 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -6949,8 +6949,14 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) /* 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"); @@ -7009,7 +7015,7 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) /* Verify index type */ if(low == H5F_LIBVER_LATEST) { if(early_alloc) { - if(idx_type != H5D_CHUNK_IDX_FARRAY) + if(idx_type != H5D_CHUNK_IDX_NONE) FAIL_PUTS_ERROR("should be using implicit indexing"); } else if(idx_type != H5D_CHUNK_IDX_BT2) FAIL_PUTS_ERROR("should be using v2 B-tree as index"); @@ -7111,8 +7117,14 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) /* 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"); @@ -9235,6 +9247,8 @@ test_fixed_array(hid_t fapl) && !compress #endif /* H5_HAVE_FILTER_DEFLATE */ ) { + 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 */ @@ -9275,6 +9289,8 @@ test_fixed_array(hid_t fapl) && !compress #endif /* H5_HAVE_FILTER_DEFLATE */ ) { + 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 { @@ -9313,6 +9329,8 @@ test_fixed_array(hid_t fapl) && !compress #endif /* H5_HAVE_FILTER_DEFLATE */ ) { + 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 */ diff --git a/test/objcopy.c b/test/objcopy.c index 229284d..1c95dc7 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -2751,7 +2751,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, 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_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3166,7 +3166,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, 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_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3501,7 +3501,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, 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(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3521,7 +3521,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, 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(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -5217,7 +5217,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL2, 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_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -8429,7 +8429,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL2, 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_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ |