Merging in latest from upstream (HDFFV/hdf5:refs/heads/develop)

* commit '4c558700ab33934e7358483c5d20fea4823baf9e':
  Update RELEASE.txt for reference changes
  Fix reference type comparison in h5dump
  Make wrappers, tests and tools use H5Treclaim() instead of H5Dvlen_reclaim()
  Add new H5R API that abstracts object, region and attribute reference types
  Remove ability to loc by ref from H5VL layer
  Add support for retrieving object name by token
  Add H5VL_OBJECT_GET_TYPE to get object type
  Add H5VL_MAX_TOKEN_SIZE and H5VL_token_t
  Adapt Jerome's "file info" H5VL 'get' query to retrieve container token info.
  Fix H5VL_blob_get to return size of blob
  Add 'blob' callbacks to VOL, along with a native implementation to store them in the global heap, and changed the VL datatype conversion code to use blobs.
  Remove debugging logic from the new t_bigio test
  Expanded t_bigio.c to include Jordan's test from HDFFV-10539
  Another cleanup pass as suggested by the reviewers.
  Fix some typos and remove an unused prototype from H5Sprivate.h
  At the suggestion of the PR reviewers, moved the mpio_create_large_type to H5mpi.c and renamed the function appropriately.  Also moved some support functions to set and get the vvalue where we transistion to using derived datatypes.
  Made code review edit suggested by Jerome, plus various code updates to files that I touched to eliminate compile warnings (on my Linux box).
  No functional changes, just removed some tab characters
  Make the initial bug fixes to allow >2GB writes with Independent IO
This commit is contained in:
Allen Byrne 2019-10-08 16:14:40 -05:00
commit d42203b1d4
111 changed files with 12543 additions and 3296 deletions

View File

@ -167,8 +167,10 @@
./examples/h5_select.c
./examples/h5_attribute.c
./examples/h5_mount.c
./examples/h5_reference.c
./examples/h5_ref2reg.c
./examples/h5_ref_compat.c
./examples/h5_ref_extern.c
./examples/h5_reference_deprec.c
./examples/h5_ref2reg_deprec.c
./examples/h5_shared_mesg.c
./examples/ph5example.c
./examples/h5_vds.c
@ -782,6 +784,7 @@
./src/H5Ochunk.c
./src/H5Ocont.c
./src/H5Ocopy.c
./src/H5Ocopy_ref.c
./src/H5Odbg.c
./src/H5Odeprec.c
./src/H5Odrvinfo.c
@ -911,6 +914,7 @@
./src/H5Tprecis.c
./src/H5Tprivate.h
./src/H5Tpublic.h
./src/H5Tref.c
./src/H5Tstrpad.c
./src/H5Tvisit.c
./src/H5Tvlen.c
@ -925,6 +929,7 @@
./src/H5VLnative.c
./src/H5VLnative.h
./src/H5VLnative_attr.c
./src/H5VLnative_blob.c
./src/H5VLnative_dataset.c
./src/H5VLnative_datatype.c
./src/H5VLnative_file.c
@ -1106,6 +1111,7 @@
./test/null_vol_connector.h
./test/ohdr.c
./test/objcopy.c
./test/objcopy_ref.c
./test/page_buffer.c
./test/paged_nopersist.h5
./test/paged_persist.h5
@ -1175,6 +1181,7 @@
./test/tmtimeo.h5
./test/ttime.c
./test/trefer.c
./test/trefer_deprec.c
./test/trefstr.c
./test/tselect.c
./test/tsizeslheap.h5

View File

@ -78,7 +78,9 @@ $Source = "";
"off_t" => "o",
"H5O_type_t" => "Ot",
"H5P_class_t" => "p",
"hobj_ref_t" => "r",
"hobj_ref_t" => "Ro",
"hdset_reg_ref_t" => "Rd",
"H5R_ref_t" => "Rr",
"H5R_type_t" => "Rt",
"char" => "s",
"unsigned char" => "s",
@ -99,6 +101,7 @@ $Source = "";
"unsigned long long" => "UL",
"H5VL_attr_get_t" => "Va",
"H5VL_attr_specific_t" => "Vb",
"H5VL_blob_specific_t" => "VB",
"H5VL_class_value_t" => "VC",
"H5VL_dataset_get_t" => "Vc",
"H5VL_dataset_specific_t" => "Vd",

View File

@ -369,10 +369,10 @@ void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DS
hid_t space_id = space.getId();
hid_t xfer_plist_id = xfer_plist.getId();
herr_t ret_value = H5Dvlen_reclaim(type_id, space_id, xfer_plist_id, buf);
herr_t ret_value = H5Treclaim(type_id, space_id, xfer_plist_id, buf);
if (ret_value < 0)
{
throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed");
throw DataSetIException("DataSet::vlenReclaim", "H5Treclaim failed");
}
}
@ -397,10 +397,10 @@ void DataSet::vlenReclaim(void* buf, const DataType& type, const DataSpace& spac
hid_t space_id = space.getId();
hid_t xfer_plist_id = xfer_plist.getId();
herr_t ret_value = H5Dvlen_reclaim(type_id, space_id, xfer_plist_id, buf);
herr_t ret_value = H5Treclaim(type_id, space_id, xfer_plist_id, buf);
if (ret_value < 0)
{
throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed");
throw DataSetIException("DataSet::vlenReclaim", "H5Treclaim failed");
}
}

View File

