28 #ifndef TABLES_DATAMANAGER_H 29 #define TABLES_DATAMANAGER_H 33 #include <casacore/casa/aips.h> 34 #include <casacore/tables/Tables/ColumnCache.h> 35 #include <casacore/tables/DataMan/TSMOption.h> 36 #include <casacore/casa/BasicSL/String.h> 37 #include <casacore/casa/BasicSL/Complex.h> 38 #include <casacore/casa/Utilities/CountedPtr.h> 39 #include <casacore/casa/IO/ByteIO.h> 40 #include <casacore/casa/OS/Mutex.h> 48 class DataManagerColumn;
57 template<
class T>
class Array;
364 const String& dataTypeId);
368 const String& dataTypeId);
372 const String& dataTypeId);
435 const String& dataTypeId) = 0;
439 const String& dataTypeId) = 0;
443 const String& dataTypeId) = 0;
449 int dataType,
const String& dataTypeId)
const;
536 static DataManagerCtor
getCtor (
const String& dataManagerType);
617 : isFixedShape_p(
False) {;}
624 { isFixedShape_p = isFixedShape; }
628 {
return isFixedShape_p; }
631 virtual int dataType()
const = 0;
637 virtual String dataTypeId()
const;
644 virtual Bool isWritable()
const;
648 virtual void setMaxLength (
uInt maxLength);
654 { setShapeColumn (shape); isFixedShape_p =
True; }
663 virtual void setShapeTiled (
uInt rownr,
const IPosition& shape,
668 virtual Bool isShapeDefined (
uInt rownr);
684 virtual Bool canChangeShape()
const;
695 virtual Bool canAccessScalarColumn (
Bool& reask)
const;
707 virtual Bool canAccessScalarColumnCells (
Bool& reask)
const;
718 virtual Bool canAccessArrayColumn (
Bool& reask)
const;
730 virtual Bool canAccessArrayColumnCells (
Bool& reask)
const;
741 virtual Bool canAccessSlice (
Bool& reask)
const;
752 virtual Bool canAccessColumnSlice (
Bool& reask)
const;
771 { getBoolV (rownr, dataPtr); }
773 { getuCharV (rownr, dataPtr); }
775 { getShortV (rownr, dataPtr); }
777 { getuShortV (rownr, dataPtr); }
779 { getIntV (rownr, dataPtr); }
781 { getuIntV (rownr, dataPtr); }
783 { getInt64V (rownr, dataPtr); }
784 void get (
uInt rownr,
float* dataPtr)
785 { getfloatV (rownr, dataPtr); }
786 void get (
uInt rownr,
double* dataPtr)
787 { getdoubleV (rownr, dataPtr); }
789 { getComplexV (rownr, dataPtr); }
791 { getDComplexV (rownr, dataPtr); }
793 { getStringV (rownr, dataPtr); }
795 void get (
uInt rownr,
void* dataPtr)
796 { getOtherV (rownr, dataPtr); }
808 { putBoolV (rownr, dataPtr); }
810 { putuCharV (rownr, dataPtr); }
812 { putShortV (rownr, dataPtr); }
814 { putuShortV (rownr, dataPtr); }
816 { putIntV (rownr, dataPtr); }
818 { putuIntV (rownr, dataPtr); }
820 { putInt64V (rownr, dataPtr); }
822 { putfloatV (rownr, dataPtr); }
824 { putdoubleV (rownr, dataPtr); }
826 { putComplexV (rownr, dataPtr); }
828 { putDComplexV (rownr, dataPtr); }
830 { putStringV (rownr, dataPtr); }
833 { putOtherV (rownr, dataPtr); }
842 virtual void getScalarColumnV (
void* dataPtr);
850 virtual void putScalarColumnV (
const void* dataPtr);
858 virtual void getScalarColumnCellsV (
const RefRows& rownrs,
867 virtual void putScalarColumnCellsV (
const RefRows& rownrs,
868 const void* dataPtr);
877 virtual uInt getBlockV (
uInt rownr,
uInt nrmax,
void* dataPtr);
886 virtual void putBlockV (
uInt rownr,
uInt nrmax,
const void* dataPtr);
894 virtual void getArrayV (
uInt rownr,
void* dataPtr);
902 virtual void putArrayV (
uInt rownr,
const void* dataPtr);
910 virtual void getArrayColumnV (
void* dataPtr);
918 virtual void putArrayColumnV (
const void* dataPtr);
926 virtual void getArrayColumnCellsV (
const RefRows& rownrs,
935 virtual void putArrayColumnCellsV (
const RefRows& rownrs,
936 const void* dataPtr);
944 virtual void getSliceV (
uInt rownr,
const Slicer& slicer,
void* dataPtr);
952 virtual void putSliceV (
uInt rownr,
const Slicer& slicer,
953 const void* dataPtr);
961 virtual void getColumnSliceV (
const Slicer& slicer,
void* dataPtr);
969 virtual void putColumnSliceV (
const Slicer& slicer,
const void* dataPtr);
977 virtual void getColumnSliceCellsV (
const RefRows& rownrs,
978 const Slicer& slicer,
void* dataPtr);
986 virtual void putColumnSliceCellsV (
const RefRows& rownrs,
988 const void* dataPtr);
992 void throwGet()
const;
996 void throwPut()
const;
1000 { colName_p = colName; }
1004 {
return colName_p; }
1010 virtual void getBoolV (
uInt rownr,
Bool* dataPtr);
1011 virtual void getuCharV (
uInt rownr,
uChar* dataPtr);
1012 virtual void getShortV (
uInt rownr,
Short* dataPtr);
1013 virtual void getuShortV (
uInt rownr,
uShort* dataPtr);
1014 virtual void getIntV (
uInt rownr,
Int* dataPtr);
1015 virtual void getuIntV (
uInt rownr,
uInt* dataPtr);
1016 virtual void getInt64V (
uInt rownr,
Int64* dataPtr);
1017 virtual void getfloatV (
uInt rownr,
float* dataPtr);
1018 virtual void getdoubleV (
uInt rownr,
double* dataPtr);
1019 virtual void getComplexV (
uInt rownr,
Complex* dataPtr);
1020 virtual void getDComplexV (
uInt rownr,
DComplex* dataPtr);
1021 virtual void getStringV (
uInt rownr,
String* dataPtr);
1023 virtual void getOtherV (
uInt rownr,
void* dataPtr);
1029 virtual void putBoolV (
uInt rownr,
const Bool* dataPtr);
1030 virtual void putuCharV (
uInt rownr,
const uChar* dataPtr);
1031 virtual void putShortV (
uInt rownr,
const Short* dataPtr);
1032 virtual void putuShortV (
uInt rownr,
const uShort* dataPtr);
1033 virtual void putIntV (
uInt rownr,
const Int* dataPtr);
1034 virtual void putuIntV (
uInt rownr,
const uInt* dataPtr);
1035 virtual void putInt64V (
uInt rownr,
const Int64* dataPtr);
1036 virtual void putfloatV (
uInt rownr,
const float* dataPtr);
1037 virtual void putdoubleV (
uInt rownr,
const double* dataPtr);
1038 virtual void putComplexV (
uInt rownr,
const Complex* dataPtr);
1039 virtual void putDComplexV (
uInt rownr,
const DComplex* dataPtr);
1040 virtual void putStringV (
uInt rownr,
const String* dataPtr);
1042 virtual void putOtherV (
uInt rownr,
const void* dataPtr);
1052 virtual void setShapeColumn (
const IPosition& shape);
1064 void getScalarColumnBase (
ArrayBase& dataPtr);
1065 void putScalarColumnBase (
const ArrayBase& dataPtr);
1067 void putScalarColumnCellsBase (
const RefRows& rownrs,
const ArrayBase& dataPtr);
1068 void getArrayColumnBase (
ArrayBase& data);
1069 void putArrayColumnBase (
const ArrayBase& data);
1071 void putArrayColumnCellsBase (
const RefRows& rownrs,
const ArrayBase& data);
1075 void putColumnSliceBase (
const Slicer& slicer,
const ArrayBase& data);
1076 void getColumnSliceCellsBase (
const RefRows& rownrs,
1078 void putColumnSliceCellsBase (
const RefRows& rownrs,
1082 void getSliceArr (
uInt row,
const Slicer& section,
1088 void putSliceArr (
uInt row,
const Slicer& section,
void put(uInt rownr, const uInt *dataPtr)
A Vector of integers, for indexing into Array<T> objects.
void setMultiFile(MultiFileBase *mfile)
Tell the data manager that MultiFile can be used.
void setColumnName(const String &colName)
Set the column name.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
virtual Bool canRenameColumn() const
Does the data manager allow to rename columns? (default yes)
const TSMOption & tsmOption() const
Get the TSM option.
static void registerCtor(const String &type, DataManagerCtor func)
Register a mapping of a data manager type to its static construction function.
void setFixedShapeColumn(const IPosition &shape)
Set the shape of all (fixed-shaped) arrays in the column.
Non-templated base class for templated Array class.
Create a new table - define shapes, data managers, etc.
void throwDataTypeOther(const String &columnName, int dataType) const
Throw an exception in case data type is TpOther, because the storage managers (and maybe other data m...
Bool isFixedShape() const
Is this a fixed shape column?
static std::map< String, DataManagerCtor > initRegisterMap()
Register the main data managers.
std::complex< Float > Complex
Main interface class to a read/write table.
void put(uInt rownr, const double *dataPtr)
void decrementNcolumn()
Decrement number of columns (in case a column is deleted).
const ColumnCache * columnCachePtr() const
virtual uInt open1(uInt nrrow, AipsIO &ios)
Open as above.
virtual Bool flush(AipsIO &ios, Bool fsync)=0
Flush and optionally fsync the data.
virtual Record getProperties() const
Get data manager properties that can be modified.
Abstract base class to combine multiple files in a single one.
virtual Bool isRegular() const
Is this a regular storage manager? It is regular if it allows addition of rows and writing data in th...
AipsIO is the object persistency mechanism of Casacore.
virtual void removeRow(uInt rownr)
Delete a row from all columns.
virtual void showCacheStatistics(std::ostream &) const
Show the data manager's IO statistics.
Abstract base class for a column in a data manager.
void put(uInt rownr, const Int *dataPtr)
virtual void open(uInt nrrow, AipsIO &ios)=0
Let the data manager initialize itself for an existing table.
virtual void reopenRW()
Reopen the data manager for read/write access.
virtual Bool canRemoveColumn() const
Does the data manager allow to delete columns? (default no)
void put(uInt rownr, const void *dataPtr)
This function is the put for all non-standard data types.
static DataManagerCtor getCtor(const String &dataManagerType)
Get the "constructor" of a data manager (thread-safe).
const String & columnName() const
Get rhe column name.
virtual void deleteManager()=0
The data manager will be deleted (because all its columns are requested to be deleted).
virtual Bool canRemoveRow() const
Does the data manager allow to delete rows? (default no)
virtual void setMaximumCacheSize(uInt nbytes)
Set the maximum cache size (in bytes) to be used by a storage manager.
virtual Bool canAddColumn() const
Does the data manager allow to add columns? (default no)
virtual void addRow(uInt nrrow)
Add rows to all columns.
MultiFileBase * multiFile()
Get the MultiFile pointer (can be 0).
void put(uInt rownr, const Bool *dataPtr)
Put the scalar value into the given row.
uInt ncolumn() const
Get the nr of columns in this data manager (can be zero).
Class to manage a set of table columns.
DataManagerColumn * createIndArrColumn(const String &columnName, int dataType, const String &dataTypeId)
Create an indirect array column.
ColumnCache & columnCache()
Get access to the ColumnCache object.
uInt sequenceNr() const
Get the (unique) sequence nr of this data manager.
Bool asBigEndian() const
Have the data to be stored in big or little endian canonical format?
Table & table() const
Get the table this object is associated with.
void dataManagerInfo(Record &info) const
Add SEQNR and SPEC (the DataManagerSpec subrecord) to the info.
DataManager * getClone() const
Has the object already been cloned?
static Bool isRegistered(const String &dataManagerType)
Test if a data manager is registered (thread-safe).
Referenced counted pointer for constant data.
DataManagerColumn()
Create a column.
void put(uInt rownr, const DComplex *dataPtr)
ByteIO::OpenOption fileOption() const
Get the AipsIO option of the underlying file.
std::complex< Double > DComplex
virtual DataManagerColumn * makeScalarColumn(const String &columnName, int dataType, const String &dataTypeId)=0
Create a column in the data manager on behalf of a table column.
virtual void resync(uInt nrrow)=0
Resync the data by rereading cached data from the file.
void checkDataType(const DataManagerColumn *colPtr, const String &columnName, int dataType, const String &dataTypeId) const
Check if the data type of the created data manager column is correct.
Class holding the row numbers in a RefTable.
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
void put(uInt rownr, const float *dataPtr)
virtual DataManagerColumn * makeIndArrColumn(const String &columnName, int dataType, const String &dataTypeId)=0
Create an indirect array column.
virtual void setProperties(const Record &spec)
Modify data manager properties given in record fields.
void setTsmOption(const TSMOption &tsmOption)
Tell the data manager which TSM option to use.
virtual void prepare()
Let the data manager initialize itself further.
DataManager & operator=(const DataManager &)
Assignment cannot be used for this base class.
Options for the Tiled Storage Manager Access.
A hierarchical collection of named fields of various types.
bool Bool
Define the standard types used by Casacore.
void setClone(DataManager *clone) const
Set the pointer to the clone.
void linkToTable(Table &tab)
Link the data manager to the Table object.
void put(uInt rownr, const uChar *dataPtr)
virtual void removeColumn(DataManagerColumn *)
Delete a column.
A caching object for a table column.
virtual Bool isStorageManager() const
Is the data manager a storage manager? The default is yes.
virtual DataManagerColumn * reallocateColumn(DataManagerColumn *column)
Reallocate the column object if it is part of this data manager.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
void put(uInt rownr, const Short *dataPtr)
virtual Bool hasMultiFileSupport() const
Does the data manager support use of MultiFile? A derived class has to return True if it can use the ...
virtual DataManagerColumn * makeDirArrColumn(const String &columnName, int dataType, const String &dataTypeId)=0
Create a direct array column.
virtual void create(uInt nrrow)=0
Let the data manager initialize itself for a new table.
Specify which elements to extract from an n-dimensional array.
Wrapper around a pthreads mutex.
DataManager()
Default constructor.
virtual String dataManagerType() const =0
Return the type name of the data manager (in fact its class name).
virtual DataManager * clone() const =0
Make a clone of the derived object.
virtual void addColumn(DataManagerColumn *)
Add a column.
void put(uInt rownr, const uShort *dataPtr)
OpenOption
Define the possible ByteIO open options.
Abstract base class for a data manager.
virtual Bool canAddRow() const
Does the data manager allow to add rows? (default no)
void setIsFixedShape(Bool isFixedShape)
Set the isFixedShape flag.
virtual uInt resync1(uInt nrrow)
Resync as above.
String fileName() const
Compose a unique filename from the table name and sequence number.
void setEndian(Bool bigEndian)
Tell the data manager if big or little endian format is needed.
void put(uInt rownr, const String *dataPtr)
void put(uInt rownr, const Complex *dataPtr)
String: the storage and methods of handling collections of characters.
virtual Record dataManagerSpec() const
Return a record containing data manager specifications.
MultiFileBase * multiFile_p
DataManagerColumn * createDirArrColumn(const String &columnName, int dataType, const String &dataTypeId)
Create a direct array column.
DataManagerColumn * createScalarColumn(const String &columnName, int dataType, const String &dataTypeId)
Create a column in the data manager on behalf of a table column.
virtual String dataManagerName() const
Return the name of the data manager.
void setSeqnr(uInt nr)
Set the sequence number of this data manager.
this file contains all the compiler specific defines
virtual Bool canReallocateColumns() const
Tell if the data manager wants to reallocate the data manager column objects.
static DataManager * unknownDataManager(const String &dataManagerType, const Record &spec)
Serve as default function for theirRegisterMap, which catches all unknown data manager types...
void put(uInt rownr, const Int64 *dataPtr)
static std::map< String, DataManagerCtor > theirRegisterMap
Declare the mapping of the data manager type name to a static "makeObject" function.
String keywordName(const String &keyword) const
Compose a keyword name from the given keyword appended with the sequence number (e.g.