casacore
|
#include <MultiHDF5.h>
Public Member Functions | |
MultiHDF5 (const String &name, ByteIO::OpenOption, Int blockSize=0) | |
Open or create a MultiHDF5 with the given name. | |
MultiHDF5 (const String &name, const std::shared_ptr< MultiFileBase > &parent, ByteIO::OpenOption, Int blockSize=0) | |
Open or create a MultiHDF5 which is nested in the given parent. | |
~MultiHDF5 () override | |
The destructor flushes and closes the file. | |
MultiHDF5 (const MultiHDF5 &)=delete | |
Copy constructor and assignment not possible. | |
MultiHDF5 & | operator= (const MultiHDF5 &)=delete |
std::shared_ptr< MultiFileBase > | makeNested (const std::shared_ptr< MultiFileBase > &parent, const String &name, ByteIO::OpenOption, Int blockSize) const override |
Make the correct MultiFileBase object for a nested file. | |
void | reopenRW () override |
Open the given logical file and return its file id. | |
void | fsync () override |
Fsync the file (i.e., force the data to be physically written). | |
const std::shared_ptr< HDF5File > & | getHDF5File () const |
Get the HDF5File object. | |
const HDF5Object & | getHDF5Object () const |
![]() | |
MultiFileBase (const String &name, Int blockSize, Bool useODirect) | |
Create a MultiFileBase object with the given name. | |
virtual | ~MultiFileBase () |
The destructor flushes dirty blocks and closes the container file. | |
MultiFileBase (const MultiFileBase &)=delete | |
Forbid copy constructor. | |
MultiFileBase & | operator= (const MultiFileBase &)=delete |
Forbid assignment. | |
String | fileName () const |
Get the file name of the MultiFileBase container file. | |
Bool | isWritable () const |
Is the container file writable? | |
Int | openFile (const String &name) |
Open the given logical file and return its file id. | |
Int | createFile (const String &name, ByteIO::OpenOption=ByteIO::New) |
Create a new logical file and return its file id. | |
void | flushFile (Int fileId) |
Flush the possible dirty buffer of the given logical file. | |
void | closeFile (Int fileId) |
Close a logical file. | |
void | deleteFile (Int fileId) |
Delete a logical file. | |
Int64 | fileSize (Int fileId) const |
Get the size of a logical file. | |
Int64 | read (Int fileId, void *buffer, Int64 size, Int64 offset) |
Read a block at the given offset in the logical file. | |
Int64 | write (Int fileId, const void *buffer, Int64 size, Int64 offset) |
Write a block at the given offset in the logical file. | |
void | truncate (Int fileId, Int64 size) |
Truncate the logical file to the given size. | |
void | flush () |
Flush the file by writing all dirty data and all header info. | |
Int64 | blockSize () const |
Get the block size used. | |
uInt | nfile () const |
Get the nr of logical files. | |
Int64 | nblock () const |
Get the total nr of data blocks used. | |
const std::vector< MultiFileInfo > & | info () const |
Get the info object (for test purposes mainly). | |
const std::vector< Int64 > & | freeBlocks () const |
Get the free blocks (for test purposes mainly). | |
Int | fileId (const String &name, Bool throwExcp=True) const |
Return the file id of a file in the MultiFileBase object. | |
Bool | useODirect () const |
Is O_DIRECT used? | |
Private Member Functions | |
void | init (ByteIO::OpenOption option) |
Initialize the MultiFile object. | |
void | doOpenFile (MultiFileInfo &) override |
Do the class-specific actions on opening a file. | |
void | doCloseFile (MultiFileInfo &) override |
Do the class-specific actions on closing a file. | |
void | doAddFile (MultiFileInfo &) override |
Do the class-specific actions on adding a file. | |
void | doDeleteFile (MultiFileInfo &) override |
Do the class-specific actions on deleting a file. | |
void | doTruncateFile (MultiFileInfo &info, uInt64 nrblk) override |
Truncate the file to nrblk blocks (does nothing). | |
void | doFlushFile () override |
Flush the file itself. | |
void | close () override |
Flush and close the file. | |
void | writeHeader () override |
Write the header info. | |
void | readHeader (Bool always=True) override |
Read the header info. | |
void | extend (MultiFileInfo &info, Int64 lastblk) override |
Extend the virtual file to fit lastblk. | |
void | readBlock (MultiFileInfo &info, Int64 blknr, void *buffer) override |
Read a data block. | |
void | writeBlock (MultiFileInfo &info, Int64 blknr, const void *buffer) override |
Write a data block. | |
Private Attributes | |
std::shared_ptr< HDF5File > | itsFile |
std::shared_ptr< HDF5Group > | itsGroup |
HDF5Object * | itsHDF5 |
This points to the HDF5Group if present, otherwise to the HDF5File. | |
Additional Inherited Members | |
![]() | |
static std::shared_ptr< MultiFileBase > | openMF (const String &fileName) |
Open the correct MultiFileBase (as plain or HDF5). | |
![]() | |
void | resync () |
Resync with another process by clearing the buffers and rereading the header. | |
void | setNewFile () |
Set the flags and blockSize for a new MultiFile/HDF5. | |
![]() | |
String | itsName |
Int64 | itsBlockSize |
Int64 | itsNrBlock |
Int64 | itsHdrCounter |
std::vector< MultiFileInfo > | itsInfo |
std::shared_ptr< MultiFileBuffer > | itsBuffer |
Bool | itsUseODirect |
Bool | itsWritable |
Bool | itsChanged |
std::vector< Int64 > | itsFreeBlocks |
Class to combine multiple files in a single HDF5 file.
Public interface
This class is a container file holding multiple virtual files. It is primarily meant as a container file for the storage manager files of a table to reduce the number of files used (especially for Lustre) and to reduce the number of open files (especially when concatenating tables).
A secondary goal is offering the ability to use an IO buffer size that matches the file system well (large buffer size for e.g. ZFS).
The SetupNewTable constructor has a StorageOption argument to define if a MultiFile has to be used and if so, the buffer size to use. It is also possible to specify that through aipsrc variables.
A virtual file is spread over multiple (fixed size) data blocks in the MultiFile. A data block is never shared by multiple files. For each virtual file MultiFile keeps a MultiFileInfo object telling the file size and the blocks numbers used for the file. When flushing the MultiFile, this meta info is written into a header block and, if needed, continuation blocks. On open and resync, it is read back.
A virtual file is represented by an MFFileIO object, which is derived from ByteIO and as such part of the casacore IO framework. It makes it possible for applications to access a virtual file in the same way as a regular file.
It is possible to delete a virtual file. Its blocks will be added to the free block list (which is also stored in the meta info).
In principle it is possible to use the MultiFile functions directly. However, in general it is much easier to use an MFFileIO object per virtual file as shown below.
Definition at line 100 of file MultiHDF5.h.
|
explicit |
Open or create a MultiHDF5 with the given name.
Upon creation the block size can be given. If 0, it uses the block size of the file system the file is on.
|
explicit |
Open or create a MultiHDF5 which is nested in the given parent.
The data are read/written in a group with the given name in the parent. Upon creation the block size can be given. If 0, it uses the block size of the parent.
|
override |
The destructor flushes and closes the file.
|
delete |
Copy constructor and assignment not possible.
|
overrideprivatevirtual |
Flush and close the file.
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Do the class-specific actions on adding a file.
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Do the class-specific actions on closing a file.
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Do the class-specific actions on deleting a file.
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Flush the file itself.
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Do the class-specific actions on opening a file.
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Truncate the file to nrblk
blocks (does nothing).
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Extend the virtual file to fit lastblk.
Implements casacore::MultiFileBase.
|
overridevirtual |
Fsync the file (i.e., force the data to be physically written).
Implements casacore::MultiFileBase.
|
inline |
|
inline |
Definition at line 145 of file MultiHDF5.h.
References itsHDF5.
|
private |
Initialize the MultiFile object.
|
overridevirtual |
Make the correct MultiFileBase object for a nested file.
It creates a new group under which the virtual files are created.
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Read a data block.
Implements casacore::MultiFileBase.
Read the header info.
If always==False, the info is only read if the header counter has changed.
Implements casacore::MultiFileBase.
|
overridevirtual |
Open the given logical file and return its file id.
If the name is unknown, an exception is thrown. It creates the HDF5 group and dataset opbject. Reopen the underlying file for read/write access. Nothing will be done if the file is writable already. Otherwise it will be reopened and an exception will be thrown if it is not possible to reopen it for read/write access.
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Write a data block.
Implements casacore::MultiFileBase.
|
overrideprivatevirtual |
Write the header info.
Implements casacore::MultiFileBase.
|
private |
Definition at line 180 of file MultiHDF5.h.
Referenced by getHDF5File().
|
private |
Definition at line 181 of file MultiHDF5.h.
|
private |
This points to the HDF5Group if present, otherwise to the HDF5File.
It tells where the HDF5 data are accessed.
Definition at line 184 of file MultiHDF5.h.
Referenced by getHDF5Object().