@ -66,7 +66,7 @@ class H5_DLLCPP DSetMemXferPropList : public PropList {
void getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const;
// Sets the memory manager for variable-length datatype
// allocation in H5Dread and H5Dvlen_reclaim.
// allocation in H5Dread and H5Treclaim.
void setVlenMemManager(H5MM_allocate_t alloc, void* alloc_info,
H5MM_free_t free, void* free_info) const;
@ -75,7 +75,7 @@ class H5_DLLCPP DSetMemXferPropList : public PropList {
void setVlenMemManager() const;
// Gets the memory manager for variable-length datatype
// allocation in H5Dread and H5Tvlen_reclaim.
// allocation in H5Dread and H5Treclaim.
void getVlenMemManager(H5MM_allocate_t& alloc, void** alloc_info,
H5MM_free_t& free, void** free_info) const;

View File

@ -23,9 +23,11 @@ set (examples
h5_select
h5_attribute
h5_mount
h5_reference
h5_ref_extern
h5_ref_compat
h5_reference_deprec
h5_drivers
h5_ref2reg
h5_ref2reg_deprec
h5_extlink
h5_elink_unix2win
h5_shared_mesg

View File

@ -34,8 +34,9 @@ INSTALL_TOP_FILES = README
EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \
h5_crtgrpd h5_subset h5_cmprss h5_rdwt h5_crtgrpar h5_extend \
h5_crtatt h5_crtgrp h5_crtdat \
h5_group h5_select h5_attribute h5_mount h5_reference h5_drivers \
h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg h5_vds h5_vds-exc \
h5_group h5_select h5_attribute h5_mount h5_reference_deprec h5_drivers \
h5_ref_extern h5_ref_compat \
h5_ref2reg_deprec h5_extlink h5_elink_unix2win h5_shared_mesg h5_vds h5_vds-exc \
h5_vds-exclim h5_vds-eiger h5_vds-simpleIO h5_vds-percival \
h5_vds-percival-unlim h5_vds-percival-unlim-maxmin
TEST_SCRIPT=testh5cc.sh
@ -47,8 +48,9 @@ INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \
h5_crtgrpd.c h5_subset.c h5_cmprss.c h5_rdwt.c h5_crtgrpar.c \
h5_extend.c h5_crtatt.c h5_crtgrp.c h5_crtdat.c \
h5_compound.c h5_group.c h5_select.c h5_attribute.c h5_mount.c \
h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \
h5_ref2reg.c h5_shared_mesg.c ph5example.c h5_vds.c h5_vds-exc.c \
h5_reference_deprec.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \
h5_ref_extern.c h5_ref_compat.c \
h5_ref2reg_deprec.c h5_shared_mesg.c ph5example.c h5_vds.c h5_vds-exc.c \
h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c h5_vds-percival.c \
h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c
@ -111,8 +113,10 @@ h5_read: $(srcdir)/h5_read.c
h5_select: $(srcdir)/h5_select.c
h5_attribute: $(srcdir)/h5_attribute.c
h5_mount: $(srcdir)/h5_mount.c
h5_reference: $(srcdir)/h5_reference.c
h5_ref2reg: $(srcdir)/h5_ref2reg.c
h5_ref_compat: $(srcdir)/h5_ref_compat.c
h5_ref_extern: $(srcdir)/h5_ref_extern.c
h5_reference_deprec: $(srcdir)/h5_reference_deprec.c
h5_ref2reg_deprec: $(srcdir)/h5_ref2reg_deprec.c
h5_drivers: $(srcdir)/h5_drivers.c
ph5example: $(srcdir)/ph5example.c
h5_dtransform: $(srcdir)/h5_dtransform.c

90
examples/h5_ref_compat.c Normal file
View File

@ -0,0 +1,90 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* The example below illustrates the use of the new API with a file that was
* written using the old-style reference API, showing how one can take
* advantage of the automatic type conversion from old reference type to new
* reference type.
*/
#include <stdlib.h>
#include "hdf5.h"
#include <assert.h>
#define H5FILE_NAME "refer_deprec.h5"
#define NDIMS 1 /* Number of dimensions */
#define BUF_SIZE 4 /* Size of example buffer */
#define NREFS 1 /* Number of references */
int
main(void) {
hid_t file1, dset1, space1;
hsize_t dset1_dims[NDIMS] = { BUF_SIZE };
int dset_buf[BUF_SIZE];
hid_t dset2, space2;
hsize_t dset2_dims[NDIMS] = { NREFS };
hobj_ref_t ref_buf[NREFS] = { 0 };
H5R_ref_t new_ref_buf[NREFS] = { 0 };
H5O_type_t obj_type;
int i;
for (i = 0; i < BUF_SIZE; i++)
dset_buf[i] = i;
/* Create file with one dataset and close it */
file1 = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
space1 = H5Screate_simple(NDIMS, dset1_dims, NULL);
dset1 = H5Dcreate2(file1, "dataset1", H5T_NATIVE_INT, space1, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Sclose(space1);
/**
* Create reference to dataset1 with deprecated API
* (reminder: there is no destroy call for those references)
*/
H5Rcreate(&ref_buf[0], file1, "dataset1", H5R_OBJECT, H5I_INVALID_HID);
/* Store reference in separate dataset using deprecated reference type */
space2 = H5Screate_simple(NDIMS, dset2_dims, NULL);
dset2 = H5Dcreate2(file1, "references", H5T_STD_REF_OBJ, space2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(dset2, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf);
H5Dclose(dset2);
H5Sclose(space2);
H5Fclose(file1);
/* Read reference from file using new reference type */
file1 = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT);
dset2 = H5Dopen2(file1, "references", H5P_DEFAULT);
H5Dread(dset2, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_ref_buf);
H5Dclose(dset2);
/* Access reference and read dataset data through new API */
assert(H5Rget_type((const H5R_ref_t *)&new_ref_buf[0]) == H5R_OBJECT2);
H5Rget_obj_type3((const H5R_ref_t *)&new_ref_buf[0], H5P_DEFAULT, &obj_type);
assert(obj_type == H5O_TYPE_DATASET);
dset1 = H5Ropen_object((const H5R_ref_t *)&new_ref_buf[0], H5P_DEFAULT, H5P_DEFAULT);
H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Rdestroy(&new_ref_buf[0]);
for (i = 0; i < BUF_SIZE; i++)
assert(dset_buf[i] == i);
return 0;
}

94
examples/h5_ref_extern.c Normal file
View File

@ -0,0 +1,94 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* The example below illustrates the use of the new API with files that are
* opened read-only. Created references to the objects in that file are
* stored into a separate file, and accessed from that file, without the user
* explicitly opening the original file that was referenced.
*/
#include <stdlib.h>
#include "hdf5.h"
#include <assert.h>
#define H5FILE_NAME1 "refer_extern1.h5"
#define H5FILE_NAME2 "refer_extern2.h5"
#define NDIMS 1 /* Number of dimensions */
#define BUF_SIZE 4 /* Size of example buffer */
#define NREFS 1 /* Number of references */
int
main(void) {
hid_t file1, dset1, space1;
hsize_t dset1_dims[NDIMS] = { BUF_SIZE };
int dset_buf[BUF_SIZE];
hid_t file2, dset2, space2;
hsize_t dset2_dims[NDIMS] = { NREFS };
H5R_ref_t ref_buf[NREFS] = { 0 };
H5O_type_t obj_type;
int i;
for (i = 0; i < BUF_SIZE; i++)
dset_buf[i] = i;
/* Create file with one dataset and close it */
file1 = H5Fcreate(H5FILE_NAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
space1 = H5Screate_simple(NDIMS, dset1_dims, NULL);
dset1 = H5Dcreate2(file1, "dataset1", H5T_NATIVE_INT, space1, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Sclose(space1);
H5Fclose(file1);
/* Create reference to dataset1 in "refer_extern1.h5" */
file1 = H5Fopen(H5FILE_NAME1, H5F_ACC_RDONLY, H5P_DEFAULT);
H5Rcreate_object(file1, "dataset1", &ref_buf[0]);
H5Fclose(file1);
/* Store reference in dataset in separate file "refer_extern2.h5" */
file2 = H5Fcreate(H5FILE_NAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
space2 = H5Screate_simple(NDIMS, dset2_dims, NULL);
dset2 = H5Dcreate2(file2, "references", H5T_STD_REF, space2, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(dset2, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf);
H5Dclose(dset2);
H5Sclose(space2);
H5Fclose(file2);
H5Rdestroy(&ref_buf[0]);
/* Read reference back from "refer_extern2.h5" */
file2 = H5Fopen(H5FILE_NAME2, H5F_ACC_RDONLY, H5P_DEFAULT);
dset2 = H5Dopen2(file2, "references", H5P_DEFAULT);
H5Dread(dset2, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf);
H5Dclose(dset2);
H5Fclose(file2);
/* Access reference and read dataset data without opening original file */
assert(H5Rget_type((const H5R_ref_t *)&ref_buf[0]) == H5R_OBJECT2);
H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[0], H5P_DEFAULT, &obj_type);
assert(obj_type == H5O_TYPE_DATASET);
dset1 = H5Ropen_object((const H5R_ref_t *)&ref_buf[0], H5P_DEFAULT, H5P_DEFAULT);
H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Rdestroy(&ref_buf[0]);
for (i = 0; i < BUF_SIZE; i++)
assert(dset_buf[i] == i);
return 0;
}

View File

@ -112,12 +112,16 @@ then
rm h5_attribute &&\
RunTest h5_mount &&\
rm h5_mount &&\
RunTest h5_reference &&\
rm h5_reference &&\
RunTest h5_reference_deprec &&\
rm h5_reference_deprec &&\
RunTest h5_ref_extern &&\
rm h5_ref_extern &&\
RunTest h5_ref_compat &&\
rm h5_ref_compat &&\
RunTest h5_drivers &&\
rm h5_drivers &&\
RunTest h5_ref2reg &&\
rm h5_ref2reg &&\
RunTest h5_ref2reg_deprec &&\
rm h5_ref2reg_deprec &&\
RunTest h5_extlink &&\
rm h5_extlink &&\
RunTest h5_elink_unix2win &&\

View File

@ -544,7 +544,7 @@ h5dvlen_get_max_len_c ( hid_t_f *dset_id , hid_t_f *type_id, hid_t_f *space_id,
c_len = 0;
for (i=0; i < num_elem; i++) c_len = H5_MAX(c_len, c_buf[i].len);
*len = (size_t_f)c_len;
H5Dvlen_reclaim(c_type_id, c_space_id, H5P_DEFAULT, c_buf);
H5Treclaim(c_type_id, c_space_id, H5P_DEFAULT, c_buf);
ret_value = 0;
DONE:
@ -690,7 +690,7 @@ h5dread_vl_integer_c ( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_sp
len[i] = (size_t_f)c_buf[i].len;
memcpy(&buf[i*max_len], c_buf[i].p, c_buf[i].len*sizeof(int_f));
}
H5Dvlen_reclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
ret_value = 0;
DONE:
HDfree(c_buf);
@ -779,7 +779,7 @@ h5dwrite_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_spa
if( status < 0) goto DONE;
ret_value = 0;
DONE:
H5Dvlen_reclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
HDfree(c_buf);
HDfree(tmp);
return ret_value;
@ -861,7 +861,7 @@ h5dread_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_spac
}
HD5packFstring(tmp, _fcdtocp(buf), (size_t)(max_len*num_elem));
ret_value = 0;
H5Dvlen_reclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
HDfree(c_buf);
HDfree(tmp);
return ret_value;
@ -1006,7 +1006,7 @@ h5dread_vl_real_c ( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_space
memcpy(&buf[i*max_len], c_buf[i].p, c_buf[i].len*sizeof(real_f));
}
H5Dvlen_reclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
ret_value = 0;
DONE:
HDfree(c_buf);
@ -1284,7 +1284,7 @@ h5dget_access_plist_c (hid_t_f *dset_id, hid_t_f *plist_id)
* NAME
* h5dvlen_reclaim_c
* PURPOSE
* Call H5Dvlen_reclaim
* Call H5Treclaim
* INPUTS
* type_id - Identifier of the datatype.
* space_id - Identifier of the dataspace.
@ -1307,9 +1307,9 @@ h5dvlen_reclaim_c(hid_t_f *type_id, hid_t_f *space_id, hid_t_f *plist_id, void *
herr_t status;
/*
* Call H5Dvlen_reclaim function.
* Call H5Treclaim function.
*/
status = H5Dvlen_reclaim((hid_t)*type_id, (hid_t)*space_id, (hid_t)*plist_id, buf);
status = H5Treclaim((hid_t)*type_id, (hid_t)*space_id, (hid_t)*plist_id, buf);
if ( status < 0 ) return ret_value;
ret_value = 0;

View File

@ -275,7 +275,7 @@ herr_t H5DSattach_scale(hid_t did,
goto out;
/* close */
if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0)
if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
if(H5Sclose(sid) < 0)
goto out;
@ -361,7 +361,7 @@ herr_t H5DSattach_scale(hid_t did,
goto out;
/* close */
if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0)
if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
if(H5Sclose(sid) < 0)
goto out;
@ -753,7 +753,7 @@ herr_t H5DSdetach_scale(hid_t did,
}
/* close */
if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0)
if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
if(H5Sclose(sid) < 0)
goto out;
@ -896,7 +896,7 @@ out:
dsbuf = NULL;
}
if(buf) {
/* Failure occured before H5Dvlen_reclaim was called;
/* Failure occured before H5Treclaim was called;
free the pointers allocated when we read data in */
for(i = 0; i < rank; i++) {
if(buf[i].p)
@ -1073,7 +1073,7 @@ htri_t H5DSis_attached(hid_t did,
/* close */
if (H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf) < 0)
if (H5Treclaim(tid,sid,H5P_DEFAULT,buf) < 0)
goto out;
if (H5Sclose(sid) < 0)
goto out;
@ -1373,7 +1373,7 @@ herr_t H5DSiterate_scales(hid_t did,
} /* if */
/* close */
if (H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf) < 0)
if (H5Treclaim(tid,sid,H5P_DEFAULT,buf) < 0)
goto out;
if (H5Sclose(sid) < 0)
goto out;
@ -1391,7 +1391,7 @@ herr_t H5DSiterate_scales(hid_t did,
out:
H5E_BEGIN_TRY {
if(buf) {
H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf);
H5Treclaim(tid,sid,H5P_DEFAULT,buf);
HDfree(buf);
}
H5Sclose(sid);
@ -2095,7 +2095,7 @@ int H5DSget_num_scales(hid_t did,
nscales = (int)buf[idx].len;
/* close */
if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0)
if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
if(H5Sclose(sid) < 0)
goto out;

View File

@ -940,7 +940,7 @@ herr_t H5PTfree_vlen_buff( hid_t table_id,
goto error;
/* Free the memory. If this succeeds, ret_value should be 0. */
if((ret_value = H5Dvlen_reclaim(table->type_id, space_id, H5P_DEFAULT, buff)) < 0)
if((ret_value = H5Treclaim(table->type_id, space_id, H5P_DEFAULT, buff)) < 0)
goto error;
/* If the dataspace cannot be closed, return -2 to indicate that memory */

View File

@ -248,6 +248,16 @@ New Features
(NAF - 2019/03/01)
- Add new H5R_ref_t type for object, dataset region and _attribute_
references. This new type will deprecate the current hobj_ref_t
and hdset_reg_ref_t types for references. Added H5T_REF datatype
to read and write new reference types. As opposed to previous
reference types, reference creation no longer modifies existing
files. New reference types also now support references to external
files.
(JS - 2019/10/08)
- Remove H5I_REFERENCE from the library
This ID class was never used by the library and has been removed.

View File

@ -446,6 +446,7 @@ set (H5O_SOURCES
${HDF5_SRC_DIR}/H5Ochunk.c
${HDF5_SRC_DIR}/H5Ocont.c
${HDF5_SRC_DIR}/H5Ocopy.c
${HDF5_SRC_DIR}/H5Ocopy_ref.c
${HDF5_SRC_DIR}/H5Odbg.c
${HDF5_SRC_DIR}/H5Odeprec.c
${HDF5_SRC_DIR}/H5Odrvinfo.c
@ -616,6 +617,7 @@ set (H5T_SOURCES
${HDF5_SRC_DIR}/H5Torder.c
${HDF5_SRC_DIR}/H5Tpad.c
${HDF5_SRC_DIR}/H5Tprecis.c
${HDF5_SRC_DIR}/H5Tref.c
${HDF5_SRC_DIR}/H5Tstrpad.c
${HDF5_SRC_DIR}/H5Tvisit.c
${HDF5_SRC_DIR}/H5Tvlen.c
@ -649,6 +651,7 @@ set (H5VL_SOURCES
${HDF5_SRC_DIR}/H5VLint.c
${HDF5_SRC_DIR}/H5VLnative.c
${HDF5_SRC_DIR}/H5VLnative_attr.c
${HDF5_SRC_DIR}/H5VLnative_blob.c
${HDF5_SRC_DIR}/H5VLnative_dataset.c
${HDF5_SRC_DIR}/H5VLnative_datatype.c
${HDF5_SRC_DIR}/H5VLnative_file.c

View File

@ -2270,7 +2270,7 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s
H5MM_memcpy(attr_dst->shared->data, buf, attr_dst->shared->data_size);
if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, NULL, "unable to reclaim variable-length data")
} /* end if */
else {
@ -2401,17 +2401,9 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src,
/* Check for expanding references */
if(cpy_info->expand_ref) {
size_t ref_count;
size_t dst_dt_size; /* Destination datatype size */
/* Determine size of the destination datatype */
if(0 == (dst_dt_size = H5T_get_size(attr_dst->shared->dt)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
/* Determine # of reference elements to copy */
ref_count = attr_dst->shared->data_size / dst_dt_size;
/* Copy objects referenced in source buffer to destination file and set destination elements */
if(H5O_copy_expand_ref(file_src, attr_dst->shared->data, file_dst, attr_dst->shared->data, ref_count, H5T_get_ref_type(attr_dst->shared->dt), cpy_info) < 0)
if(H5O_copy_expand_ref(file_src, H5I_INVALID_HID, attr_src->shared->dt,
attr_src->shared->data, attr_src->shared->data_size, file_dst, attr_dst->shared->data, cpy_info) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
} /* end if */
else

View File

@ -704,56 +704,6 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Diterate() */
/*-------------------------------------------------------------------------
* Function: H5Dvlen_reclaim
*
* Purpose: Frees the buffers allocated for storing variable-length data
* in memory. Only frees the VL data in the selection defined in the
* dataspace. The dataset transfer property list is required to find the
* correct allocation/free methods for the VL data in the buffer.
*
* Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Thursday, June 10, 1999
*
*-------------------------------------------------------------------------
*/
herr_t
H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf)
{
H5S_t *space; /* Dataspace for iteration */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "iii*x", type_id, space_id, dxpl_id, buf);
/* Check args */
if(H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument")
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace")
if(!(H5S_has_extent(space)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set")
/* Get the default dataset transfer property list if the user didn't provide one */
if(H5P_DEFAULT == dxpl_id)
dxpl_id = H5P_DATASET_XFER_DEFAULT;
else
if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
/* Call internal routine */
ret_value = H5D_vlen_reclaim(type_id, space, buf);
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Dvlen_reclaim() */
/*-------------------------------------------------------------------------
* Function: H5Dvlen_get_buf_size

View File

@ -6088,23 +6088,15 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed")
/* Reclaim space from variable length data */
if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, H5_ITER_ERROR, "unable to reclaim variable-length data")
} /* end if */
else if(fix_ref) {
/* Check for expanding references */
/* (background buffer has already been zeroed out, if not expanding) */
if(udata->cpy_info->expand_ref) {
size_t ref_count;
size_t dt_size;
/* Determine # of reference elements to copy */
if((dt_size = H5T_get_size(udata->dt_src)) == 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "size must not be 0")
ref_count = nbytes / dt_size;
/* Copy the reference elements */
if(H5O_copy_expand_ref(udata->file_src, buf, udata->idx_info_dst->f, bkg, ref_count, H5T_get_ref_type(udata->dt_src), udata->cpy_info) < 0)
if(H5O_copy_expand_ref(udata->file_src, udata->tid_src, udata->dt_src, buf, nbytes, udata->idx_info_dst->f, bkg, udata->cpy_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy reference attribute")
} /* end if */

View File

@ -551,26 +551,16 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds
H5MM_memcpy(storage_dst->buf, buf, storage_dst->size);
if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data")
} /* end if */
else if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) {
if(f_src != f_dst) {
/* Check for expanding references */
if(cpy_info->expand_ref) {
size_t ref_count;
size_t src_dt_size; /* Source datatype size */
/* Determine largest datatype size */
if(0 == (src_dt_size = H5T_get_size(dt_src)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
/* Determine # of reference elements to copy */
ref_count = storage_src->size / src_dt_size;
/* Copy objects referenced in source buffer to destination file and set destination elements */
if(H5O_copy_expand_ref(f_src, storage_src->buf, f_dst,
storage_dst->buf, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0)
if (H5O_copy_expand_ref(f_src, tid_src, dt_src, storage_src->buf,
storage_src->size, f_dst, storage_dst->buf, cpy_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
} /* end if */
else

View File

@ -1543,19 +1543,14 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
/* Reclaim space from variable length data */
if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data")
} /* end if */
else if(fix_ref) {
/* Check for expanding references */
if(cpy_info->expand_ref) {
size_t ref_count;
/* Determine # of reference elements to copy */
ref_count = src_nbytes / H5T_get_size(dt_src);
/* Copy the reference elements */
if(H5O_copy_expand_ref(f_src, buf, f_dst, bkg, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0)
if(H5O_copy_expand_ref(f_src, tid_src, dt_src, buf, buf_size, f_dst, bkg, cpy_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
/* After fix ref, copy the new reference elements to the buffer to write out */

View File

@ -303,5 +303,55 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Dextend() */
/*-------------------------------------------------------------------------
* Function: H5Dvlen_reclaim
*
* Purpose: Frees the buffers allocated for storing variable-length data
* in memory. Only frees the VL data in the selection defined in the
* dataspace. The dataset transfer property list is required to find the
* correct allocation/free methods for the VL data in the buffer.
*
* Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Thursday, June 10, 1999
*
*-------------------------------------------------------------------------
*/
herr_t
H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf)
{
H5S_t *space; /* Dataspace for iteration */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "iii*x", type_id, space_id, dxpl_id, buf);
/* Check args */
if(H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument")
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace")
if(!(H5S_has_extent(space)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set")
/* Get the default dataset transfer property list if the user didn't provide one */
if(H5P_DEFAULT == dxpl_id)
dxpl_id = H5P_DATASET_XFER_DEFAULT;
else
if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
/* Call internal routine */
ret_value = H5T_reclaim(type_id, space, buf);
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Dvlen_reclaim() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -547,7 +547,7 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type)
/* To use at least v18 format versions or not */
use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18);
/* Copy the datatype if it's a custom datatype or if it'll change when it's location is changed */
/* Copy the datatype if it's a custom datatype or if it'll change when its location is changed */
if(!immutable || relocatable || use_at_least_v18) {
/* Copy datatype for dataset */
if((dset->shared->type = H5T_copy(type, H5T_COPY_ALL)) == NULL)
@ -2540,50 +2540,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__get_offset() */
/*-------------------------------------------------------------------------
* Function: H5D_vlen_reclaim
*
* Purpose: Frees the buffers allocated for storing variable-length data
* in memory. Only frees the VL data in the selection defined in the
* dataspace.
*
* Return: Non-negative on success, negative on failure
*-------------------------------------------------------------------------
*/
herr_t
H5D_vlen_reclaim(hid_t type_id, H5S_t *space, void *buf)
{
H5T_t *type; /* Datatype */
H5S_sel_iter_op_t dset_op; /* Operator for iteration */
H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */
herr_t ret_value = FAIL; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Check args */
HDassert(H5I_DATATYPE == H5I_get_type(type_id));
HDassert(space);
HDassert(buf);
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype")
/* Get the allocation info */
if(H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info")
/* Call H5S_select_iterate with args, etc. */
dset_op.op_type = H5S_SEL_ITER_OP_APP;
dset_op.u.app_op.op = H5T_vlen_reclaim;
dset_op.u.app_op.type_id = type_id;
ret_value = H5S_select_iterate(buf, type, space, &dset_op, &vl_alloc_info);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_vlen_reclaim() */
/*-------------------------------------------------------------------------
* Function: H5D__vlen_get_buf_size_alloc

View File

@ -32,11 +32,6 @@
#include "H5VLnative_private.h" /* Native VOL connector */
#ifdef H5_HAVE_PARALLEL
/* Remove this if H5R_DATASET_REGION is no longer used in this file */
#include "H5Rpublic.h"
#endif /*H5_HAVE_PARALLEL*/
/****************/
/* Local Macros */
@ -478,33 +473,33 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set")
/* H5S_select_shape_same() has been modified to accept topologically identical
* selections with different rank as having the same shape (if the most
* rapidly changing coordinates match up), but the I/O code still has
* selections with different rank as having the same shape (if the most
* rapidly changing coordinates match up), but the I/O code still has
* difficulties with the notion.
*
* To solve this, we check to see if H5S_select_shape_same() returns true,
* and if the ranks of the mem and file spaces are different. If the are,
* construct a new mem space that is equivalent to the old mem space, and
* To solve this, we check to see if H5S_select_shape_same() returns true,
* and if the ranks of the mem and file spaces are different. If the are,
* construct a new mem space that is equivalent to the old mem space, and
* use that instead.
*
* Note that in general, this requires us to touch up the memory buffer as
* Note that in general, this requires us to touch up the memory buffer as
* well.
*/
if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) &&
H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) {
void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
/* to the beginning of the projected mem space. */
/* Attempt to construct projected dataspace for memory dataspace */
if(H5S_select_construct_projection(mem_space, &projected_mem_space,
(unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, (const void **)&adj_buf, type_info.dst_type_size) < 0)
(unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf, type_info.dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace")
HDassert(projected_mem_space);
HDassert(adj_buf);
/* Switch to using projected memory dataspace & adjusted buffer */
mem_space = projected_mem_space;
buf = adj_buf;
buf = (void *)adj_buf; /* Casting away 'const' OK -QAK */
} /* end if */
@ -712,27 +707,27 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
if(!(H5S_has_extent(mem_space)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set")
/* H5S_select_shape_same() has been modified to accept topologically
* identical selections with different rank as having the same shape
* (if the most rapidly changing coordinates match up), but the I/O
/* H5S_select_shape_same() has been modified to accept topologically
* identical selections with different rank as having the same shape
* (if the most rapidly changing coordinates match up), but the I/O
* code still has difficulties with the notion.
*
* To solve this, we check to see if H5S_select_shape_same() returns
* true, and if the ranks of the mem and file spaces are different.
* If the are, construct a new mem space that is equivalent to the
* To solve this, we check to see if H5S_select_shape_same() returns
* true, and if the ranks of the mem and file spaces are different.
* If the are, construct a new mem space that is equivalent to the
* old mem space, and use that instead.
*
* Note that in general, this requires us to touch up the memory buffer
* Note that in general, this requires us to touch up the memory buffer
* as well.
*/
if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) &&
H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) {
void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
/* to the beginning of the projected mem space. */
/* Attempt to construct projected dataspace for memory dataspace */
if(H5S_select_construct_projection(mem_space, &projected_mem_space,
(unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, (const void **)&adj_buf, type_info.src_type_size) < 0)
(unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf, type_info.src_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace")
HDassert(projected_mem_space);
HDassert(adj_buf);

View File

@ -170,9 +170,6 @@ H5_DLL herr_t H5D_flush_all(H5F_t *f);
H5_DLL hid_t H5D_get_create_plist(const H5D_t *dset);
H5_DLL hid_t H5D_get_access_plist(const H5D_t *dset);
/* Functions that operate on vlen data */
H5_DLL herr_t H5D_vlen_reclaim(hid_t type_id, H5S_t *space, void *buf);
/* Functions that operate on chunked storage */
H5_DLL herr_t H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr);

View File

@ -156,7 +156,6 @@ H5_DLL herr_t H5Dread_chunk(hid_t dset_id, hid_t dxpl_id,
const hsize_t *offset, uint32_t *filters, void *buf);
H5_DLL herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id,
H5D_operator_t op, void *operator_data);
H5_DLL herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf);
H5_DLL herr_t H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size);
H5_DLL herr_t H5Dfill(const void *fill, hid_t fill_type, void *buf,
hid_t buf_type, hid_t space);
@ -203,6 +202,7 @@ H5_DLL hid_t H5Dcreate1(hid_t file_id, const char *name, hid_t type_id,
hid_t space_id, hid_t dcpl_id);
H5_DLL hid_t H5Dopen1(hid_t file_id, const char *name);
H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t size[]);
H5_DLL herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf);
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -22,15 +22,15 @@
#include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */
#include "H5private.h" /* Generic Functions */
#include "H5private.h" /* Generic Functions */
#include "H5CXprivate.h" /* API Contexts */
#include "H5Dprivate.h" /* Dataset functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* File access */
#include "H5FDprivate.h" /* File drivers */
#include "H5FDmpi.h" /* MPI-based file drivers */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Dprivate.h" /* Dataset functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* File access */
#include "H5FDprivate.h" /* File drivers */
#include "H5FDmpi.h" /* MPI-based file drivers */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
#ifdef H5_HAVE_PARALLEL
@ -1324,6 +1324,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__mpio_read() */
/*-------------------------------------------------------------------------
* Function: H5FD__mpio_write
@ -1366,6 +1367,7 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id,
#endif
int size_i;
hbool_t use_view_this_time = FALSE;
hbool_t derived_type = FALSE;
H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */
herr_t ret_value = SUCCEED;
@ -1391,8 +1393,6 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id,
if(H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off")
size_i = (int)size;
if((hsize_t)size_i != size)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i")
#ifdef H5FDmpio_DEBUG
if(H5FD_mpio_Debug[(int)'w'])
@ -1430,6 +1430,20 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id,
*/
mpi_off = 0;
} /* end if */
else if(size != (hsize_t)size_i) {
/* If HERE, then we need to work around the integer size limit
* of 2GB. The input size_t size variable cannot fit into an integer,
* but we can get around that limitation by creating a different datatype
* and then setting the integer size (or element count) to 1 when using
* the derived_type.
*/
if (H5_mpio_create_large_type(size, 0, MPI_BYTE, &buf_type) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "can't create MPI-I/O datatype")
derived_type = TRUE;
size_i = 1;
}
/* Write the data. */
if(use_view_this_time) {
@ -1506,6 +1520,9 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id,
file->local_eof = addr + (haddr_t)bytes_written;
done:
if(derived_type) {
MPI_Type_free(&buf_type);
}
#ifdef H5FDmpio_DEBUG
if(H5FD_mpio_Debug[(int)'t'])
HDfprintf(stdout, "%s: Leaving, proc %d: ret_value = %d\n", FUNC, file->mpi_rank, ret_value );

View File

@ -139,18 +139,14 @@ H5F__set_vol_conn(H5F_t *file)
/* Sanity check */
HDassert(0 != connector_prop.connector_id);
/* Copy connector info, if it exists */
if(connector_prop.connector_info) {
H5VL_class_t *connector; /* Pointer to connector */
/* Retrieve the connector for the ID */
if(NULL == (file->shared->vol_cls = (H5VL_class_t *)H5I_object(connector_prop.connector_id)))
HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID")
/* Retrieve the connector for the ID */
if(NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop.connector_id)))
HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID")
/* Allocate and copy connector info */
if(H5VL_copy_connector_info(connector, &new_connector_info, connector_prop.connector_info) < 0)
/* Allocate and copy connector info, if it exists */
if(connector_prop.connector_info)
if(H5VL_copy_connector_info(file->shared->vol_cls, &new_connector_info, connector_prop.connector_info) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "connector info copy failed")
} /* end if */
/* Cache the connector ID & info for the container */
file->shared->vol_id = connector_prop.connector_id;
@ -1377,6 +1373,7 @@ H5F__dest(H5F_t *f, hbool_t flush)
if(H5I_dec_ref(f->shared->vol_id) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close VOL connector ID")
f->shared->vol_cls = NULL;
/* Close the file */
if(H5FD_close(f->shared->lf) < 0)

View File

@ -29,9 +29,6 @@
/* Get package's private header */
#include "H5Fprivate.h"
/* Other public headers needed by this file */
#include "H5VLpublic.h" /* Virtual Object Layer */
/* Other private headers needed by this file */
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
@ -313,6 +310,7 @@ struct H5F_shared_t {
/* Cached VOL connector ID & info */
hid_t vol_id; /* ID of VOL connector for the container */
const H5VL_class_t *vol_cls; /* Pointer to VOL connector class for the container */
void *vol_info; /* Copy of VOL connector info for container */
/* File space allocation information */
@ -413,6 +411,7 @@ H5_DLL herr_t H5F__close(H5F_t *f);
H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high);
H5_DLL H5F_t *H5F__get_file(void *obj, H5I_type_t type);
H5_DLL hid_t H5F__get_file_id(H5F_t *file, hbool_t app_ref);
H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info);
/* File mount related routines */
H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id);

View File

@ -25,14 +25,15 @@ typedef struct H5F_t H5F_t;
#include "H5Fpublic.h"
/* Public headers needed by this file */
#include "H5FDpublic.h" /* File drivers */
#include "H5FDpublic.h" /* File drivers */
#include "H5VLpublic.h" /* Virtual Object Layer */
/* Private headers needed by this file */
#include "H5MMprivate.h" /* Memory management */
#include "H5MMprivate.h" /* Memory management */
#ifdef H5_HAVE_PARALLEL
#include "H5Pprivate.h" /* Property lists */
#include "H5Pprivate.h" /* Property lists */
#endif /* H5_HAVE_PARALLEL */
#include "H5VMprivate.h" /* Vectors and arrays */
#include "H5VMprivate.h" /* Vectors and arrays */
/**************************/
@ -335,6 +336,7 @@ typedef struct H5F_t H5F_t;
#define H5F_NULL_FSM_ADDR(F) ((F)->shared->null_fsm_addr)
#define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag)
#define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V))
#define H5F_VOL_CLS(F) ((F)->shared->vol_cls)
#else /* H5F_MODULE */
#define H5F_LOW_BOUND(F) (H5F_get_low_bound(F))
#define H5F_HIGH_BOUND(F) (H5F_get_high_bound(F))
@ -395,6 +397,7 @@ typedef struct H5F_t H5F_t;
#define H5F_NULL_FSM_ADDR(F) (H5F_get_null_fsm_addr(F))
#define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F))
#define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V)))
#define H5F_VOL_CLS(F) (H5F_get_vol_cls(F))
#endif /* H5F_MODULE */
@ -755,6 +758,7 @@ H5_DLL hbool_t H5F_get_point_of_no_return(const H5F_t *f);
H5_DLL hbool_t H5F_get_null_fsm_addr(const H5F_t *f);
H5_DLL hbool_t H5F_get_min_dset_ohdr(const H5F_t *f);
H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize);
H5_DLL const H5VL_class_t *H5F_get_vol_cls(const H5F_t *f);
/* Functions than retrieve values set/cached from the superblock/FCPL */
H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f);

View File

@ -1279,3 +1279,66 @@ H5F_get_null_fsm_addr(const H5F_t *f)
FUNC_LEAVE_NOAPI(f->shared->null_fsm_addr)
} /* end H5F_get_null_fsm_addr() */
/*-------------------------------------------------------------------------
* Function: H5F_get_vol_cls
*
* Purpose: Get the VOL class for the file
*
* Return: VOL class pointer for file, can't fail
*
* Programmer: Quincey Koziol
* Saturday, August 17, 2019
*
*-------------------------------------------------------------------------
*/
const H5VL_class_t *
H5F_get_vol_cls(const H5F_t *f)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(f);
HDassert(f->shared);
FUNC_LEAVE_NOAPI(f->shared->vol_cls)
} /* end H5F_get_vol_cls */
/*-------------------------------------------------------------------------
* Function: H5F_get_cont_info
*
* Purpose: Get the VOL container info for the file
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Saturday, August 17, 2019
*
*-------------------------------------------------------------------------
*/
herr_t
H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(f);
HDassert(f->shared);
/* Verify structure version */
if(info->version != H5VL_CONTAINER_INFO_VERSION)
HGOTO_ERROR(H5E_FILE, H5E_VERSION, FAIL, "wrong container info version #")
/* Set the container info fields */
info->feature_flags = 0; /* None currently defined */
info->token_size = H5F_SIZEOF_ADDR(f);
info->blob_id_size = H5HG_HEAP_ID_SIZE(f);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_get_cont_info */

View File

@ -49,6 +49,10 @@ typedef struct H5HG_heap_t H5HG_heap_t;
#define H5HG_FREE_SIZE(H) (H5HG_get_free_size(H))
#endif /* H5HG_MODULE */
/* Size of encoded global heap ID */
/* (size of file address + 32-bit integer) */
#define H5HG_HEAP_ID_SIZE(F) ((size_t)H5F_SIZEOF_ADDR(F) + H5_SIZEOF_UINT32_T)
/* Main global heap routines */
H5_DLL herr_t H5HG_insert(H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/);

View File

@ -263,8 +263,8 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE2("i", "ia", loc_id, addr);
loc_params.type = H5VL_OBJECT_BY_ADDR;
loc_params.loc_data.loc_by_addr.addr = addr;
loc_params.type = H5VL_OBJECT_BY_TOKEN;
loc_params.loc_data.loc_by_token.token = &addr;
loc_params.obj_type = H5I_get_type(loc_id);
/* Get the location object */

View File

@ -85,8 +85,6 @@ static herr_t H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*
hid_t ocpypl_id, hid_t lcpl_id);
static herr_t H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc,
const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id);
static herr_t H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc,
H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info);
static herr_t H5O__copy_free_comm_dt_cb(void *item, void *key, void *op_data);
static int H5O__copy_comm_dt_cmp(const void *dt1, const void *dt2);
static herr_t H5O__copy_search_comm_dt_cb(hid_t group, const char *name,
@ -110,7 +108,6 @@ H5FL_DEFINE(H5O_copy_search_comm_dt_key_t);
/* Declare a free list to manage haddr_t variables */
H5FL_DEFINE(haddr_t);
/*****************************/
/* Library Private Variables */
/*****************************/
@ -1233,201 +1230,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__copy_obj() */
/*-------------------------------------------------------------------------
* Function: H5O__copy_obj_by_ref
*
* Purpose: Copy the object pointed by _src_ref.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Peter Cao
* Aug 7 2006
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc,
H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
HDassert(src_oloc);
HDassert(dst_oloc);
/* Perform the copy, or look up existing copy */
if((ret_value = H5O_copy_header_map(src_oloc, dst_oloc, cpy_info, FALSE, NULL, NULL)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Check if a new valid object is copied to the destination */
if(H5F_addr_defined(dst_oloc->addr) && (ret_value > SUCCEED)) {
char tmp_obj_name[80];
H5G_name_t new_path;
H5O_loc_t new_oloc;
H5G_loc_t new_loc;
/* Set up group location for new object */
new_loc.oloc = &new_oloc;
new_loc.path = &new_path;
H5G_loc_reset(&new_loc);
new_oloc.file = dst_oloc->file;
new_oloc.addr = dst_oloc->addr;
/* Pick a default name for the new object */
HDsnprintf(tmp_obj_name, sizeof(tmp_obj_name), "~obj_pointed_by_%llu", (unsigned long long)dst_oloc->addr);
/* Create a link to the newly copied object */
/* Note: since H5O_copy_header_map actually copied the target object, it
* must exist either in cache or on disk, therefore it is is safe to not
* pass the obj_type and udata fields returned by H5O_copy_header_map.
* This could be changed in the future to slightly improve performance
* --NAF */
if(H5L_link(dst_root_loc, tmp_obj_name, &new_loc, cpy_info->lcpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert link")
H5G_loc_free(&new_loc);
} /* if (H5F_addr_defined(dst_oloc.addr)) */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__copy_obj_by_ref() */
/*-------------------------------------------------------------------------
* Function: H5O_copy_expand_ref
*
* Purpose: Copy the object pointed by _src_ref.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Peter Cao
* Aug 7 2006
*
*-------------------------------------------------------------------------
*/
herr_t
H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, H5F_t *file_dst,
void *_dst_ref, size_t ref_count, H5R_type_t ref_type, H5O_copy_t *cpy_info)
{
H5O_loc_t dst_oloc; /* Copied object object location */
H5O_loc_t src_oloc; /* Temporary object location for source object */
H5G_loc_t dst_root_loc; /* The location of root group of the destination file */
const uint8_t *q; /* Pointer to source OID to store */
uint8_t *p; /* Pointer to destination OID to store */
size_t i; /* Local index variable */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
/* Sanity checks */
HDassert(file_src);
HDassert(_src_ref);
HDassert(file_dst);
HDassert(_dst_ref);
HDassert(ref_count);
HDassert(cpy_info);
/* Initialize object locations */
H5O_loc_reset(&src_oloc);
H5O_loc_reset(&dst_oloc);
src_oloc.file = file_src;
dst_oloc.file = file_dst;
/* Set up the root group in the destination file */
if(NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(file_dst))))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group")
if(NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(file_dst))))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group")
/* Copy object references */
if(H5R_OBJECT == ref_type) {
hobj_ref_t *src_ref = (hobj_ref_t *)_src_ref;
hobj_ref_t *dst_ref = (hobj_ref_t *)_dst_ref;
/* Making equivalent references in the destination file */
for(i = 0; i < ref_count; i++) {
/* Set up for the object copy for the reference */
q = (uint8_t *)(&src_ref[i]);
H5F_addr_decode(src_oloc.file, (const uint8_t **)&q, &(src_oloc.addr));
dst_oloc.addr = HADDR_UNDEF;
/* Attempt to copy object from source to destination file */
if(src_oloc.addr != (haddr_t)0) {
if(H5O__copy_obj_by_ref(&src_oloc, &dst_oloc, &dst_root_loc, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
} /* end if */
else
/* Set parameters so the reference is written as all 0's */
HDmemset(&dst_oloc.addr, 0, sizeof(dst_oloc.addr));
/* Set the object reference info for the destination file */
p = (uint8_t *)(&dst_ref[i]);
H5F_addr_encode(dst_oloc.file, &p, dst_oloc.addr);
} /* end for */
} /* end if */
/* Copy region references */
else if(H5R_DATASET_REGION == ref_type) {
hdset_reg_ref_t *src_ref = (hdset_reg_ref_t *)_src_ref;
hdset_reg_ref_t *dst_ref = (hdset_reg_ref_t *)_dst_ref;
uint8_t *buf = NULL; /* Buffer to store serialized selection in */
H5HG_t hobjid; /* Heap object ID */
size_t buf_size; /* Length of object in heap */
/* Making equivalent references in the destination file */
for(i = 0; i < ref_count; i++) {
/* Get the heap ID for the dataset region */
q = (const uint8_t *)(&src_ref[i]);
H5F_addr_decode(src_oloc.file, (const uint8_t **)&q, &(hobjid.addr));
UINT32DECODE(q, hobjid.idx);
if(hobjid.addr != (haddr_t)0) {
/* Get the dataset region from the heap (allocate inside routine) */
if((buf = (uint8_t *)H5HG_read(src_oloc.file, &hobjid, NULL, &buf_size)) == NULL)
HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information")
/* Get the object oid for the dataset */
q = (const uint8_t *)buf;
H5F_addr_decode(src_oloc.file, (const uint8_t **)&q, &(src_oloc.addr));
dst_oloc.addr = HADDR_UNDEF;
/* copy the object pointed by the ref to the destination */
if(H5O__copy_obj_by_ref(&src_oloc, &dst_oloc, &dst_root_loc, cpy_info) < 0) {
H5MM_xfree(buf);
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
} /* end if */
/* Serialize object ID */
p = (uint8_t *)buf;
H5F_addr_encode(dst_oloc.file, &p, dst_oloc.addr);
/* Save the serialized buffer to the destination */
if(H5HG_insert(dst_oloc.file, buf_size, buf, &hobjid) < 0) {
H5MM_xfree(buf);
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "Unable to write dataset region information")
} /* end if */
} /* end if */
else
/* Set parameters so the reference is written as all 0's */
HDmemset(&hobjid, 0, sizeof(hobjid));
/* Set the dataset region reference info for the destination file */
p = (uint8_t *)(&dst_ref[i]);
H5F_addr_encode(dst_oloc.file, &p, hobjid.addr);
UINT32ENCODE(p, hobjid.idx);
/* Free the buffer allocated in H5HG_read() */
H5MM_xfree(buf);
} /* end for */
} /* end if */
else
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_copy_expand_ref() */
/*-------------------------------------------------------------------------
* Function: H5O__copy_free_comm_dt_cb

485
src/H5Ocopy_ref.c Normal file
View File

@ -0,0 +1,485 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*-------------------------------------------------------------------------
*
* Created: H5Ocopy_ref.c
*
* Purpose: Object with references copying routines.
*
*-------------------------------------------------------------------------
*/
/****************/
/* Module Setup */
/****************/
#include "H5Omodule.h" /* This source code file is part of the H5O module */
#define H5F_FRIEND /* Suppress error about including H5Fpkg */
#define H5R_FRIEND /* Suppress error about including H5Rpkg */
/***********/
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Fpkg.h" /* File */
#include "H5Iprivate.h" /* IDs */
#include "H5Lprivate.h" /* Links */
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5Rpkg.h" /* References */
/****************/
/* Local Macros */
/****************/
/******************/
/* Local Typedefs */
/******************/
/********************/
/* Package Typedefs */
/********************/
/********************/
/* Local Prototypes */
/********************/
static herr_t H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc,
H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info);
static herr_t H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc,
const void *buf_src, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc,
void *buf_dst, size_t ref_count, H5O_copy_t *cpy_info);
static herr_t H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc,
const void *buf_src, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc,
void *buf_dst, size_t ref_count, H5O_copy_t *cpy_info);
static herr_t H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src,
H5T_t *dt_src, const void *buf_src, size_t nbytes_src, H5O_loc_t *dst_oloc,
H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count,
H5O_copy_t *cpy_info);
/*********************/
/* Package Variables */
/*********************/
/* Declare extern the free list to manage blocks of type conversion data */
H5FL_BLK_EXTERN(type_conv);
/*****************************/
/* Library Private Variables */
/*****************************/
/*******************/
/* Local Variables */
/*******************/
/*-------------------------------------------------------------------------
* Function: H5O__copy_obj_by_ref
*
* Purpose: Copy the object pointed to by src_oloc.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc,
H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
HDassert(src_oloc);
HDassert(dst_oloc);
/* Perform the copy, or look up existing copy */
if((ret_value = H5O_copy_header_map(src_oloc, dst_oloc, cpy_info, FALSE, NULL, NULL)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Check if a new valid object is copied to the destination */
if(H5F_addr_defined(dst_oloc->addr) && (ret_value > SUCCEED)) {
char tmp_obj_name[80];
H5G_name_t new_path;
H5O_loc_t new_oloc;
H5G_loc_t new_loc;
/* Set up group location for new object */
new_loc.oloc = &new_oloc;
new_loc.path = &new_path;
H5G_loc_reset(&new_loc);
new_oloc.file = dst_oloc->file;
new_oloc.addr = dst_oloc->addr;
/* Pick a default name for the new object */
HDsnprintf(tmp_obj_name, sizeof(tmp_obj_name), "~obj_pointed_by_%llu", (unsigned long long)dst_oloc->addr);
/* Create a link to the newly copied object */
/* Note: since H5O_copy_header_map actually copied the target object, it
* must exist either in cache or on disk, therefore it is is safe to not
* pass the obj_type and udata fields returned by H5O_copy_header_map.
* This could be changed in the future to slightly improve performance
* --NAF */
if(H5L_link(dst_root_loc, tmp_obj_name, &new_loc, cpy_info->lcpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert link")
H5G_loc_free(&new_loc);
} /* if (H5F_addr_defined(dst_oloc.addr)) */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__copy_obj_by_ref() */
/*-------------------------------------------------------------------------
* Function: H5O__copy_expand_ref_object1
*
* Purpose: Copy the object pointed by a deprecated object reference.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src,
H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, void *buf_dst,
size_t ref_count, H5O_copy_t *cpy_info)
{
const hobj_ref_t *src_ref = (const hobj_ref_t *)buf_src;
hobj_ref_t *dst_ref = (hobj_ref_t *)buf_dst;
const unsigned char zeros[H5R_OBJ_REF_BUF_SIZE] = { 0 };
size_t buf_size = H5R_OBJ_REF_BUF_SIZE;
size_t i; /* Local index variable */
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
/* Making equivalent references in the destination file */
for(i = 0; i < ref_count; i++) {
const unsigned char *src_buf = (const unsigned char *)&src_ref[i];
unsigned char *dst_buf = (unsigned char *)&dst_ref[i];
/* If data is not initialized, copy zeros and skip */
if(0 == HDmemcmp(src_buf, zeros, buf_size)) {
HDmemset(dst_buf, 0, buf_size);
continue;
}
/* Set up for the object copy for the reference */
if(H5R__decode_addr_obj_compat(src_buf, &buf_size, &src_oloc->addr) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode src object address")
if(!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer")
dst_oloc->addr = HADDR_UNDEF;
/* Attempt to copy object from source to destination file */
if(H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Set the object reference info for the destination file */
if(H5R__encode_addr_obj_compat(dst_oloc->addr, dst_buf, &buf_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to encode dst object address")
} /* end for */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__copy_expand_ref_object1() */
/*-------------------------------------------------------------------------
* Function: H5O__copy_expand_ref_region1
*
* Purpose: Copy the object pointed by a deprecated region reference.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src,
H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, void *buf_dst,
size_t ref_count, H5O_copy_t *cpy_info)
{
const hdset_reg_ref_t *src_ref = (const hdset_reg_ref_t *)buf_src;
hdset_reg_ref_t *dst_ref = (hdset_reg_ref_t *)buf_dst;
const unsigned char zeros[H5R_DSET_REG_REF_BUF_SIZE] = { 0 };
size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE;
size_t i; /* Local index variable */
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
/* Making equivalent references in the destination file */
for(i = 0; i < ref_count; i++) {
const unsigned char *src_buf = (const unsigned char *)&src_ref[i];
unsigned char *dst_buf = (unsigned char *)&dst_ref[i];
unsigned char *data = NULL;
size_t data_size;
const uint8_t *p;
uint8_t *q;
/* If data is not initialized, copy zeros and skip */
if(0 == HDmemcmp(src_buf, zeros, buf_size)) {
HDmemset(dst_buf, 0, buf_size);
continue;
}
/* Read from heap */
if(H5R__decode_heap(src_oloc->file, src_buf, &buf_size, &data, &data_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode dataset region information")
/* Get object address */
p = (const uint8_t *)data;
H5F_addr_decode(src_oloc->file, &p, &src_oloc->addr);
if(!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0) {
H5MM_free(data);
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer")
}
dst_oloc->addr = HADDR_UNDEF;
/* Attempt to copy object from source to destination file */
if(H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) {
H5MM_free(data);
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
} /* end if */
/* Serialize object addr */
q = (uint8_t *)data;
H5F_addr_encode(dst_oloc->file, &q, dst_oloc->addr);
/* Write to heap */
if(H5R__encode_heap(dst_oloc->file, dst_buf, &buf_size, data, (size_t)data_size) < 0) {
H5MM_free(data);
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode dataset region information")
}
/* Free the buffer allocated in H5R__decode_heap() */
H5MM_free(data);
} /* end for */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__copy_expand_ref_region1() */
/*-------------------------------------------------------------------------
* Function: H5O__copy_expand_ref_object2
*
* Purpose: Copy the object pointed by a reference (object, region, attribute).
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src,
const void *buf_src, size_t nbytes_src, H5O_loc_t *dst_oloc,
H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count,
H5O_copy_t *cpy_info)
{
H5T_t *dt_mem = NULL; /* Memory datatype */
H5T_t *dt_dst = NULL; /* Destination datatype */
hid_t tid_mem = H5I_INVALID_HID; /* Datatype ID for memory datatype */
hid_t tid_dst = H5I_INVALID_HID; /* Datatype ID for memory datatype */
H5T_path_t *tpath_src_mem = NULL,
*tpath_mem_dst = NULL; /* Datatype conversion paths */
size_t i; /* Local index variable */
hbool_t reg_tid_src = (tid_src == H5I_INVALID_HID);
hid_t dst_loc_id = H5I_INVALID_HID;
void *conv_buf = NULL; /* Buffer for converting data */
size_t conv_buf_size = 0; /* Buffer size */
void *reclaim_buf = NULL; /* Buffer for reclaiming data */
H5S_t *buf_space = NULL; /* Dataspace describing buffer */
hsize_t buf_dim[1] = {ref_count}; /* Dimension for buffer */
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
/* Create datatype ID for src datatype. */
if((tid_src == H5I_INVALID_HID) && (tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
/* create a memory copy of the reference datatype */
if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy")
if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) {
(void)H5T_close_real(dt_mem);
HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
} /* end if */
/* create reference datatype at the destinaton file */
if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy")
if(H5T_set_loc(dt_dst, dst_oloc->file, H5T_LOC_DISK) < 0) {
(void)H5T_close_real(dt_dst);
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
} /* end if */
if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) {
(void)H5T_close_real(dt_dst);
HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype")
} /* end if */
/* Set up the conversion functions */
if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes")
if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes")
/* Use extra conversion buffer (TODO we should avoid using an extra buffer once the H5Ocopy code has been reworked) */
conv_buf_size = MAX(H5T_get_size(dt_src), H5T_get_size(dt_mem)) * ref_count;
if(NULL == (conv_buf = H5FL_BLK_MALLOC(type_conv, conv_buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer")
H5MM_memcpy(conv_buf, buf_src, nbytes_src);
/* Convert from source file to memory */
if(H5T_convert(tpath_src_mem, tid_src, tid_mem, ref_count, (size_t)0, (size_t)0, conv_buf, NULL) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
/* Retrieve loc ID */
if((dst_loc_id = H5F__get_file_id(dst_oloc->file, FALSE)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Making equivalent references in the destination file */
for(i = 0; i < ref_count; i++) {
H5R_ref_t *ref_ptr = (H5R_ref_t *)conv_buf;
H5R_ref_priv_t *ref = (H5R_ref_priv_t *)&ref_ptr[i];
size_t token_size = sizeof(src_oloc->addr);
/* Get src object address */
if(H5R__get_obj_token(ref, (H5VL_token_t *)&src_oloc->addr, &token_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object token")
/* Attempt to copy object from source to destination file */
if(H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Set dst object address */
if(H5R__set_obj_token(ref, (const H5VL_token_t *)&dst_oloc->addr, token_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set object token")
if(H5R__set_loc_id(ref, dst_loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set destination loc id")
} /* end for */
/* Copy into another buffer, to reclaim memory later */
if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, conv_buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer")
H5MM_memcpy(reclaim_buf, conv_buf, conv_buf_size);
if(NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
/* Convert from memory to destination file */
if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, ref_count, (size_t)0, (size_t)0, conv_buf, NULL) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
H5MM_memcpy(buf_dst, conv_buf, nbytes_src);
/* Reclaim space from reference data */
if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "unable to reclaim reference data")
done:
if(buf_space && (H5S_close(buf_space) < 0))
HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't close dataspace")
/* Don't decrement ID, we want to keep underlying datatype */
if(reg_tid_src && (tid_src > 0) && (NULL == H5I_remove(tid_src)))
HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if((tid_mem > 0) && H5I_dec_ref(tid_mem) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if((tid_dst > 0) && H5I_dec_ref(tid_dst) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(reclaim_buf)
reclaim_buf = H5FL_BLK_FREE(type_conv, reclaim_buf);
if(conv_buf)
conv_buf = H5FL_BLK_FREE(type_conv, conv_buf);
if((dst_loc_id != H5I_INVALID_HID) && (H5I_dec_ref(dst_loc_id) < 0))
HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__copy_expand_ref_object2() */
/*-------------------------------------------------------------------------
* Function: H5O_copy_expand_ref
*
* Purpose: Copy the object pointed by a reference.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src,
void *buf_src, size_t nbytes_src, H5F_t *file_dst, void *buf_dst,
H5O_copy_t *cpy_info)
{
H5O_loc_t dst_oloc; /* Copied object object location */
H5O_loc_t src_oloc; /* Temporary object location for source object */
H5G_loc_t dst_root_loc; /* The location of root group of the destination file */
size_t ref_count;
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
/* Sanity checks */
HDassert(file_src);
HDassert(buf_src);
HDassert(file_dst);
HDassert(buf_dst);
HDassert(nbytes_src);
HDassert(cpy_info);
/* Initialize object locations */
H5O_loc_reset(&src_oloc);
H5O_loc_reset(&dst_oloc);
src_oloc.file = file_src;
dst_oloc.file = file_dst;
/* Set up the root group in the destination file */
if(NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(file_dst))))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group")
if(NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(file_dst))))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group")
/* Determine # of reference elements to copy */
ref_count = nbytes_src / H5T_get_size(dt_src);
/* Copy object references */
switch(H5T_get_ref_type(dt_src)) {
case H5R_OBJECT1:
if(H5O__copy_expand_ref_object1(&src_oloc, buf_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to expand H5R_OBJECT1 reference")
break;
case H5R_DATASET_REGION1:
if(H5O__copy_expand_ref_region1(&src_oloc, buf_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to expand H5R_DATASET_REGION1 reference")
break;
case H5R_DATASET_REGION2:
case H5R_ATTR:
case H5R_OBJECT2:
if(H5O__copy_expand_ref_object2(&src_oloc, tid_src, dt_src, buf_src, nbytes_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to expand reference")
break;
case H5R_BADTYPE:
case H5R_MAXTYPE:
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
break;
} /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_copy_expand_ref() */

View File

@ -129,7 +129,7 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{
*-------------------------------------------------------------------------
*/
static htri_t
H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t *dt)
H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t *dt)
{
unsigned flags, version;
unsigned i;
@ -145,7 +145,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
/* Version, class & flags */
UINT32DECODE(*pp, flags);
version = (flags>>4) & 0x0f;
if(version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_3)
if(version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_LATEST)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "bad version number for datatype message")
dt->shared->version = version;
dt->shared->type = (H5T_class_t)(flags & 0x0f);
@ -331,7 +331,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Decode the field's datatype information */
if((can_upgrade = H5O_dtype_decode_helper(f, ioflags, pp, temp_type)) < 0) {
if((can_upgrade = H5O_dtype_decode_helper(ioflags, pp, temp_type)) < 0) {
for(j = 0; j <= i; j++)
H5MM_xfree(dt->shared->u.compnd.memb[j].name);
H5MM_xfree(dt->shared->u.compnd.memb);
@ -438,16 +438,28 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
/* Set reference type */
dt->shared->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f);
if(dt->shared->u.atomic.u.r.rtype <= H5R_BADTYPE
|| dt->shared->u.atomic.u.r.rtype >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "invalid reference type");
/* Set extra information for object references, so the hobj_ref_t gets swizzled correctly */
if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT) {
/* Mark location this type as undefined for now. The caller function should
* decide the location. */
dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC;
/* Set generic flag */
if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT2
|| dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION2
|| dt->shared->u.atomic.u.r.rtype == H5R_ATTR) {
dt->shared->u.atomic.u.r.opaque = TRUE;
dt->shared->u.atomic.u.r.version = (unsigned)((flags >> 4) & 0x0f);
if(dt->shared->u.atomic.u.r.version != H5R_ENCODE_VERSION)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "reference version does not match");
} else
dt->shared->u.atomic.u.r.opaque = FALSE;
/* This type needs conversion */
dt->shared->force_conv = TRUE;
} /* end if */
/* This type needs conversion */
dt->shared->force_conv = TRUE;
/* Mark location of this type as undefined for now. The caller
* function should decide the location. */
if(H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
break;
case H5T_ENUM:
@ -457,7 +469,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
dt->shared->u.enumer.nmembs = dt->shared->u.enumer.nalloc = flags & 0xffff;
if(NULL == (dt->shared->parent = H5T__alloc()))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
if(H5O_dtype_decode_helper(f, ioflags, pp, dt->shared->parent) < 0)
if(H5O_dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent datatype")
/* Check if the parent of this enum has a version greater than the
@ -499,7 +511,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
/* Decode base type of VL information */
if(NULL == (dt->shared->parent = H5T__alloc()))
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed")
if(H5O_dtype_decode_helper(f, ioflags, pp, dt->shared->parent) < 0)
if(H5O_dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type")
/* Check if the parent of this vlen has a version greater than the
@ -511,7 +523,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
/* Mark location this type as undefined for now. The caller function should
* decide the location. */
if(H5T_set_loc(dt, f, H5T_LOC_BADLOC) < 0)
if(H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
break;
@ -540,7 +552,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p
/* Decode base type of array */
if(NULL == (dt->shared->parent = H5T__alloc()))
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed")
if(H5O_dtype_decode_helper(f, ioflags, pp, dt->shared->parent) < 0)
if(H5O_dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode array parent type")
/* Check if the parent of this array has a version greater than the
@ -596,7 +608,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
{
unsigned flags = 0;
uint8_t *hdr = (uint8_t *)*pp;
@ -956,7 +968,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
} /* end if */
/* Subtype */
if(H5O_dtype_encode_helper(f, pp, dt->shared->u.compnd.memb[i].type) < 0)
if(H5O_dtype_encode_helper(pp, dt->shared->u.compnd.memb[i].type) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type")
} /* end for */
}
@ -964,6 +976,8 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
case H5T_REFERENCE:
flags |= (dt->shared->u.atomic.u.r.rtype & 0x0f);
if(dt->shared->u.atomic.u.r.opaque)
flags = (unsigned)(flags | (((unsigned)dt->shared->u.atomic.u.r.version & 0x0f) << 4));
break;
case H5T_ENUM:
@ -976,7 +990,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
flags = dt->shared->u.enumer.nmembs & 0xffff;
/* Parent type */
if(H5O_dtype_encode_helper(f, pp, dt->shared->parent) < 0)
if(H5O_dtype_encode_helper(pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode parent datatype")
/* Names, each a multiple of eight bytes */
@ -1012,7 +1026,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
} /* end if */
/* Encode base type of VL information */
if(H5O_dtype_encode_helper(f, pp, dt->shared->parent) < 0)
if(H5O_dtype_encode_helper(pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type")
break;
@ -1050,7 +1064,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
} /* end if */
/* Encode base type of array's information */
if(H5O_dtype_encode_helper(f, pp, dt->shared->parent) < 0)
if(H5O_dtype_encode_helper(pp, dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type")
break;
@ -1091,7 +1105,7 @@ done:
function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
H5O_dtype_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
H5O_dtype_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
unsigned *ioflags/*in,out*/, size_t H5_ATTR_UNUSED p_size, const uint8_t *p)
{
H5T_t *dt = NULL;
@ -1107,7 +1121,7 @@ H5O_dtype_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Perform actual decode of message */
if(H5O_dtype_decode_helper(f, ioflags, &p, dt) < 0)
if(H5O_dtype_decode_helper(ioflags, &p, dt) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode type")
/* Set return value */
@ -1136,7 +1150,7 @@ done:
message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
H5O_dtype_encode(H5F_t *f, uint8_t *p, const void *mesg)
H5O_dtype_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *mesg)
{
const H5T_t *dt = (const H5T_t *) mesg;
herr_t ret_value = SUCCEED; /* Return value */
@ -1149,7 +1163,7 @@ H5O_dtype_encode(H5F_t *f, uint8_t *p, const void *mesg)
HDassert(dt);
/* encode */
if(H5O_dtype_encode_helper(f, &p, dt) < 0)
if(H5O_dtype_encode_helper(&p, dt) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type")
done:

View File

@ -742,7 +742,7 @@ H5O_fill_reset_dyn(H5O_fill_t *fill)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create scalar dataspace")
/* Reclaim any variable length components of the fill value */
if(H5D_vlen_reclaim(fill_type_id, fill_space, fill->buf) < 0) {
if(H5T_reclaim(fill_type_id, fill_space, fill->buf) < 0) {
H5S_close(fill_space);
HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "unable to reclaim variable-length fill value data")
} /* end if */

View File

@ -981,8 +981,8 @@ H5_DLL herr_t H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disable
H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
H5O_copy_t *cpy_info, hbool_t inc_depth,
H5O_type_t *obj_type, void **udata);
H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref,
H5F_t *file_dst, void *_dst_ref, size_t ref_count, H5R_type_t ref_type,
H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src,
void *buf_src, size_t nbytes_src, H5F_t *file_dst, void *buf_dst,
H5O_copy_t *cpy_info);
H5_DLL herr_t H5O_copy(const H5G_loc_t *src_loc, const char *src_name,
H5G_loc_t *dst_loc, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id);

View File

@ -1519,7 +1519,7 @@ done:
*
* Purpose: Sets the memory allocate/free pair for VL datatypes. The
* allocation routine is called when data is read into a new
* array and the free routine is called when H5Dvlen_reclaim is
* array and the free routine is called when H5Treclaim is
* called. The alloc_info and free_info are user parameters
* which are passed to the allocation and freeing functions
* respectively. To reset the allocate/free functions to the
@ -1563,7 +1563,7 @@ done:
*
* Purpose: Sets the memory allocate/free pair for VL datatypes. The
* allocation routine is called when data is read into a new
* array and the free routine is called when H5Dvlen_reclaim is
* array and the free routine is called when H5Treclaim is
* called. The alloc_info and free_info are user parameters
* which are passed to the allocation and freeing functions
* respectively. To reset the allocate/free functions to the

View File

@ -169,6 +169,8 @@ hid_t H5P_CLS_STRING_CREATE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL;
hid_t H5P_CLS_VOL_INITIALIZE_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_VOL_INITIALIZE_g = NULL;
hid_t H5P_CLS_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID;
H5P_genclass_t *H5P_CLS_REFERENCE_ACCESS_g = NULL;
/*
* Predefined property lists for each predefined class. These are initialized
@ -192,6 +194,7 @@ hid_t H5P_LST_OBJECT_COPY_ID_g = H5I_INVALID_HID;
hid_t H5P_LST_LINK_CREATE_ID_g = H5I_INVALID_HID;
hid_t H5P_LST_LINK_ACCESS_ID_g = H5I_INVALID_HID;
hid_t H5P_LST_VOL_INITIALIZE_ID_g = H5I_INVALID_HID;
hid_t H5P_LST_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID;
/* Root property list class library initialization object */
const H5P_libclass_t H5P_CLS_ROOT[1] = {{
@ -312,6 +315,25 @@ const H5P_libclass_t H5P_CLS_VINI[1] = {{
NULL /* Class close callback info */
}};
/* Reference access property list class library initialization object */
/* (move to proper source code file when used for real) */
const H5P_libclass_t H5P_CLS_RACC[1] = {{
"reference access", /* Class name for debugging */
H5P_TYPE_REFERENCE_ACCESS, /* Class type */
&H5P_CLS_FILE_ACCESS_g, /* Parent class */
&H5P_CLS_REFERENCE_ACCESS_g, /* Pointer to class */
&H5P_CLS_REFERENCE_ACCESS_ID_g, /* Pointer to class ID */
&H5P_LST_REFERENCE_ACCESS_ID_g, /* Pointer to default property list ID */
NULL, /* Default property registration routine*/
NULL, /* Class creation callback */
NULL, /* Class creation callback info */
NULL, /* Class copy callback */
NULL, /* Class copy callback info */
NULL, /* Class close callback */
NULL /* Class close callback info */
}};
/* Library property list classes defined in other code modules */
/* (And not present in src/H5Pprivate.h) */
@ -364,7 +386,8 @@ static H5P_libclass_t const * const init_class[] = {
H5P_CLS_ACRT, /* Attribute creation */
H5P_CLS_AACC, /* Attribute access */
H5P_CLS_LCRT, /* Link creation */
H5P_CLS_VINI /* VOL initialization */
H5P_CLS_VINI, /* VOL initialization */
H5P_CLS_RACC /* Reference access */
};
/* Declare a free list to manage the H5P_genclass_t struct */
@ -440,7 +463,7 @@ H5P__init_package(void)
FUNC_ENTER_PACKAGE
/* Sanity check */
HDcompile_assert(H5P_TYPE_MAP_ACCESS == (H5P_TYPE_MAX_TYPE - 1));
HDcompile_assert(H5P_TYPE_REFERENCE_ACCESS == (H5P_TYPE_MAX_TYPE - 1));
/*
* Initialize the Generic Property class & object groups.
@ -564,6 +587,7 @@ H5P_term_package(void)
H5P_LST_LINK_CREATE_ID_g =
H5P_LST_LINK_ACCESS_ID_g =
H5P_LST_VOL_INITIALIZE_ID_g =
H5P_LST_REFERENCE_ACCESS_ID_g =
H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID;
} /* end if */
} /* end if */
@ -594,6 +618,7 @@ H5P_term_package(void)
H5P_CLS_LINK_CREATE_g =
H5P_CLS_LINK_ACCESS_g =
H5P_CLS_VOL_INITIALIZE_g =
H5P_CLS_REFERENCE_ACCESS_g =
H5P_CLS_FILE_MOUNT_g = NULL;
H5P_CLS_ROOT_ID_g =
@ -616,6 +641,7 @@ H5P_term_package(void)
H5P_CLS_LINK_CREATE_ID_g =
H5P_CLS_LINK_ACCESS_ID_g =
H5P_CLS_VOL_INITIALIZE_ID_g =
H5P_CLS_REFERENCE_ACCESS_ID_g =
H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID;
} /* end if */
} /* end if */
@ -5453,8 +5479,8 @@ H5P__new_plist_of_type(H5P_plist_type_t type)
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDcompile_assert(H5P_TYPE_MAP_ACCESS == (H5P_TYPE_MAX_TYPE - 1));
HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_MAP_ACCESS);
HDcompile_assert(H5P_TYPE_REFERENCE_ACCESS == (H5P_TYPE_MAX_TYPE - 1));
HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_REFERENCE_ACCESS);
/* Check arguments */
if(type == H5P_TYPE_USER)
@ -5544,6 +5570,10 @@ H5P__new_plist_of_type(H5P_plist_type_t type)
class_id = H5P_CLS_VOL_INITIALIZE_ID_g;
break;
case H5P_TYPE_REFERENCE_ACCESS:
class_id = H5P_CLS_REFERENCE_ACCESS_ID_g;
break;
case H5P_TYPE_USER: /* shut compiler warnings up */
case H5P_TYPE_ROOT:
case H5P_TYPE_MAX_TYPE:

View File

@ -81,6 +81,7 @@ typedef enum H5P_plist_type_t {
H5P_TYPE_VOL_INITIALIZE = 19,
H5P_TYPE_MAP_CREATE = 20,
H5P_TYPE_MAP_ACCESS = 21,
H5P_TYPE_REFERENCE_ACCESS = 22,
H5P_TYPE_MAX_TYPE
} H5P_plist_type_t;

View File

@ -71,6 +71,7 @@
#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g)
#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g)
#define H5P_VOL_INITIALIZE (H5OPEN H5P_CLS_VOL_INITIALIZE_ID_g)
#define H5P_REFERENCE_ACCESS (H5OPEN H5P_CLS_REFERENCE_ACCESS_ID_g)
/*
* The library's default property lists
@ -93,6 +94,7 @@
#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g)
#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g)
#define H5P_VOL_INITIALIZE_DEFAULT (H5OPEN H5P_LST_VOL_INITIALIZE_ID_g)
#define H5P_REFERENCE_ACCESS_DEFAULT (H5OPEN H5P_LST_REFERENCE_ACCESS_ID_g)
/* Common creation order flags (for links in groups and attributes on objects) */
#define H5P_CRT_ORDER_TRACKED 0x0001
@ -204,6 +206,7 @@ H5_DLLVAR hid_t H5P_CLS_OBJECT_COPY_ID_g;
H5_DLLVAR hid_t H5P_CLS_LINK_CREATE_ID_g;
H5_DLLVAR hid_t H5P_CLS_LINK_ACCESS_ID_g;
H5_DLLVAR hid_t H5P_CLS_VOL_INITIALIZE_ID_g;
H5_DLLVAR hid_t H5P_CLS_REFERENCE_ACCESS_ID_g;
/* Default roperty list IDs */
/* (Internal to library, do not use! Use macros above) */
@ -225,6 +228,7 @@ H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_ID_g;
H5_DLLVAR hid_t H5P_LST_LINK_CREATE_ID_g;
H5_DLLVAR hid_t H5P_LST_LINK_ACCESS_ID_g;
H5_DLLVAR hid_t H5P_LST_VOL_INITIALIZE_ID_g;
H5_DLLVAR hid_t H5P_LST_REFERENCE_ACCESS_ID_g;
/*********************/
/* Public Prototypes */

1003
src/H5R.c

File diff suppressed because it is too large Load Diff

View File

@ -37,14 +37,15 @@
#include "H5Ppublic.h" /* Property lists */
/* Private headers needed by this file */
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5Gprivate.h" /* Groups */
#include "H5Eprivate.h" /* Error handling */
#include "H5Gprivate.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
#include "H5Oprivate.h" /* Object headers */
#include "H5Oprivate.h" /* Object headers */
#include "H5Rpkg.h" /* References */
#include "H5Sprivate.h" /* Dataspaces */
/****************/
@ -81,53 +82,61 @@
/* Local Variables */
/*******************/
#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: H5Rget_obj_type1
*
* Purpose: Retrieves the type of the object that an object points to.
* Purpose: Retrieves the type of the object that a reference points to.
*
* Parameters:
* id IN: Dataset reference object is in or location ID of
* object that the dataset is located within
* ref_type IN: Type of reference to query
* ref IN: Reference to query
*
* Return: Success: An object type (as defined in H5Gpublic.h)
* Failure: H5G_UNKNOWN
* Return: Object type (as defined in H5Gpublic.h) on success
* H5G_UNKNOWN on failure
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref)
{
H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
H5VL_loc_params_t loc_params;
H5O_type_t obj_type; /* Object type */
H5G_obj_t ret_value; /* Return value */
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
haddr_t obj_addr; /* Object address */
H5O_type_t obj_type; /* Object type */
const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */
H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_API(H5G_UNKNOWN)
H5TRACE3("Go", "iRt*x", id, ref_type, ref);
/* Check args */
if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type")
if (ref == NULL)
if(buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer")
if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type")
/* Get the VOL object */
if(NULL == (vol_obj = H5VL_vol_object(id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier")
/* Currently restrict API usage to native VOL
* TODO check for terminal connector or use capability flag */
/* Get object type */
if((vol_obj_type = H5I_get_type(id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier")
/* Get object address */
if(H5R__decode_addr_compat(id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5G_UNKNOWN, "unable to get object address")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(id);
loc_params.type = H5VL_OBJECT_BY_TOKEN;
loc_params.loc_data.loc_by_token.token = &obj_addr;
loc_params.obj_type = vol_obj_type;
/* Get the vol object */
if (NULL == (vol_obj = H5VL_vol_object(id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid file identifier")
/* Get the object information */
if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_type, (int)ref_type, ref) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5G_UNKNOWN, "unable to determine object type")
/* Retrieve object's type */
if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_type) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5G_UNKNOWN, "can't retrieve object type")
/* Set return value */
ret_value = H5G_map_obj_type(obj_type);
@ -140,54 +149,61 @@ done:
/*-------------------------------------------------------------------------
* Function: H5Rdereference1
*
* Purpose: Opens the HDF5 object referenced.
* Purpose: Given a reference to some object, open that object and return an
* ID for that object.
*
* Parameters:
* id IN: Dataset reference object is in or location ID of
* object that the dataset is located within
* ref_type IN: Type of reference to create
* ref IN: Reference to open
*
* Return: Success: Valid HDF5 ID
* Failure: H5I_INVALID_HID
* Return: Valid ID on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
hid_t
H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref)
H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref)
{
H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
H5I_type_t opened_type;
void *opened_obj = NULL;
H5VL_loc_params_t loc_params;
hid_t ret_value = H5I_INVALID_HID; /* Return value */
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
haddr_t obj_addr; /* Object address */
H5I_type_t opened_type; /* Opened object type */
void *opened_obj = NULL; /* Opened object */
const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE3("i", "iRt*x", obj_id, ref_type, _ref);
H5TRACE3("i", "iRt*x", obj_id, ref_type, ref);
/* Check args */
if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type")
if (_ref == NULL)
if(buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer")
if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type")
/* Get the VOL object */
if (NULL == (vol_obj = H5VL_vol_object(obj_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier")
if(NULL == (vol_obj = H5VL_vol_object(obj_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
loc_params.type = H5VL_OBJECT_BY_REF;
loc_params.loc_data.loc_by_ref.ref_type = ref_type;
loc_params.loc_data.loc_by_ref._ref = _ref;
loc_params.loc_data.loc_by_ref.lapl_id = H5P_DATASET_ACCESS_DEFAULT;
loc_params.obj_type = H5I_get_type(obj_id);
/* Currently restrict API usage to native VOL
* TODO check for terminal connector or use capability flag */
/* Get object type */
if((vol_obj_type = H5I_get_type(obj_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
/* Get object address */
if(H5R__decode_addr_compat(obj_id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object address")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
loc_params.loc_data.loc_by_token.token = &obj_addr;
loc_params.obj_type = vol_obj_type;
/* Dereference */
if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to dereference object")
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by address")
/* Get an atom for the object */
/* Register object */
if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle")
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle")
done:
FUNC_LEAVE_API(ret_value)
@ -195,3 +211,363 @@ done:
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*-------------------------------------------------------------------------
* Function: H5Rcreate
*
* Purpose: Creates a particular type of reference specified with REF_TYPE,
* in the space pointed to by REF. The LOC_ID and NAME are used to locate the
* object pointed to and the SPACE_ID is used to choose the region pointed to
* (for Dataset Region references).
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type,
hid_t space_id)
{
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
haddr_t obj_addr; /* Object address */
hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */
unsigned char *buf = (unsigned char *)ref; /* Return reference pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "*xi*sRti", ref, loc_id, name, ref_type, space_id);
/* Check args */
if(buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given")
if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
/* Set up collective metadata if appropriate */
if(H5CX_set_loc(loc_id) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info")
/* Get the VOL object */
if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Currently restrict API usage to native VOL
* TODO check for terminal connector or use capability flag */
/* Get object type */
if((vol_obj_type = H5I_get_type(loc_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = name;
loc_params.obj_type = vol_obj_type;
/* Get the object address */
if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_addr) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object address")
/* Create reference */
if(ref_type == H5R_OBJECT1) {
size_t buf_size = H5R_OBJ_REF_BUF_SIZE;
if((ret_value = H5R__encode_addr_obj_compat(obj_addr, buf, &buf_size)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode object reference")
} else {
void *vol_obj_file = NULL;
H5F_t *f = NULL;
H5S_t *space = NULL; /* Pointer to dataspace containing region */
size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE;
/* Get the file for the object */
if((file_id = H5F_get_file_id(loc_id, vol_obj_type, FALSE)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Retrieve VOL object */
if(NULL == (vol_obj_file = H5VL_vol_object(file_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Retrieve file from VOL object */
if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj_file)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object")
/* Retrieve space */
if(space_id == H5I_BADID)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid")
if(NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
/* Encode dataset region */
if((ret_value = H5R__encode_addr_region_compat(f, obj_addr, space, buf, &buf_size)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode region reference")
}
done:
if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0)
HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file")
FUNC_LEAVE_API(ret_value)
} /* end H5Rcreate() */
/*-------------------------------------------------------------------------
* Function: H5Rget_obj_type2
*
* Purpose: Given a reference to some object, this function returns the type
* of object pointed to.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref,
H5O_type_t *obj_type)
{
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
haddr_t obj_addr; /* Object address */
const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type);
/* Check args */
if(buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
/* Get the VOL object */
if(NULL == (vol_obj = H5VL_vol_object(id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Currently restrict API usage to native VOL
* TODO check for terminal connector or use capability flag */
/* Get object type */
if((vol_obj_type = H5I_get_type(id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Get object address */
if(H5R__decode_addr_compat(id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
loc_params.loc_data.loc_by_token.token = &obj_addr;
loc_params.obj_type = vol_obj_type;
/* Retrieve object's type */
if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object type")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Rget_obj_type2() */
/*-------------------------------------------------------------------------
* Function: H5Rdereference2
*
* Purpose: Given a reference to some object, open that object and return an
* ID for that object.
*
* Return: Valid ID on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
hid_t
H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type,
const void *ref)
{
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
haddr_t obj_addr; /* Object address */
H5I_type_t opened_type; /* Opened object type */
void *opened_obj = NULL; /* Opened object */
const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, ref);
/* Check args */
if(oapl_id < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list")
if(buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer")
if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type")
/* Verify access property list and set up collective metadata if appropriate */
if(H5CX_set_apl(&oapl_id, H5P_CLS_DACC, obj_id, FALSE) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
/* Get the VOL object */
if(NULL == (vol_obj = H5VL_vol_object(obj_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier")
/* Currently restrict API usage to native VOL
* TODO check for terminal connector or use capability flag */
/* Get object type */
if((vol_obj_type = H5I_get_type(obj_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
/* Get object address */
if(H5R__decode_addr_compat(obj_id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object address")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
loc_params.loc_data.loc_by_token.token = &obj_addr;
loc_params.obj_type = vol_obj_type;
/* Open object by address */
if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by address")
/* Register object */
if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Rdereference2() */
/*-------------------------------------------------------------------------
* Function: H5Rget_region
*
* Purpose: Given a reference to some object, creates a copy of the dataset
* pointed to's dataspace and defines a selection in the copy which is the
* region pointed to.
*
* Return: Valid ID on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
hid_t
H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref)
{
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
void *vol_obj_file = NULL; /* VOL file */
H5F_t *f = NULL; /* Native file */
size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Reference buffer size */
H5S_t *space = NULL; /* Dataspace object */
hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */
const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */
hid_t ret_value; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE3("i", "iRt*x", id, ref_type, ref);
/* Check args */
if(buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer")
if(ref_type != H5R_DATASET_REGION1)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type")
/* Get the VOL object */
if(NULL == (vol_obj = H5VL_vol_object(id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier")
/* Get object type */
if((vol_obj_type = H5I_get_type(id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
/* Currently restrict API usage to native VOL
* TODO check for terminal connector or use capability flag */
/* Get the file for the object */
if((file_id = H5F_get_file_id(id, vol_obj_type, FALSE)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file or file object")
/* Retrieve VOL object */
if(NULL == (vol_obj_file = H5VL_vol_object(file_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
/* Retrieve file from VOL object */
if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj_file)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL object")
/* Get the dataspace with the correct region selected */
if(H5R__decode_addr_region_compat(f, buf, &buf_size, NULL, &space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace")
/* Atomize */
if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom")
done:
if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0)
HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file")
FUNC_LEAVE_API(ret_value)
} /* end H5Rget_region1() */
/*-------------------------------------------------------------------------
* Function: H5Rget_name
*
* Purpose: Given a reference to some object, determine a path to the object
* referenced in the file.
*
* Return: Non-negative length of the path on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
ssize_t
H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name,
size_t size)
{
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
haddr_t obj_addr; /* Object address */
const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */
ssize_t ret_value = -1; /* Return value */
FUNC_ENTER_API((-1))
H5TRACE5("Zs", "iRt*x*sz", id, ref_type, ref, name, size);
/* Check args */
if(buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer")
if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type")
/* Get the VOL object */
if(NULL == (vol_obj = H5VL_vol_object(id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier")
/* Currently restrict API usage to native VOL
* TODO check for terminal connector or use capability flag */
/* Get object type */
if((vol_obj_type = H5I_get_type(id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier")
/* Get object address */
if(H5R__decode_addr_compat(id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, (-1), "unable to get object address")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
loc_params.loc_data.loc_by_token.token = &obj_addr;
loc_params.obj_type = vol_obj_type;
/* Retrieve object's name */
if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Rget_name() */

File diff suppressed because it is too large Load Diff

View File

@ -36,11 +36,51 @@
/* Package Private Macros */
/**************************/
/* Encode flags */
#define H5R_IS_EXTERNAL 0x1 /* Set when encoding reference to external file */
/* Macros for convenience */
#define H5R_REF_FILENAME(x) ((x)->ref.obj.filename)
#define H5R_REF_ATTRNAME(x) ((x)->ref.attr.name)
/* Header size */
#define H5R_ENCODE_HEADER_SIZE (2 * H5_SIZEOF_UINT8_T)
/****************************/
/* Package Private Typedefs */
/****************************/
/* Object reference */
typedef struct H5R_ref_priv_obj_t {
H5VL_token_t token; /* Object token */
char *filename; /* File name */
} H5R_ref_priv_obj_t;
/* Region reference */
typedef struct H5R_ref_priv_reg_t {
H5R_ref_priv_obj_t obj; /* Object reference */
H5S_t *space; /* Selection */
} H5R_ref_priv_reg_t;
/* Attribute reference */
typedef struct H5R_ref_priv_attr_t {
H5R_ref_priv_obj_t obj; /* Object reference */
char *name; /* Attribute name */
} H5R_ref_priv_attr_t;
/* Generic reference type (keep it cache aligned) */
typedef struct H5R_ref_priv_t {
union {
H5R_ref_priv_obj_t obj;/* Object reference */
H5R_ref_priv_reg_t reg;/* Region reference */
H5R_ref_priv_attr_t attr;/* Attribute Reference */
} ref;
hid_t loc_id; /* Cached location identifier */
uint32_t encode_size; /* Cached encoding size */
int8_t type; /* Reference type */
uint8_t token_size; /* Cached token size */
char unused[18]; /* Unused */
} H5R_ref_priv_t;
/*****************************/
/* Package Private Variables */
@ -50,11 +90,41 @@
/******************************/
/* Package Private Prototypes */
/******************************/
H5_DLL herr_t H5R__create(void *ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space);
H5_DLL hid_t H5R__dereference(H5F_t *file, hid_t dapl_id, H5R_type_t ref_type, const void *_ref);
H5_DLL H5S_t *H5R__get_region(H5F_t *file, const void *_ref);
H5_DLL herr_t H5R__get_obj_type(H5F_t *file, H5R_type_t ref_type, const void *_ref, H5O_type_t *obj_type);
H5_DLL ssize_t H5R__get_name(H5F_t *file, H5R_type_t ref_type, const void *_ref, char *name, size_t size);
H5_DLL herr_t H5R__create_object(const H5VL_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref);
H5_DLL herr_t H5R__create_region(const H5VL_token_t *obj_token, size_t token_size, H5S_t *space, H5R_ref_priv_t *ref);
H5_DLL herr_t H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size, const char *attr_name, H5R_ref_priv_t *ref);
H5_DLL herr_t H5R__destroy(H5R_ref_priv_t *ref);
H5_DLL herr_t H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref);
H5_DLL hid_t H5R__get_loc_id(const H5R_ref_priv_t *ref);
H5_DLL hid_t H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id);
H5_DLL H5R_type_t H5R__get_type(const H5R_ref_priv_t *ref);
H5_DLL htri_t H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2);
H5_DLL herr_t H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref);
H5_DLL herr_t H5R__get_obj_token(const H5R_ref_priv_t *ref, H5VL_token_t *obj_token, size_t *token_size);
H5_DLL herr_t H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token, size_t token_size);
H5_DLL herr_t H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space);
H5_DLL ssize_t H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size);
H5_DLL ssize_t H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size);
H5_DLL herr_t H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, size_t *nalloc, unsigned flags);
H5_DLL herr_t H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref);
/* Native HDF5 specific routines */
H5_DLL herr_t H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, const unsigned char *data, size_t data_size);
H5_DLL herr_t H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned char **data_ptr, size_t *data_size);
H5_DLL herr_t H5R__free_heap(H5F_t *f, const unsigned char *buf, size_t nbytes);
H5_DLL herr_t H5R__decode_addr_compat(hid_t id, H5I_type_t type, H5R_type_t ref_type, const unsigned char *buf, haddr_t *addr_ptr);
H5_DLL herr_t H5R__encode_addr_obj_compat(haddr_t obj_addr, unsigned char *buf, size_t *nalloc);
H5_DLL herr_t H5R__decode_addr_obj_compat(const unsigned char *buf, size_t *nbytes, haddr_t *obj_addr_ptr);
H5_DLL herr_t H5R__encode_addr_region_compat(H5F_t *f, haddr_t obj_addr, H5S_t *space, unsigned char *buf, size_t *nalloc);
H5_DLL herr_t H5R__decode_addr_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, haddr_t *obj_addr_ptr, H5S_t **space_ptr);
#endif /* _H5Rpkg_H */

View File

@ -25,6 +25,8 @@
/* Library Private Macros */
/**************************/
#define H5R_ENCODE_VERSION 0x1 /* Version for encoding references */
/****************************/
/* Library Private Typedefs */
@ -41,4 +43,3 @@
/******************************/
#endif /* _H5Rprivate_H */

View File

@ -26,47 +26,64 @@
/* Public Macros */
/*****************/
/* Note! Be careful with the sizes of the references because they should really
* depend on the run-time values in the file. Unfortunately, the arrays need
* to be defined at compile-time, so we have to go with the worst case sizes
* for them. -QAK
*/
/* Deprecated reference buffer sizes that are kept for backward compatibility */
#define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t)
/* 4 is used instead of sizeof(int) to permit portability between the Crays
* and other machines (the heap ID is always encoded as an int32 anyway).
*/
#define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t) + 4)
/* Default reference buffer size.
* Note! Be careful with the sizes of the references because they should really
* depend on the run-time values in the file.
*/
#define H5R_REF_BUF_SIZE (64)
/*******************/
/* Public Typedefs */
/*******************/
/* Reference types */
typedef enum H5R_type_t {
H5R_BADTYPE = (-1), /* Invalid Reference Type */
H5R_OBJECT, /* Object reference */
H5R_DATASET_REGION, /* Dataset Region Reference */
H5R_MAXTYPE /* Highest type (Invalid as true type) */
/*
* Reference types allowed.
* DO NOT CHANGE THE ORDER or VALUES as reference type values are encoded into
* the datatype message header.
*/
typedef enum {
H5R_BADTYPE = (-1), /* Invalid reference type */
H5R_OBJECT1 = 0, /* Backward compatibility (object) */
H5R_DATASET_REGION1 = 1, /* Backward compatibility (region) */
H5R_OBJECT2 = 2, /* Object reference */
H5R_DATASET_REGION2 = 3, /* Region reference */
H5R_ATTR = 4, /* Attribute Reference */
H5R_MAXTYPE = 5 /* Highest type (invalid) */
} H5R_type_t;
/* Object reference structure for user's code
* This needs to be large enough to store largest haddr_t on a worst case
* machine (8 bytes currently).
/* Deprecated types are kept for backward compatibility with previous versions */
/**
* Deprecated object reference type that is used with deprecated reference APIs.
* Note! This type can only be used with the "native" HDF5 VOL connector.
*/
typedef haddr_t hobj_ref_t;
/* Dataset Region reference structure for user's code
/**
* Dataset region reference type that is used with deprecated reference APIs.
* (Buffer to store heap ID and index)
* This needs to be large enough to store largest haddr_t in a worst case
* machine (8 bytes currently) plus an int
* machine (8 bytes currently) plus an int.
* Note! This type can only be used with the "native" HDF5 VOL connector.
*/
typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE];
/**
* Opaque reference type. The same reference type is used for object,
* dataset region and attribute references. This is the type that
* should always be used with the current reference API.
*/
typedef unsigned char H5R_ref_t[H5R_REF_BUF_SIZE];
/********************/
/* Public Variables */
/********************/
/*********************/
/* Public Prototypes */
/*********************/
@ -75,30 +92,57 @@ typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE];
extern "C" {
#endif
H5_DLL herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name,
H5R_type_t ref_type, hid_t space_id);
H5_DLL hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref);
H5_DLL hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, const void *ref);
H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *_ref,
H5O_type_t *obj_type);
H5_DLL ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, const void *ref,
char *name /*out*/, size_t size);
/* Constructors */
H5_DLL herr_t H5Rcreate_object(hid_t loc_id, const char *name, H5R_ref_t *ref_ptr);
H5_DLL herr_t H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, H5R_ref_t *ref_ptr);
H5_DLL herr_t H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, H5R_ref_t *ref_ptr);
H5_DLL herr_t H5Rdestroy(H5R_ref_t *ref_ptr);
/* Info */
H5_DLL H5R_type_t H5Rget_type(const H5R_ref_t *ref_ptr);
H5_DLL htri_t H5Requal(const H5R_ref_t *ref1_ptr, const H5R_ref_t *ref2_ptr);
H5_DLL herr_t H5Rcopy(const H5R_ref_t *src_ref_ptr, H5R_ref_t *dst_ref_ptr);
/* Dereference */
H5_DLL hid_t H5Ropen_object(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id);
H5_DLL hid_t H5Ropen_region(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id);
H5_DLL hid_t H5Ropen_attr(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id);
/* Get type */
H5_DLL herr_t H5Rget_obj_type3(const H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type);
/* Get name */
H5_DLL ssize_t H5Rget_file_name(const H5R_ref_t *ref_ptr, char *buf, size_t size);
H5_DLL ssize_t H5Rget_obj_name(const H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size);
H5_DLL ssize_t H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *buf, size_t size);
/* Symbols defined for compatibility with previous versions of the HDF5 API.
*
* Use of these symbols is deprecated.
* Use of these symbols is or will be deprecated.
*/
#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Macros */
/* Versions for compatibility */
#define H5R_OBJECT H5R_OBJECT1
#define H5R_DATASET_REGION H5R_DATASET_REGION1
/* Function prototypes */
H5_DLL H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *_ref);
#ifndef H5_NO_DEPRECATED_SYMBOLS
H5_DLL H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref);
H5_DLL hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
H5_DLL herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id);
H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type);
H5_DLL hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref);
H5_DLL hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, const void *ref);
H5_DLL ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, const void *ref, char *name, size_t size);
#ifdef __cplusplus
}
#endif
#endif /* _H5Rpublic_H */

View File

@ -1357,7 +1357,6 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims,
/* Check args */
HDassert(rank <= H5S_MAX_RANK);
HDassert(0 == rank || dims);
/* shift out of the previous state to a "simple" dataspace. */
if(H5S__extent_release(&space->extent) < 0)
@ -1378,7 +1377,7 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims,
space->extent.size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)rank);
/* Copy the dimensions & compute the number of elements in the extent */
for(u = 0, nelem = 1; u < space->extent.rank; u++) {
for(u = 0, nelem = 1; dims && (u < space->extent.rank); u++) {
space->extent.size[u] = dims[u];
nelem *= dims[u];
} /* end for */
@ -1390,7 +1389,7 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims,
if(max != NULL)
H5MM_memcpy(space->extent.max, max, sizeof(hsize_t) * rank);
else
for(u = 0; u < space->extent.rank; u++)
for(u = 0; dims && (u < space->extent.rank); u++)
space->extent.max[u] = dims[u];
} /* end else */

View File

@ -42,11 +42,10 @@
/* Local Macros */
/****************/
#define H5S_MPIO_INITIAL_ALLOC_COUNT 256
#define TWO_GIG_LIMIT 2147483648
#ifndef H5S_MAX_MPI_COUNT
#define H5S_MAX_MPI_COUNT 536870911 /* (2^29)-1 */
#endif
/*******************/
/* Local Variables */
/*******************/
/******************/
/* Local Typedefs */
@ -88,8 +87,6 @@ static herr_t H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list);
static herr_t H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
size_t elmt_size, const MPI_Datatype *elmt_type, MPI_Datatype *span_type,
H5S_mpio_mpitype_list_t *type_list, uint64_t op_gen);
static herr_t H5S__mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes,
MPI_Datatype old_type, MPI_Datatype *new_type);
/*****************************/
@ -102,40 +99,9 @@ static herr_t H5S__mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_
/*********************/
/*******************/
/* Local Variables */
/*******************/
static hsize_t bigio_count = H5S_MAX_MPI_COUNT;
/* Declare a free list to manage the H5S_mpio_mpitype_node_t struct */
H5FL_DEFINE_STATIC(H5S_mpio_mpitype_node_t);
/*-------------------------------------------------------------------------
* Function: H5S_mpio_set_bigio_count
*
* Purpose: Allow us to programatically change the switch point
* when we utilize derived datatypes. This is of
* particular interest for allowing nightly testing
*
* Return: The current/previous value of bigio_count.
*
* Programmer: Richard Warren, March 10, 2017
*
*-------------------------------------------------------------------------
*/
hsize_t
H5S_mpio_set_bigio_count(hsize_t new_count)
{
hsize_t orig_count = bigio_count;
if((new_count > 0) && (new_count < TWO_GIG_LIMIT))
bigio_count = new_count;
return orig_count;
} /* end H5S_mpio_set_bigio_count() */
/*-------------------------------------------------------------------------
* Function: H5S__mpio_all_type
@ -160,6 +126,7 @@ H5S__mpio_all_type(const H5S_t *space, size_t elmt_size,
hsize_t total_bytes;
hssize_t snelmts; /* Total number of elmts (signed) */
hsize_t nelmts; /* Total number of elmts */
hsize_t bigio_count; /* Transition point to create derived type */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@ -173,6 +140,7 @@ H5S__mpio_all_type(const H5S_t *space, size_t elmt_size,
H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t);
total_bytes = (hsize_t)elmt_size * nelmts;
bigio_count = H5_mpio_get_bigio_count();
/* Verify that the size can be expressed as a 32 bit integer */
if(bigio_count >= total_bytes) {
@ -183,7 +151,7 @@ H5S__mpio_all_type(const H5S_t *space, size_t elmt_size,
} /* end if */
else {
/* Create a LARGE derived datatype for this transfer */
if(H5S__mpio_create_large_type(total_bytes, 0, MPI_BYTE, new_type) < 0)
if(H5_mpio_create_large_type(total_bytes, 0, MPI_BYTE, new_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large datatype from the all selection")
*count = 1;
*is_derived_type = TRUE;
@ -250,6 +218,7 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points,
int *blocks = NULL; /* Array of block sizes for MPI hindexed create call */
hsize_t u; /* Local index variable */
#endif
hsize_t bigio_count; /* Transition point to create derived type */
int mpi_code; /* MPI error code */
herr_t ret_value = SUCCEED; /* Return value */
@ -260,6 +229,8 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points,
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
elmt_type_created = TRUE;
bigio_count = H5_mpio_get_bigio_count();
/* Check whether standard or BIGIO processing will be employeed */
if(bigio_count >= num_points) {
#if MPI_VERSION >= 3
@ -518,7 +489,7 @@ done:
* selection and so the memory datatype has to be permuted using the
* permutation map created by the file selection.
*
* Note: This routine is called from H5S_mpio_space_type(), which is
* Note: This routine is called from H5_mpio_space_type(), which is
* called first for the file dataspace and creates
*
* Return: Non-negative on success, negative on failure.
@ -678,6 +649,7 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size,
hsize_t count;
} d[H5S_MAX_RANK];
hsize_t bigio_count; /* Transition point to create derived type */
hsize_t offset[H5S_MAX_RANK];
hsize_t max_xtent[H5S_MAX_RANK];
H5S_hyper_dim_t *diminfo; /* [rank] */
@ -696,6 +668,7 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size,
HDassert(space);
HDassert(sizeof(MPI_Aint) >= sizeof(elmt_size));
bigio_count = H5_mpio_get_bigio_count();
/* Initialize selection iterator */
if(H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
@ -824,7 +797,7 @@ if(H5DEBUG(S)) {
} /* end if */
else
/* Create the compound datatype for this operation (> 2GB) */
if(H5S__mpio_create_large_type(elmt_size, 0, MPI_BYTE, &inner_type) < 0)
if(H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &inner_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large inner datatype in hyper selection")
/*******************************************************
@ -878,7 +851,7 @@ if(H5DEBUG(S))
* Again we need to check that the number of BLOCKS can fit into
* a 32 bit integer */
if(bigio_count < d[i].block) {
if(H5S__mpio_create_large_type(d[i].block, 0, inner_type, &block_type) < 0)
if(H5_mpio_create_large_type(d[i].block, 0, inner_type, &block_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large block datatype in hyper selection")
} /* end if */
else
@ -899,7 +872,7 @@ if(H5DEBUG(S))
* we call the large type creation function to handle that
*/
if(bigio_count < d[i].count) {
if(H5S__mpio_create_large_type(d[i].count, stride_in_bytes, block_type, &outer_type) < 0)
if(H5_mpio_create_large_type(d[i].count, stride_in_bytes, block_type, &outer_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large outer datatype in hyper selection")
} /* end if */
/* otherwise a regular create_hvector will do */
@ -1001,6 +974,7 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
MPI_Datatype elmt_type; /* MPI datatype for an element */
hbool_t elmt_type_is_derived = FALSE; /* Whether the element type has been created */
MPI_Datatype span_type; /* MPI datatype for overall span tree */
hsize_t bigio_count; /* Transition point to create derived type */
hsize_t down[H5S_MAX_RANK]; /* 'down' sizes for each dimension */
uint64_t op_gen; /* Operation generation value */
int mpi_code; /* MPI return code */
@ -1014,13 +988,14 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size,
HDassert(space->select.sel_info.hslab->span_lst);
HDassert(space->select.sel_info.hslab->span_lst->head);
bigio_count = H5_mpio_get_bigio_count();
/* Create the base type for an element */
if(bigio_count >= elmt_size) {
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
} /* end if */
else
if(H5S__mpio_create_large_type(elmt_size, 0, MPI_BYTE, &elmt_type) < 0)
if(H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &elmt_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection")
elmt_type_is_derived = TRUE;
@ -1124,8 +1099,10 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
H5S_mpio_mpitype_list_t *type_list, uint64_t op_gen)
{
H5S_hyper_span_t *span; /* Hyperslab span to iterate with */
hsize_t bigio_count; /* Transition point to create derived type */
size_t alloc_count = 0; /* Number of span tree nodes allocated at this level */
size_t outercount; /* Number of span tree nodes at this level */
size_t outercount = 0; /* Number of span tree nodes at this level */
MPI_Datatype *inner_type = NULL;
hbool_t inner_types_freed = FALSE; /* Whether the inner_type MPI datatypes have been freed */
int *blocklen = NULL;
@ -1140,6 +1117,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
HDassert(spans);
HDassert(type_list);
bigio_count = H5_mpio_get_bigio_count();
/* Check if we've visited this span tree before */
if(spans->op_gen != op_gen) {
H5S_mpio_mpitype_node_t *type_node; /* Pointer to new node in MPI data type list */
@ -1185,7 +1163,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
H5_CHECK_OVERFLOW(nelmts, hsize_t, int)
blocklen[outercount] = (int)nelmts;
if(bigio_count < blocklen[outercount])
if(bigio_count < (hsize_t)blocklen[outercount])
large_block = TRUE; /* at least one block type is large, so set this flag to true */
span = span->next;
@ -1202,8 +1180,8 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
MPI_Datatype temp_type = MPI_DATATYPE_NULL;
/* create the block type from elmt_type while checking the 32 bit int limit */
if(blocklen[u] > bigio_count) {
if(H5S__mpio_create_large_type(blocklen[u], 0, *elmt_type, &temp_type) < 0)
if((hsize_t)(blocklen[u]) > bigio_count) {
if(H5_mpio_create_large_type(blocklen[u], 0, *elmt_type, &temp_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection")
} /* end if */
else
@ -1453,113 +1431,5 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_mpio_space_type() */
/*-------------------------------------------------------------------------
* Function: H5S__mpio_create_large_type
*
* Purpose: Create a large datatype of size larger than what a 32 bit integer
* can hold.
*
* Return: Non-negative on success, negative on failure.
*
* *new_type the new datatype created
*
* Programmer: Mohamad Chaarawi
*
*-------------------------------------------------------------------------
*/
static herr_t
H5S__mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes,
MPI_Datatype old_type, MPI_Datatype *new_type)
{
int num_big_types; /* num times the 2G datatype will be repeated */
int remaining_bytes; /* the number of bytes left that can be held in an int value */
hsize_t leftover;
int block_len[2];
int mpi_code; /* MPI return code */
MPI_Datatype inner_type, outer_type, leftover_type, type[2];
MPI_Aint disp[2], old_extent;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Calculate how many Big MPI datatypes are needed to represent the buffer */
num_big_types = (int)(num_elements/bigio_count);
leftover = num_elements - num_big_types * (hsize_t)bigio_count;
H5_CHECKED_ASSIGN(remaining_bytes, int, leftover, hsize_t);
/* Create a contiguous datatype of size equal to the largest
* number that a 32 bit integer can hold x size of old type.
* If the displacement is 0, then the type is contiguous, otherwise
* use type_hvector to create the type with the displacement provided
*/
if (0 == stride_bytes) {
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(bigio_count, old_type, &inner_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
} /* end if */
else
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(bigio_count, 1, stride_bytes, old_type, &inner_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
/* Create a contiguous datatype of the buffer (minus the remaining < 2GB part)
* If a stride is present, use hvector type
*/
if(0 == stride_bytes) {
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(num_big_types, inner_type, &outer_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
} /* end if */
else
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(num_big_types, 1, stride_bytes, inner_type, &outer_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
MPI_Type_free(&inner_type);
/* If there is a remaining part create a contiguous/vector datatype and then
* use a struct datatype to encapsulate everything.
*/
if(remaining_bytes) {
if(stride_bytes == 0) {
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(remaining_bytes, old_type, &leftover_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
} /* end if */
else
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)(num_elements - (hsize_t)num_big_types * bigio_count), 1, stride_bytes, old_type, &leftover_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
/* As of version 4.0, OpenMPI now turns off MPI-1 API calls by default,
* so we're using the MPI-2 version even though we don't need the lb
* value.
*/
{
MPI_Aint unused_lb_arg;
MPI_Type_get_extent(old_type, &unused_lb_arg, &old_extent);
}
/* Set up the arguments for MPI_Type_struct constructor */
type[0] = outer_type;
type[1] = leftover_type;
block_len[0] = 1;
block_len[1] = 1;
disp[0] = 0;
disp[1] = (old_extent + stride_bytes) * num_big_types * (MPI_Aint)bigio_count;
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, block_len, disp, type, new_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
MPI_Type_free(&outer_type);
MPI_Type_free(&leftover_type);
} /* end if */
else
/* There are no remaining bytes so just set the new type to
* the outer type created */
*new_type = outer_type;
if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S__mpio_create_large_type() */
#endif /* H5_HAVE_PARALLEL */

View File

@ -307,7 +307,6 @@ H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter);
H5_DLL herr_t H5S_sel_iter_close(H5S_sel_iter_t *sel_iter);
#ifdef H5_HAVE_PARALLEL
H5_DLL hsize_t H5S_mpio_set_bigio_count(hsize_t new_count);
H5_DLL herr_t H5S_mpio_space_type(const H5S_t *space, size_t elmt_size,
/* out: */ MPI_Datatype *new_type,
int *count,

169
src/H5T.c
View File

@ -226,18 +226,34 @@
#define H5T_INIT_TYPE_REF_COMMON { \
H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \
H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \
dt->shared->force_conv = TRUE; \
dt->shared->u.atomic.u.r.f = NULL; \
dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC; \
dt->shared->u.atomic.u.r.cls = NULL; \
}
#define H5T_INIT_TYPE_OBJREF_CORE { \
H5T_INIT_TYPE_REF_COMMON \
dt->shared->force_conv = TRUE; \
dt->shared->u.atomic.u.r.rtype = H5R_OBJECT; \
dt->shared->u.atomic.u.r.loc = H5T_LOC_MEMORY; \
dt->shared->u.atomic.u.r.rtype = H5R_OBJECT1; \
dt->shared->u.atomic.u.r.opaque = FALSE; \
dt->shared->u.atomic.u.r.version = 0; \
}
#define H5T_INIT_TYPE_REGREF_CORE { \
H5T_INIT_TYPE_REF_COMMON \
dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION; \
dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION1; \
dt->shared->u.atomic.u.r.opaque = FALSE; \
dt->shared->u.atomic.u.r.version = 0; \
}
/* rtype value is only used as a placeholder to differentiate the type from
* other types, any opaque (i.e. "new") reference type could be used.
*/
#define H5T_INIT_TYPE_REF_CORE { \
H5T_INIT_TYPE_REF_COMMON \
dt->shared->u.atomic.u.r.rtype = H5R_OBJECT2; \
dt->shared->u.atomic.u.r.opaque = TRUE; \
dt->shared->u.atomic.u.r.version = H5R_ENCODE_VERSION; \
}
/* Define the code templates for the "SIZE_TMPL" in the H5T_INIT_TYPE macro */
@ -295,7 +311,7 @@ static htri_t H5T__compiler_conv(H5T_t *src, H5T_t *dst);
static herr_t H5T__set_size(H5T_t *dt, size_t size);
static herr_t H5T__close_cb(H5T_t *dt);
static H5T_path_t *H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_func_t *conv);
static hbool_t H5T__detect_reg_ref(const H5T_t *dt);
static hbool_t H5T__detect_vlen_ref(const H5T_t *dt);
/*****************************/
@ -354,6 +370,7 @@ hid_t H5T_STD_B64BE_g = FAIL;
hid_t H5T_STD_B64LE_g = FAIL;
hid_t H5T_STD_REF_OBJ_g = FAIL;
hid_t H5T_STD_REF_DSETREG_g = FAIL;
hid_t H5T_STD_REF_g = FAIL;
hid_t H5T_UNIX_D32BE_g = FAIL;
hid_t H5T_UNIX_D32LE_g = FAIL;
@ -444,6 +461,7 @@ size_t H5T_POINTER_COMP_ALIGN_g = 0;
size_t H5T_HVL_COMP_ALIGN_g = 0;
size_t H5T_HOBJREF_COMP_ALIGN_g = 0;
size_t H5T_HDSETREGREF_COMP_ALIGN_g = 0;
size_t H5T_REF_COMP_ALIGN_g = 0;
/*
* Alignment constraints for native types. These are initialized at run time
@ -737,7 +755,9 @@ H5T__init_package(void)
H5T_t *enum_type=NULL; /* Datatype structure for enum objects */
H5T_t *vlen=NULL; /* Datatype structure for vlen objects */
H5T_t *array=NULL; /* Datatype structure for array objects */
H5T_t *objref=NULL; /* Datatype structure for object reference objects */
H5T_t *objref=NULL; /* Datatype structure for deprecated reference objects */
H5T_t *regref=NULL; /* Datatype structure for deprecated region references */
H5T_t *ref=NULL; /* Datatype structure for opaque references */
hsize_t dim[1]={1}; /* Dimension info for array datatype */
herr_t status;
hbool_t copied_dtype = TRUE; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */
@ -989,12 +1009,23 @@ H5T__init_package(void)
*------------------------------------------------------------
*/
/* Object reference (i.e. object header address in file) */
H5T_INIT_TYPE(OBJREF, H5T_STD_REF_OBJ_g, ALLOC, -, SET, H5R_OBJ_REF_BUF_SIZE)
/* Deprecated object reference type */
H5T_INIT_TYPE(OBJREF, H5T_STD_REF_OBJ_g, ALLOC, -, NOSET, -)
if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
objref = dt; /* Keep type for later */
/* Dataset Region reference (i.e. selection inside a dataset) */
H5T_INIT_TYPE(REGREF, H5T_STD_REF_DSETREG_g, ALLOC, -, SET, H5R_DSET_REG_REF_BUF_SIZE)
/* Deprecated region reference type */
H5T_INIT_TYPE(REGREF, H5T_STD_REF_DSETREG_g, ALLOC, -, NOSET, -)
if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
regref = dt; /* Keep type for later */
/* Opaque reference type */
H5T_INIT_TYPE(REF, H5T_STD_REF_g, ALLOC, -, NOSET, -)
if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
ref = dt; /* Keep type for later */
/*
* Register conversion functions beginning with the most general and
@ -1030,6 +1061,10 @@ H5T__init_package(void)
status |= H5T__register_int(H5T_PERS_SOFT, "vlen", vlen, vlen, H5T__conv_vlen);
status |= H5T__register_int(H5T_PERS_SOFT, "array", array, array, H5T__conv_array);
status |= H5T__register_int(H5T_PERS_SOFT, "objref", objref, objref, H5T__conv_order_opt);
status |= H5T__register_int(H5T_PERS_SOFT, "regref", regref, regref, H5T__conv_noop);
status |= H5T__register_int(H5T_PERS_SOFT, "ref", ref, ref, H5T__conv_ref);
status |= H5T__register_int(H5T_PERS_SOFT, "objref_ref", objref, ref, H5T__conv_ref);
status |= H5T__register_int(H5T_PERS_SOFT, "regref_ref", regref, ref, H5T__conv_ref);
/*
* Native conversions should be listed last since we can use hardware to
@ -1473,6 +1508,7 @@ H5T_top_term_package(void)
H5T_STD_B64LE_g = FAIL;
H5T_STD_REF_OBJ_g = FAIL;
H5T_STD_REF_DSETREG_g = FAIL;
H5T_STD_REF_g = FAIL;
H5T_UNIX_D32BE_g = FAIL;
H5T_UNIX_D32LE_g = FAIL;
@ -2882,6 +2918,56 @@ done:
} /* end H5Tconvert() */
/*-------------------------------------------------------------------------
* Function: H5Treclaim
*
* Purpose: Frees the buffers allocated for storing variable-length data
* in memory. Only frees the VL data in the selection defined in the
* dataspace. The dataset transfer property list is required to find the
* correct allocation/free methods for the VL data in the buffer.
*
* Return: Non-negative on success, negative on failure
*
* Programmer: Quincey Koziol
* Thursday, June 10, 1999
*
*-------------------------------------------------------------------------
*/
herr_t
H5Treclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf)
{
H5S_t *space; /* Dataspace for iteration */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "iii*x", type_id, space_id, dxpl_id, buf);
/* Check args */
if(H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument")
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace")
if(!(H5S_has_extent(space)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set")
/* Get the default dataset transfer property list if the user didn't provide one */
if(H5P_DEFAULT == dxpl_id)
dxpl_id = H5P_DATASET_XFER_DEFAULT;
else
if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
/* Call internal routine */
ret_value = H5T_reclaim(type_id, space, buf);
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Treclaim() */
/*-------------------------------------------------------------------------
* Function: H5Tencode
*
@ -4456,28 +4542,10 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
HGOTO_DONE(-1);
if(dt1->shared->u.atomic.u.r.rtype > dt2->shared->u.atomic.u.r.rtype)
HGOTO_DONE(1);
switch(dt1->shared->u.atomic.u.r.rtype) {
case H5R_OBJECT:
if(dt1->shared->u.atomic.u.r.loc < dt2->shared->u.atomic.u.r.loc)
HGOTO_DONE(-1);
if(dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc)
HGOTO_DONE(1);
break;
case H5R_DATASET_REGION:
/* Does this need more to distinguish it? -QAK 11/30/98 */
/*void */
break;
case H5R_BADTYPE:
case H5R_MAXTYPE:
HDassert("invalid type" && 0);
break;
default:
HDassert("not implemented yet" && 0);
break;
}
if(dt1->shared->u.atomic.u.r.loc < dt2->shared->u.atomic.u.r.loc)
HGOTO_DONE(-1);
if(dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc)
HGOTO_DONE(1);
break;
case H5T_NO_CLASS:
@ -5330,7 +5398,7 @@ done:
htri_t H5T_set_loc(dt,f,loc)
H5T_t *dt; IN/OUT: Pointer to the datatype to mark
H5F_t *f; IN: Pointer to the file the datatype is in
H5T_vlen_type_t loc IN: location of type
H5T_loc_t loc IN: location of type
RETURNS
One of two values on success:
@ -5455,17 +5523,9 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc)
break;
case H5T_REFERENCE:
/* Only need to change location of object references */
if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT) {
/* Mark this reference */
if(loc != dt->shared->u.atomic.u.r.loc) {
/* Set the location */
dt->shared->u.atomic.u.r.loc = loc;
/* Indicate that the location changed */
ret_value = TRUE;
} /* end if */
} /* end if */
/* Reference types go through type conversion */
if((ret_value = H5T__ref_set_loc(dt, f, loc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "Unable to set reference location");
break;
case H5T_NO_CLASS:
@ -5492,7 +5552,7 @@ done:
*
* Purpose: Check if a datatype will change between disk and memory.
*
* Notes: Currently, only variable-length and object references change
* Notes: Currently, only variable-length and references change
* between disk & memory (see cases where things are changed in
* the H5T_set_loc() code above).
*
@ -5527,9 +5587,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5T_detect_reg_ref
* Function: H5T__detect_vlen_ref
*
* Purpose: Check whether a datatype contains (or is) a region reference
* Purpose: Check whether a datatype contains (or is) a vlen reference
* datatype.
*
* Return: TRUE (1) or FALSE (0) on success
@ -5541,7 +5601,7 @@ done:
*-------------------------------------------------------------------------
*/
static hbool_t
H5T__detect_reg_ref(const H5T_t *dt)
H5T__detect_vlen_ref(const H5T_t *dt)
{
unsigned u; /* Local index variable */
hbool_t ret_value = FALSE; /* Return value */
@ -5551,8 +5611,9 @@ H5T__detect_reg_ref(const H5T_t *dt)
/* Sanity checks */
HDassert(dt);
/* Check if this datatype is a region reference */
if(H5T_REFERENCE == dt->shared->type && H5R_DATASET_REGION == dt->shared->u.atomic.u.r.rtype)
/* Check if this datatype is a vlen reference */
/* TODO currently H5T_STD_REF is always considered as a vlen type */
if(H5T_REFERENCE == dt->shared->type && !dt->shared->u.atomic.u.r.opaque)
HGOTO_DONE(TRUE);
/* Check for types that might have the correct type as a component */
@ -5561,14 +5622,14 @@ H5T__detect_reg_ref(const H5T_t *dt)
/* Iterate over all the compound datatype's fields */
for(u = 0; u < dt->shared->u.compnd.nmembs; u++)
/* Recurse on field's datatype */
if(H5T__detect_reg_ref(dt->shared->u.compnd.memb[u].type))
if(H5T__detect_vlen_ref(dt->shared->u.compnd.memb[u].type))
HGOTO_DONE(TRUE);
break;
case H5T_ARRAY:
case H5T_VLEN:
case H5T_ENUM:
HGOTO_DONE(H5T__detect_reg_ref(dt->shared->parent));
HGOTO_DONE(H5T__detect_vlen_ref(dt->shared->parent));
break;
case H5T_NO_CLASS:
@ -5586,7 +5647,7 @@ H5T__detect_reg_ref(const H5T_t *dt)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__detect_reg_ref() */
} /* end H5T__detect_vlen_ref() */
/*-------------------------------------------------------------------------
@ -5622,7 +5683,7 @@ H5T_is_vl_storage(const H5T_t *dt)
if(H5T_detect_class(dt, H5T_VLEN, FALSE))
ret_value = TRUE;
else if(H5T_detect_class(dt, H5T_REFERENCE, FALSE))
ret_value = H5T__detect_reg_ref(dt);
ret_value = H5T__detect_vlen_ref(dt);
else
ret_value = FALSE;

View File

@ -30,7 +30,6 @@
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5HGprivate.h" /* Global Heaps */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
@ -1019,6 +1018,9 @@ H5FL_BLK_DEFINE_STATIC(vlen_seq);
/* Declare a free list to manage pieces of array data */
H5FL_BLK_DEFINE_STATIC(array_seq);
/* Declare a free list to manage pieces of reference data */
H5FL_BLK_DEFINE_STATIC(ref_seq);
/*-------------------------------------------------------------------------
* Function: H5T__conv_noop
@ -3020,17 +3022,16 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
hbool_t noop_conv = FALSE; /* Flag to indicate a noop conversion */
hbool_t write_to_file = FALSE; /* Flag to indicate writing to file */
htri_t parent_is_vlen; /* Flag to indicate parent is vlen datatyp */
size_t bg_seq_len = 0; /* The number of elements in the background sequence */
hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */
H5T_t *src = NULL; /*source datatype */
H5T_t *dst = NULL; /*destination datatype */
H5HG_t bg_hobjid, parent_hobjid;
uint8_t *s = NULL; /*source buffer */
uint8_t *d = NULL; /*destination buffer */
uint8_t *b = NULL; /*background buffer */
ssize_t s_stride, d_stride; /*src and dst strides */
ssize_t b_stride; /*bkg stride */
size_t safe; /*how many elements are safe to process in each pass */
size_t bg_seq_len = 0;
size_t src_base_size, dst_base_size;/*source & destination base size*/
void *conv_buf = NULL; /*temporary conversion buffer */
size_t conv_buf_size = 0; /*size of conversion buffer in bytes */
@ -3055,13 +3056,13 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype")
if(H5T_VLEN != src->shared->type)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype")
if(H5T_VLEN != dst->shared->type)
if(H5T_VLEN != dst->shared->type)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype")
if(H5T_VLEN_STRING == src->shared->u.vlen.type && H5T_VLEN_STRING == dst->shared->u.vlen.type) {
if((H5T_CSET_ASCII == src->shared->u.vlen.cset && H5T_CSET_UTF8 == dst->shared->u.vlen.cset)
|| (H5T_CSET_ASCII == dst->shared->u.vlen.cset && H5T_CSET_UTF8 == src->shared->u.vlen.cset))
|| (H5T_CSET_ASCII == dst->shared->u.vlen.cset && H5T_CSET_UTF8 == src->shared->u.vlen.cset))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "The library doesn't convert between strings of ASCII and UTF")
}
} /* end if */
/* Variable-length types don't need a background buffer */
cdata->need_bkg = H5T_BKG_NO;
@ -3179,25 +3180,27 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
} /* end else */
for(elmtno = 0; elmtno < safe; elmtno++) {
hbool_t is_nil; /* Whether sequence is "nil" */
/* Check for "nil" source sequence */
if((*(src->shared->u.vlen.isnull))(src->shared->u.vlen.f, s)) {
if((*(src->shared->u.vlen.cls->isnull))(src->shared->u.vlen.f, s, &is_nil) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check if VL data is 'nil'")
else if(is_nil) {
/* Write "nil" sequence to destination location */
if((*(dst->shared->u.vlen.setnull))(dst->shared->u.vlen.f, d, b) < 0)
if((*(dst->shared->u.vlen.cls->setnull))(dst->shared->u.vlen.f, d, b) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'")
} /* end if */
} /* end else-if */
else {
ssize_t sseq_len; /* (signed) The number of elements in the current sequence*/
size_t seq_len; /* The number of elements in the current sequence*/
size_t seq_len; /* The number of elements in the current sequence */
/* Get length of element sequences */
if((sseq_len = (*(src->shared->u.vlen.getlen))(s)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect length")
seq_len = (size_t)sseq_len;
if((*(src->shared->u.vlen.cls->getlen))(src->shared->u.vlen.f, s, &seq_len) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length")
/* If we are reading from memory and there is no conversion, just get the pointer to sequence */
if(write_to_file && noop_conv) {
/* Get direct pointer to sequence */
if(NULL == (conv_buf = (*(src->shared->u.vlen.getptr))(s)))
if(NULL == (conv_buf = (*(src->shared->u.vlen.cls->getptr))(s)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer")
} /* end if */
else {
@ -3213,17 +3216,17 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
conv_buf_size = ((1 / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * H5T_VLEN_MIN_CONF_BUF_SIZE;
if(NULL == (conv_buf = H5FL_BLK_CALLOC(vlen_seq, conv_buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion")
}
} /* end if */
else if(conv_buf_size < MAX(src_size, dst_size)) {
/* Only allocate conversion buffer in H5T_VLEN_MIN_CONF_BUF_SIZE increments */
conv_buf_size = ((MAX(src_size, dst_size) / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * H5T_VLEN_MIN_CONF_BUF_SIZE;
if(NULL == (conv_buf = H5FL_BLK_REALLOC(vlen_seq, conv_buf, conv_buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion")
HDmemset(conv_buf, 0, conv_buf_size);
} /* end if */
} /* end else-if */
/* Read in VL sequence */
if((*(src->shared->u.vlen.read))(src->shared->u.vlen.f, s, conv_buf, src_size) < 0)
if((*(src->shared->u.vlen.cls->read))(src->shared->u.vlen.f, s, conv_buf, src_size) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data")
} /* end else */
@ -3241,9 +3244,14 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
/* If we are writing and there is a nested VL type, read
* the sequence into the background buffer */
if(nested) {
const uint8_t *tmp = b;
/* Sanity check */
HDassert(write_to_file);
UINT32DECODE(tmp, bg_seq_len);
/* Get length of background element sequence */
if((*(dst->shared->u.vlen.cls->getlen))(dst->shared->u.vlen.f, b, &bg_seq_len) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length")
/* Read sequence if length > 0 */
if(bg_seq_len > 0) {
if(tmp_buf_size < (bg_seq_len * MAX(src_base_size, dst_base_size))) {
tmp_buf_size = (bg_seq_len * MAX(src_base_size, dst_base_size));
@ -3251,10 +3259,10 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion")
HDmemset(tmp_buf, 0, tmp_buf_size);
} /* end if */
H5F_addr_decode(dst->shared->u.vlen.f, &tmp, &(bg_hobjid.addr));
UINT32DECODE(tmp, bg_hobjid.idx);
if(NULL == H5HG_read(dst->shared->u.vlen.f, &bg_hobjid, tmp_buf, NULL))
HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer")
/* Read in background VL sequence */
if((*(dst->shared->u.vlen.cls->read))(dst->shared->u.vlen.f, b, tmp_buf, bg_seq_len) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data")
} /* end if */
/* If the sequence gets shorter, pad out the original sequence with zeros */
@ -3268,26 +3276,23 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
} /* end if */
/* Write sequence to destination location */
if((*(dst->shared->u.vlen.write))(dst->shared->u.vlen.f, &vl_alloc_info, d, conv_buf, b, seq_len, dst_base_size) < 0)
if((*(dst->shared->u.vlen.cls->write))(dst->shared->u.vlen.f, &vl_alloc_info, d, conv_buf, b, seq_len, dst_base_size) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data")
if(!noop_conv) {
/* For nested VL case, free leftover heap objects from the deeper level if the length of new data elements is shorter than the old data elements.*/
if(nested && seq_len < bg_seq_len) {
size_t parent_seq_len;
const uint8_t *tmp;
size_t u;
/* TMP_P is reset each time in the loop because DST_BASE_SIZE may include some data in addition to VL info. - SLU */
for(u = seq_len; u < bg_seq_len; u++) {
tmp = (uint8_t *)tmp_buf + u * dst_base_size;
UINT32DECODE(tmp, parent_seq_len);
if(parent_seq_len > 0) {
H5F_addr_decode(dst->shared->u.vlen.f, &tmp, &(parent_hobjid.addr));
UINT32DECODE(tmp, parent_hobjid.idx);
if(H5HG_remove(dst->shared->u.vlen.f, &parent_hobjid) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object")
} /* end if */
/* Sanity check */
HDassert(write_to_file);
tmp = (uint8_t *)tmp_buf + seq_len * dst_base_size;
for(u = seq_len; u < bg_seq_len; u++, tmp += dst_base_size) {
/* Delete sequence in destination location */
if((*(dst->shared->u.vlen.cls->del))(dst->shared->u.vlen.f, tmp) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove heap object")
} /* end for */
} /* end if */
} /* end if */
@ -3474,6 +3479,195 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__conv_array() */
/*-------------------------------------------------------------------------
* Function: H5T__conv_ref
*
* Purpose: Converts between reference datatypes in memory and on disk.
* This is a soft conversion function.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
size_t buf_stride, size_t bkg_stride, void *buf, void *bkg)
{
H5T_t *src = NULL; /* source datatype */
H5T_t *dst = NULL; /* destination datatype */
uint8_t *s = NULL; /* source buffer */
uint8_t *d = NULL; /* destination buffer */
uint8_t *b = NULL; /* background buffer */
ssize_t s_stride, d_stride; /* src and dst strides */
ssize_t b_stride; /* bkg stride */
size_t safe; /* how many elements are safe to process in each pass */
void *conv_buf = NULL; /* temporary conversion buffer */
size_t conv_buf_size = 0; /* size of conversion buffer in bytes */
size_t elmtno; /* element number counter */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_PACKAGE
switch(cdata->command) {
case H5T_CONV_INIT:
/*
* First, determine if this conversion function applies to the
* conversion path SRC_ID-->DST_ID. If not, return failure;
* otherwise initialize the `priv' field of `cdata' with
* information that remains (almost) constant for this
* conversion path.
*/
if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id)))
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype")
if(H5T_REFERENCE != src->shared->type)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_REFERENCE datatype")
if(H5T_REFERENCE != dst->shared->type)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_REFERENCE datatype")
/* Only allow for source reference that is not an opaque type, destination must be opaque */
if(!dst->shared->u.atomic.u.r.opaque)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not an H5T_STD_REF datatype")
/* Reference types don't need a background buffer */
cdata->need_bkg = H5T_BKG_NO;
break;
case H5T_CONV_FREE:
break;
case H5T_CONV_CONV:
{
/*
* Conversion.
*/
if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
HDassert(src->shared->u.atomic.u.r.cls);
/* Initialize source & destination strides */
if(buf_stride) {
HDassert(buf_stride >= src->shared->size);
HDassert(buf_stride >= dst->shared->size);
H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t);
s_stride = d_stride = (ssize_t)buf_stride;
} /* end if */
else {
H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t);
H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t);
s_stride = (ssize_t)src->shared->size;
d_stride = (ssize_t)dst->shared->size;
} /* end else */
if(bkg) {
if(bkg_stride)
b_stride = (ssize_t)bkg_stride;
else
b_stride = d_stride;
} /* end if */
else
b_stride = 0;
/* The outer loop of the type conversion macro, controlling which */
/* direction the buffer is walked */
while(nelmts > 0) {
/* Check if we need to go backwards through the buffer */
if(d_stride > s_stride) {
/* Sanity check */
HDassert(s_stride > 0);
HDassert(d_stride > 0);
HDassert(b_stride >= 0);
/* Compute the number of "safe" destination elements at */
/* the end of the buffer (Those which don't overlap with */
/* any source elements at the beginning of the buffer) */
safe = nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride);
/* If we're down to the last few elements, just wrap up */
/* with a "real" reverse copy */
if(safe < 2) {
s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride;
b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride;
s_stride = -s_stride;
d_stride = -d_stride;
b_stride = -b_stride;
safe = nelmts;
} /* end if */
else {
s = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride;
d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride;
b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride;
} /* end else */
} /* end if */
else {
/* Single forward pass over all data */
s = d = (uint8_t *)buf;
b = (uint8_t *)bkg;
safe = nelmts;
} /* end else */
for(elmtno = 0; elmtno < safe; elmtno++) {
size_t buf_size;
hbool_t dst_copy = FALSE;
/* Get size of references */
if(0 == (buf_size = src->shared->u.atomic.u.r.cls->getsize(
src->shared->u.atomic.u.r.f, s, src->shared->size,
dst->shared->u.atomic.u.r.f, &dst_copy)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect size")
/* Check if conversion buffer is large enough, resize if necessary. */
if(conv_buf_size < buf_size) {
conv_buf_size = buf_size;
if(NULL == (conv_buf = H5FL_BLK_REALLOC(ref_seq, conv_buf, conv_buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion")
HDmemset(conv_buf, 0, conv_buf_size);
} /* end if */
if(dst_copy && (src->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) {
H5MM_memcpy(conv_buf, s, buf_size);
} else {
/* Read reference */
if(src->shared->u.atomic.u.r.cls->read(
src->shared->u.atomic.u.r.f, s, src->shared->size,
dst->shared->u.atomic.u.r.f, conv_buf, buf_size) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read reference data")
}
if(dst_copy && (dst->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) {
H5MM_memcpy(d, conv_buf, buf_size);
} else {
/* Write reference to destination location */
if(dst->shared->u.atomic.u.r.cls->write(
src->shared->u.atomic.u.r.f, conv_buf, buf_size, src->shared->u.atomic.u.r.rtype,
dst->shared->u.atomic.u.r.f, d, dst->shared->size, b) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write reference data")
}
/* Advance pointers */
s += s_stride;
d += d_stride;
b += b_stride;
} /* end for */
/* Decrement number of elements left to convert */
nelmts -= safe;
} /* end while */
} /* end case */
break;
default: /* Some other command we don't know about yet.*/
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command")
} /* end switch */
done:
/* Release the conversion buffer (always allocated, except on errors) */
if(conv_buf)
conv_buf = H5FL_BLK_FREE(ref_seq, conv_buf);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__conv_ref() */
/*-------------------------------------------------------------------------
* Function: H5T__conv_i_i
@ -9305,3 +9499,84 @@ H5T_reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order)
FUNC_LEAVE_NOAPI(SUCCEED)
}
/*-------------------------------------------------------------------------
* Function: H5T_reclaim
*
* Purpose: Frees the buffers allocated for storing variable-length data
* in memory. Only frees the VL data in the selection defined in the
* dataspace.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_reclaim(hid_t type_id, H5S_t *space, void *buf)
{
H5T_t *type; /* Datatype */
H5S_sel_iter_op_t dset_op; /* Operator for iteration */
H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */
herr_t ret_value = FAIL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Check args */
HDassert(H5I_DATATYPE == H5I_get_type(type_id));
HDassert(space);
HDassert(buf);
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype")
/* Get the allocation info */
if(H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info")
/* Call H5S_select_iterate with args, etc. */
dset_op.op_type = H5S_SEL_ITER_OP_LIB;
dset_op.u.lib_op = H5T_reclaim_cb;
ret_value = H5S_select_iterate(buf, type, space, &dset_op, &vl_alloc_info);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_reclaim() */
/*-------------------------------------------------------------------------
* Function: H5T_reclaim_cb
*
* Purpose: Iteration callback to reclaim conversion allocated memory for a
* buffer element.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_reclaim_cb(void *elem, const H5T_t *dt, unsigned H5_ATTR_UNUSED ndim,
const hsize_t H5_ATTR_UNUSED *point, void *op_data)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Sanity check */
HDassert(elem);
HDassert(dt);
if(dt->shared->type == H5T_REFERENCE) {
if(H5T_ref_reclaim(elem, dt) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim ref elements")
} else {
HDassert(op_data);
/* Allow vlen reclaim to recurse into that routine */
if(H5T_vlen_reclaim(elem, dt, (H5T_vlen_alloc_info_t *)op_data) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_reclaim_cb() */

View File

@ -126,7 +126,6 @@ static H5T_t *
H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_align,
size_t *offset, size_t *comp_size)
{
H5T_t *dt; /* Datatype to make native */
H5T_t *super_type; /* Super type of VL, array and enum datatypes */
H5T_t *nat_super_type; /* Native form of VL, array & enum super datatype */
H5T_t *new_type = NULL; /* New native datatype */
@ -218,26 +217,36 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali
case H5T_REFERENCE:
{
H5T_t *dt; /* Datatype to make native */
size_t align;
size_t ref_size;
int not_equal;
if(NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type")
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy reference type")
/* Decide if the data type is object or dataset region reference. */
/* Decide if the data type is object reference. */
if(NULL == (dt = (H5T_t *)H5I_object(H5T_STD_REF_OBJ_g)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type")
not_equal = H5T_cmp(ret_value, dt, FALSE);
/* Update size, offset and compound alignment for parent. */
if(!not_equal) {
if(0 == H5T_cmp(ret_value, dt, FALSE)) {
align = H5T_HOBJREF_COMP_ALIGN_g;
ref_size = sizeof(hobj_ref_t);
} /* end if */
else {
align = H5T_HDSETREGREF_COMP_ALIGN_g;
ref_size = sizeof(hdset_reg_ref_t);
/* Decide if the data type is dataset region reference. */
if(NULL == (dt = (H5T_t *)H5I_object(H5T_STD_REF_DSETREG_g)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type")
if (0 == H5T_cmp(ret_value, dt, FALSE)) {
align = H5T_HDSETREGREF_COMP_ALIGN_g;
ref_size = sizeof(hdset_reg_ref_t);
} /* end if */
else {
/* Only pointers to underlying opaque reference types */
align = H5T_REF_COMP_ALIGN_g;
ref_size = sizeof(H5R_ref_t);
} /* end else */
} /* end else */
if(H5T__cmp_offset(comp_size, offset, ref_size, (size_t)1, align, struct_align) < 0)

View File

@ -95,9 +95,14 @@
/* This version also encodes array types more efficiently */
#define H5O_DTYPE_VERSION_3 3
/* This is the version that adds support for new reference types and prevents
* older versions of the library to attempt reading unknown types.
*/
#define H5O_DTYPE_VERSION_4 4
/* The latest version of the format. Look through the 'encode helper' routine
* and 'size' callback for places to change when updating this. */
#define H5O_DTYPE_VERSION_LATEST H5O_DTYPE_VERSION_3
#define H5O_DTYPE_VERSION_LATEST H5O_DTYPE_VERSION_4
/* Flags for visiting datatype */
@ -175,37 +180,52 @@ struct H5T_path_t {
H5T_cdata_t cdata; /*data for this function */
};
/* Reference function pointers */
typedef size_t (*H5T_ref_getsizefunc_t)(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, hbool_t *dst_copy);
typedef herr_t (*H5T_ref_readfunc_t)(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, void *dst_buf, size_t dst_size);
typedef herr_t (*H5T_ref_writefunc_t)(H5F_t *src_f, const void *src_buf, size_t src_size, H5R_type_t src_type, H5F_t *dst_f, void *dst_buf, size_t dst_size, void *bg_buf);
typedef struct H5T_ref_class_t {
H5T_ref_getsizefunc_t getsize; /* get reference size (bytes) */
H5T_ref_readfunc_t read; /* read reference into buffer */
H5T_ref_writefunc_t write; /* write reference from buffer */
} H5T_ref_class_t;
typedef struct H5T_atomic_t {
H5T_order_t order; /*byte order */
size_t prec; /*precision in bits */
size_t offset; /*bit position of lsb of value */
H5T_pad_t lsb_pad;/*type of lsb padding */
H5T_pad_t msb_pad;/*type of msb padding */
H5T_order_t order; /* byte order */
size_t prec; /* precision in bits */
size_t offset; /* bit position of lsb of value */
H5T_pad_t lsb_pad; /* type of lsb padding */
H5T_pad_t msb_pad; /* type of msb padding */
union {
struct {
H5T_sign_t sign; /*type of integer sign */
} i; /*integer; integer types */
struct {
H5T_sign_t sign; /* type of integer sign */
} i; /* integer; integer types */
struct {
size_t sign; /*bit position of sign bit */
size_t epos; /*position of lsb of exponent */
size_t esize; /*size of exponent in bits */
uint64_t ebias; /*exponent bias */
size_t mpos; /*position of lsb of mantissa */
size_t msize; /*size of mantissa */
H5T_norm_t norm; /*normalization */
H5T_pad_t pad; /*type of padding for internal bits */
} f; /*floating-point types */
struct {
size_t sign; /* bit position of sign bit */
size_t epos; /* position of lsb of exponent */
size_t esize; /* size of exponent in bits */
uint64_t ebias; /* exponent bias */
size_t mpos; /* position of lsb of mantissa */
size_t msize; /* size of mantissa */
H5T_norm_t norm; /* normalization */
H5T_pad_t pad; /* type of padding for internal bits */
} f; /* floating-point types */
struct {
H5T_cset_t cset; /*character set */
H5T_str_t pad; /*space or null padding of extra bytes */
} s; /*string types */
struct {
H5T_cset_t cset; /* character set */
H5T_str_t pad; /* space or null padding of extra bytes */
} s; /* string types */
struct {
H5R_type_t rtype; /*type of reference stored */
H5T_loc_t loc; /* Location of data in buffer */
} r; /*reference types */
struct {
H5R_type_t rtype; /* type of reference stored */
unsigned version; /* version of encoded reference */
hbool_t opaque; /* opaque reference type */
H5T_loc_t loc; /* location of data in buffer */
H5F_t *f; /* file pointer (if data is on disk) */
const H5T_ref_class_t *cls; /* Pointer to ref class callbacks */
} r; /* reference types */
} u;
} H5T_atomic_t;
@ -243,14 +263,6 @@ typedef struct H5T_enum_t {
char **name; /*array of symbol names */
} H5T_enum_t;
/* VL function pointers */
typedef ssize_t (*H5T_vlen_getlenfunc_t)(const void *vl_addr);
typedef void * (*H5T_vlen_getptrfunc_t)(void *vl_addr);
typedef htri_t (*H5T_vlen_isnullfunc_t)(const H5F_t *f, void *vl_addr);
typedef herr_t (*H5T_vlen_readfunc_t)(H5F_t *f, void *_vl, void *buf, size_t len);
typedef herr_t (*H5T_vlen_writefunc_t)(H5F_t *f, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size);
typedef herr_t (*H5T_vlen_setnullfunc_t)(H5F_t *f, void *_vl, void *_bg);
/* VL types */
typedef enum {
H5T_VLEN_BADTYPE = -1, /* invalid VL Type */
@ -259,20 +271,35 @@ typedef enum {
H5T_VLEN_MAXTYPE /* highest type (Invalid as true type) */
} H5T_vlen_type_t;
/* VL function pointers */
typedef herr_t (*H5T_vlen_getlen_func_t)(H5F_t *f, const void *vl_addr, size_t *len);
typedef void * (*H5T_vlen_getptr_func_t)(void *vl_addr);
typedef herr_t (*H5T_vlen_isnull_func_t)(const H5F_t *f, void *vl_addr, hbool_t *isnull);
typedef herr_t (*H5T_vlen_setnull_func_t)(H5F_t *f, void *_vl, void *_bg);
typedef herr_t (*H5T_vlen_read_func_t)(H5F_t *f, void *_vl, void *buf, size_t len);
typedef herr_t (*H5T_vlen_write_func_t)(H5F_t *f, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size);
typedef herr_t (*H5T_vlen_delete_func_t)(H5F_t *f, const void *_vl);
/* VL datatype callbacks */
typedef struct H5T_vlen_class_t {
H5T_vlen_getlen_func_t getlen; /* Function to get VL sequence size (in element units, not bytes) */
H5T_vlen_getptr_func_t getptr; /* Function to get VL sequence pointer */
H5T_vlen_isnull_func_t isnull; /* Function to check if VL value is NIL */
H5T_vlen_setnull_func_t setnull;/* Function to set a VL value to NIL */
H5T_vlen_read_func_t read; /* Function to read VL sequence into buffer */
H5T_vlen_write_func_t write; /* Function to write VL sequence from buffer */
H5T_vlen_delete_func_t del; /* Function to delete VL sequence */
} H5T_vlen_class_t;
/* A VL datatype */
typedef struct H5T_vlen_t {
H5T_vlen_type_t type; /* Type of VL data in buffer */
H5T_loc_t loc; /* Location of VL data in buffer */
H5T_cset_t cset; /* For VL string. character set */
H5T_str_t pad; /* For VL string. space or null padding of
H5T_cset_t cset; /* For VL string: character set */
H5T_str_t pad; /* For VL string: space or null padding of
* extra bytes */
H5F_t *f; /* File ID (if VL data is on disk) */
H5T_vlen_getptrfunc_t getptr; /* Function to get VL sequence pointer */
H5T_vlen_getlenfunc_t getlen; /* Function to get VL sequence size (in element units, not bytes) */
H5T_vlen_isnullfunc_t isnull; /* Function to check if VL value is NIL */
H5T_vlen_readfunc_t read; /* Function to read VL sequence into buffer */
H5T_vlen_writefunc_t write; /* Function to write VL sequence from buffer */
H5T_vlen_setnullfunc_t setnull; /* Function to set a VL value to NIL */
const H5T_vlen_class_t *cls; /* Pointer to VL class callbacks */
} H5T_vlen_t;
/* An opaque datatype */
@ -371,6 +398,7 @@ H5_DLLVAR size_t H5T_POINTER_COMP_ALIGN_g;
H5_DLLVAR size_t H5T_HVL_COMP_ALIGN_g;
H5_DLLVAR size_t H5T_HOBJREF_COMP_ALIGN_g;
H5_DLLVAR size_t H5T_HDSETREGREF_COMP_ALIGN_g;
H5_DLLVAR size_t H5T_REF_COMP_ALIGN_g;
/*
* Alignment information for native types. A value of N indicates that the
@ -483,6 +511,9 @@ H5_DLL herr_t H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
H5_DLL herr_t H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t nelmts, size_t buf_stride,
size_t bkg_stride, void *buf, void *bkg);
H5_DLL herr_t H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t nelmts, size_t buf_stride,
size_t bkg_stride, void *buf, void *bkg);
H5_DLL herr_t H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t nelmts, size_t buf_stride,
size_t bkg_stride, void *_buf, void *bkg);
@ -1149,6 +1180,9 @@ H5_DLL H5T_t *H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/
H5_DLL int H5T__get_array_ndims(const H5T_t *dt);
H5_DLL int H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]);
/* Reference functions */
H5_DLL htri_t H5T__ref_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc);
/* Compound functions */
H5_DLL herr_t H5T__insert(H5T_t *parent, const char *name, size_t offset,
const H5T_t *member);

View File

@ -52,6 +52,9 @@ typedef struct H5T_t H5T_t;
typedef struct H5T_stats_t H5T_stats_t;
typedef struct H5T_path_t H5T_path_t;
/* Forward reference of H5S_t */
struct H5S_t;
/* How to copy a datatype */
typedef enum H5T_copy_t {
H5T_COPY_TRANSIENT,
@ -130,7 +133,10 @@ H5_DLL H5T_bkg_t H5T_path_bkg(const H5T_path_t *p);
H5_DLL H5T_subset_info_t *H5T_path_compound_subset(const H5T_path_t *p);
H5_DLL herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id,
size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg);
H5_DLL herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *_op_data);
H5_DLL herr_t H5T_reclaim(hid_t type_id, struct H5S_t *space, void *buf);
H5_DLL herr_t H5T_reclaim_cb(void *elem, const H5T_t *dt, unsigned ndim, const hsize_t *point, void *op_data);
H5_DLL herr_t H5T_ref_reclaim(void *elem, const H5T_t *dt);
H5_DLL herr_t H5T_vlen_reclaim(void *elem, const H5T_t *dt, H5T_vlen_alloc_info_t *alloc_info);
H5_DLL herr_t H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt);
H5_DLL htri_t H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc);
H5_DLL htri_t H5T_is_sensible(const H5T_t *dt);

View File

@ -262,8 +262,9 @@ H5_DLLVAR hid_t H5T_IEEE_F64LE_g;
#define H5T_STD_B32LE (H5OPEN H5T_STD_B32LE_g)
#define H5T_STD_B64BE (H5OPEN H5T_STD_B64BE_g)
#define H5T_STD_B64LE (H5OPEN H5T_STD_B64LE_g)
#define H5T_STD_REF_OBJ (H5OPEN H5T_STD_REF_OBJ_g)
#define H5T_STD_REF_OBJ (H5OPEN H5T_STD_REF_OBJ_g)
#define H5T_STD_REF_DSETREG (H5OPEN H5T_STD_REF_DSETREG_g)
#define H5T_STD_REF (H5OPEN H5T_STD_REF_g)
H5_DLLVAR hid_t H5T_STD_I8BE_g;
H5_DLLVAR hid_t H5T_STD_I8LE_g;
H5_DLLVAR hid_t H5T_STD_I16BE_g;
@ -290,6 +291,7 @@ H5_DLLVAR hid_t H5T_STD_B64BE_g;
H5_DLLVAR hid_t H5T_STD_B64LE_g;
H5_DLLVAR hid_t H5T_STD_REF_OBJ_g;
H5_DLLVAR hid_t H5T_STD_REF_DSETREG_g;
H5_DLLVAR hid_t H5T_STD_REF_g;
/*
* Types which are particular to Unix.
@ -591,6 +593,7 @@ H5_DLL H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata);
H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id);
H5_DLL herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts,
void *buf, void *background, hid_t plist_id);
H5_DLL herr_t H5Treclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf);
/* Symbols defined for compatibility with previous versions of the HDF5 API.
*

761
src/H5Tref.c Normal file
View File

@ -0,0 +1,761 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Module Info: This module contains the functionality for reference
* datatypes in the H5T interface.
*/
#include "H5Tmodule.h" /* This source code file is part of the H5T module */
#define H5F_FRIEND /*suppress error about including H5Fpkg */
#define H5R_FRIEND /*suppress error about including H5Rpkg */
#include "H5private.h" /* Generic Functions */
#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5Fpkg.h" /* File */
#include "H5Rpkg.h" /* References */
#include "H5Tpkg.h" /* Datatypes */
/****************/
/* Local Macros */
/****************/
#define H5T_REF_MEM_SIZE (H5R_REF_BUF_SIZE)
#define H5T_REF_OBJ_MEM_SIZE (H5R_OBJ_REF_BUF_SIZE)
#define H5T_REF_DSETREG_MEM_SIZE (H5R_DSET_REG_REF_BUF_SIZE)
#define H5T_REF_OBJ_DISK_SIZE(f) (H5F_SIZEOF_ADDR(f))
#define H5T_REF_DSETREG_DISK_SIZE(f) (H5HG_HEAP_ID_SIZE(f))
/******************/
/* Local Typedefs */
/******************/
/* For region compatibility support */
struct H5Tref_dsetreg {
haddr_t obj_addr; /* Object address */
H5S_t *space; /* Dataspace */
};
/********************/
/* Local Prototypes */
/********************/
static size_t H5T__ref_mem_getsize(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, hbool_t *dst_copy);
static herr_t H5T__ref_mem_read(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, void *dst_buf, size_t dst_size);
static herr_t H5T__ref_mem_write(H5F_t *src_f, const void *src_buf, size_t src_size, H5R_type_t src_type, H5F_t *dst_f, void *dst_buf, size_t dst_size, void *bg_buf);
static size_t H5T__ref_disk_getsize(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, hbool_t *dst_copy);
static herr_t H5T__ref_disk_read(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, void *dst_buf, size_t dst_size);
static herr_t H5T__ref_disk_write(H5F_t *src_f, const void *src_buf, size_t src_size, H5R_type_t src_type, H5F_t *dst_f, void *dst_buf, size_t dst_size, void *bg_buf);
/* For compatibility */
static size_t H5T__ref_obj_disk_getsize(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, hbool_t *dst_copy);
static herr_t H5T__ref_obj_disk_read(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, void *dst_buf, size_t dst_size);
static size_t H5T__ref_dsetreg_disk_getsize(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, hbool_t *dst_copy);
static herr_t H5T__ref_dsetreg_disk_read(H5F_t *src_f, const void *src_buf, size_t src_size, H5F_t *dst_f, void *dst_buf, size_t dst_size);
/*******************/
/* Local Variables */
/*******************/
/* Class for reference in memory */
static const H5T_ref_class_t H5T_ref_mem_g = {
H5T__ref_mem_getsize, /* 'getsize' */
H5T__ref_mem_read, /* 'read' */
H5T__ref_mem_write /* 'write' */
};
static const H5T_ref_class_t H5T_ref_disk_g = {
H5T__ref_disk_getsize, /* 'getsize' */
H5T__ref_disk_read, /* 'read' */
H5T__ref_disk_write /* 'write' */
};
static const H5T_ref_class_t H5T_ref_obj_disk_g = {
H5T__ref_obj_disk_getsize, /* 'getsize' */
H5T__ref_obj_disk_read, /* 'read' */
NULL /* 'write' */
};
static const H5T_ref_class_t H5T_ref_dsetreg_disk_g = {
H5T__ref_dsetreg_disk_getsize, /* 'getsize' */
H5T__ref_dsetreg_disk_read, /* 'read' */
NULL /* 'write' */
};
/*-------------------------------------------------------------------------
* Function: H5T__ref_set_loc
*
* Purpose: Sets the location of a reference datatype to be either on disk
* or in memory
*
* Return:
* One of two values on success:
* TRUE - If the location of any reference types changed
* FALSE - If the location of any reference types is the same
* Negative value is returned on failure
*
*-------------------------------------------------------------------------
*/
htri_t
H5T__ref_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc)
{
htri_t ret_value = FALSE; /* Indicate success, but no location change */
FUNC_ENTER_PACKAGE
HDassert(dt);
/* f is NULL when loc == H5T_LOC_MEMORY */
HDassert(loc >= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC);
/* Only change the location if it's different */
if(loc == dt->shared->u.atomic.u.r.loc && f == dt->shared->u.atomic.u.r.f)
HGOTO_DONE(FALSE)
switch(loc) {
case H5T_LOC_MEMORY: /* Memory based reference datatype */
HDassert(NULL == f);
/* Mark this type as being stored in memory */
dt->shared->u.atomic.u.r.loc = H5T_LOC_MEMORY;
/* Reset file ID (since this reference is in memory) */
dt->shared->u.atomic.u.r.f = f; /* f is NULL */
if(dt->shared->u.atomic.u.r.opaque) {
/* Size in memory, disk size is different */
dt->shared->size = H5T_REF_MEM_SIZE;
dt->shared->u.atomic.prec = 8 * dt->shared->size;
/* Set up the function pointers to access the reference in memory */
dt->shared->u.atomic.u.r.cls = &H5T_ref_mem_g;
} else if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT1) {
/* Size in memory, disk size is different */
dt->shared->size = H5T_REF_OBJ_MEM_SIZE;
dt->shared->u.atomic.prec = 8 * dt->shared->size;
/* Unused for now */
dt->shared->u.atomic.u.r.cls = NULL;
} else if(dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION1) {
/* Size in memory, disk size is different */
dt->shared->size = H5T_REF_DSETREG_MEM_SIZE;
dt->shared->u.atomic.prec = 8 * dt->shared->size;
/* Unused for now */
dt->shared->u.atomic.u.r.cls = NULL;
}
break;
case H5T_LOC_DISK: /* Disk based reference datatype */
HDassert(f);
/* Mark this type as being stored on disk */
dt->shared->u.atomic.u.r.loc = H5T_LOC_DISK;
/* Set file pointer (since this reference is on disk) */
dt->shared->u.atomic.u.r.f = f;
if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT1) {
/* Size on disk, memory size is different */
dt->shared->size = H5T_REF_OBJ_DISK_SIZE(f);
dt->shared->u.atomic.prec = 8 * dt->shared->size;
/* Set up the function pointers to access the reference in memory */
dt->shared->u.atomic.u.r.cls = &H5T_ref_obj_disk_g;
} else if(dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION1) {
/* Size on disk, memory size is different */
dt->shared->size = H5T_REF_DSETREG_DISK_SIZE(f);
dt->shared->u.atomic.prec = 8 * dt->shared->size;
/* Set up the function pointers to access the reference in memory */
dt->shared->u.atomic.u.r.cls = &H5T_ref_dsetreg_disk_g;
} else {
H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0};
size_t ref_encode_size;
H5R_ref_priv_t fixed_ref;
/* Get container info */
if(H5F__get_cont_info(f, &cont_info) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get file container info")
/* Retrieve min encode size (when references have no vlen part) */
HDmemset(&fixed_ref, 0, sizeof(fixed_ref));
fixed_ref.type = (int8_t)H5R_OBJECT2;
fixed_ref.token_size = (uint8_t)cont_info.token_size;
if(H5R__encode(NULL, &fixed_ref, NULL, &ref_encode_size, 0) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't get encode size")
/* Size on disk, memory size is different */
dt->shared->size = MAX(H5_SIZEOF_UINT32_T +
H5R_ENCODE_HEADER_SIZE + cont_info.blob_id_size,
ref_encode_size);
dt->shared->u.atomic.prec = 8 * dt->shared->size;
/* Set up the function pointers to access the information on
* disk. Region and attribute references are stored identically
* on disk, so use the same functions.
*/
dt->shared->u.atomic.u.r.cls = &H5T_ref_disk_g;
}
break;
case H5T_LOC_BADLOC:
/* Allow undefined location. In H5Odtype.c, H5O_dtype_decode sets undefined
* location for reference type and leaves it for the caller to decide.
*/
dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC;
/* Reset file pointer */
dt->shared->u.atomic.u.r.f = NULL;
/* Reset the function pointers */
dt->shared->u.atomic.u.r.cls = NULL;
break;
case H5T_LOC_MAXLOC:
/* MAXLOC is invalid */
default:
HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid reference datatype location")
} /* end switch */
/* Indicate that the location changed */
ret_value = TRUE;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_set_loc() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_mem_getsize
*
* Purpose: Retrieves the size of a memory based reference.
*
* Return: Non-negative on success/zero on failure
*
*-------------------------------------------------------------------------
*/
static size_t
H5T__ref_mem_getsize(H5F_t H5_ATTR_UNUSED *src_f, const void *src_buf,
size_t H5_ATTR_UNUSED src_size, H5F_t *dst_f, hbool_t *dst_copy)
{
void *vol_obj = NULL;
const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf;
unsigned flags = 0;
size_t ret_value = 0;
FUNC_ENTER_STATIC
HDassert(src_buf);
HDassert(src_size == H5T_REF_MEM_SIZE);
/* Retrieve VOL object */
if(NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier")
/* Retrieve file from VOL object */
if(NULL == (src_f = (H5F_t *)H5VL_object_data(vol_obj)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object")
/* Set external flag if referenced file is not destination file */
flags |= (src_f->shared != dst_f->shared) ? H5R_IS_EXTERNAL : 0;
/* Force re-calculating encoding size if any flags are set */
if(flags || !src_ref->encode_size) {
/* Pass the correct encoding version for the selection depending on the
* file libver bounds, this is later retrieved in H5S hyper encode */
if(src_ref->type == (int8_t)H5R_DATASET_REGION2)
H5CX_set_libver_bounds(dst_f);
/* Determine encoding size */
if(H5R__encode(H5F_ACTUAL_NAME(src_f), src_ref, NULL, &ret_value, flags) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, 0, "unable to determine encoding size")
} else {
/* Can do a direct copy and skip blob decoding */
if(src_ref->type == (int8_t)H5R_OBJECT2)
*dst_copy = TRUE;
/* Get cached encoding size */
ret_value = src_ref->encode_size;
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_mem_getsize() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_mem_read
*
* Purpose: "Reads" the memory based reference into a buffer
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5T__ref_mem_read(H5F_t H5_ATTR_UNUSED *src_f, const void *src_buf,
size_t H5_ATTR_UNUSED src_size, H5F_t *dst_f, void *dst_buf,
size_t dst_size)
{
void *vol_obj = NULL;
const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf;
unsigned flags = 0;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
HDassert(src_buf);
HDassert(src_size == H5T_REF_MEM_SIZE);
HDassert(dst_f);
HDassert(dst_buf);
HDassert(dst_size);
/* Retrieve VOL object */
if(NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier")
/* Retrieve file from VOL object */
if(NULL == (src_f = (H5F_t *)H5VL_object_data(vol_obj)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object")
/* Set external flag if referenced file is not destination file */
flags |= (src_f->shared != dst_f->shared) ? H5R_IS_EXTERNAL : 0;
/* Pass the correct encoding version for the selection depending on the
* file libver bounds, this is later retrieved in H5S hyper encode */
if(src_ref->type == (int8_t)H5R_DATASET_REGION2)
H5CX_set_libver_bounds(dst_f);
/* Encode reference */
if(H5R__encode(H5F_ACTUAL_NAME(src_f), src_ref, dst_buf, &dst_size, flags) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Cannot encode reference")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_mem_read() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_mem_write
*
* Purpose: "Writes" the memory reference from a buffer
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5T__ref_mem_write(H5F_t *src_f, const void *src_buf, size_t src_size,
H5R_type_t src_type, H5F_t H5_ATTR_UNUSED *dst_f, void *dst_buf,
size_t dst_size, void H5_ATTR_UNUSED *bg_buf)
{
hid_t file_id = H5I_INVALID_HID;
H5R_ref_priv_t *dst_ref = (H5R_ref_priv_t *)dst_buf;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
HDassert(src_f);
HDassert(src_buf);
HDassert(src_size);
HDassert(dst_buf);
HDassert(dst_size == H5T_REF_MEM_SIZE);
/* Make sure reference buffer is correctly initialized */
HDmemset(dst_buf, 0, dst_size);
switch(src_type) {
case H5R_OBJECT1: {
if(H5R__create_object((const H5VL_token_t *)src_buf, sizeof(haddr_t), dst_ref) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference")
}
break;
case H5R_DATASET_REGION1: {
const struct H5Tref_dsetreg *src_reg = (const struct H5Tref_dsetreg *)src_buf;
if(H5R__create_region((const H5VL_token_t *)&src_reg->obj_addr, sizeof(src_reg->obj_addr), src_reg->space, dst_ref) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create region reference")
/* create_region creates its internal copy of the space */
if(H5S_close(src_reg->space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "Cannot close dataspace")
}
break;
case H5R_DATASET_REGION2:
/* Pass the correct encoding version for the selection depending on the
* file libver bounds, this is later retrieved in H5S hyper decode */
H5CX_set_libver_bounds(src_f);
H5_ATTR_FALLTHROUGH
case H5R_OBJECT2:
case H5R_ATTR:
/* Decode reference */
if(H5R__decode((const unsigned char *)src_buf, &src_size, dst_ref) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Cannot decode reference")
break;
case H5R_BADTYPE:
case H5R_MAXTYPE:
default:
HDassert("unknown reference type" && 0);
HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
}
/* If no filename set, this is not an external reference */
if(NULL == H5R_REF_FILENAME(dst_ref)) {
/* TODO temporary hack to retrieve file object */
if((file_id = H5F__get_file_id(src_f, FALSE)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Attach loc ID to reference and hold reference to it */
if(H5R__set_loc_id(dst_ref, file_id, TRUE) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference")
}
done:
if((file_id != H5I_INVALID_HID) && (H5I_dec_ref(file_id) < 0))
HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_mem_write() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_disk_getsize
*
* Purpose: Retrieves the length of a disk based reference.
*
* Return: Non-negative value (cannot fail)
*
*-------------------------------------------------------------------------
*/
static size_t
H5T__ref_disk_getsize(H5F_t H5_ATTR_UNUSED *src_f, const void *src_buf,
size_t src_size, H5F_t H5_ATTR_UNUSED *dst_f, hbool_t *dst_copy)
{
const uint8_t *p = (const uint8_t *)src_buf;
unsigned flags;
H5R_type_t ref_type;
size_t ret_value = 0;
FUNC_ENTER_STATIC
HDassert(src_buf);
/* Set reference type */
ref_type = (H5R_type_t)*p++;
if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid reference type")
/* Set flags */
flags = (unsigned)*p++;
if(!(flags & H5R_IS_EXTERNAL) && (ref_type == H5R_OBJECT2)) {
/* Can do a direct copy and skip blob decoding */
*dst_copy = TRUE;
ret_value = src_size;
} else {
/* Retrieve encoded data size */
UINT32DECODE(p, ret_value);
/* Add size of the header */
ret_value += H5R_ENCODE_HEADER_SIZE;
}
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_disk_getsize() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_disk_read
*
* Purpose: Reads the disk based reference into a buffer
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5T__ref_disk_read(H5F_t *src_f, const void *src_buf, size_t src_size,
H5F_t H5_ATTR_UNUSED *dst_f, void *dst_buf, size_t dst_size)
{
H5VL_object_t *vol_obj = NULL; /* Object info */
hid_t file_id = H5I_INVALID_HID;
const uint8_t *p = (const uint8_t *)src_buf;
uint8_t *q = (uint8_t *)dst_buf;
size_t buf_size_left = src_size;
size_t expected_size = dst_size;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
HDassert(src_f);
HDassert(src_buf);
HDassert(dst_buf);
HDassert(dst_size);
/* TODO temporary hack to retrieve file object */
if((file_id = H5F__get_file_id(src_f, FALSE)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(NULL == (vol_obj = H5VL_vol_object(file_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
/* Copy header manually */
HDmemcpy(q, p, H5R_ENCODE_HEADER_SIZE);
p += H5R_ENCODE_HEADER_SIZE;
q += H5R_ENCODE_HEADER_SIZE;
expected_size -= H5R_ENCODE_HEADER_SIZE;
/* Skip the length of the sequence */
p += H5_SIZEOF_UINT32_T;
HDassert(buf_size_left > H5_SIZEOF_UINT32_T);
buf_size_left -= H5_SIZEOF_UINT32_T;
/* Retrieve blob */
if(H5VL_blob_get(vol_obj, p, q, &dst_size, NULL) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get blob")
if(dst_size != expected_size)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Expected data size does not match")
done:
if((file_id != H5I_INVALID_HID) && (H5I_dec_ref(file_id) < 0))
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file id")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_disk_read() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_disk_write
*
* Purpose: Writes the disk based reference from a buffer
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5T__ref_disk_write(H5F_t H5_ATTR_UNUSED *src_f, const void *src_buf,
size_t src_size, H5R_type_t H5_ATTR_UNUSED src_type, H5F_t *dst_f,
void *dst_buf, size_t dst_size, void *bg_buf)
{
H5VL_object_t *vol_obj = NULL; /* Object info */
hid_t file_id = H5I_INVALID_HID;
const uint8_t *p = (const uint8_t *)src_buf;
uint8_t *q = (uint8_t *)dst_buf;
size_t buf_size_left = dst_size;
uint8_t *p_bg = (uint8_t *)bg_buf;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
HDassert(src_buf);
HDassert(src_size);
HDassert(dst_f);
HDassert(dst_buf);
/* TODO temporary hack to retrieve file object */
if((file_id = H5F__get_file_id(dst_f, FALSE)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(NULL == (vol_obj = H5VL_vol_object(file_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
/* TODO Should get rid of bg stuff */
if(p_bg) {
size_t p_buf_size_left = dst_size;
/* Skip the length of the reference */
p_bg += H5_SIZEOF_UINT32_T;
HDassert(p_buf_size_left > H5_SIZEOF_UINT32_T);
p_buf_size_left -= H5_SIZEOF_UINT32_T;
/* Remove blob for old data */
if(H5VL_blob_specific(vol_obj, (void *)p_bg, H5VL_BLOB_DELETE) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob")
} /* end if */
/* Copy header manually so that it does not get encoded into the blob */
HDmemcpy(q, p, H5R_ENCODE_HEADER_SIZE);
p += H5R_ENCODE_HEADER_SIZE;
q += H5R_ENCODE_HEADER_SIZE;
src_size -= H5R_ENCODE_HEADER_SIZE;
buf_size_left -= H5_SIZEOF_UINT32_T;
/* Set the size */
UINT32ENCODE(q, src_size);
HDassert(buf_size_left > H5_SIZEOF_UINT32_T);
buf_size_left -= H5_SIZEOF_UINT32_T;
/* Store blob */
if(H5VL_blob_put(vol_obj, p, src_size, q, NULL) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to put blob")
done:
if((file_id != H5I_INVALID_HID) && (H5I_dec_ref(file_id) < 0))
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file id")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_disk_write() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_obj_disk_getsize
*
* Purpose: Retrieves the length of a disk based reference.
*
* Return: Non-negative value (cannot fail)
*
*-------------------------------------------------------------------------
*/
static size_t
H5T__ref_obj_disk_getsize(H5F_t H5_ATTR_UNUSED *src_f,
const void H5_ATTR_UNUSED *src_buf, size_t H5_ATTR_UNUSED src_size,
H5F_t H5_ATTR_UNUSED *dst_f, hbool_t H5_ATTR_UNUSED *dst_copy)
{
size_t ret_value = sizeof(haddr_t);
FUNC_ENTER_STATIC_NOERR
HDassert(src_buf);
HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f));
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_obj_disk_getsize() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_obj_disk_read
*
* Purpose: Reads the disk based reference into a buffer
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5T__ref_obj_disk_read(H5F_t H5_ATTR_UNUSED *src_f, const void *src_buf,
size_t src_size, H5F_t H5_ATTR_UNUSED *dst_f, void *dst_buf,
size_t H5_ATTR_UNUSED dst_size)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
HDassert(src_f);
HDassert(src_buf);
HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f));
HDassert(dst_buf);
HDassert(dst_size == sizeof(haddr_t));
/* Get object address */
if(H5R__decode_addr_obj_compat((const unsigned char *)src_buf, &src_size, (haddr_t *)dst_buf) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object address")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_obj_disk_read() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_dsetreg_disk_getsize
*
* Purpose: Retrieves the length of a disk based reference.
*
* Return: Non-negative value (cannot fail)
*
*-------------------------------------------------------------------------
*/
static size_t
H5T__ref_dsetreg_disk_getsize(H5F_t H5_ATTR_UNUSED *f,
const void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNUSED buf_size,
H5F_t H5_ATTR_UNUSED *dst_f, hbool_t H5_ATTR_UNUSED *dst_copy)
{
size_t ret_value = sizeof(struct H5Tref_dsetreg);
FUNC_ENTER_STATIC_NOERR
HDassert(buf);
HDassert(buf_size == H5T_REF_DSETREG_DISK_SIZE(f));
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_dsetreg_disk_getsize() */
/*-------------------------------------------------------------------------
* Function: H5T__ref_dsetreg_disk_read
*
* Purpose: Reads the disk based reference into a buffer
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
static herr_t
H5T__ref_dsetreg_disk_read(H5F_t *src_f, const void *src_buf, size_t src_size,
H5F_t H5_ATTR_UNUSED *dst_f, void *dst_buf, size_t H5_ATTR_UNUSED dst_size)
{
struct H5Tref_dsetreg *dst_reg = (struct H5Tref_dsetreg *)dst_buf;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
HDassert(src_f);
HDassert(src_buf);
HDassert(src_size == H5T_REF_DSETREG_DISK_SIZE(src_f));
HDassert(dst_buf);
HDassert(dst_size == sizeof(struct H5Tref_dsetreg));
/* Retrieve object address and space */
if(H5R__decode_addr_region_compat(src_f, (const unsigned char *)src_buf, &src_size, &dst_reg->obj_addr, &dst_reg->space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_dsetreg_disk_read() */
/*-------------------------------------------------------------------------
* Function: H5T_ref_reclaim
*
* Purpose: Internal routine to free reference datatypes
*
* Return: Non-negative on success / Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_ref_reclaim(void *elem, const H5T_t *dt)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Sanity checks */
HDassert(elem);
HDassert(dt && (dt->shared->type == H5T_REFERENCE));
if(dt->shared->u.atomic.u.r.opaque
&& (H5R__destroy((H5R_ref_priv_t *)elem) < 0))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "cannot free reference")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_ref_reclaim() */

File diff suppressed because it is too large Load Diff

View File

@ -177,7 +177,12 @@ static herr_t H5VL__request_specific(void *req, const H5VL_class_t *cls,
static herr_t H5VL__request_optional(void *req, const H5VL_class_t *cls,
va_list arguments);
static herr_t H5VL__request_free(void *req, const H5VL_class_t *cls);
static herr_t H5VL__blob_put(void *obj, const H5VL_class_t *cls,
const void *buf, size_t size, void *blob_id, void *ctx);
static herr_t H5VL__blob_get(void *obj, const H5VL_class_t *cls,
const void *blob_id, void *buf, size_t *size, void *ctx);
static herr_t H5VL__blob_specific(void *obj, const H5VL_class_t *cls,
void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments);
/*********************/
/* Package Variables */
@ -6562,6 +6567,350 @@ done:
FUNC_LEAVE_API_NOINIT(ret_value)
} /* end H5VLrequest_free() */
/*-------------------------------------------------------------------------
* Function: H5VL__blob_put
*
* Purpose: Put a blob through the VOL
*
* Return: SUCCEED / FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL__blob_put(void *obj, const H5VL_class_t *cls, const void *buf, size_t size,
void *blob_id, void *ctx)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Sanity check */
HDassert(obj);
HDassert(cls);
HDassert(size == 0 || buf);
HDassert(blob_id);
/* Check if the corresponding VOL callback exists */
if(NULL == cls->blob_cls.put)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob put' method")
/* Call the corresponding VOL callback */
if((cls->blob_cls.put)(obj, buf, size, blob_id, ctx) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put callback failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__blob_put() */
/*-------------------------------------------------------------------------
* Function: H5VL_blob_put
*
* Purpose: Put a blob through the VOL
*
* Return: SUCCEED / FAIL
*
* Programmer: Quincey Koziol
* Wednesday, August 21, 2019
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size,
void *blob_id, void *ctx)
{
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
HDassert(vol_obj);
HDassert(size == 0 || buf);
HDassert(blob_id);
/* Set wrapper info in API context */
if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info")
vol_wrapper_set = TRUE;
/* Call the corresponding VOL callback */
if(H5VL__blob_put(vol_obj->data, vol_obj->connector->cls, buf, size, blob_id, ctx) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed")
done:
/* Reset object wrapping info in API context */
if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_blob_put() */
/*-------------------------------------------------------------------------
* Function: H5VLblob_put
*
* Purpose: Put a blob through the VOL
*
* Return: SUCCEED / FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size,
void *blob_id, void *ctx)
{
H5VL_class_t *cls; /* VOL connector's class struct */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API_NOINIT
H5TRACE6("e", "*xi*xz*x*x", obj, connector_id, buf, size, blob_id, ctx);
/* Get class pointer */
if(NULL == obj)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object")
if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
/* Call the corresponding VOL callback */
if(H5VL__blob_put(obj, cls, buf, size, blob_id, ctx) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed")
done:
FUNC_LEAVE_API_NOINIT(ret_value)
} /* end H5VLblob_put() */
/*-------------------------------------------------------------------------
* Function: H5VL__blob_get
*
* Purpose: Get a blob through the VOL
*
* Return: SUCCEED / FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL__blob_get(void *obj, const H5VL_class_t *cls, const void *blob_id,
void *buf, size_t *size, void *ctx)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Sanity check */
HDassert(obj);
HDassert(cls);
HDassert(blob_id);
HDassert(size || buf);
/* Check if the corresponding VOL callback exists */
if(NULL == cls->blob_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob get' method")
/* Call the corresponding VOL callback */
if((cls->blob_cls.get)(obj, blob_id, buf, size, ctx) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get callback failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__blob_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_blob_get
*
* Purpose: Get a blob through the VOL
*
* Return: SUCCEED / FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf,
size_t *size, void *ctx)
{
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
HDassert(vol_obj);
HDassert(blob_id);
HDassert(size || buf);
/* Set wrapper info in API context */
if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info")
vol_wrapper_set = TRUE;
/* Call the corresponding VOL callback */
if(H5VL__blob_get(vol_obj->data, vol_obj->connector->cls, blob_id, buf, size, ctx) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed")
done:
/* Reset object wrapping info in API context */
if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_blob_get() */
/*-------------------------------------------------------------------------
* Function: H5VLblob_get
*
* Purpose: Get a blob through the VOL
*
* Return: SUCCEED / FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf,
size_t *size, void *ctx)
{
H5VL_class_t *cls; /* VOL connector's class struct */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API_NOINIT
H5TRACE6("e", "*xi*x*x*z*x", obj, connector_id, blob_id, buf, size, ctx);
/* Get class pointer */
if(NULL == obj)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object")
if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
/* Call the corresponding VOL callback */
if(H5VL__blob_get(obj, cls, blob_id, buf, size, ctx) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed")
done:
FUNC_LEAVE_API_NOINIT(ret_value)
} /* end H5VLblob_get() */
/*-------------------------------------------------------------------------
* Function: H5VL__blob_specific
*
* Purpose: Specific operation on blobs through the VOL
*
* Return: SUCCEED / FAIL
*
* Programmer: Quincey Koziol
* Saturday, August 17, 2019
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id,
H5VL_blob_specific_t specific_type, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Sanity check */
HDassert(obj);
HDassert(cls);
HDassert(blob_id);
/* Check if the corresponding VOL callback exists */
if(NULL == cls->blob_cls.specific)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob specific' method")
/* Call the corresponding VOL callback */
if((cls->blob_cls.specific)(obj, blob_id, specific_type, arguments) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__blob_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL_blob_specific
*
* Purpose: Specific operation on blobs through the VOL
*
* Return: Success: Non-negative
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id,
H5VL_blob_specific_t specific_type, ...)
{
va_list arguments; /* Argument list passed from the API call */
hbool_t arg_started = FALSE; /* Whether the va_list has been started */
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
HDassert(vol_obj);
HDassert(blob_id);
/* Set wrapper info in API context */
if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info")
vol_wrapper_set = TRUE;
/* Call the corresponding internal VOL routine */
HDva_start(arguments, specific_type);
arg_started = TRUE;
if((ret_value = H5VL__blob_specific(vol_obj->data, vol_obj->connector->cls, blob_id, specific_type, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback")
done:
/* End access to the va_list, if we started it */
if(arg_started)
HDva_end(arguments);
/* Reset object wrapping info in API context */
if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_blob_specific() */
/*-------------------------------------------------------------------------
* Function: H5VLblob_specific
*
* Purpose: Specific operation on blobs through the VOL
*
* Return: SUCCEED / FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id,
H5VL_blob_specific_t specific_type, va_list arguments)
{
H5VL_class_t *cls; /* VOL connector's class struct */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API_NOINIT
H5TRACE5("e", "*xi*xVBx", obj, connector_id, blob_id, specific_type, arguments);
/* Get class pointer */
if(NULL == obj)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object")
if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
/* Call the corresponding VOL callback */
if(H5VL__blob_specific(obj, cls, blob_id, specific_type, arguments) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob specific operation failed")
done:
FUNC_LEAVE_API_NOINIT(ret_value)
} /* end H5VLblob_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL__optional

View File

@ -37,11 +37,23 @@
#define H5VL_CAP_FLAG_NONE 0 /* No special connector capabilities */
#define H5VL_CAP_FLAG_THREADSAFE 0x01 /* Connector is threadsafe */
/* Container info version */
#define H5VL_CONTAINER_INFO_VERSION 0x01 /* Container info struct version */
/* The maximum size allowed for blobs */
#define H5VL_MAX_BLOB_ID_SIZE (16) /* Allow for 128-bits blob IDs */
/* The maximum size allowed for tokens */
#define H5VL_MAX_TOKEN_SIZE (16) /* Allow for 128-bits tokens */
/*******************/
/* Public Typedefs */
/*******************/
/* type for tokens. Token are unique and permanent identifiers that are
* used to reference HDF5 objects. */
typedef unsigned char H5VL_token_t[H5VL_MAX_TOKEN_SIZE];
/* types for attribute GET callback */
typedef enum H5VL_attr_get_t {
H5VL_ATTR_GET_ACPL, /* creation property list */
@ -92,10 +104,11 @@ typedef enum H5VL_datatype_specific_t {
/* types for file GET callback */
typedef enum H5VL_file_get_t {
H5VL_FILE_GET_CONT_INFO, /* file get container info */
H5VL_FILE_GET_FAPL, /* file access property list */
H5VL_FILE_GET_FCPL, /* file creation property list */
H5VL_FILE_GET_INTENT, /* file intent */
H5VL_FILE_GET_FILENO, /* file number */
H5VL_FILE_GET_INTENT, /* file intent */
H5VL_FILE_GET_NAME, /* file name */
H5VL_FILE_GET_OBJ_COUNT, /* object count in file */
H5VL_FILE_GET_OBJ_IDS /* object ids in file */
@ -146,18 +159,16 @@ typedef enum H5VL_link_specific_t {
/* types for object GET callback */
typedef enum H5VL_object_get_t {
H5VL_REF_GET_NAME, /* object name, for reference */
H5VL_REF_GET_REGION, /* dataspace of region */
H5VL_REF_GET_TYPE, /* type of object */
H5VL_OBJECT_GET_NAME /* object name */
H5VL_OBJECT_GET_NAME, /* object name */
H5VL_OBJECT_GET_TYPE /* object type */
} H5VL_object_get_t;
/* types for object SPECIFIC callback */
typedef enum H5VL_object_specific_t {
H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */
H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */
H5VL_OBJECT_LOOKUP, /* Lookup object */
H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */
H5VL_REF_CREATE, /* H5Rcreate */
H5VL_OBJECT_FLUSH, /* H5{D|G|O|T}flush */
H5VL_OBJECT_REFRESH /* H5{D|G|O|T}refresh */
} H5VL_object_specific_t;
@ -169,56 +180,67 @@ typedef enum H5VL_request_specific_t {
H5VL_REQUEST_WAITALL /* Wait until all requests complete */
} H5VL_request_specific_t;
/* types for different ways that objects are located in an HDF5 container */
/* types for 'blob' SPECIFIC callback */
typedef enum H5VL_blob_specific_t {
H5VL_BLOB_DELETE, /* Delete a blob (by ID) */
H5VL_BLOB_GETSIZE, /* Get size of blob */
H5VL_BLOB_ISNULL, /* Check if a blob ID is "null" */
H5VL_BLOB_SETNULL /* Set a blob ID to the connector's "null" blob ID value */
} H5VL_blob_specific_t;
/* Types for different ways that objects are located in an HDF5 container */
typedef enum H5VL_loc_type_t {
H5VL_OBJECT_BY_SELF,
H5VL_OBJECT_BY_NAME,
H5VL_OBJECT_BY_IDX,
H5VL_OBJECT_BY_ADDR,
H5VL_OBJECT_BY_REF
H5VL_OBJECT_BY_TOKEN
} H5VL_loc_type_t;
struct H5VL_loc_by_name {
typedef struct H5VL_loc_by_name {
const char *name;
hid_t lapl_id;
};
} H5VL_loc_by_name_t;
struct H5VL_loc_by_idx {
typedef struct H5VL_loc_by_idx {
const char *name;
H5_index_t idx_type;
H5_iter_order_t order;
hsize_t n;
hid_t lapl_id;
};
} H5VL_loc_by_idx_t;
struct H5VL_loc_by_addr {
haddr_t addr;
};
typedef struct H5VL_loc_by_token {
void *token;
} H5VL_loc_by_token_t;
struct H5VL_loc_by_ref {
H5R_type_t ref_type;
const void *_ref;
hid_t lapl_id;
};
/* Structure to hold parameters for object locations.
* either: BY_ADDR, BY_ID, BY_NAME, BY_IDX, BY_REF
/* Structure to hold parameters for object locations.
* Either: BY_SELF, BY_NAME, BY_IDX, BY_TOKEN
*
* Note: Leave loc_by_addr as the first union member so we
* Note: Leave loc_by_token as the first union member so we
* can perform the simplest initialization of the struct
* without raising warnings.
*
* Note: BY_SELF requires no union members.
*/
typedef struct H5VL_loc_params_t {
H5I_type_t obj_type;
H5VL_loc_type_t type;
union{
struct H5VL_loc_by_addr loc_by_addr;
struct H5VL_loc_by_name loc_by_name;
struct H5VL_loc_by_idx loc_by_idx;
struct H5VL_loc_by_ref loc_by_ref;
union {
H5VL_loc_by_token_t loc_by_token;
H5VL_loc_by_name_t loc_by_name;
H5VL_loc_by_idx_t loc_by_idx;
} loc_data;
} H5VL_loc_params_t;
/* Info for H5VL_FILE_GET_CONT_INFO */
typedef struct H5VL_file_cont_info_t {
unsigned version; /* version information (keep first) */
uint64_t feature_flags; /* Container feature flags */
/* (none currently defined) */
size_t token_size; /* Size of tokens */
size_t blob_id_size; /* Size of blob IDs */
} H5VL_file_cont_info_t;
/* VOL connector info fields & callbacks */
typedef struct H5VL_info_class_t {
size_t size; /* Size of the VOL info */
@ -355,6 +377,14 @@ typedef struct H5VL_request_class_t {
herr_t (*free)(void *req);
} H5VL_request_class_t;
/* 'blob' routines */
typedef struct H5VL_blob_class_t {
herr_t (*put)(void *obj, const void *buf, size_t size, void *blob_id, void *ctx);
herr_t (*get)(void *obj, const void *blob_id, void *buf, size_t *size, void *ctx);
herr_t (*specific)(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments);
herr_t (*optional)(void *obj, void *blob_id, va_list arguments);
} H5VL_blob_class_t;
/*
* VOL connector identifiers. Values 0 through 255 are for connectors defined
* by the HDF5 library. Values 256 through 511 are available for testing new
@ -386,8 +416,9 @@ typedef struct H5VL_class_t {
H5VL_link_class_t link_cls; /* Link (H5L*) class callbacks */
H5VL_object_class_t object_cls; /* Object (H5O*) class callbacks */
/* Services */
/* Infrastructure / Services */
H5VL_request_class_t request_cls; /* Asynchronous request class callbacks */
H5VL_blob_class_t blob_cls; /* 'blob' callbacks */
/* Catch-all */
herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); /* Optional callback */
@ -398,6 +429,7 @@ typedef struct H5VL_class_t {
/* Public Variables */
/********************/
/*********************/
/* Public Prototypes */
/*********************/

View File

@ -13,7 +13,7 @@
/*
* This file contains public declarations for authoring VOL connectors
* which act as "passthrough" connectors that forward their API calls to
* an underlying connector.
* an underlying connector.
*
* An example of this might be a logging connector, which creates log messages
* and then passes the call on to an underlying VOL connector.
@ -158,6 +158,15 @@ H5_DLL herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_s
H5_DLL herr_t H5VLrequest_optional(void *req, hid_t connector_id, va_list arguments);
H5_DLL herr_t H5VLrequest_free(void *req, hid_t connector_id);
/* Public wrappers for blob callbacks */
H5_DLL herr_t H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, void *blob_id, void *ctx);
H5_DLL herr_t H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf, size_t *size, void *ctx);
H5_DLL herr_t H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments);
/* Public wrappers for generic 'optional' callback */
H5_DLL herr_t H5VLoptional(void *obj, hid_t connector_id, hid_t dxpl_id,
void **req, va_list arguments);
#ifdef __cplusplus
}
#endif

View File

@ -543,6 +543,7 @@ static H5VL_object_t *
H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t wrap_obj)
{
H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */
hbool_t conn_rc_incr = FALSE; /* Whether the VOL connector refcount has been incremented */
H5VL_object_t *ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@ -569,6 +570,7 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t
/* Bump the reference count on the VOL connector */
H5VL__conn_inc_rc(vol_connector);
conn_rc_incr = TRUE;
/* If this is a datatype, we have to hide the VOL object under the H5T_t pointer */
if(H5I_DATATYPE == type) {
@ -579,6 +581,12 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t
ret_value = (H5VL_object_t *)new_vol_obj;
done:
/* Cleanup on error */
if(NULL == ret_value) {
if(conn_rc_incr && H5VL__conn_dec_rc(vol_connector) < 0)
HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector")
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__new_vol_obj() */
@ -759,16 +767,17 @@ done:
* get the connector information instead of it being passed in.
*
* Return: Success: A valid HDF5 ID
* Failure: H5I_INVALID_HID
* Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref)
{
H5VL_class_t *cls = NULL;
H5VL_t *connector = NULL; /* VOL connector struct */
hid_t ret_value = H5I_INVALID_HID;
H5VL_class_t *cls = NULL; /* VOL connector class */
H5VL_t *connector = NULL; /* VOL connector struct */
hbool_t conn_id_incr = FALSE; /* Whether the VOL connector ID has been incremented */
hid_t ret_value = H5I_INVALID_HID;/* Return value */
FUNC_ENTER_NOAPI(FAIL)
@ -783,12 +792,24 @@ H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool
connector->id = connector_id;
if(H5I_inc_ref(connector->id, FALSE) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector")
conn_id_incr = TRUE;
/* Get an ID for the VOL object */
if((ret_value = H5VL_register(type, obj, connector, app_ref)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle")
done:
/* Clean up on error */
if(ret_value < 0) {
/* Decrement VOL connector ID ref count on error */
if(conn_id_incr && H5I_dec_ref(connector_id) < 0)
HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement ref count on VOL connector")
/* Free VOL connector struct */
if(NULL != connector)
connector = H5FL_FREE(H5VL_t, connector);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_register_using_vol_id() */

View File

@ -11,8 +11,8 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: The native VOL connector where access is to a single HDF5 file
* using HDF5 VFDs.
* Purpose: The native VOL connector where access is to a single HDF5 file
* using HDF5 VFDs.
*/
#include "H5private.h" /* Generic Functions */
@ -120,6 +120,12 @@ static H5VL_class_t H5VL_native_cls_g = {
NULL, /* optional */
NULL /* free */
},
{ /* blob_cls */
H5VL__native_blob_put, /* put */
H5VL__native_blob_get, /* get */
H5VL__native_blob_specific, /* specific */
NULL /* optional */
},
NULL /* optional */
};

View File

@ -17,6 +17,9 @@
#ifndef _H5VLnative_H
#define _H5VLnative_H
/* Public headers needed by this file */
#include "H5VLpublic.h" /* Virtual Object Layer */
/* Identifier for the native VOL connector */
#define H5VL_NATIVE (H5VL_native_register())

237
src/H5VLnative_blob.c Normal file
View File

@ -0,0 +1,237 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: Blob callbacks for the native VOL connector
*/
/***********/
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* File access */
#include "H5HGprivate.h" /* Global Heaps */
#include "H5VLnative_private.h" /* Native VOL connector */
/****************/
/* Local Macros */
/****************/
/******************/
/* Local Typedefs */
/******************/
/********************/
/* Local Prototypes */
/********************/
/*********************/
/* Package Variables */
/*********************/
/*****************************/
/* Library Private Variables */
/*****************************/
/*******************/
/* Local Variables */
/*******************/
/*-------------------------------------------------------------------------
* Function: H5VL__native_blob_put
*
* Purpose: Handles the blob 'put' callback
*
* Return: SUCCEED / FAIL
*
* Programmer: Quincey Koziol
* Friday, August 15, 2019
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id,
void H5_ATTR_UNUSED *ctx)
{
H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */
uint8_t *id = (uint8_t *)blob_id; /* Pointer to blob ID */
H5HG_t hobjid; /* New VL sequence's heap ID */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check parameters */
HDassert(f);
HDassert(size == 0 || buf);
HDassert(id);
/* Write the VL information to disk (allocates space also) */
if(H5HG_insert(f, size, (void *)buf, &hobjid) < 0)
HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write blob information")
/* Encode the heap information */
H5F_addr_encode(f, &id, hobjid.addr);
UINT32ENCODE(id, hobjid.idx);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_blob_put() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_blob_get
*
* Purpose: Handles the blob 'get' callback
*
* Return: SUCCEED / FAIL
*
* Programmer: Quincey Koziol
* Friday, August 15, 2019
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t *size,
void H5_ATTR_UNUSED *ctx)
{
H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */
const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the disk blob ID */
H5HG_t hobjid; /* Global heap ID for sequence */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(f);
HDassert(id);
HDassert(buf);
/* Get the heap information */
H5F_addr_decode(f, &id, &hobjid.addr);
UINT32DECODE(id, hobjid.idx);
/* Check if this sequence actually has any data */
if(hobjid.addr > 0)
/* Read the VL information from disk */
if(NULL == H5HG_read(f, &hobjid, buf, size))
HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "unable to read VL information")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_blob_get() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_blob_specific
*
* Purpose: Handles the blob 'specific' callback
*
* Return: SUCCEED / FAIL
*
* Programmer: Quincey Koziol
* Friday, August 15, 2019
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL__native_blob_specific(void *obj, void *blob_id,
H5VL_blob_specific_t specific_type, va_list arguments)
{
H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(f);
HDassert(blob_id);
switch(specific_type) {
case H5VL_BLOB_GETSIZE:
{
const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */
size_t *size = HDva_arg(arguments, size_t *);
H5HG_t hobjid; /* blob's heap ID */
/* Get heap information */
H5F_addr_decode(f, &id, &(hobjid.addr));
UINT32DECODE(id, hobjid.idx);
/* Free heap object */
if(hobjid.addr > 0) {
if(H5HG_get_obj_size(f, &hobjid, size) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object")
} /* end if */
else
*size = 0; /* Return '0' size for 'nil' blob ID */
break;
}
case H5VL_BLOB_ISNULL:
{
const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */
hbool_t *isnull = HDva_arg(arguments, hbool_t *);
haddr_t addr; /* Sequence's heap address */
/* Get the heap address */
H5F_addr_decode(f, &id, &addr);
/* Check if heap address is 'nil' */
*isnull = (addr == 0 ? TRUE : FALSE);
break;
}
case H5VL_BLOB_SETNULL:
{
uint8_t *id = (uint8_t *)blob_id; /* Pointer to the blob ID */
/* Encode the "nil" heap pointer information */
H5F_addr_encode(f, &id, (haddr_t)0);
UINT32ENCODE(id, 0);
break;
}
case H5VL_BLOB_DELETE:
{
const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */
H5HG_t hobjid; /* VL sequence's heap ID */
/* Get heap information */
H5F_addr_decode(f, &id, &hobjid.addr);
UINT32DECODE(id, hobjid.idx);
/* Free heap object */
if(hobjid.addr > 0)
if(H5HG_remove(f, &hobjid) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
} /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_blob_specific() */

View File

@ -129,6 +129,18 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type,
FUNC_ENTER_PACKAGE
switch(get_type) {
/* "get container info" */
case H5VL_FILE_GET_CONT_INFO:
{
H5VL_file_cont_info_t *info = HDva_arg(arguments, H5VL_file_cont_info_t *);
/* Retrieve the file's container info */
if(H5F__get_cont_info((H5F_t *)obj, info) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file container info")
break;
}
/* H5Fget_access_plist */
case H5VL_FILE_GET_FAPL:
{
@ -139,7 +151,7 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type,
/* Retrieve the file's access property list */
if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list")
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file access property list")
if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
@ -163,42 +175,6 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type,
break;
}
/* H5Fget_obj_count */
case H5VL_FILE_GET_OBJ_COUNT:
{
unsigned types = HDva_arg(arguments, unsigned);
ssize_t *ret = HDva_arg(arguments, ssize_t *);
size_t obj_count = 0; /* Number of opened objects */
f = (H5F_t *)obj;
/* Perform the query */
if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
/* Set the return value */
*ret = (ssize_t)obj_count;
break;
}
/* H5Fget_obj_ids */
case H5VL_FILE_GET_OBJ_IDS:
{
unsigned types = HDva_arg(arguments, unsigned);
size_t max_objs = HDva_arg(arguments, size_t);
hid_t *oid_list = HDva_arg(arguments, hid_t *);
ssize_t *ret = HDva_arg(arguments, ssize_t *);
size_t obj_count = 0; /* Number of opened objects */
f = (H5F_t *)obj;
/* Perform the query */
if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed")
/* Set the return value */
*ret = (ssize_t)obj_count;
break;
}
/* H5Fget_intent */
case H5VL_FILE_GET_INTENT:
{
@ -266,6 +242,42 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type,
break;
}
/* H5Fget_obj_count */
case H5VL_FILE_GET_OBJ_COUNT:
{
unsigned types = HDva_arg(arguments, unsigned);
ssize_t *ret = HDva_arg(arguments, ssize_t *);
size_t obj_count = 0; /* Number of opened objects */
f = (H5F_t *)obj;
/* Perform the query */
if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
/* Set the return value */
*ret = (ssize_t)obj_count;
break;
}
/* H5Fget_obj_ids */
case H5VL_FILE_GET_OBJ_IDS:
{
unsigned types = HDva_arg(arguments, unsigned);
size_t max_objs = HDva_arg(arguments, size_t);
hid_t *oid_list = HDva_arg(arguments, hid_t *);
ssize_t *ret = HDva_arg(arguments, ssize_t *);
size_t obj_count = 0; /* Number of opened objects */
f = (H5F_t *)obj;
/* Perform the query */
if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed")
/* Set the return value */
*ret = (ssize_t)obj_count;
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information")
} /* end switch */
@ -397,7 +409,6 @@ H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type,
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
} /* end switch */

View File

@ -16,7 +16,6 @@
*/
#define H5O_FRIEND /* Suppress error about including H5Opkg */
#define H5R_FRIEND /* Suppress error about including H5Rpkg */
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
@ -25,7 +24,6 @@
#include "H5Iprivate.h" /* IDs */
#include "H5Opkg.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
#include "H5Rpkg.h" /* References */
#include "H5VLprivate.h" /* Virtual Object Layer */
#include "H5VLnative_private.h" /* Native VOL connector */
@ -71,34 +69,14 @@ H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_typ
break;
}
case H5VL_OBJECT_BY_ADDR:
case H5VL_OBJECT_BY_TOKEN:
{
/* Open the object */
if(NULL == (ret_value = H5O_open_by_addr(&loc, loc_params->loc_data.loc_by_addr.addr, opened_type)))
if(NULL == (ret_value = H5O_open_by_addr(&loc, *(haddr_t *)loc_params->loc_data.loc_by_token.token, opened_type)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address")
break;
}
case H5VL_OBJECT_BY_REF:
{
hid_t temp_id = H5I_INVALID_HID;
H5F_t *file = NULL;
/* Get the file pointer from the entry */
file = loc.oloc->file;
/* Create reference */
if((temp_id = H5R__dereference(file, loc_params->loc_data.loc_by_ref.lapl_id,
loc_params->loc_data.loc_by_ref.ref_type,
loc_params->loc_data.loc_by_ref._ref)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, NULL, "unable to dereference object")
*opened_type = H5I_get_type(temp_id);
if(NULL == (ret_value = H5I_remove(temp_id)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object")
break;
}
case H5VL_OBJECT_BY_SELF:
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters")
@ -166,53 +144,6 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
switch(get_type) {
/* H5Rget_region */
case H5VL_REF_GET_REGION:
{
hid_t *ret = HDva_arg(arguments, hid_t *);
H5R_type_t H5_ATTR_UNUSED ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */
void *ref = HDva_arg(arguments, void *);
H5S_t *space = NULL; /* Dataspace object */
/* Get the dataspace with the correct region selected */
if((space = H5R__get_region(loc.oloc->file, ref)) == NULL)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve region")
/* Atomize */
if((*ret = H5I_register(H5I_DATASPACE, space, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
break;
}
/* H5Rget_obj_type1/2 */
case H5VL_REF_GET_TYPE:
{
H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *);
H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */
void *ref = HDva_arg(arguments, void *);
/* Get the object information */
if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type")
break;
}
/* H5Rget_name */
case H5VL_REF_GET_NAME:
{
ssize_t *ret = HDva_arg(arguments, ssize_t *);
char *name = HDva_arg(arguments, char *);
size_t size = HDva_arg(arguments, size_t);
H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */
void *ref = HDva_arg(arguments, void *);
/* Get name */
if((*ret = H5R__get_name(loc.oloc->file, ref_type, ref, name, size)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path")
break;
}
/* Object name */
case H5VL_OBJECT_GET_NAME:
{
@ -225,13 +156,13 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj
if((*ret = H5G_get_name(&loc, name, size, NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve object name")
} /* end if */
else if(loc_params->type == H5VL_OBJECT_BY_ADDR) {
else if(loc_params->type == H5VL_OBJECT_BY_TOKEN) {
H5O_loc_t obj_oloc; /* Object location */
/* Initialize the object location */
H5O_loc_reset(&obj_oloc);
obj_oloc.file = loc.oloc->file;
obj_oloc.addr = loc_params->loc_data.loc_by_addr.addr;
obj_oloc.addr = *(haddr_t *)loc_params->loc_data.loc_by_token.token;
/* Retrieve object's name */
if((*ret = H5G_get_name_by_addr(loc.oloc->file, &obj_oloc, name, size)) < 0)
@ -242,6 +173,29 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj
break;
}
/* Object type */
case H5VL_OBJECT_GET_TYPE:
{
H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *);
if(loc_params->type == H5VL_OBJECT_BY_TOKEN) {
H5O_loc_t obj_oloc; /* Object location */
unsigned rc; /* Reference count of object */
/* Initialize the object location */
H5O_loc_reset(&obj_oloc);
obj_oloc.file = loc.oloc->file;
obj_oloc.addr = *(haddr_t *)loc_params->loc_data.loc_by_token.token;
/* Get the # of links for object, and its type */
/* (To check to make certain that this object hasn't been deleted) */
if(H5O_get_rc_and_type(&obj_oloc, &rc, obj_type) < 0 || 0 == rc)
HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object")
} else
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_type parameters")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object")
} /* end switch */
@ -300,6 +254,37 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V
break;
}
/* Lookup object */
case H5VL_OBJECT_LOOKUP:
{
void *token = va_arg(arguments, void *);
HDassert(token);
if(loc_params->type == H5VL_OBJECT_BY_NAME) {
H5G_loc_t obj_loc; /* Group hier. location of object */
H5G_name_t obj_path; /* Object group hier. path */
H5O_loc_t obj_oloc; /* Object object location */
/* Set up opened group location to fill in */
obj_loc.oloc = &obj_oloc;
obj_loc.path = &obj_path;
H5G_loc_reset(&obj_loc);
/* Find the object */
if(H5G_loc_find(&loc, loc_params->loc_data.loc_by_name.name, &obj_loc) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
*(haddr_t *)token = obj_loc.oloc->addr;
/* Release the object location */
if(H5G_loc_free(&obj_loc) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
} /* end if */
else
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters")
break;
}
case H5VL_OBJECT_VISIT:
{
H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */
@ -347,24 +332,6 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V
break;
}
case H5VL_REF_CREATE:
{
void *ref = HDva_arg(arguments, void *);
const char *name = HDva_arg(arguments, char *);
H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */
hid_t space_id = HDva_arg(arguments, hid_t);
H5S_t *space = NULL; /* Pointer to dataspace containing region */
if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
/* Create reference */
if(H5R__create(ref, &loc, name, ref_type, space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type")
} /* end switch */

View File

@ -17,13 +17,34 @@
#ifndef _H5VLnative_private_H
#define _H5VLnative_private_H
/* Private headers needed by this file */
#include "H5VLnative.h" /* Native VOL connector */
/**************************/
/* Library Private Macros */
/**************************/
/****************************/
/* Library Private Typedefs */
/****************************/
/*****************************/
/* Library Private Variables */
/*****************************/
/******************************/
/* Library Private Prototypes */
/******************************/
#ifdef __cplusplus
extern "C" {
#endif
/* Atrribute callbacks */
/* Attribute callbacks */
H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req);
H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req);
@ -80,6 +101,11 @@ H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type,
H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
H5_DLL herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req);
/* Blob callbacks */
H5_DLL herr_t H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx);
H5_DLL herr_t H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t *size, void *ctx);
H5_DLL herr_t H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments);
#ifdef __cplusplus
}
#endif

View File

@ -178,6 +178,12 @@ static herr_t H5VL_pass_through_request_specific(void *req, H5VL_request_specifi
static herr_t H5VL_pass_through_request_optional(void *req, va_list arguments);
static herr_t H5VL_pass_through_request_free(void *req);
/* Blob callbacks */
static herr_t H5VL_pass_through_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx);
static herr_t H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf, size_t *size, void *ctx);
static herr_t H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments);
/*******************/
/* Local variables */
/*******************/
@ -196,14 +202,14 @@ static const H5VL_class_t H5VL_pass_through_g = {
H5VL_pass_through_info_cmp, /* compare */
H5VL_pass_through_info_free, /* free */
H5VL_pass_through_info_to_str, /* to_str */
H5VL_pass_through_str_to_info, /* from_str */
H5VL_pass_through_str_to_info /* from_str */
},
{ /* wrap_cls */
H5VL_pass_through_get_object, /* get_object */
H5VL_pass_through_get_wrap_ctx, /* get_wrap_ctx */
H5VL_pass_through_wrap_object, /* wrap_object */
H5VL_pass_through_unwrap_object, /* unwrap_object */
H5VL_pass_through_free_wrap_ctx, /* free_wrap_ctx */
H5VL_pass_through_free_wrap_ctx /* free_wrap_ctx */
},
{ /* attribute_cls */
H5VL_pass_through_attr_create, /* create */
@ -255,14 +261,14 @@ static const H5VL_class_t H5VL_pass_through_g = {
H5VL_pass_through_link_move, /* move */
H5VL_pass_through_link_get, /* get */
H5VL_pass_through_link_specific, /* specific */
H5VL_pass_through_link_optional, /* optional */
H5VL_pass_through_link_optional /* optional */
},
{ /* object_cls */
H5VL_pass_through_object_open, /* open */
H5VL_pass_through_object_copy, /* copy */
H5VL_pass_through_object_get, /* get */
H5VL_pass_through_object_specific, /* specific */
H5VL_pass_through_object_optional, /* optional */
H5VL_pass_through_object_optional /* optional */
},
{ /* request_cls */
H5VL_pass_through_request_wait, /* wait */
@ -272,6 +278,12 @@ static const H5VL_class_t H5VL_pass_through_g = {
H5VL_pass_through_request_optional, /* optional */
H5VL_pass_through_request_free /* free */
},
{ /* blob_cls */
H5VL_pass_through_blob_put, /* put */
H5VL_pass_through_blob_get, /* get */
H5VL_pass_through_blob_specific, /* specific */
NULL /* optional */
},
NULL /* optional */
};
@ -2834,3 +2846,83 @@ H5VL_pass_through_request_free(void *obj)
return ret_value;
} /* end H5VL_pass_through_request_free() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_blob_put
*
* Purpose: Handles the blob 'put' callback
*
* Return: SUCCEED / FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL_pass_through_blob_put(void *obj, const void *buf, size_t size,
void *blob_id, void *ctx)
{
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
herr_t ret_value;
#ifdef ENABLE_PASSTHRU_LOGGING
printf("------- PASS THROUGH VOL BLOB Put\n");
#endif
ret_value = H5VLblob_put(o->under_object, o->under_vol_id, buf, size,
blob_id, ctx);
return ret_value;
} /* end H5VL_pass_through_blob_put() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_blob_get
*
* Purpose: Handles the blob 'get' callback
*
* Return: SUCCEED / FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf,
size_t *size, void *ctx)
{
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
herr_t ret_value;
#ifdef ENABLE_PASSTHRU_LOGGING
printf("------- PASS THROUGH VOL BLOB Get\n");
#endif
ret_value = H5VLblob_get(o->under_object, o->under_vol_id, blob_id, buf,
size, ctx);
return ret_value;
} /* end H5VL_pass_through_blob_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_blob_specific
*
* Purpose: Handles the blob 'specific' callback
*
* Return: SUCCEED / FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL_pass_through_blob_specific(void *obj, void *blob_id,
H5VL_blob_specific_t specific_type, va_list arguments)
{
H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj;
herr_t ret_value;
#ifdef ENABLE_PASSTHRU_LOGGING
printf("------- PASS THROUGH VOL BLOB Specific\n");
#endif
ret_value = H5VLblob_specific(o->under_object, o->under_vol_id, blob_id,
specific_type, arguments);
return ret_value;
} /* end H5VL_pass_through_blob_specific() */

View File

@ -17,6 +17,9 @@
#ifndef _H5VLpassthru_H
#define _H5VLpassthru_H
/* Public headers needed by this file */
#include "H5VLpublic.h" /* Virtual Object Layer */
/* Identifier for the pass-through VOL connector */
#define H5VL_PASSTHRU (H5VL_pass_through_register())

View File

@ -193,6 +193,11 @@ H5_DLL herr_t H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_s
H5_DLL herr_t H5VL_request_optional(const H5VL_object_t *vol_obj, ...);
H5_DLL herr_t H5VL_request_free(const H5VL_object_t *vol_obj);
/* Blob functions */
H5_DLL herr_t H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, void *blob_id, void *ctx);
H5_DLL herr_t H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size_t *size, void *ctx);
H5_DLL herr_t H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_specific_t specific_type, ...);
/* Generic functions */
H5_DLL herr_t H5VL_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id,void **req, ...);

View File

@ -107,8 +107,8 @@ typedef struct detected_t {
unsigned int comp_align; /* alignment for structure */
} detected_t;
/* This structure holds structure alignment for pointers, hvl_t, hobj_ref_t,
* hdset_reg_ref_t */
/* This structure holds structure alignment for pointers, vlen and reference
* types. */
typedef struct malign_t {
const char *name;
unsigned int comp_align; /* alignment for structure */
@ -383,9 +383,8 @@ precision (detected_t *d)
/*-------------------------------------------------------------------------
* Function: DETECT_M
*
* Purpose: This macro takes only miscellaneous structures or pointer
* (pointer, hvl_t, hobj_ref_t, hdset_reg_ref_t). It
* constructs the names and decides the alignment in structure.
* Purpose: This macro takes only miscellaneous structures or pointer.
* It constructs the names and decides the alignment in structure.
*
* Return: void
*-------------------------------------------------------------------------
@ -761,8 +760,8 @@ H5T__init_native(void)\n\
H5T_native_order_g = H5T_ORDER_%s;\n", "BE");
}
/* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */
fprintf(rawoutstream, "\n /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */\n");
/* Structure alignment for pointers, vlen and reference types */
fprintf(rawoutstream, "\n /* Structure alignment for pointers, vlen and reference types */\n");
for(j=0; j<na; j++)
fprintf(rawoutstream, " H5T_%s_COMP_ALIGN_g = %lu;\n", misc_align[j].name, (unsigned long)(misc_align[j].comp_align));
@ -1544,11 +1543,12 @@ detect_C99_floats(void)
static void HDF_NO_UBSAN
detect_alignments(void)
{
/* Detect structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */
/* Detect structure alignment for pointers, vlen and reference types */
DETECT_M(void *, POINTER, m_g[na_g]); na_g++;
DETECT_M(hvl_t, HVL, m_g[na_g]); na_g++;
DETECT_M(hobj_ref_t, HOBJREF, m_g[na_g]); na_g++;
DETECT_M(hdset_reg_ref_t, HDSETREGREF, m_g[na_g]); na_g++;
DETECT_M(H5R_ref_t, REF, m_g[na_g]); na_g++;
}

View File

@ -22,6 +22,64 @@
#ifdef H5_HAVE_PARALLEL
/****************/
/* Local Macros */
/****************/
#define TWO_GIG_LIMIT (1 << 31)
#ifndef H5_MAX_MPI_COUNT
#define H5_MAX_MPI_COUNT (1 << 30)
#endif
/*******************/
/* Local Variables */
/*******************/
static hsize_t bigio_count = H5_MAX_MPI_COUNT;
/*-------------------------------------------------------------------------
* Function: H5_mpio_set_bigio_count
*
* Purpose: Allow us to programatically change the switch point
* when we utilize derived datatypes. This is of
* particular interest for allowing nightly testing
*
* Return: The current/previous value of bigio_count.
*
* Programmer: Richard Warren, March 10, 2017
*
*-------------------------------------------------------------------------
*/
hsize_t
H5_mpio_set_bigio_count(hsize_t new_count)
{
hsize_t orig_count = bigio_count;
if((new_count > 0) && (new_count < (hsize_t)TWO_GIG_LIMIT)) {
bigio_count = new_count;
}
return orig_count;
} /* end H5_mpio_set_bigio_count() */
/*-------------------------------------------------------------------------
* Function: H5_mpio_get_bigio_count
*
* Purpose: Allow other HDF5 library functions to access
* the current value for bigio_count.
*
* Return: The current/previous value of bigio_count.
*
* Programmer: Richard Warren, October 7, 2019
*
*-------------------------------------------------------------------------
*/
hsize_t
H5_mpio_get_bigio_count()
{
return bigio_count;
}
/*-------------------------------------------------------------------------
* Function: H5_mpi_comm_dup
@ -392,5 +450,114 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5_mpi_info_cmp() */
/*-------------------------------------------------------------------------
* Function: H5_mpio_create_large_type
*
* Purpose: Create a large datatype of size larger than what a 32 bit integer
* can hold.
*
* Return: Non-negative on success, negative on failure.
*
* *new_type the new datatype created
*
* Programmer: Mohamad Chaarawi
*
*-------------------------------------------------------------------------
*/
herr_t
H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes,
MPI_Datatype old_type, MPI_Datatype *new_type)
{
int num_big_types; /* num times the 2G datatype will be repeated */
int remaining_bytes; /* the number of bytes left that can be held in an int value */
hsize_t leftover;
int block_len[2];
int mpi_code; /* MPI return code */
MPI_Datatype inner_type, outer_type, leftover_type, type[2];
MPI_Aint disp[2], old_extent;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Calculate how many Big MPI datatypes are needed to represent the buffer */
num_big_types = (int)(num_elements/bigio_count);
leftover = num_elements - num_big_types * (hsize_t)bigio_count;
H5_CHECKED_ASSIGN(remaining_bytes, int, leftover, hsize_t);
/* Create a contiguous datatype of size equal to the largest
* number that a 32 bit integer can hold x size of old type.
* If the displacement is 0, then the type is contiguous, otherwise
* use type_hvector to create the type with the displacement provided
*/
if (0 == stride_bytes) {
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(bigio_count, old_type, &inner_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
} /* end if */
else
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(bigio_count, 1, stride_bytes, old_type, &inner_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
/* Create a contiguous datatype of the buffer (minus the remaining < 2GB part)
* If a stride is present, use hvector type
*/
if(0 == stride_bytes) {
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(num_big_types, inner_type, &outer_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
} /* end if */
else
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(num_big_types, 1, stride_bytes, inner_type, &outer_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
MPI_Type_free(&inner_type);
/* If there is a remaining part create a contiguous/vector datatype and then
* use a struct datatype to encapsulate everything.
*/
if(remaining_bytes) {
if(stride_bytes == 0) {
if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(remaining_bytes, old_type, &leftover_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
} /* end if */
else
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)(num_elements - (hsize_t)num_big_types * bigio_count), 1, stride_bytes, old_type, &leftover_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
/* As of version 4.0, OpenMPI now turns off MPI-1 API calls by default,
* so we're using the MPI-2 version even though we don't need the lb
* value.
*/
{
MPI_Aint unused_lb_arg;
MPI_Type_get_extent(old_type, &unused_lb_arg, &old_extent);
}
/* Set up the arguments for MPI_Type_struct constructor */
type[0] = outer_type;
type[1] = leftover_type;
block_len[0] = 1;
block_len[1] = 1;
disp[0] = 0;
disp[1] = (old_extent + stride_bytes) * num_big_types * (MPI_Aint)bigio_count;
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, block_len, disp, type, new_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code)
MPI_Type_free(&outer_type);
MPI_Type_free(&leftover_type);
} /* end if */
else
/* There are no remaining bytes so just set the new type to
* the outer type created */
*new_type = outer_type;
if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5_mpio_create_large_type() */
#endif /* H5_HAVE_PARALLEL */

View File

@ -2670,12 +2670,15 @@ H5_DLL herr_t H5_combine_path(const char *path1, const char *path2, char **ful
#ifdef H5_HAVE_PARALLEL
/* Generic MPI functions */
H5_DLL hsize_t H5_mpio_get_bigio_count();
H5_DLL herr_t H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new);
H5_DLL herr_t H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new);
H5_DLL herr_t H5_mpi_comm_free(MPI_Comm *comm);
H5_DLL herr_t H5_mpi_info_free(MPI_Info *info);
H5_DLL herr_t H5_mpi_comm_cmp(MPI_Comm comm1, MPI_Comm comm2, int *result);
H5_DLL herr_t H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result);
H5_DLL herr_t H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes,
MPI_Datatype old_type, MPI_Datatype *new_type);
#endif /* H5_HAVE_PARALLEL */
/* Functions for debugging */

View File

@ -34,6 +34,7 @@
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FDprivate.h" /* File drivers */
#include "H5Rprivate.h" /* References */
#include "H5Ipkg.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5VLprivate.h" /* Virtual Object Layer */
@ -1856,22 +1857,51 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
} /* end else */
break;
case 'r':
if(ptr) {
if(vp)
HDfprintf(out, "0x%lx", (unsigned long)vp);
else
HDfprintf(out, "NULL");
} /* end if */
else {
hobj_ref_t ref = HDva_arg(ap, hobj_ref_t);
HDfprintf(out, "Reference Object=%a", ref);
} /* end else */
break;
case 'R':
switch(type[1]) {
case 'o':
if(ptr) {
if(vp)
HDfprintf(out, "0x%lx", (unsigned long)vp);
else
HDfprintf(out, "NULL");
} /* end if */
else {
hobj_ref_t ref = HDva_arg(ap, hobj_ref_t);
HDfprintf(out, "Reference Object=%a", ref);
} /* end else */
break;
case 'd':
if(ptr) {
if(vp)
HDfprintf(out, "0x%lx", (unsigned long)vp);
else
HDfprintf(out, "NULL");
} /* end if */
else {
/* Note! region references are array types */
HDfprintf(out, "Reference Region");
goto error;
} /* end else */
break;
case 'r':
if(ptr) {
if(vp)
HDfprintf(out, "0x%lx", (unsigned long)vp);
else
HDfprintf(out, "NULL");
} /* end if */
else {
/* Note! reference types are opaque types */
HDfprintf(out, "Reference Opaque");
goto error;
} /* end else */
break;
case 't':
if(ptr) {
if(vp)
@ -1887,12 +1917,24 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
HDfprintf(out, "H5R_BADTYPE");
break;
case H5R_OBJECT:
HDfprintf(out, "H5R_OBJECT");
case H5R_OBJECT1:
HDfprintf(out, "H5R_OBJECT1");
break;
case H5R_DATASET_REGION:
HDfprintf(out, "H5R_DATASET_REGION");
case H5R_DATASET_REGION1:
HDfprintf(out, "H5R_DATASET_REGION1");
break;
case H5R_OBJECT2:
HDfprintf(out, "H5R_OBJECT2");
break;
case H5R_DATASET_REGION2:
HDfprintf(out, "H5R_DATASET_REGION2");
break;
case H5R_ATTR:
HDfprintf(out, "H5R_ATTR");
break;
case H5R_MAXTYPE:
@ -2592,6 +2634,35 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
} /* end switch */
} /* end else */
break;
case 'B':
if(ptr) {
if(vp)
HDfprintf (out, "0x%lx", (unsigned long)vp);
else
HDfprintf(out, "NULL");
} /* end if */
else {
H5VL_blob_specific_t specific = (H5VL_blob_specific_t)HDva_arg(ap, int);
switch(specific) {
case H5VL_BLOB_DELETE:
HDfprintf(out, "H5VL_BLOB_DELETE");
break;
case H5VL_BLOB_GETSIZE:
HDfprintf(out, "H5VL_BLOB_GETSIZE");
break;
case H5VL_BLOB_ISNULL:
HDfprintf(out, "H5VL_BLOB_ISNULL");
break;
case H5VL_BLOB_SETNULL:
HDfprintf(out, "H5VL_BLOB_SETNULL");
break;
default:
HDfprintf(out, "%ld", (long)specific);
break;
} /* end switch */
} /* end else */
break;
case 'C':
if(ptr) {
if(vp)
@ -2729,18 +2800,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
H5VL_file_get_t get = (H5VL_file_get_t)HDva_arg(ap, int);
switch(get) {
case H5VL_FILE_GET_CONT_INFO:
HDfprintf(out, "H5VL_FILE_GET_CONT_INFO");
break;
case H5VL_FILE_GET_FAPL:
HDfprintf(out, "H5VL_FILE_GET_FAPL");
break;
case H5VL_FILE_GET_FCPL:
HDfprintf(out, "H5VL_FILE_GET_FCPL");
break;
case H5VL_FILE_GET_INTENT:
HDfprintf(out, "H5VL_FILE_GET_INTENT");
break;
case H5VL_FILE_GET_FILENO:
HDfprintf(out, "H5VL_FILE_GET_FILENO");
break;
case H5VL_FILE_GET_INTENT:
HDfprintf(out, "H5VL_FILE_GET_INTENT");
break;
case H5VL_FILE_GET_NAME:
HDfprintf(out, "H5VL_FILE_GET_NAME");
break;
@ -2926,18 +3000,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
H5VL_object_get_t get = (H5VL_object_get_t)HDva_arg(ap, int);
switch(get) {
case H5VL_REF_GET_REGION:
HDfprintf(out, "H5VL_REF_GET_REGION");
break;
case H5VL_REF_GET_TYPE:
HDfprintf(out, "H5VL_REF_GET_TYPE");
break;
case H5VL_REF_GET_NAME:
HDfprintf(out, "H5VL_REF_GET_NAME");
break;
case H5VL_OBJECT_GET_NAME:
HDfprintf(out, "H5VL_OBJECT_GET_NAME");
break;
case H5VL_OBJECT_GET_TYPE:
HDfprintf(out, "H5VL_OBJECT_GET_TYPE");
break;
default:
HDfprintf(out, "%ld", (long)get);
break;
@ -2961,12 +3029,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case H5VL_OBJECT_EXISTS:
HDfprintf(out, "H5VL_OBJECT_EXISTS");
break;
case H5VL_OBJECT_LOOKUP:
HDfprintf(out, "H5VL_OBJECT_LOOKUP");
break;
case H5VL_OBJECT_VISIT:
HDfprintf(out, "H5VL_OBJECT_VISIT");
break;
case H5VL_REF_CREATE:
HDfprintf(out, "H5VL_REF_CREATE");
break;
case H5VL_OBJECT_FLUSH:
HDfprintf(out, "H5VL_OBJECT_FLUSH");
break;

View File

@ -83,7 +83,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5O.c H5Odeprec.c H5Oainfo.c H5Oalloc.c H5Oattr.c \
H5Oattribute.c H5Obogus.c H5Obtreek.c H5Ocache.c H5Ocache_image.c \
H5Ochunk.c \
H5Ocont.c H5Ocopy.c H5Odbg.c H5Odrvinfo.c H5Odtype.c H5Oefl.c \
H5Ocont.c H5Ocopy.c H5Ocopy_ref.c H5Odbg.c H5Odrvinfo.c H5Odtype.c H5Oefl.c \
H5Ofill.c H5Oflush.c H5Ofsinfo.c H5Oginfo.c \
H5Oint.c H5Olayout.c \
H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c \
@ -114,10 +114,12 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5Tfloat.c H5Tinit.c H5Tnative.c H5Toffset.c H5Toh.c \
H5Topaque.c \
H5Torder.c \
H5Tref.c \
H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c H5Tvlen.c H5TS.c \
H5VL.c H5VLcallback.c H5VLint.c H5VLnative.c \
H5VLnative_attr.c H5VLnative_dataset.c H5VLnative_datatype.c \
H5VLnative_file.c H5VLnative_group.c H5VLnative_link.c H5VLnative_object.c \
H5VLnative_attr.c H5VLnative_blob.c H5VLnative_dataset.c \
H5VLnative_datatype.c H5VLnative_file.c H5VLnative_group.c \
H5VLnative_link.c H5VLnative_object.c \
H5VLpassthru.c \
H5VM.c H5WB.c H5Z.c \
H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c \

View File

@ -194,6 +194,7 @@ set (testhdf5_SOURCES
${HDF5_TEST_SOURCE_DIR}/tmeta.c
${HDF5_TEST_SOURCE_DIR}/tmisc.c
${HDF5_TEST_SOURCE_DIR}/trefer.c
${HDF5_TEST_SOURCE_DIR}/trefer_deprec.c
${HDF5_TEST_SOURCE_DIR}/trefstr.c
${HDF5_TEST_SOURCE_DIR}/tselect.c
${HDF5_TEST_SOURCE_DIR}/tskiplist.c
@ -250,6 +251,7 @@ set (H5_TESTS
external
external_env
efc
objcopy_ref
objcopy
links
unlink

View File

@ -59,7 +59,7 @@ TEST_PROG= testhdf5 \
stab gheap evict_on_close farray earray btree2 fheap \
pool accum hyperslab istore bittests dt_arith page_buffer \
dtypes dsets chunk_info cmpd_dset filter_fail extend direct_chunk \
external efc objcopy links unlink twriteorder big mtime fillval mount \
external efc objcopy objcopy_ref links unlink twriteorder big mtime fillval mount \
flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \
enc_dec_plist_cross_platform getname vfd ros3 s3comms hdfs ntypes \
dangle dtransform reserved cross_read freespace mf vds file_image \
@ -190,7 +190,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
stdio.h5 sec2.h5 dtypes[0-9].h5 dtypes1[0].h5 dt_arith[1-2].h5 tattr.h5 \
tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \
fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 ttime.h5 \
trefer[1-3].h5 tvltypes.h5 tvlstr.h5 tvlstr2.h5 twriteorder.dat \
trefer[1-3].h5 trefer_*.h5 tvltypes.h5 tvlstr.h5 tvlstr2.h5 twriteorder.dat \
flush.h5 flush-swmr.h5 noflush.h5 noflush-swmr.h5 flush_extend.h5 \
flush_extend-swmr.h5 noflush_extend.h5 noflush_extend-swmr.h5 \
enum1.h5 titerate.h5 ttsafe.h5 tarray1.h5 tgenprop.h5 \
@ -218,7 +218,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
# Sources for testhdf5 executable
testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
tgenprop.c th5o.c th5s.c tcoords.c theap.c tid.c titerate.c tmeta.c tmisc.c \
trefer.c trefstr.c tselect.c tskiplist.c tsohm.c ttime.c ttst.c tunicode.c \
trefer.c trefer_deprec.c trefstr.c tselect.c tskiplist.c tsohm.c ttime.c ttst.c tunicode.c \
tvlstr.c tvltypes.c
# Sources for Use Cases

View File

@ -4085,8 +4085,8 @@ test_nbit_compound_3(hid_t file)
* Cleanup
*----------------------------------------------------------------------
*/
if(H5Dvlen_reclaim(cmpd_tid, space, H5P_DEFAULT, new_data) < 0) goto error;
if(H5Dvlen_reclaim(cmpd_tid, space, H5P_DEFAULT, orig_data) < 0) goto error;
if(H5Treclaim(cmpd_tid, space, H5P_DEFAULT, new_data) < 0) goto error;
if(H5Treclaim(cmpd_tid, space, H5P_DEFAULT, orig_data) < 0) goto error;
if(H5Tclose(i_tid) < 0) goto error;
if(H5Tclose(str_tid) < 0) goto error;
if(H5Tclose(vl_str_tid) < 0) goto error;

View File

@ -1809,7 +1809,7 @@ test_compound_9(void)
goto error;
} /* end if */
if(H5Dvlen_reclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) {
if(H5Treclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim read data\n");
goto error;
@ -1875,7 +1875,7 @@ test_compound_9(void)
goto error;
} /* end if */
if(H5Dvlen_reclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) {
if(H5Treclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) {
H5_FAILED(); AT();
HDprintf("Can't read data\n");
goto error;
@ -2063,12 +2063,12 @@ test_compound_10(void)
goto error;
}
} /* end for */
if(H5Dvlen_reclaim(arr_tid, space_id, H5P_DEFAULT, &rdata) < 0) {
if(H5Treclaim(arr_tid, space_id, H5P_DEFAULT, &rdata) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim read data\n");
goto error;
} /* end if */
if(H5Dvlen_reclaim(arr_tid, space_id, H5P_DEFAULT, &wdata) < 0) {
if(H5Treclaim(arr_tid, space_id, H5P_DEFAULT, &wdata) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim read data\n");
goto error;
@ -2226,7 +2226,7 @@ test_compound_11(void)
TEST_ERROR
} /* end if */
} /* end for */
if(H5Dvlen_reclaim(little_tid2, space_id, H5P_DEFAULT, buf) < 0) {
if(H5Treclaim(little_tid2, space_id, H5P_DEFAULT, buf) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim data\n");
goto error;
@ -2270,7 +2270,7 @@ test_compound_11(void)
TEST_ERROR
} /* end if */
} /* end for */
if(H5Dvlen_reclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) {
if(H5Treclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim data\n");
goto error;
@ -2308,7 +2308,7 @@ test_compound_11(void)
TEST_ERROR
} /* end if */
} /* end for */
if(H5Dvlen_reclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) {
if(H5Treclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim data\n");
goto error;
@ -2811,13 +2811,13 @@ test_compound_14(void)
goto error;
} /* end if */
if(H5Dvlen_reclaim(cmpd_m1_tid, space_id, H5P_DEFAULT, &rdata1) < 0) {
if(H5Treclaim(cmpd_m1_tid, space_id, H5P_DEFAULT, &rdata1) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim read data\n");
goto error;
} /* end if */
rdata1.str = NULL;
if(H5Dvlen_reclaim(cmpd_m2_tid, space_id, H5P_DEFAULT, &rdata2) < 0) {
if(H5Treclaim(cmpd_m2_tid, space_id, H5P_DEFAULT, &rdata2) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim read data\n");
goto error;
@ -2898,13 +2898,13 @@ test_compound_14(void)
goto error;
} /* end if */
if(H5Dvlen_reclaim(cmpd_m1_tid, space_id, H5P_DEFAULT, &rdata1) < 0) {
if(H5Treclaim(cmpd_m1_tid, space_id, H5P_DEFAULT, &rdata1) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim read data\n");
goto error;
} /* end if */
rdata1.str = NULL;
if(H5Dvlen_reclaim(cmpd_m2_tid, space_id, H5P_DEFAULT, &rdata2) < 0) {
if(H5Treclaim(cmpd_m2_tid, space_id, H5P_DEFAULT, &rdata2) < 0) {
H5_FAILED(); AT();
HDprintf("Can't reclaim read data\n");
goto error;

View File

@ -1516,7 +1516,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, fillval) < 0) TEST_ERROR
/* Release any VL components */
if(H5Dvlen_reclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
/* Clear the read buffer */
HDmemset(val_rd, 0, val_size);
@ -1572,7 +1572,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR
/* Release any VL components */
if(H5Dvlen_reclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
/* Clear the read buffer */
HDmemset(val_rd, 0, val_size);
@ -1613,7 +1613,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR
/* Release any VL components */
if(H5Dvlen_reclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
/* Clear the read buffer */
HDmemset(val_rd, 0, val_size);
@ -1652,7 +1652,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR
/* Release any VL components */
if(H5Dvlen_reclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
/* Clear the read buffer */
HDmemset(val_rd, 0, val_size);
@ -1693,7 +1693,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR
/* Release any VL components */
if(H5Dvlen_reclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
/* Clear the read buffer */
HDmemset(val_rd, 0, val_size);
@ -1739,7 +1739,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
if(H5Dwrite(dset, dtype, mspace, fspace, H5P_DEFAULT, fillval) < 0) TEST_ERROR
/* Release any VL components */
if(H5Dvlen_reclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
/* Clear the read buffer */
HDmemset(val_rd, 0, val_size);
@ -1758,7 +1758,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, fillval) < 0) TEST_ERROR
/* Release any VL components */
if(H5Dvlen_reclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
/* Clear the read buffer */
HDmemset(val_rd, 0, val_size);
@ -1786,7 +1786,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR
/* Release any VL components */
if(H5Dvlen_reclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR
/* Clear the read buffer */
HDmemset(val_rd, 0, val_size);

View File

@ -2735,11 +2735,11 @@ ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) {
}
if ((pass) && (write_data)) {
ret = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, wdata);
ret = H5Treclaim(tid, sid, H5P_DEFAULT, wdata);
if (ret < 0) {
pass = FALSE;
failure_mssg = "ds_ctg_v: H5Dvlen_reclaim() failed.";
failure_mssg = "ds_ctg_v: H5Treclaim() failed.";
}
HDassert(ret >= 0);
@ -3003,11 +3003,11 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) {
}
if ((pass) && (write_data)) {
ret = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rdata);
ret = H5Treclaim(tid, sid, H5P_DEFAULT, rdata);
if (ret < 0) {
pass = FALSE;
failure_mssg = "vrfy_ds_ctg_v: H5Dvlen_reclaim() failed.";
failure_mssg = "vrfy_ds_ctg_v: H5Treclaim() failed.";
}
HDassert(ret >= 0);

View File

@ -1779,10 +1779,10 @@ test_vl_dtype(hid_t file)
} /* end for */
/* Reclaim the read VL data */
if(H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, rdata) < 0) TEST_ERROR;
if(H5Treclaim(native_type, space, H5P_DEFAULT, rdata) < 0) TEST_ERROR;
/* Reclaim the write VL data */
if(H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, wdata) < 0) TEST_ERROR;
if(H5Treclaim(native_type, space, H5P_DEFAULT, wdata) < 0) TEST_ERROR;
/* Close Dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@ -1808,8 +1808,8 @@ error:
H5E_BEGIN_TRY {
if(native_type > 0) {
H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, rdata);
H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, wdata);
H5Treclaim(native_type, space, H5P_DEFAULT, rdata);
H5Treclaim(native_type, space, H5P_DEFAULT, wdata);
} /* end if */
H5Sclose(space);
H5Dclose(dataset);

View File

@ -547,7 +547,7 @@ done:
if(tid >0 && sid > 0) {
hid_t dxpl_id = H5Pcreate(H5P_DATASET_XFER);
H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL);
H5Dvlen_reclaim(tid, sid, dxpl_id, buf);
H5Treclaim(tid, sid, dxpl_id, buf);
H5Pclose(dxpl_id);
}
if(sid > 0)
@ -794,9 +794,9 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_
/* Reclaim vlen data, if necessary */
if(H5Tdetect_class(tid, H5T_VLEN) == TRUE)
if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR
if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE)
if(H5Dvlen_reclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR
if(H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR
/* Release raw data buffers */
HDfree(rbuf);
@ -1306,9 +1306,9 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf)
/* Reclaim vlen data, if necessary */
if(H5Tdetect_class(tid, H5T_VLEN) == TRUE)
if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR
if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE)
if(H5Dvlen_reclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR
if(H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR
/* Release raw data buffers */
HDfree(rbuf);
@ -5290,7 +5290,7 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_
if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -5307,7 +5307,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
H5Treclaim(tid, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid);
H5Sclose(sid);
@ -5473,7 +5473,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid
if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -5490,7 +5490,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
H5Treclaim(tid, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Pclose(pid);
H5Tclose(tid);
@ -5618,7 +5618,7 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid
if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -5635,7 +5635,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
H5Treclaim(tid, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid);
H5Sclose(sid);
@ -5896,8 +5896,8 @@ compare_attribute_compound_vlstr(hid_t loc, hid_t loc2)
/* Reclaim vlen buffer */
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid, sid, dxpl_id, &rbuf) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid, sid, dxpl_id, &rbuf2) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, dxpl_id, &rbuf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, dxpl_id, &rbuf2) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
/* Close the dataspaces */
@ -5917,8 +5917,8 @@ error:
H5E_BEGIN_TRY {
H5Aclose(aid);
H5Aclose(aid2);
H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, &rbuf);
H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, &rbuf2);
H5Treclaim(tid, sid, H5P_DEFAULT, &rbuf);
H5Treclaim(tid, sid, H5P_DEFAULT, &rbuf2);
H5Sclose(sid);
H5Sclose(sid2);
H5Tclose(tid);
@ -6219,7 +6219,7 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -6239,7 +6239,7 @@ error:
H5Dclose(did2);
H5Dclose(did);
H5Pclose(pid);
H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
H5Treclaim(tid, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid);
H5Sclose(sid);
@ -8050,7 +8050,7 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -8068,7 +8068,7 @@ error:
H5Pclose(pid);
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf);
H5Treclaim(tid_copy, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid);
H5Tclose(tid_copy);
@ -8197,7 +8197,7 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl
if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -8214,7 +8214,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf);
H5Treclaim(tid_copy, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid);
H5Tclose(tid_copy);
@ -8364,7 +8364,7 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -8382,7 +8382,7 @@ error:
H5Pclose(pid);
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf);
H5Treclaim(tid_copy, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid);
H5Tclose(tid_copy);
@ -8521,7 +8521,7 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_
if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -8539,7 +8539,7 @@ error:
H5Pclose(pid);
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf);
H5Treclaim(tid_copy, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid);
H5Tclose(tid_copy);
@ -8683,7 +8683,7 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -8701,7 +8701,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf);
H5Treclaim(tid2, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Pclose(pid);
H5Tclose(tid);
@ -8856,7 +8856,7 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h
if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -8874,7 +8874,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf);
H5Treclaim(tid2, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Pclose(pid);
H5Tclose(tid);
@ -9057,7 +9057,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -9076,7 +9076,7 @@ error:
H5Pclose(pid);
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf);
H5Treclaim(tid2, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid);
H5Tclose(tid2);
@ -9233,7 +9233,7 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap
if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -9252,7 +9252,7 @@ error:
H5Pclose(pid);
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf);
H5Treclaim(tid2, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid);
H5Tclose(tid2);
@ -9389,7 +9389,7 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -9407,7 +9407,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
H5Treclaim(tid, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Tclose(tid2);
H5Tclose(tid);
@ -9542,7 +9542,7 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl
if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -9560,7 +9560,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
H5Treclaim(tid, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Pclose(pid);
H5Tclose(tid2);
@ -9695,7 +9695,7 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl
if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR
if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR
if(H5Pclose(dxpl_id) < 0) TEST_ERROR
} /* end if */
@ -9713,7 +9713,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
H5Treclaim(tid, sid, H5P_DEFAULT, buf);
H5Pclose(dxpl_id);
H5Pclose(pid);
H5Tclose(tid2);

1739
test/objcopy_ref.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2658,7 +2658,7 @@ static int test_random_rank4_vl( hid_t fapl, hid_t dcpl, hbool_t do_fillvalue,
} /* end else */
/* Free read buffer */
if(H5Dvlen_reclaim(type, mspace, H5P_DEFAULT, rbuf) < 0)
if(H5Treclaim(type, mspace, H5P_DEFAULT, rbuf) < 0)
TEST_ERROR
} /* end if */
@ -2678,7 +2678,7 @@ static int test_random_rank4_vl( hid_t fapl, hid_t dcpl, hbool_t do_fillvalue,
/* Close */
if(H5Sselect_all(mspace) < 0)
TEST_ERROR
if(H5Dvlen_reclaim(type, mspace, H5P_DEFAULT, wbuf) < 0)
if(H5Treclaim(type, mspace, H5P_DEFAULT, wbuf) < 0)
TEST_ERROR
free(fill_value.p);
if(H5Sclose(mspace) < 0)

View File

@ -1268,15 +1268,15 @@ test_array_vlen_atomic(void)
} /* end for */
/* Reclaim the read VL data */
ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close dataset transfer property list */
ret = H5Pclose(xfer_pid);
@ -1523,15 +1523,15 @@ test_array_vlen_array(void)
} /* end for */
/* Reclaim the read VL data */
ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close dataset transfer property list */
ret = H5Pclose(xfer_pid);

View File

@ -57,7 +57,8 @@ main(int argc, char *argv[])
AddTest("attr", test_attr, cleanup_attr, "Attributes", NULL);
AddTest("select", test_select, cleanup_select, "Selections", NULL);
AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL);
AddTest("reference", test_reference, cleanup_reference, "References", NULL);
AddTest("ref_deprec", test_reference_deprec, cleanup_reference_deprec, "Deprecated References", NULL);
AddTest("ref", test_reference, cleanup_reference, "References", NULL);
AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL);
AddTest("vlstrings", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL);
AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL);

View File

@ -192,6 +192,7 @@ void test_attr(void);
void test_select(void);
void test_time(void);
void test_reference(void);
void test_reference_deprec(void);
void test_vltypes(void);
void test_vlstrings(void);
void test_iterate(void);
@ -215,6 +216,7 @@ void cleanup_attr(void);
void cleanup_select(void);
void cleanup_time(void);
void cleanup_reference(void);
void cleanup_reference_deprec(void);
void cleanup_vltypes(void);
void cleanup_vlstrings(void);
void cleanup_iterate(void);

View File

@ -2640,8 +2640,8 @@ test_file_double_file_dataset_open(hbool_t new_format)
HDmemset(buffer, 0, sizeof(char*) * 5);
ret = H5Dread(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer);
CHECK(ret, FAIL, "H5Dread");
ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, buffer);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, buffer);
CHECK(ret, FAIL, "H5Treclaim");
/* Second file's dataset close */
ret = H5Dclose(did2);
@ -2655,8 +2655,8 @@ test_file_double_file_dataset_open(hbool_t new_format)
HDmemset(buffer, 0, sizeof(char*) * 5);
ret = H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer);
CHECK(ret, FAIL, "H5Dread");
ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, buffer);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, buffer);
CHECK(ret, FAIL, "H5Treclaim");
/* First file's dataset close */
ret = H5Dclose(did1);

View File

@ -460,8 +460,8 @@ static void test_misc2_write_attribute(void)
ret = H5Aread(att1, type, &data_check);
CHECK(ret, FAIL, "H5Aread");
ret = H5Dvlen_reclaim(type, dataspace, H5P_DEFAULT, &data_check);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(type, dataspace, H5P_DEFAULT, &data_check);
CHECK(ret, FAIL, "H5Treclaim");
ret = H5Aclose(att1);
CHECK(ret, FAIL, "H5Aclose");
@ -486,8 +486,8 @@ static void test_misc2_write_attribute(void)
ret = H5Aread(att2, type, &data_check);
CHECK(ret, FAIL, "H5Aread");
ret = H5Dvlen_reclaim(type, dataspace, H5P_DEFAULT, &data_check);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(type, dataspace, H5P_DEFAULT, &data_check);
CHECK(ret, FAIL, "H5Treclaim");
ret = H5Aclose(att2);
CHECK(ret, FAIL, "H5Aclose");
@ -535,8 +535,8 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name
ret = H5Aread(att, type, &data_check);
CHECK(ret, FAIL, "H5Aread");
ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &data_check);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(type, space, H5P_DEFAULT, &data_check);
CHECK(ret, FAIL, "H5Treclaim");
ret = H5Sclose(space);
CHECK(ret, FAIL, "H5Sclose");
@ -994,8 +994,8 @@ test_misc5(void)
}
/* Reclaim the memory for the VL information */
ret=H5Dvlen_reclaim(mem_type_id, space_id, H5P_DEFAULT, &buf);
CHECK(ret,FAIL,"H5Dvlen_reclaim");
ret=H5Treclaim(mem_type_id, space_id, H5P_DEFAULT, &buf);
CHECK(ret,FAIL,"H5Treclaim");
/* Close dataspace */
ret=H5Sclose(space_id);
@ -2061,8 +2061,8 @@ test_misc12(void)
CHECK(ret, FAIL, "H5Sselect_all");
/* Reclaim VL data memory */
ret = H5Dvlen_reclaim(tid1, space, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(tid1, space, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Everything */
ret = H5Dclose(dataset);

File diff suppressed because it is too large Load Diff

1827
test/trefer_deprec.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -352,8 +352,8 @@ void test_vl_string(hid_t fid, const char *string)
VERIFY(HDstrcmp(string, read_buf[0]), 0, "strcmp");
/* Reclaim the read VL data */
ret = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, read_buf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(type_id, space_id, H5P_DEFAULT, read_buf);
CHECK(ret, FAIL, "H5Treclaim");
/* Close all */
ret = H5Dclose(dset_id);

View File

@ -208,11 +208,11 @@ test_vlstrings_basic(void)
} /* end for */
/* Reclaim the read VL data */
ret = H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -314,8 +314,8 @@ test_vlstrings_special(void)
} /* end for */
/* Reclaim the read VL data */
ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -537,8 +537,8 @@ test_compact_vlstring(void)
} /* end for */
/* Reclaim the read VL data */
ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(tid1, sid1, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -762,8 +762,8 @@ static void read_scalar_dset(hid_t file, hid_t type, hid_t space, char *name, ch
if(HDstrcmp(data, data_read))
TestErrPrintf("Expected %s for dataset %s but read %s\n", data, name, data_read);
ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &data_read);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(type, space, H5P_DEFAULT, &data_read);
CHECK(ret, FAIL, "H5Treclaim");
}
/****************************************************************

View File

@ -415,11 +415,11 @@ test_vltypes_vlen_atomic(void)
} /* end for */
/* Reclaim the read VL data */
ret = H5Dvlen_reclaim(tid1, sid1, xfer_pid, rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(tid1, sid1, xfer_pid, rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used, 0, "H5Dvlen_reclaim");
VERIFY(mem_used, 0, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -499,24 +499,24 @@ test_vltypes_vlen_atomic(void)
/* Try to reclaim read data using "bad" dataspace with no extent
* Should fail */
H5E_BEGIN_TRY {
ret=H5Dvlen_reclaim(tid1,sid2,xfer_pid,rdata);
ret=H5Treclaim(tid1,sid2,xfer_pid,rdata);
} H5E_END_TRY
VERIFY(ret, FAIL, "H5Dvlen_reclaim");
VERIFY(ret, FAIL, "H5Treclaim");
/* Reclaim the read VL data */
ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close datatype */
ret = H5Tclose(tid1);
@ -659,15 +659,15 @@ rewrite_vltypes_vlen_atomic(void)
} /* end for */
/* Reclaim the read VL data */
ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -803,15 +803,15 @@ test_vltypes_vlen_compound(void)
} /* end for */
/* Reclaim the VL data */
ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -948,15 +948,15 @@ rewrite_vltypes_vlen_compound(void)
} /* end for */
/* Reclaim the VL data */
ret=H5Dvlen_reclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid1,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -1118,12 +1118,12 @@ test_vltypes_compound_vlen_vlen(void)
} /* end for */
/* Reclaim the VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -1360,12 +1360,12 @@ test_vltypes_compound_vlstr(void)
} /* end for */
/* Reclaim the VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Use this part for new data */
HDstrcpy(str, "bbbbbbbb\0");
@ -1418,12 +1418,12 @@ test_vltypes_compound_vlstr(void)
} /* end for */
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,wdata2);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata2);
CHECK(ret, FAIL, "H5Treclaim");
/* Reclaim the VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,rdata2);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata2);
CHECK(ret, FAIL, "H5Treclaim");
ret = H5Dclose(dset2);
CHECK(ret, FAIL, "H5Dclose");
@ -1568,11 +1568,11 @@ test_vltypes_compound_vlen_atomic(void)
} /* end for */
/* Reclaim the VL data */
ret = H5Dvlen_reclaim(tid2, sid1, xfer_pid, rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(tid2, sid1, xfer_pid, rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used, 0, "H5Dvlen_reclaim");
VERIFY(mem_used, 0, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -1634,16 +1634,16 @@ test_vltypes_compound_vlen_atomic(void)
} /* end for */
/* Reclaim the VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close datatype */
ret = H5Tclose(tid2);
@ -1786,15 +1786,15 @@ rewrite_vltypes_compound_vlen_atomic(void)
} /* end for */
/* Reclaim the VL data */
ret=H5Dvlen_reclaim(tid2,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -1997,15 +1997,15 @@ test_vltypes_vlen_vlen_atomic(void)
} /* end for */
/* Reclaim all the (nested) VL data */
ret=H5Dvlen_reclaim(tid2,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -2177,15 +2177,15 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void)
} /* end for */
/* Reclaim all the (nested) VL data */
ret=H5Dvlen_reclaim(tid2,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -2353,15 +2353,15 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void)
} /* end for */
/* Reclaim all the (nested) VL data */
ret=H5Dvlen_reclaim(tid2,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,xfer_pid,rdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Make certain the VL memory has been freed */
VERIFY(mem_used,0,"H5Dvlen_reclaim");
VERIFY(mem_used,0,"H5Treclaim");
/* Reclaim the write VL data */
ret=H5Dvlen_reclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata);
CHECK(ret, FAIL, "H5Treclaim");
/* Close Dataset */
ret = H5Dclose(dataset);
@ -2743,8 +2743,8 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Treclaim");
/* Clear the read buffer */
HDmemset(rbuf, 0, dset_elmts * sizeof(dtype1_struct));
@ -2778,8 +2778,8 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Treclaim");
ret = H5Dclose(dset_id);
CHECK(ret, FAIL, "H5Dclose");
@ -2808,8 +2808,8 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Treclaim");
/* Clear the read buffer */
HDmemset(rbuf, 0, dset_elmts * sizeof(dtype1_struct));
@ -2843,8 +2843,8 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Treclaim");
ret = H5Dclose(dset_id);
CHECK(ret, FAIL, "H5Dclose");
@ -2970,8 +2970,8 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Treclaim");
/* Clear the read buffer */
HDmemset(rbuf, 0, dset_elmts * sizeof(dtype1_struct));
@ -3019,8 +3019,8 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Treclaim");
ret = H5Dclose(dset_id);
CHECK(ret, FAIL, "H5Dclose");
@ -3066,8 +3066,8 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Treclaim");
/* Clear the read buffer */
HDmemset(rbuf, 0, dset_elmts * sizeof(dtype1_struct));
@ -3115,8 +3115,8 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Treclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Treclaim");
ret = H5Dclose(dset_id);
CHECK(ret, FAIL, "H5Dclose");

View File

@ -4,7 +4,8 @@
#include "H5Dprivate.h" /* For Chunk tests */
/* FILENAME and filenames must have the same number of names */
const char *FILENAME[2]={ "bigio_test.h5",
const char *FILENAME[3]={ "bigio_test.h5",
"single_rank_independent_io.h5",
NULL
};
@ -29,7 +30,8 @@ const char *FILENAME[2]={ "bigio_test.h5",
#define DATASET5 "DSET5"
#define DXFER_COLLECTIVE_IO 0x1 /* Collective IO*/
#define DXFER_INDEPENDENT_IO 0x2 /* Independent IO collectively */
#define DXFER_BIGCOUNT 536870916
#define DXFER_BIGCOUNT (1 < 29)
#define LARGE_DIM 1610612736
#define HYPER 1
#define POINT 2
@ -40,7 +42,7 @@ typedef hsize_t B_DATATYPE;
int facc_type = FACC_MPIO; /*Test file access type */
int dxfer_coll_type = DXFER_COLLECTIVE_IO;
size_t bigcount = DXFER_BIGCOUNT;
size_t bigcount = (size_t)DXFER_BIGCOUNT;
int nerrors = 0;
int mpi_size, mpi_rank;
@ -51,6 +53,8 @@ static void coll_chunktest(const char* filename, int chunk_factor, int select_fa
int api_option, int file_selection, int mem_selection, int mode);
hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type);
hsize_t H5_mpio_set_bigio_count(hsize_t new_count);
/*
* Setup the coordinates for point selection.
*/
@ -478,22 +482,19 @@ static void
dataset_big_write(void)
{
hid_t xfer_plist; /* Dataset transfer properties list */
hid_t sid; /* Dataspace ID */
hid_t file_dataspace; /* File dataspace ID */
hid_t mem_dataspace; /* memory dataspace ID */
hid_t xfer_plist; /* Dataset transfer properties list */
hid_t sid; /* Dataspace ID */
hid_t file_dataspace; /* File dataspace ID */
hid_t mem_dataspace; /* memory dataspace ID */
hid_t dataset;
hid_t datatype; /* Datatype ID */
hsize_t dims[RANK]; /* dataset dim sizes */
hsize_t start[RANK]; /* for hyperslab setting */
hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */
hsize_t block[RANK]; /* for hyperslab setting */
hsize_t dims[RANK]; /* dataset dim sizes */
hsize_t start[RANK]; /* for hyperslab setting */
hsize_t count[RANK],stride[RANK]; /* for hyperslab setting */
hsize_t block[RANK]; /* for hyperslab setting */
hsize_t *coords = NULL;
int i;
herr_t ret; /* Generic return value */
hid_t fid; /* HDF5 file ID */
hid_t acc_tpl; /* File access templates */
hsize_t h;
herr_t ret; /* Generic return value */
hid_t fid; /* HDF5 file ID */
hid_t acc_tpl; /* File access templates */
size_t num_points;
B_DATATYPE * wdata;
@ -806,8 +807,6 @@ dataset_big_read(void)
hsize_t start[RANK]; /* for hyperslab setting */
hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */
hsize_t block[RANK]; /* for hyperslab setting */
int i,j,k;
hsize_t h;
size_t num_points;
hsize_t *coords = NULL;
herr_t ret; /* Generic return value */
@ -1120,6 +1119,63 @@ dataset_big_read(void)
} /* dataset_large_readAll */
static void
single_rank_independent_io(void)
{
if (mpi_rank == 0)
HDprintf("single_rank_independent_io\n");
if (MAINPROCESS) {
hsize_t dims[] = { LARGE_DIM };
hid_t file_id = -1;
hid_t fapl_id = -1;
hid_t dset_id = -1;
hid_t fspace_id = -1;
hid_t mspace_id = -1;
void *data = NULL;
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
VRFY((fapl_id >= 0), "H5P_FILE_ACCESS");
H5Pset_fapl_mpio(fapl_id, MPI_COMM_SELF, MPI_INFO_NULL);
file_id = H5Fcreate(FILENAME[1], H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
VRFY((file_id >= 0), "H5Dcreate2 succeeded");
fspace_id = H5Screate_simple(1, dims, NULL);
VRFY((fspace_id >= 0), "H5Screate_simple fspace_id succeeded");
/*
* Create and write to a >2GB dataset from a single rank.
*/
dset_id = H5Dcreate2(file_id, "test_dset", H5T_NATIVE_INT, fspace_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
VRFY((dset_id >= 0), "H5Dcreate2 succeeded");
data = malloc(LARGE_DIM * sizeof(int));
if (mpi_rank == 0)
H5Sselect_all(fspace_id);
else
H5Sselect_none(fspace_id);
dims[0] = LARGE_DIM;
mspace_id = H5Screate_simple(1, dims, NULL);
VRFY((mspace_id >= 0), "H5Screate_simple mspace_id succeeded");
H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data);
free(data);
H5Sclose(mspace_id);
H5Sclose(fspace_id);
H5Pclose(fapl_id);
H5Dclose(dset_id);
H5Fclose(file_id);
HDremove(FILENAME[1]);
}
MPI_Barrier(MPI_COMM_WORLD);
}
/*
* Create the appropriate File access property list
@ -1395,7 +1451,6 @@ coll_chunktest(const char* filename,
size_t num_points; /* for point selection */
hsize_t *coords = NULL; /* for point selection */
int i;
/* Create the data space */
@ -1873,7 +1928,7 @@ int main(int argc, char **argv)
int ExpressMode = 0;
hsize_t newsize = 1048576;
/* Set the bigio processing limit to be 'newsize' bytes */
hsize_t oldsize = H5S_mpio_set_bigio_count(newsize);
hsize_t oldsize = H5_mpio_set_bigio_count(newsize);
/* Having set the bigio handling to a size that is managable,
* we'll set our 'bigcount' variable to be 2X that limit so
@ -1918,6 +1973,8 @@ int main(int argc, char **argv)
coll_chunk2();
MPI_Barrier(MPI_COMM_WORLD);
coll_chunk3();
MPI_Barrier(MPI_COMM_WORLD);
single_rank_independent_io();
}
/* turn off alarm */

View File

@ -145,7 +145,7 @@ test_page_buffer_access(void)
ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)0);
VRFY((ret == 0), "");
ret = H5Pset_file_space_page_size(fcpl, sizeof(int)*100);
ret = H5Pset_file_space_page_size(fcpl, sizeof(int)*128);
VRFY((ret == 0), "");
ret = H5Pset_page_buffer_size(fapl, sizeof(int)*100000, 0, 0);
VRFY((ret == 0), "");
@ -180,7 +180,6 @@ test_page_buffer_access(void)
data[i] = -1;
if(MAINPROCESS) {
hid_t fapl_self = H5I_INVALID_HID;
fapl_self = create_faccess_plist(MPI_COMM_SELF, MPI_INFO_NULL, facc_type);
ret = H5Pset_page_buffer_size(fapl_self, sizeof(int)*1000, 0, 0);
@ -433,7 +432,7 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str
hsize_t dims[RANK], i;
hsize_t num_elements;
int k;
char dset_name[10];
char dset_name[20];
H5F_t *f = NULL;
H5C_t *cache_ptr = NULL;
H5AC_cache_config_t config;
@ -590,7 +589,7 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy,
hsize_t block[RANK];
int i, k, ndims;
hsize_t num_elements;
char dset_name[10];
char dset_name[20];
H5F_t *f = NULL;
H5C_t *cache_ptr = NULL;
H5AC_cache_config_t config;
@ -665,8 +664,8 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy,
ndims = H5Sget_simple_extent_dims(sid, dims, NULL);
VRFY((ndims == 2), "H5Sget_simple_extent_dims succeeded");
VRFY(dims[0] == ROW_FACTOR*mpi_size, "Wrong dataset dimensions");
VRFY(dims[1] == COL_FACTOR*mpi_size, "Wrong dataset dimensions");
VRFY(dims[0] == (hsize_t)(ROW_FACTOR*mpi_size), "Wrong dataset dimensions");
VRFY(dims[1] == (hsize_t)(COL_FACTOR*mpi_size), "Wrong dataset dimensions");
ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block);
VRFY((ret >= 0), "H5Sset_hyperslab succeeded");
@ -679,7 +678,7 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy,
ret = H5Sclose(sid);
VRFY((ret == 0), "");
for (i=0; i < num_elements; i++)
for (i=0; i < (int)num_elements; i++)
VRFY((data_array[i] == mpi_rank+1), "Dataset Verify failed");
}

View File

@ -515,12 +515,12 @@ hsize_t diff_attr(hid_t loc1_id,
/* Free buf1 and buf2, check both VLEN-data VLEN-string to reclaim any
* VLEN memory first */
if(TRUE == h5tools_detect_vlen(mtype1_id))
H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
HDfree(buf1);
buf1 = NULL;
if(TRUE == h5tools_detect_vlen(mtype2_id))
H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
HDfree(buf2);
buf2 = NULL;
@ -551,12 +551,12 @@ done:
H5E_BEGIN_TRY {
if(buf1) {
if(buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id))
H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
HDfree(buf1);
} /* end if */
if(buf2) {
if(buf2hasdata && TRUE == h5tools_detect_vlen(mtype2_id))
H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
HDfree(buf2);
} /* end if */

Some files were not shown because too many files have changed in this diff Show More