casa
5.7.0-16
|
Read/write array in external format for a storage manager. More...
#include <StArrayFile.h>
Public Member Functions | |
StManArrayFile (const String &name, ByteIO::OpenOption, uInt version=0, Bool bigEndian=True, uInt bufferSize=0, MultiFileBase *mfile=0) | |
Construct the object and attach it to the give file. More... | |
~StManArrayFile () | |
Close the possibly opened file. More... | |
Bool | flush (Bool fsync) |
Flush and optionally fsync the data. More... | |
void | reopenRW () |
Reopen the file for read/write access. More... | |
void | resync () |
Resync the file (i.e. More... | |
Int64 | length () |
Return the current file length (merely a debug tool). More... | |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const Bool *dummy) |
Put the array shape and store its file offset into the offset argument. More... | |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const Char *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const uChar *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const Short *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const uShort *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const Int *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const uInt *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const Int64 *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const uInt64 *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const Float *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const Double *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const Complex *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const DComplex *dummy) |
uInt | putShape (const IPosition &shape, Int64 &fileOffset, const String *dummy) |
uInt | getRefCount (Int64 offset) |
Get the reference count. More... | |
void | putRefCount (uInt refCount, Int64 offset) |
Put the reference count. More... | |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Bool *) |
Put nr elements at the given file offset and array offset. More... | |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Char *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uChar *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Short *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uShort *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Int *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uInt *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Int64 *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const uInt64 *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Float *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Double *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const Complex *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const DComplex *) |
void | put (Int64 fileOffset, uInt arrayOffset, uInt nr, const String *) |
uInt | getShape (Int64 fileOffset, IPosition &shape) |
Get the shape at the given file offset. More... | |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, Bool *) |
Get nr elements at the given file offset and array offset. More... | |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, Char *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, uChar *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, Short *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, uShort *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, Int *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, uInt *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, Int64 *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, uInt64 *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, Float *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, Double *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, Complex *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, DComplex *) |
void | get (Int64 fileOffset, uInt arrayOffset, uInt nr, String *) |
void | copyArrayBool (Int64 to, Int64 from, uInt nr) |
Copy the array with nr elements from one file offset to another. More... | |
void | copyArrayChar (Int64 to, Int64 from, uInt nr) |
void | copyArrayuChar (Int64 to, Int64 from, uInt nr) |
void | copyArrayShort (Int64 to, Int64 from, uInt nr) |
void | copyArrayuShort (Int64 to, Int64 from, uInt nr) |
void | copyArrayInt (Int64 to, Int64 from, uInt nr) |
void | copyArrayuInt (Int64 to, Int64 from, uInt nr) |
void | copyArrayInt64 (Int64 to, Int64 from, uInt nr) |
void | copyArrayuInt64 (Int64 to, Int64 from, uInt nr) |
void | copyArrayFloat (Int64 to, Int64 from, uInt nr) |
void | copyArrayDouble (Int64 to, Int64 from, uInt nr) |
void | copyArrayComplex (Int64 to, Int64 from, uInt nr) |
void | copyArrayDComplex (Int64 to, Int64 from, uInt nr) |
void | copyArrayString (Int64 to, Int64 from, uInt nr) |
Private Member Functions | |
uInt | put (const Int &) |
Put a single value at the current file offset. More... | |
uInt | put (const uInt &) |
uInt | putRes (const IPosition &shape, Int64 &fileOffset, float lenElem) |
Put the array shape at the end of the file and reserve space for nr elements (each lenElem bytes long). More... | |
uInt | get (Int &) |
Get a single value at the current file offset. More... | |
uInt | get (uInt &) |
void | copyData (Int64 to, Int64 from, uInt length) |
Copy data with the given length from one file offset to another. More... | |
void | setpos (Int64 offset) |
Position the file on the given offset. More... | |
Read/write array in external format for a storage manager.
Internal
StManArrayFile is a class used by table storage managers to store indirect arrays in a file.
StManArrayFile is for use by the table storage manager, in particular to read/write indirectly stored arrays. Instead of holding the data in memory, they are written directly into a file. It also allows to access a part of an array, which is needed for the table system to access an array section. It does not use a cache of its own, but it is relying on the underlying system routines to cache and buffer adequately.
This class could in principle also be used for other array purposes, for example, to implement a paged array class for really huge arrays.
An StManArrayFile object is connected to one file. It is possible to hold multiple arrays in the file, each with its own shape. An array is stored as its shape followed by the actual data (all in canonical format). An array of strings is written as an array of offsets pointing to the actual strings. When a string gets a new value, the new value is written at the end of the file and the file space with the old value is lost.
Currently only the basic types are supported, but arbitrary types could also be supported by writing/reading an element in the normal way into the AipsIO buffer. It would only require that AipsIO would contain a function to get its buffers and to restart them.
The AipsIO class was not suitable for indirect table arrays, because it uses memory to hold the data. Furthermore it is not possible to access part of the data in AipsIO.
Definition at line 129 of file StArrayFile.h.
casacore::StManArrayFile::StManArrayFile | ( | const String & | name, |
ByteIO::OpenOption | , | ||
uInt | version = 0 , |
||
Bool | bigEndian = True , |
||
uInt | bufferSize = 0 , |
||
MultiFileBase * | mfile = 0 |
||
) |
Construct the object and attach it to the give file.
The OpenOption determines how the file is opened (e.g. ByteIO::New for a new file). The buffersize is used to allocate a buffer of a proper size for the underlying filebuf object (see iostream package). A bufferSize 0 means using the default size (currently 65536).
casacore::StManArrayFile::~StManArrayFile | ( | ) |
Close the possibly opened file.
Copy the array with nr
elements from one file offset to another.
Copy data with the given length from one file offset to another.
Flush and optionally fsync the data.
It returns True when any data was written since the last flush.
Get nr elements at the given file offset and array offset.
The file offset of the first array element is the file offset of the shape plus the length of the shape in the file. The array offset is counted in number of elements. It can be used to get only a (contiguous) section of the array.
Get a single value at the current file offset.
It returns the length of the value in the file.
Definition at line 338 of file StArrayFile.h.
References iofil_p, and casacore::TypeIO::read().
Definition at line 342 of file StArrayFile.h.
References iofil_p, and casacore::TypeIO::read().
Get the shape at the given file offset.
It will reshape the IPosition vector when needed. It returns the length of the shape in the file.
|
inline |
Return the current file length (merely a debug tool).
Definition at line 158 of file StArrayFile.h.
References leng_p.
Put nr elements at the given file offset and array offset.
The file offset of the first array element is the file offset of the shape plus the length of the shape in the file. The array offset is counted in number of elements. It can be used to put only a (contiguous) section of the array.
void casacore::StManArrayFile::put | ( | Int64 | fileOffset, |
uInt | arrayOffset, | ||
uInt | nr, | ||
const DComplex * | |||
) |
Put a single value at the current file offset.
It returns the length of the value in the file.
Definition at line 328 of file StArrayFile.h.
References hasPut_p, iofil_p, casacore::True, and casacore::TypeIO::write().
Definition at line 333 of file StArrayFile.h.
References hasPut_p, iofil_p, casacore::True, and casacore::TypeIO::write().
Put the reference count.
An exception is thrown if a value other than 1 is put for version 0.
|
private |
Put the array shape at the end of the file and reserve space for nr elements (each lenElem bytes long).
It fills the file offset of the shape. It returns the length of the shape in the file.
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const Bool * | dummy | ||
) |
Put the array shape and store its file offset into the offset argument.
Reserve file space for the associated array. The length of the shape part in the file is returned. The file offset plus the shape length is the starting offset of the actual array data (which can be used by get and put). Space is reserved to store the reference count.
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const Char * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const uChar * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const Short * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const uShort * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const Int * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const uInt * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const Int64 * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const uInt64 * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const Float * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const Double * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const Complex * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const DComplex * | dummy | ||
) |
uInt casacore::StManArrayFile::putShape | ( | const IPosition & | shape, |
Int64 & | fileOffset, | ||
const String * | dummy | ||
) |
|
inline |
Reopen the file for read/write access.
Definition at line 324 of file StArrayFile.h.
References file_p, and casacore::ByteIO::reopenRW().
void casacore::StManArrayFile::resync | ( | ) |
Resync the file (i.e.
clear possible cache information).
|
private |
Position the file on the given offset.
|
private |
Definition at line 279 of file StArrayFile.h.
Referenced by reopenRW().
|
private |
Definition at line 284 of file StArrayFile.h.
Referenced by put().
|
private |
Definition at line 280 of file StArrayFile.h.
|
private |
Definition at line 281 of file StArrayFile.h.
Referenced by length().
|
private |
Definition at line 285 of file StArrayFile.h.
|
private |
Definition at line 294 of file StArrayFile.h.
|
private |
Definition at line 293 of file StArrayFile.h.
|
private |
Definition at line 291 of file StArrayFile.h.
|
private |
Definition at line 289 of file StArrayFile.h.
|
private |
Definition at line 287 of file StArrayFile.h.
|
private |
Definition at line 286 of file StArrayFile.h.
|
private |
Definition at line 292 of file StArrayFile.h.
|
private |
Definition at line 290 of file StArrayFile.h.
|
private |
Definition at line 288 of file StArrayFile.h.
|
private |
Definition at line 283 of file StArrayFile.h.
|
private |
Definition at line 282 of file StArrayFile.h.