casacore
|
A class representing an HDF5 data set. More...
#include <HDF5DataSet.h>
Public Member Functions | |
HDF5DataSet (const HDF5Object &, const String &, const IPosition &shape, const IPosition &tileShape, const Bool *) | |
Create an HDF5 data set in the given hid (file or group). More... | |
HDF5DataSet (const HDF5Object &, const String &, const IPosition &shape, const IPosition &tileShape, const uChar *) | |
HDF5DataSet (const HDF5Object &, const String &, const IPosition &shape, const IPosition &tileShape, const Int *) | |
HDF5DataSet (const HDF5Object &, const String &, const IPosition &shape, const IPosition &tileShape, const Int64 *) | |
HDF5DataSet (const HDF5Object &, const String &, const IPosition &shape, const IPosition &tileShape, const Float *) | |
HDF5DataSet (const HDF5Object &, const String &, const IPosition &shape, const IPosition &tileShape, const Double *) | |
HDF5DataSet (const HDF5Object &, const String &, const IPosition &shape, const IPosition &tileShape, const Complex *) | |
HDF5DataSet (const HDF5Object &, const String &, const IPosition &shape, const IPosition &tileShape, const DComplex *) | |
HDF5DataSet (const HDF5Object &, const String &, const Bool *) | |
Open an existing HDF5 data set in the given hid (file or group). More... | |
HDF5DataSet (const HDF5Object &, const String &, const uChar *) | |
HDF5DataSet (const HDF5Object &, const String &, const Int *) | |
HDF5DataSet (const HDF5Object &, const String &, const Int64 *) | |
HDF5DataSet (const HDF5Object &, const String &, const Float *) | |
HDF5DataSet (const HDF5Object &, const String &, const Double *) | |
HDF5DataSet (const HDF5Object &, const String &, const Complex *) | |
HDF5DataSet (const HDF5Object &, const String &, const DComplex *) | |
~HDF5DataSet () | |
The destructor closes the HDF5 dataset object. More... | |
virtual void | close () |
Close the hid if valid. More... | |
void | setCacheSize (uInt nchunks) |
Set the cache size (in chunks) for the data set. More... | |
const IPosition & | shape () const |
Get the shape. More... | |
const IPosition & | tileShape () const |
Get the tile (chunk) shape. More... | |
void | get (const Slicer &, ArrayBase &buf, Bool resize=False) |
Get a section of data into the array. More... | |
void | get (const Slicer &, void *buf) |
Get a section of data. More... | |
void | put (const Slicer &, const ArrayBase &buf) |
Put a section of data. More... | |
void | put (const Slicer &, const void *buf) |
Put a section of data. More... | |
void | extend (const IPosition &shape) |
Extend the dataset if an axis in the new shape is larger. More... | |
![]() | |
HDF5Object () | |
Default constructor sets to invalid hid. More... | |
virtual | ~HDF5Object () |
The destructor in a derived class should close the hid appropriately. More... | |
bool | isValid () const |
Is it a valid hid? More... | |
hid_t | getHid () const |
Get the hid. More... | |
operator hid_t () const | |
Convert automatically to hid_t. More... | |
void | setName (const String &name) |
Get or set the name. More... | |
const String & | getName () const |
Static Public Member Functions | |
static DataType | getDataType (hid_t, const String &name) |
Get the data type for the data set with the given name. More... | |
static Block< hsize_t > | fromShape (const IPosition &shape) |
Helper functions to convert shapes. More... | |
static IPosition | toShape (const Block< hsize_t > &b) |
![]() | |
static Bool | hasHDF5Support () |
Check if there is HDF5 support compiled in. More... | |
static void | throwNoHDF5 () |
If no HDF5, throw an exception that HDF5 is not supported. More... | |
Private Member Functions | |
HDF5DataSet (const HDF5DataSet &that) | |
Copy constructor cannot be used. More... | |
HDF5DataSet & | operator= (const HDF5DataSet &that) |
Assignment cannot be used. More... | |
void | create (const HDF5Object &, const String &, const IPosition &shape, const IPosition &tileShape) |
Create the data set. More... | |
void | open (const HDF5Object &, const String &) |
Open the data set and check if the external data type matches. More... | |
void | closeDataSet () |
Close the dataset (but not other hids). More... | |
Private Attributes | |
HDF5HidDataSpace | itsDSid |
HDF5HidProperty | itsPLid |
HDF5HidProperty | itsDaplid |
IPosition | itsShape |
IPosition | itsTileShape |
HDF5DataType | itsDataType |
const HDF5Object * | itsParent |
Additional Inherited Members | |
![]() | |
void | setHid (hid_t hid) |
Set the hid. More... | |
void | clearHid () |
Clear the hid (set to invalid). More... | |
A class representing an HDF5 data set.
Public interface
This class wraps the HDF5 functions to create and open a data set. It is meant to be used in class HDF5Array, but can be used in itself as well. Only a limited number of data types are supported. They are: boolean (stored as chars), 4-byte integer, and single and double precision real and complex.
The data set has a fixed shape, thus cannot be extended nor resized. It can be stored in a tiled (chunked) way by specifying the tile shape when creating it.
It is possible to read or write a section of the data set by using an appropriate Slicer object. Note that the Slicer object must be fully filled; it does not infer missing info from the array shape.
Casacore arrays are in Fortran order, while HDF5 uses C order. Therefore array axes are reversed, thus axes in shapes, slicers, etc.
It was overkill to use the HDF5 C++ interface. Instead little wrappers have been written. HDF5DataSet can be embedded in a shared pointer making it possible to share an HDF5 data set amongst various HDF5Array objects and close (i.e. destruct) the HDF5 data set object when needed.
Definition at line 86 of file HDF5DataSet.h.
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const IPosition & | shape, | ||
const IPosition & | tileShape, | ||
const Bool * | |||
) |
Create an HDF5 data set in the given hid (file or group).
It gets the given name, shape (also tile shape), and data type.
Referenced by tileShape().
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const IPosition & | shape, | ||
const IPosition & | tileShape, | ||
const uChar * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const IPosition & | shape, | ||
const IPosition & | tileShape, | ||
const Int * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const IPosition & | shape, | ||
const IPosition & | tileShape, | ||
const Int64 * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const IPosition & | shape, | ||
const IPosition & | tileShape, | ||
const Float * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const IPosition & | shape, | ||
const IPosition & | tileShape, | ||
const Double * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const IPosition & | shape, | ||
const IPosition & | tileShape, | ||
const Complex * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const IPosition & | shape, | ||
const IPosition & | tileShape, | ||
const DComplex * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const Bool * | |||
) |
Open an existing HDF5 data set in the given hid (file or group).
It checks if the internal type matches the given type.
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const uChar * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const Int * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const Int64 * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const Float * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const Double * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const Complex * | |||
) |
casacore::HDF5DataSet::HDF5DataSet | ( | const HDF5Object & | , |
const String & | , | ||
const DComplex * | |||
) |
casacore::HDF5DataSet::~HDF5DataSet | ( | ) |
The destructor closes the HDF5 dataset object.
|
private |
Copy constructor cannot be used.
|
virtual |
Close the hid if valid.
Implements casacore::HDF5Object.
|
private |
Close the dataset (but not other hids).
Referenced by tileShape().
|
private |
Create the data set.
Referenced by tileShape().
void casacore::HDF5DataSet::extend | ( | const IPosition & | shape | ) |
Extend the dataset if an axis in the new shape is larger.
Referenced by tileShape().
Helper functions to convert shapes.
It reverses the axes, because HDF5 uses C-order.
Referenced by tileShape().
Get a section of data into the array.
The array is resized if its shape does not match the slicer's shape. This is only possible if the array is empty or if resize=True. It is not checked if the data type of array and HDF5DataSet match.
void casacore::HDF5DataSet::get | ( | const Slicer & | , |
void * | buf | ||
) |
Get a section of data.
The buffer must be large enough to hold the section.
|
static |
Get the data type for the data set with the given name.
|
private |
Open the data set and check if the external data type matches.
Referenced by tileShape().
|
private |
Assignment cannot be used.
Referenced by tileShape().
Put a section of data.
The shape of the array and slicer must match. It is not checked if the data type of array and HDF5DataSet match.
Referenced by tileShape().
void casacore::HDF5DataSet::put | ( | const Slicer & | , |
const void * | buf | ||
) |
Put a section of data.
The buffer must be large enough to hold the section.
void casacore::HDF5DataSet::setCacheSize | ( | uInt | nchunks | ) |
Set the cache size (in chunks) for the data set.
It needs to close and reopen the DataSet to take effect.
|
inline |
|
inline |
Get the tile (chunk) shape.
Definition at line 141 of file HDF5DataSet.h.
References closeDataSet(), create(), extend(), casacore::False, fromShape(), HDF5DataSet(), itsTileShape, open(), operator=(), put(), and toShape().
Referenced by tileShape().
|
private |
Definition at line 191 of file HDF5DataSet.h.
|
private |
Definition at line 194 of file HDF5DataSet.h.
|
private |
Definition at line 189 of file HDF5DataSet.h.
|
private |
Definition at line 195 of file HDF5DataSet.h.
|
private |
Definition at line 190 of file HDF5DataSet.h.
|
private |
Definition at line 192 of file HDF5DataSet.h.
Referenced by shape().
|
private |
Definition at line 193 of file HDF5DataSet.h.
Referenced by tileShape().