casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
casacore::StIndArray Class Reference

Read/write indirect arrays. More...

#include <StIndArray.h>

Public Member Functions

 StIndArray (Int64 fileOffset)
 Construct the object with the given file offset. More...
 
 StIndArray (const StIndArray &)
 Copy constructor. More...
 
StIndArrayoperator= (const StIndArray &)
 Assignment. More...
 
 ~StIndArray ()
 
const IPositionshape () const
 Get the shape. More...
 
Int64 fileOffset () const
 Get the file offset. More...
 
Bool setShape (StManArrayFile &, int dataType, const IPosition &shape)
 Set the shape and allocate the array in the file. More...
 
void getShape (StManArrayFile &ios)
 Read the shape if not read yet. More...
 
uInt refCount (StManArrayFile &ios)
 Get the reference count. More...
 
void incrementRefCount (StManArrayFile &ios)
 Increment the reference count. More...
 
void decrementRefCount (StManArrayFile &ios)
 Decrement the reference count. More...
 
void copyData (StManArrayFile &ios, int dataType, const StIndArray &other)
 Copy the data from another array. More...
 
void getArrayV (StManArrayFile &ios, ArrayBase &arr, DataType dtype)
 Get an array value from the file at the offset held in this object. More...
 
void putArrayV (StManArrayFile &ios, const ArrayBase &arr, DataType dtype)
 Put an array value into the file at the offset held in this object. More...
 
void getSliceV (StManArrayFile &, const Slicer &, ArrayBase &dataPtr, DataType dtype)
 Get a section of the array from the file at the offset held in this object. More...
 
void putSliceV (StManArrayFile &, const Slicer &, const ArrayBase &dataPtr, DataType dtype)
 Put a section of the array into the file at the offset held in this object. More...
 

Private Member Functions

void getSliceData (StManArrayFile &, const Slicer &ns, void *value, const IPosition &userArrayShape, void(*getVec)(StManArrayFile &, Int64, uInt64, uInt64, uInt64, uInt64, void *dataPtr))
 Get sliced data, i.e. More...
 
void putSliceData (StManArrayFile &, const Slicer &ns, const void *value, const IPosition &userArrayShape, void(*putVec)(StManArrayFile &, Int64, uInt64, uInt64, uInt64, uInt64, const void *dataPtr))
 Put sliced data, i.e. More...
 
void checkShape (const IPosition &userArrayShape, const IPosition &tableArrayShape) const
 Throw an exception if the shape of the given array and the table array (slice) are not equal. More...
 

Static Private Member Functions

static void getVecBoolV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 Get a (type-dependent) vector part of a slice. More...
 
static void getVecuCharV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecShortV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecuShortV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecIntV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecuIntV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecInt64V (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecfloatV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecdoubleV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecComplexV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecDComplexV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void getVecStringV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, void *value)
 
static void putVecBoolV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 Put a (type-dependent) vector part of a slice. More...
 
