From 09913e2f8e0264dd6f312689d530d0bb5d3c431e Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Sun, 22 Jul 2018 15:22:34 -0500 Subject: Added class DSetAccPropList Description: - Added class DSetAccPropList for the dataset access property list. - Added wrapper for H5Dget_access_plist to class DataSet // Gets the access property list of this dataset. DSetAccPropList getAccessPlist() const; - Added wrappers for H5Pset_chunk_cache and H5Pget_chunk_cache to class DSetAccPropList // Sets the raw data chunk cache parameters. void setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) // Retrieves the raw data chunk cache parameters. void getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) - Added two more arguments to H5Location::createDataSet: const DSetAccPropList& dapl = DSetAccPropList::DEFAULT const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT - Added one more argument to H5Location::openDataSet: const DSetAccPropList& dapl = DSetAccPropList::DEFAULT Platforms tested: Linux/64 (jelly) Linux/32 (jam) Darwin (osx1010test) --- MANIFEST | 2 + c++/src/CMakeLists.txt | 2 + c++/src/H5AbstractDs.cpp | 1 + c++/src/H5ArrayType.cpp | 1 + c++/src/H5AtomType.cpp | 1 + c++/src/H5Attribute.cpp | 1 + c++/src/H5CommonFG.cpp | 1 + c++/src/H5CompType.cpp | 1 + c++/src/H5Cpp.h | 1 + c++/src/H5DaccProp.cpp | 162 +++++++++++++++++++++++++++++++++++++++++++++++ c++/src/H5DaccProp.h | 68 ++++++++++++++++++++ c++/src/H5DataSet.cpp | 22 +++++++ c++/src/H5DataSet.h | 3 + c++/src/H5DataType.cpp | 1 + c++/src/H5DcreatProp.cpp | 1 + c++/src/H5EnumType.cpp | 1 + c++/src/H5FaccProp.cpp | 10 +++ c++/src/H5File.cpp | 1 + c++/src/H5FloatType.cpp | 1 + c++/src/H5Group.cpp | 1 + c++/src/H5IntType.cpp | 1 + c++/src/H5Library.cpp | 5 ++ c++/src/H5Location.cpp | 54 +++++++++++----- c++/src/H5Location.h | 15 +++-- c++/src/H5Object.cpp | 1 + c++/src/H5PredType.cpp | 23 +++++-- c++/src/H5StrType.cpp | 1 + c++/src/H5VarLenType.cpp | 1 + c++/src/Makefile.am | 22 ++++--- c++/test/dsets.cpp | 115 ++++++++++++++++++++++++++++++++- 30 files changed, 481 insertions(+), 39 deletions(-) create mode 100644 c++/src/H5DaccProp.cpp create mode 100644 c++/src/H5DaccProp.h diff --git a/MANIFEST b/MANIFEST index 02c9928..24b5933 100644 --- a/MANIFEST +++ b/MANIFEST @@ -351,6 +351,8 @@ ./c++/src/H5DataSpace.h ./c++/src/H5DataType.cpp ./c++/src/H5DataType.h +./c++/src/H5DaccProp.cpp +./c++/src/H5DaccProp.h ./c++/src/H5DcreatProp.cpp ./c++/src/H5DcreatProp.h ./c++/src/H5DxferProp.cpp diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 27b71b0..945b352 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -21,6 +21,7 @@ set (CPP_SOURCES ${HDF5_CPP_SRC_SOURCE_DIR}/H5DataSet.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5DataSpace.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5DataType.cpp + ${HDF5_CPP_SRC_SOURCE_DIR}/H5DaccProp.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5DcreatProp.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5DxferProp.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5EnumType.cpp @@ -58,6 +59,7 @@ set (CPP_HDRS ${HDF5_CPP_SRC_SOURCE_DIR}/H5DataSet.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5DataSpace.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5DataType.h + ${HDF5_CPP_SRC_SOURCE_DIR}/H5DaccProp.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5DcreatProp.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5DxferProp.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5EnumType.h diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 823e873..d59a3cb 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -24,6 +24,7 @@ #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataSpace.h" diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 836c837..8ecb6da 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -21,6 +21,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index a9f6f36..9408452 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -21,6 +21,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index ccba623..33f992a 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -29,6 +29,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5AbstractDs.h" diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 979816b..6c5fdca 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -24,6 +24,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5Alltypes.h" diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index 8252d76..ae22f18 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -22,6 +22,7 @@ #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5Alltypes.h" diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index b9da80a..01fae45 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -27,6 +27,7 @@ #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5AbstractDs.h" diff --git a/c++/src/H5DaccProp.cpp b/c++/src/H5DaccProp.cpp new file mode 100644 index 0000000..c6ff705 --- /dev/null +++ b/c++/src/H5DaccProp.cpp @@ -0,0 +1,162 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include + +#include "H5Include.h" +#include "H5Exception.h" +#include "H5IdComponent.h" +#include "H5DataSpace.h" +#include "H5PropList.h" +#include "H5LaccProp.h" +#include "H5DaccProp.h" + +namespace H5 { + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +// This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control +// the order of creation and deletion of the global constants. See Design Notes +// in "H5PredType.cpp" for information. + +// Initialize a pointer for the constant +DSetAccPropList* DSetAccPropList::DEFAULT_ = 0; + +//-------------------------------------------------------------------------- +// Function: DSetAccPropList::getConstant +// Purpose: Creates a DSetAccPropList object representing the HDF5 +// constant H5P_DATASET_ACCESS, pointed to by +// DSetAccPropList::DEFAULT_ +// exception H5::PropListIException +// Description +// If DSetAccPropList::DEFAULT_ already points to an allocated +// object, throw a PropListIException. This scenario should +// not happen. +// Programmer Binh-Minh Ribler - 2015 +//-------------------------------------------------------------------------- +DSetAccPropList* DSetAccPropList::getConstant() +{ + // Tell the C library not to clean up, H5Library::termH5cpp will call + // H5close - more dependency if use H5Library::dontAtExit() + if (!IdComponent::H5dontAtexit_called) + { + (void) H5dont_atexit(); + IdComponent::H5dontAtexit_called = true; + } + + // If the constant pointer is not allocated, allocate it. Otherwise, + // throw because it shouldn't be. + if (DEFAULT_ == 0) + DEFAULT_ = new DSetAccPropList(H5P_DATASET_ACCESS); + else + throw PropListIException("DSetAccPropList::getConstant", "DSetAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return(DEFAULT_); +} + +//-------------------------------------------------------------------------- +// Function: DSetAccPropList::deleteConstants +// Purpose: Deletes the constant object that DSetAccPropList::DEFAULT_ +// points to. +// Programmer Binh-Minh Ribler - 2015 +//-------------------------------------------------------------------------- +void DSetAccPropList::deleteConstants() +{ + if (DEFAULT_ != 0) + delete DEFAULT_; +} + +//-------------------------------------------------------------------------- +// Purpose Constant for dataset creation default property +//-------------------------------------------------------------------------- +const DSetAccPropList& DSetAccPropList::DEFAULT = *getConstant(); + +#endif // DOXYGEN_SHOULD_SKIP_THIS + +//-------------------------------------------------------------------------- +// Function: DSetAccPropList default constructor +///\brief Default constructor: creates a stub dataset creation property list +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) {} + +//-------------------------------------------------------------------------- +// Function: DSetAccPropList copy constructor +///\brief Copy constructor: same HDF5 object as \a original +/// DSetAccPropList object +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +DSetAccPropList::DSetAccPropList(const DSetAccPropList& orig) : LinkAccPropList(orig) {} + +//-------------------------------------------------------------------------- +// Function: DSetAccPropList overloaded constructor +///\brief Creates a DSetAccPropList object using the id of an +/// existing dataset creation property list. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_id) {} + +//-------------------------------------------------------------------------- +// Function: DSetAccPropList::setChunkCache +///\brief Sets the raw data chunk cache parameters. +///\param rdcc_nslots - IN: Number of chunk slots in the raw data chunk cache +///\param rdcc_nbytes - IN: Total size of the raw data chunk cache +///\param rdcc_w0 - IN: The chunk preemption policy for this dataset +///\exception H5::PropListIException +///\par Description +/// The raw data chunk cache parameters includes the number of +/// objects in the meta data cache and the maximum number of +/// chunks and bytes in the raw data chunk cache. Once set, +/// these values will override the values in the file access +/// property list. +/// +/// For information, please refer to the H5Pset_chunk_cache API in +/// the HDF5 C Reference Manual. +// July 2018 +//-------------------------------------------------------------------------- +void DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const +{ + herr_t ret_value = H5Pset_chunk_cache(id, rdcc_nslots, rdcc_nbytes, rdcc_w0); + if (ret_value < 0) + { + throw PropListIException("DSetAccPropList::setChunkCache", "H5Pset_chunk_cache failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetAccPropList::getChunkCache +///\brief Retrieves the raw data chunk cache parameters. +///\param rdcc_nslots - OUT: Number of chunk slots in the raw data chunk cache +///\param rdcc_nbytes - OUT: Total size of the raw data chunk cache +///\param rdcc_w0 - OUT: The chunk preemption policy for this dataset +///\exception H5::PropListIException +///\par Description +/// For information, please refer to the H5Pget_chunk_cache API in +/// the HDF5 C Reference Manual. +// July 2018 +//-------------------------------------------------------------------------- +void DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const +{ + herr_t ret_value = H5Pget_chunk_cache(id, &rdcc_nslots, &rdcc_nbytes, &rdcc_w0); + if (ret_value < 0) + { + throw PropListIException("DSetAccPropList::getChunkCache", "H5Pget_chunk_cache failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetAccPropList destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +DSetAccPropList::~DSetAccPropList() {} + +} // end namespace diff --git a/c++/src/H5DaccProp.h b/c++/src/H5DaccProp.h new file mode 100644 index 0000000..111b4f5 --- /dev/null +++ b/c++/src/H5DaccProp.h @@ -0,0 +1,68 @@ +// C++ informative line for the emacs editor: -*- C++ -*- +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef __H5DSetAccPropList_H +#define __H5DSetAccPropList_H + +namespace H5 { + +/*! \class DSetAccPropList + \brief Class DSetAccPropList inherits from LinkAccPropList and provides + wrappers for the HDF5 dataset access property functions. +*/ +// Inheritance: LinkAccPropList -> PropList -> IdComponent +class H5_DLLCPP DSetAccPropList : public LinkAccPropList { + public: + ///\brief Default dataset creation property list. + static const DSetAccPropList& DEFAULT; + + // Creates a dataset creation property list. + DSetAccPropList(); + + // Sets the raw data chunk cache parameters. + void setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const; + + // Retrieves the raw data chunk cache parameters. + void getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const; + + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("DSetAccPropList"); } + + // Copy constructor - same as the original DSetAccPropList. + DSetAccPropList(const DSetAccPropList& orig); + + // Creates a copy of an existing dataset creation property list + // using the property list id. + DSetAccPropList(const hid_t plist_id); + + // Noop destructor. + virtual ~DSetAccPropList(); + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + + // Deletes the global constant, should only be used by the library + static void deleteConstants(); + + private: + static DSetAccPropList* DEFAULT_; + + // Creates the global constant, should only be used by the library + static DSetAccPropList* getConstant(); + +#endif // DOXYGEN_SHOULD_SKIP_THIS + +}; // end of DSetAccPropList +} // namespace H5 + +#endif // __H5DSetAccPropList_H diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index fbddd8d..db14577 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -30,6 +30,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" @@ -172,6 +173,27 @@ DSetCreatPropList DataSet::getCreatePlist() const } //-------------------------------------------------------------------------- +// Function: DataSet::getAccessPlist +///\brief Gets the dataset access property list. +///\return DSetAccPropList instance +///\exception H5::DataSetIException +// July 2018 +//-------------------------------------------------------------------------- +DSetAccPropList DataSet::getAccessPlist() const +{ + hid_t access_plist_id = H5Dget_access_plist(id); + if (access_plist_id < 0) + { + throw DataSetIException("DataSet::getAccessPlist", "H5Dget_access_plist failed"); + } + + // create and return the DSetCreatPropList object + DSetAccPropList access_plist; + f_PropList_setId(&access_plist, access_plist_id); + return(access_plist); +} + +//-------------------------------------------------------------------------- // Function: DataSet::getStorageSize ///\brief Returns the amount of storage required for a dataset. ///\return Size of the storage or 0, for no data diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index 104ccea..a0a962e 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -45,6 +45,9 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { // Gets the creation property list of this dataset. DSetCreatPropList getCreatePlist() const; + // Gets the access property list of this dataset. + DSetAccPropList getAccessPlist() const; + // Returns the address of this dataset in the file. haddr_t getOffset() const; diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 28933dd..bb27d47 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -30,6 +30,7 @@ #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index c704f85..bb899d7 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -22,6 +22,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index 00b726c..9a4ccf1 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -24,6 +24,7 @@ #include "H5DataSpace.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5AbstractDs.h" diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index 286f6e7..1657351 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -11,8 +11,18 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#ifdef OLD_HEADER_FILENAME +#include +#else +#include +#endif #include +using std::cerr; +using std::endl; + +//#include + #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index f5246f9..07d7e84 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -29,6 +29,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5CommonFG.h" diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp index 0a2c107..5fb1cb7 100644 --- a/c++/src/H5FloatType.cpp +++ b/c++/src/H5FloatType.cpp @@ -22,6 +22,7 @@ #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 25e67d3..0c2c4e8 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -29,6 +29,7 @@ #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5AbstractDs.h" diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp index dd9d042..8e19d1e 100644 --- a/c++/src/H5IntType.cpp +++ b/c++/src/H5IntType.cpp @@ -22,6 +22,7 @@ #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index 2cbdfba..fb22296 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -26,6 +26,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" @@ -184,6 +185,10 @@ void H5Library::initH5cpp() if (ret_value != 0) throw LibraryIException("H5Library::initH5cpp", "Registrating PropList::deleteConstants failed"); + ret_value = std::atexit(DSetAccPropList::deleteConstants); + if (ret_value != 0) + throw LibraryIException("H5Library::initH5cpp", "Registrating DSetAccPropList::deleteConstants failed"); + ret_value = std::atexit(LinkAccPropList::deleteConstants); if (ret_value != 0) throw LibraryIException("H5Library::initH5cpp", "Registrating LinkAccPropList::deleteConstants failed"); diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index dd82a54..2c49016 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -28,6 +28,7 @@ using namespace std; #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" @@ -903,23 +904,32 @@ Group H5Location::openGroup(const H5std_string& name) const //-------------------------------------------------------------------------- // Function: H5Location::createDataSet ///\brief Creates a new dataset at this location. -///\param name - IN: Name of the dataset to create -///\param data_type - IN: Datatype of the dataset +///\param name - IN: Name of the dataset to create +///\param data_type - IN: Datatype of the dataset ///\param data_space - IN: Dataspace for the dataset -///\param create_plist - IN: Creation properly list for the dataset +///\param dcpl - IN: Dataset creation properly list +///\param lcpl - IN: Link creation properly list +///\param dapl - IN: Dataset access properly list ///\return DataSet instance ///\exception H5::FileIException/H5::GroupIException/H5::LocationException -// Programmer Binh-Minh Ribler - 2000 +// 2000 +// Modification: +// Jul 2018 +// Added LinkCreatPropList and DSetAccPropList but did not +// follow the order in the C function: lcpl, dcpl, dapl, to +// accommodate the existing createDataSet calls. //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist) const +DataSet H5Location::createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& dcpl, const DSetAccPropList& dapl, const LinkCreatPropList& lcpl) const { // Obtain identifiers for C API hid_t type_id = data_type.getId(); hid_t space_id = data_space.getId(); - hid_t create_plist_id = create_plist.getId(); + hid_t dcpl_id = dcpl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t dapl_id = dapl.getId(); // Call C routine H5Dcreate2 to create the named dataset - hid_t dataset_id = H5Dcreate2(getId(), name, type_id, space_id, H5P_DEFAULT, create_plist_id, H5P_DEFAULT); + hid_t dataset_id = H5Dcreate2(getId(), name, type_id, space_id, lcpl_id, dcpl_id, dapl_id); // If the creation of the dataset failed, throw an exception if (dataset_id < 0) @@ -936,11 +946,16 @@ DataSet H5Location::createDataSet(const char* name, const DataType& data_type, c ///\brief This is an overloaded member function, provided for convenience. /// It differs from the above function in that it takes an /// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// 2000 +// Modification: +// Jul 2018 +// Added LinkCreatPropList and DSetAccPropList but did not +// follow the order in the C function: lcpl, dcpl, dapl, to +// accommodate the existing createDataSet calls. //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist) const +DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& dcpl, const DSetAccPropList& dapl, const LinkCreatPropList& lcpl) const { - return(createDataSet(name.c_str(), data_type, data_space, create_plist)); + return(createDataSet(name.c_str(), data_type, data_space, dcpl, dapl, lcpl)); } //-------------------------------------------------------------------------- @@ -949,13 +964,17 @@ DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data ///\param name - IN: Name of the dataset to open ///\return DataSet instance ///\exception H5::FileIException/H5::GroupIException/H5::LocationException -// Programmer Binh-Minh Ribler - 2000 +// 2000 +// Modification: +// Jul 2018 +// Added DSetAccPropList argument //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet(const char* name) const +DataSet H5Location::openDataSet(const char* name, const DSetAccPropList& dapl) const { // Call C function H5Dopen2 to open the specified dataset, giving // the location id and the dataset's name - hid_t dataset_id = H5Dopen2(getId(), name, H5P_DEFAULT); + hid_t dapl_id = dapl.getId(); + hid_t dataset_id = H5Dopen2(getId(), name, dapl_id); // If the dataset's opening failed, throw an exception if(dataset_id < 0) @@ -972,11 +991,14 @@ DataSet H5Location::openDataSet(const char* name) const ///\brief This is an overloaded member function, provided for convenience. /// It differs from the above function in that it takes an /// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +// 2000 +// Modification: +// Jul 2018 +// Added DSetAccPropList argument //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet(const H5std_string& name) const +DataSet H5Location::openDataSet(const H5std_string& name, const DSetAccPropList& dapl) const { - return(openDataSet( name.c_str())); + return(openDataSet(name.c_str(), dapl)); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 0b41493..b698081 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -105,13 +105,18 @@ class H5_DLLCPP H5Location : public IdComponent { Group openGroup(const char* name) const; Group openGroup(const H5std_string& name) const; - // Creates a new dataset in this group. - DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; - DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; + // Creates a new dataset in this location. + DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT) const; + DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT) const; + + // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3 + // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; + // DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; // Opens an existing dataset at this location. - DataSet openDataSet(const char* name) const; - DataSet openDataSet(const H5std_string& name) const; + // DSetAccPropList is added - 1.10.3 + DataSet openDataSet(const char* name, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT) const; + DataSet openDataSet(const H5std_string& name, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT) const; H5L_info_t getLinkInfo(const char* link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; H5L_info_t getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index b95e222..1c22efe 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -25,6 +25,7 @@ #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 3f153e5..57ba5e5 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -21,6 +21,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" @@ -914,10 +915,14 @@ September 2015: + PredType + DataSpace + PropList (and its subclasses below) - + FileAccPropList - + FileCreatPropList + DSetMemXferPropList + DSetCreatPropList + + DSetAccPropList + + FileAccPropList + + FileCreatPropList + + LinkAccPropList + + LinkCreatPropList + + ObjCreatPropList The new method includes these main points: @@ -1042,18 +1047,24 @@ September 2015: 4. This section shows the differences between the old and new methods for allocating the following constants - PropList constant, PropList::DEFAULT. + - DSetAccPropList constant, DSetAccPropList::DEFAULT. - DSetCreatPropList constant, DSetCreatPropList::DEFAULT. - DSetMemXferPropList constant, DSetMemXferPropList::DEFAULT. - FileCreatPropList constant, FileCreatPropList::DEFAULT. - FileAccPropList constant, FileAccPropList::DEFAULT. + - LinkAccPropList constant, LinkAccPropList::DEFAULT. + - LinkCreatPropList constant, LinkCreatPropList::DEFAULT. + - ObjCreatPropList constant, ObjCreatPropList::DEFAULT. For these constants, the library has the same changes, except the class names and the HDF5 corresponding constants. Only the items of PropList are listed, and "PropList" can be replaced by any of - DSetCreatPropList, DSetMemXferPropList, FileCreatPropList, - FileAccPropList for those classes. The HDF5 C constant "H5P_DEFAULT" - can be replaced by any of these respectively: H5P_DATASET_CREATE, - H5P_DATASET_XFER, H5P_FILE_CREATE, and H5P_FILE_ACCESS. + DSetAccPropList, DSetCreatPropList, DSetMemXferPropList, + FileCreatPropList, FileAccPropList, LinkAccPropList, LinkCreatPropList, + ObjCreatPropList for those classes. The HDF5 C constant "H5P_DEFAULT" + can be replaced by any of these respectively: H5P_DATASET_ACCESS, + H5P_DATASET_CREATE, H5P_DATASET_XFER, H5P_FILE_CREATE, H5P_FILE_ACCESS, + H5P_LINK_ACCESS, H5P_LINK_CREATE, and H5P_OBJECT_CREATE. Old Method: ---------- diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index a067d6c..0cf2a4e 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -22,6 +22,7 @@ #include "H5DxferProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/H5VarLenType.cpp b/c++/src/H5VarLenType.cpp index e70d42f..18cd831 100644 --- a/c++/src/H5VarLenType.cpp +++ b/c++/src/H5VarLenType.cpp @@ -21,6 +21,7 @@ #include "H5DcreatProp.h" #include "H5LcreatProp.h" #include "H5LaccProp.h" +#include "H5DaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/Makefile.am b/c++/src/Makefile.am index c02a9e7..ca42211 100644 --- a/c++/src/Makefile.am +++ b/c++/src/Makefile.am @@ -34,21 +34,23 @@ bin_SCRIPTS=h5c++ libhdf5_cpp_la_SOURCES=H5Exception.cpp H5IdComponent.cpp \ H5DataSpace.cpp H5PropList.cpp H5Library.cpp \ H5FaccProp.cpp H5FcreatProp.cpp H5LcreatProp.cpp \ - H5LaccProp.cpp H5DxferProp.cpp H5DcreatProp.cpp \ - H5Location.cpp H5AbstractDs.cpp H5Attribute.cpp \ - H5Object.cpp H5OcreatProp.cpp H5DataType.cpp \ - H5AtomType.cpp H5PredType.cpp H5EnumType.cpp \ - H5IntType.cpp H5FloatType.cpp H5StrType.cpp \ - H5ArrayType.cpp H5VarLenType.cpp H5CompType.cpp \ - H5DataSet.cpp H5CommonFG.cpp H5Group.cpp H5File.cpp + H5LaccProp.cpp H5DaccProp.cpp H5DxferProp.cpp \ + H5DcreatProp.cpp H5Location.cpp H5AbstractDs.cpp \ + H5Attribute.cpp H5Object.cpp H5OcreatProp.cpp \ + H5DataType.cpp H5AtomType.cpp H5PredType.cpp \ + H5EnumType.cpp H5IntType.cpp H5FloatType.cpp \ + H5StrType.cpp H5ArrayType.cpp H5VarLenType.cpp \ + H5CompType.cpp H5DataSet.cpp H5CommonFG.cpp H5Group.cpp \ + H5File.cpp # HDF5 C++ library depends on HDF5 Library. libhdf5_cpp_la_LIBADD=$(LIBHDF5) # Public headers -include_HEADERS=H5Cpp.h H5AbstractDs.h H5AtomType.h H5Attribute.h \ - H5Classes.h H5CommonFG.h H5CompType.h H5DataSet.h \ - H5DataSpace.h H5DataType.h H5OcreatProp.h H5DcreatProp.h\ +include_HEADERS=H5Cpp.h H5AbstractDs.h H5AtomType.h \ + H5Attribute.h H5Classes.h H5CommonFG.h H5CompType.h \ + H5DataSet.h H5DataSpace.h H5DataType.h H5OcreatProp.h \ + H5DaccProp.h H5DcreatProp.h H5DxferProp.h H5EnumType.h H5Exception.h H5FaccProp.h \ H5FcreatProp.h H5File.h H5FloatType.h H5Group.h \ H5IdComponent.h H5Include.h H5IntType.h H5LcreatProp.h \ diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index a3a055d..14f1bd4 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -1121,7 +1121,6 @@ static herr_t test_types(H5File& file) * Purpose Tests getObjinfo() * * Return Success: 0 - * * Failure: -1 * * July, 2018 @@ -1177,13 +1176,124 @@ static herr_t test_getinfo(H5File& file) /*------------------------------------------------------------------------- + * Function: test_chunk_cache + * + * Purpose Tests setting rdcc info on a DAPL, and interaction + * with the corresponding properties in the file structure. + * + * Return Success: 0 + * Failure: number of errors + * + * July 2018 + *------------------------------------------------------------------------- + */ +const int RANK1 = 1; +const H5std_string FILE_ACCPLIST("test_accplist.h5"); + +static herr_t test_chunk_cache(FileAccPropList fapl) +{ + SUBTEST("DSetAccPropList::set/getChunkCache"); + + try { + // Create a default dataset access and file access property lists + FileAccPropList fapl_def; + DSetAccPropList dapl; + + // Verify that chunk cache parameters are the same + int mdc_nelmts = 0; + size_t nslots_1 = 0, nslots_4 = 0, nbytes_1 = 0, nbytes_4 = 0; + double w0_1 = 0.0F, w0_4 = 0.0F; + fapl_def.getCache(mdc_nelmts, nslots_1, nbytes_1, w0_1); + dapl.getChunkCache(nslots_4, nbytes_4, w0_4); + verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + + // Set a link access property on dapl to verify property list inheritance + dapl.setNumLinks((size_t)134); + size_t nlinks = dapl.getNumLinks(); + verify_val(nlinks, (size_t)134, "DSetAccPropList::getNumLinks", __LINE__, __FILE__); + + // Make a copy of the external fapl + FileAccPropList fapl_local(fapl); + + // Set new rdcc settings on fapl local + size_t nslots_2 = nslots_1 * 2; + size_t nbytes_2 = nbytes_1 * 2; + double w0_2 = w0_1 / (double)2.0F; + fapl_local.getCache(mdc_nelmts, nslots_2, nbytes_2, w0_2); + + // Create a new file using default fcpl and the passed-in fapl + H5File file(FILE_ACCPLIST, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl_local); + + // Create dataset creation property list + DSetCreatPropList dcpl; + + // Set chunk dimensions + hsize_t cdims[RANK1]; + cdims[0] = 10; + dcpl.setChunk(RANK1, cdims); + + // Create memory space + hsize_t mdims[RANK1]; + mdims[0] = 10; + DataSpace mspace(RANK1, mdims); + + // Create a dataset using that dataset creation properties + DataSet dataset(file.createDataSet(DSET_CHUNKED_NAME, PredType::NATIVE_INT, mspace, dcpl, dapl)); + + // Get the dataset access property list + DSetAccPropList dapl2 = dataset.getAccessPlist(); + + // Retrieve and verify the raw data chunk cache parameters + nslots_4 = nbytes_4 = 0; + w0_4 = 0.0F; + dapl2.getChunkCache(nslots_4, nbytes_4, w0_4); + verify_val(nslots_2, nslots_4, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__); + verify_val(nbytes_2, nbytes_4, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__); + verify_val(H5_DBL_ABS_EQUAL(w0_2, w0_4), 1, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__); + + + // Set new values on original dapl + size_t nslots_3 = nslots_1 * 2; + size_t nbytes_3 = H5D_CHUNK_CACHE_NBYTES_DEFAULT; + double w0_3 = w0_2 / 2; + dapl.getChunkCache(nslots_3, nbytes_3, w0_3); + + // Close dataset + dataset.close(); + + // Reopen dataset + DataSet dataset2(file.openDataSet(DSET_CHUNKED_NAME, dapl)); + + // Get the dataset access property list + DSetAccPropList dapl3 = dataset2.getAccessPlist(); + + // Retrieve and verify the raw data chunk cache parameters + dapl3.getChunkCache(nslots_4, nbytes_4, w0_4); + verify_val(nslots_3, nslots_4, "DSetCreatPropList::getLayout", __LINE__, __FILE__); + verify_val(nbytes_3, nbytes_4, "DSetCreatPropList::getLayout", __LINE__, __FILE__); + verify_val(H5_DBL_ABS_EQUAL(w0_3, w0_4), 1, "DSetCreatPropList::getLayout", __LINE__, __FILE__); + + + PASSED(); + return 0; + } // end top try block + + catch (Exception& E) + { + return -1; + } +} // test_chunk_cache + + +/*------------------------------------------------------------------------- * Function: test_virtual * * Purpose Tests fixed, unlimited, and printf selections in the same * VDS * * Return Success: 0 - * * Failure: number of errors * * Programmer Binh-Minh Ribler @@ -1305,6 +1415,7 @@ void test_dset() nerrors += test_multiopen (file) < 0 ? 1:0; nerrors += test_types(file) < 0 ? 1:0; nerrors += test_virtual() < 0 ? 1:0; + nerrors += test_chunk_cache(fapl) < 0 ? 1:0; // Close group "emit diagnostics". grp.close(); -- cgit v0.12