casacore::MultiFile Class Reference

Class to combine multiple files in a single one. More...

#include <MultiFile.h>

Inheritance diagram for casacore::MultiFile:
casacore::MultiFileBase

List of all members.

Public Member Functions

 MultiFile (const String &name, ByteIO::OpenOption, Int blockSize=0)
 Open or create a MultiFile with the given name.
virtual ~MultiFile ()
 The destructor flushes and closes the file.
virtual void reopenRW ()
 Reopen the underlying file for read/write access.
virtual void fsync ()
 Fsync the file (i.e., force the data to be physically written).

Private Member Functions

virtual void doAddFile (MultiFileInfo &)
 Do the class-specific actions on adding a file.
virtual void doDeleteFile (MultiFileInfo &)
 Do the class-specific actions on deleting a file.
virtual void flushFile ()
 Flush the file itself.
virtual void close ()
 Flush and close the file.
virtual void writeHeader ()
 Write the header info.
virtual void readHeader (Bool always=True)
 Read the header info.
virtual void extend (MultiFileInfo &info, Int64 lastblk)
 Extend the virtual file to fit lastblk.
virtual void writeBlock (MultiFileInfo &info, Int64 blknr, const void *buffer)
 Write a data block.
virtual void readBlock (MultiFileInfo &info, Int64 blknr, void *buffer)
 Read a data block.

Private Attributes

FiledesIO itsIO
int itsFD

Detailed Description

Class to combine multiple files in a single one.

Intended use:

Public interface

Review Status

Test programs:
tMultiFile

Synopsis

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 the header block. If it does not fit in the header block, the rest is written in a separate "-ext" file. 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).

Example

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.

 // Create a new MultiFile using a block size of 1 MB.
 MultiFile mfile("file.mf', ByteIO::New, 1048576);
 // Create a virtual file in it.
 MFFileIO mf1(mfile, "mf1", ByteIO::New);
 // Use it (for example) as the sink of AipsIO.
 AipsIO stream (&mf1);
 // Write values.
 stream << (Int)10;
 stream << True;
 // Seek to beginning of file and read data in.
 stream.setpos (0);
 Int vali;
 Bool valb;
 stream >> vali >> valb;

To Do

Definition at line 108 of file MultiFile.h.


Constructor & Destructor Documentation

casacore::MultiFile::MultiFile ( const String name,
ByteIO::OpenOption  ,
Int  blockSize = 0 
)

Open or create a MultiFile 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.

virtual casacore::MultiFile::~MultiFile (  )  [virtual]

The destructor flushes and closes the file.


Member Function Documentation

virtual void casacore::MultiFile::close (  )  [private, virtual]

Flush and close the file.

Implements casacore::MultiFileBase.

virtual void casacore::MultiFile::doAddFile ( MultiFileInfo  )  [private, virtual]

Do the class-specific actions on adding a file.

Implements casacore::MultiFileBase.

virtual void casacore::MultiFile::doDeleteFile ( MultiFileInfo  )  [private, virtual]

Do the class-specific actions on deleting a file.

Implements casacore::MultiFileBase.

virtual void casacore::MultiFile::extend ( MultiFileInfo info,
Int64  lastblk 
) [private, virtual]

Extend the virtual file to fit lastblk.

Implements casacore::MultiFileBase.

virtual void casacore::MultiFile::flushFile (  )  [private, virtual]

Flush the file itself.

Implements casacore::MultiFileBase.

virtual void casacore::MultiFile::fsync (  )  [virtual]

Fsync the file (i.e., force the data to be physically written).

Implements casacore::MultiFileBase.

virtual void casacore::MultiFile::readBlock ( MultiFileInfo info,
Int64  blknr,
void *  buffer 
) [private, virtual]

Read a data block.

Implements casacore::MultiFileBase.

virtual void casacore::MultiFile::readHeader ( Bool  always = True  )  [private, virtual]

Read the header info.

If always==False, the info is only read if the header counter has changed.

Implements casacore::MultiFileBase.

virtual void casacore::MultiFile::reopenRW (  )  [virtual]

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.

virtual void casacore::MultiFile::writeBlock ( MultiFileInfo info,
Int64  blknr,
const void *  buffer 
) [private, virtual]

Write a data block.

Implements casacore::MultiFileBase.

virtual void casacore::MultiFile::writeHeader (  )  [private, virtual]

Write the header info.

Implements casacore::MultiFileBase.


Member Data Documentation

Definition at line 154 of file MultiFile.h.

Definition at line 153 of file MultiFile.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1