static void putVecuCharV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecShortV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecuShortV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecIntV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecuIntV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecInt64V (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecfloatV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecdoubleV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecComplexV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecDComplexV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 
static void putVecStringV (StManArrayFile &, Int64 fileOffset, uInt64 arrayStart, uInt64 length, uInt64 increment, uInt64 valueIndex, const void *value)
 

Private Attributes

Int64 fileOffset_p
 
uInt arrOffset_p
 
IPosition shape_p
 

Detailed Description

Read/write indirect arrays.

Intended use:

Internal

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Etymology

StIndArray stores indirect arrays on behalf of a storage manager.

Synopsis

StIndArray is a helper class for accessing indirect table arrays. It is the interface between a storage manager like StManAipsIO (in particular its indirect array column class

StManColumnIndArrayAipsIO) and the data storage class StManArrayFile which represents the file holding the shapes and data of the arrays. This file holds the data in canonical format.

StIndArray holds information about an array in the file.

  1. Offset of the array in the file. This points to the array shape. This is stored by storage managers and serves as the mapping between row number and array.
  2. Array data offset, i.e. the length of the shape in the file. Because the data is stored in canonical format, the length of the shape in the file is not directly known but has to be supplied this way.
  3. The actual shape of the array

The storage manager creates an StIndArray object for each row. When an array is accessed for the first time, the array data offset and the shape will be filled in by StIndArray. In this way it serves as a cache for the array shape.

StIndArray implements all necessary functions to get/put an array or an array slice from/into file supplied by the given StManArrayFile object. The StManArrayFile object itself has to be created by the storage manager and given to the StIndArray functions.

Motivation

This helper class makes it possible to share equal functionality between various storage managers handling indirect arrays. At the moment it is used by the StManAipsIO, IncrementalStMan, and StandardStMan storage managers, but it is not limited to them. It can equally well be used by any other storage manager storing (indirect) arrays via an StManArrayFile object.

Example

Note that the following example is not really useful. StIndArray is an internal class and should not be used by a casual user. The example may however give a bit of insight.

Array<Float> array(...);
// Create an StManArrayFile object to hold the arrays.
StManArrayFile stmanFile ("some.name", ByteIO::New);
// Create a still empty StIndArray object for an array.
StIndArray arrayRef(0);
// Define the shape and allocate a Float array.
// Put the array data.
arrayRef.setShape (stmanFile, TpFloat, array.shape());
arrayRef.putArrayfloatV (stmanFile, &array);
// Get the file offset of the array (for later use).
Int64 offset = arrayRef.fileOffset();
// Create an StIndArray object to read the array back.
// Of course, the same object could have been used for that purpose,
// but this shows how to create one for an existing file.
StIndArray arrayRef2(offset);
arrayRef2.getShape (stmanFile); // read shape
Array<float> array2(arrayRef2.shape()); // create with correct size
arrayRef2.getArrayfloatV (stmanFile, &array2);

To Do

Definition at line 141 of file StIndArray.h.

Constructor & Destructor Documentation

casacore::StIndArray::StIndArray ( Int64  fileOffset)

Construct the object with the given file offset.

A zero file offset means that no array has been defined yet. That may be filled in later by setShape.

casacore::StIndArray::StIndArray ( const StIndArray )

Copy constructor.

casacore::StIndArray::~StIndArray ( )

Member Function Documentation

void casacore::StIndArray::checkShape ( const IPosition userArrayShape,
const IPosition tableArrayShape 
) const
private

Throw an exception if the shape of the given array and the table array (slice) are not equal.

void casacore::StIndArray::copyData ( StManArrayFile ios,
int  dataType,
const StIndArray other 
)

Copy the data from another array.

An exception if thrown if the shapes do not match.

void casacore::StIndArray::decrementRefCount ( StManArrayFile ios)

Decrement the reference count.

Int64 casacore::StIndArray::fileOffset ( ) const
inline

Get the file offset.

Definition at line 162 of file StIndArray.h.

References fileOffset_p.

void casacore::StIndArray::getArrayV ( StManArrayFile ios,
ArrayBase arr,
DataType  dtype 
)

Get an array value from the file at the offset held in this object.

The buffer pointed to by dataPtr has to have the correct length (which is guaranteed by the ArrayColumn get function).

void casacore::StIndArray::getShape ( StManArrayFile ios)

Read the shape if not read yet.

void casacore::StIndArray::getSliceData ( StManArrayFile ,
const Slicer ns,
void *  value,
const IPosition userArrayShape,
void(*)(StManArrayFile &, Int64, uInt64, uInt64, uInt64, uInt64, void *dataPtr)  getVec 
)
private

Get sliced data, i.e.

get a section of an array. This function is used by getSliceXXXV to have common functionality in one function. It calls the given getVec function for each chunk of data. In this way the bulk of type-independent code is concentrated in getSliceData resulting in small type-dependent functions.

void casacore::StIndArray::getSliceV ( StManArrayFile ,
const Slicer ,
ArrayBase dataPtr,
DataType  dtype 
)

Get a section of the array from the file at the offset held in this object.

The buffer pointed to by dataPtr has to have the correct length (which is guaranteed by the ArrayColumn getSlice function).

static void casacore::StIndArray::getVecBoolV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate

Get a (type-dependent) vector part of a slice.

This function is called for each chunk by putSliceData.

static void casacore::StIndArray::getVecComplexV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecDComplexV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecdoubleV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecfloatV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecInt64V ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecIntV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecShortV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecStringV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecuCharV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecuIntV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
static void casacore::StIndArray::getVecuShortV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
void *  value 
)
staticprivate
void casacore::StIndArray::incrementRefCount ( StManArrayFile ios)

Increment the reference count.

StIndArray& casacore::StIndArray::operator= ( const StIndArray )

Assignment.

void casacore::StIndArray::putArrayV ( StManArrayFile ios,
const ArrayBase arr,
DataType  dtype 
)

Put an array value into the file at the offset held in this object.

The buffer pointed to by dataPtr has to have the correct length (which is guaranteed by the ArrayColumn put function).

void casacore::StIndArray::putSliceData ( StManArrayFile ,
const Slicer ns,
const void *  value,
const IPosition userArrayShape,
void(*)(StManArrayFile &, Int64, uInt64, uInt64, uInt64, uInt64, const void *dataPtr)  putVec 
)
private

Put sliced data, i.e.

put a section of an array. This function is used by putSlice to have common functionality in one function. It calls the given in putVec function for chunk of data. In this way the bulk of type-independent code is concentrated in putSliceData resulting in small type-dependent functions.

void casacore::StIndArray::putSliceV ( StManArrayFile ,
const Slicer ,
const ArrayBase dataPtr,
DataType  dtype 
)

Put a section of the array into the file at the offset held in this object.

The buffer pointed to by dataPtr has to have the correct length (which is guaranteed by the ArrayColumn putSlice function).

static void casacore::StIndArray::putVecBoolV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate

Put a (type-dependent) vector part of a slice.

This function is called for each chunk by putSliceData.

static void casacore::StIndArray::putVecComplexV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecDComplexV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecdoubleV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecfloatV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecInt64V ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecIntV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecShortV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecStringV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecuCharV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecuIntV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
static void casacore::StIndArray::putVecuShortV ( StManArrayFile ,
Int64  fileOffset,
uInt64  arrayStart,
uInt64  length,
uInt64  increment,
uInt64  valueIndex,
const void *  value 
)
staticprivate
uInt casacore::StIndArray::refCount ( StManArrayFile ios)

Get the reference count.

Bool casacore::StIndArray::setShape ( StManArrayFile ,
int  dataType,
const IPosition shape 
)

Set the shape and allocate the array in the file.

This will define the array and fill in the file offset. If the shape is already defined and does not change, nothing is done and a False value is returned. If the shape changes, the old file space is lost.

const IPosition& casacore::StIndArray::shape ( ) const
inline

Get the shape.

Definition at line 158 of file StIndArray.h.

References shape_p.

Member Data Documentation

uInt casacore::StIndArray::arrOffset_p
private

Definition at line 216 of file StIndArray.h.

Int64 casacore::StIndArray::fileOffset_p
private

Definition at line 215 of file StIndArray.h.

Referenced by fileOffset().

IPosition casacore::StIndArray::shape_p
private

Definition at line 218 of file StIndArray.h.

Referenced by shape().


The documentation for this class was generated from the following file: