28 #ifndef TABLES_TILEDSTMAN_H
29 #define TABLES_TILEDSTMAN_H
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/DataMan/DataManager.h>
35 #include <casacore/casa/Containers/Block.h>
36 #include <casacore/casa/Arrays/ArrayFwd.h>
37 #include <casacore/casa/Arrays/IPosition.h>
38 #include <casacore/casa/OS/Conversion.h>
39 #include <casacore/casa/BasicSL/String.h>
162 uInt64 maxNrPixelsPerTile = 4*1024*1024);
166 uInt64 maxNrPixelsPerTile = 4*1024*1024);
265 uInt& localTileLength)
const;
310 const char* external,
const Block<uInt>& externalOffset,
339 const String& dataTypeID);
342 const String& dataTypeID);
345 const String& dataTypeID);
391 Bool mustExist)
const;
407 const Record& values)
const;
415 const Record& values)
const;
427 const Record& values)
const;
Abstract base class for a data manager.
A drop-in replacement for Block<T*>.
String: the storage and methods of handling collections of characters.
virtual void setMaximumCacheSize(uInt nMiB)
Set the maximum cache size (in MiB) in a non-persistent way.
int coordinateDataType(const String &columnName) const
Get the data type of the coordinate column with the given name.
uInt nhypercubes() const
Return the number of hypercubes.
TiledStMan & operator=(const TiledStMan &)
Forbid assignment.
uInt headerFileGet(AipsIO &headerFile, rownr_t tabNrrow, Bool firstTime, Int extraNdim)
Read the data from the header file.
IPosition fixedCellShape_p
The fixed cell shape.
virtual TSMCube * getHypercube(rownr_t rownr)=0
void setPersMaxCacheSize(uInt nMiB)
Set the persistent maximum cache size (in MiB).
virtual void deleteManager()
The data manager will be deleted (because all its columns are requested to be deleted).
uInt getBindings(const Vector< String > &columnNames, PtrBlock< TSMColumn * > &colSet, Bool mustExist) const
Get the bindings of the columns with the given names.
virtual rownr_t open64(rownr_t nrrow, AipsIO &)
Open the storage manager for an existing table.
void setCacheSize(rownr_t rownr, uInt nbuckets, Bool forceSmaller)
Set the cache size for accessing the hypercube containing the given row.
virtual String dataManagerName() const
Get the name given to the storage manager.
void headerFileClose(AipsIO *headerFile)
Close the header file.
uInt calcCacheSize(rownr_t rownr, const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath) const
Calculate the cache size (in buckets) for accessing the hypercube containing the given row.
uInt64 bucketSize(rownr_t rownr) const
Get the bucket size (in bytes) of the hypercube in the given row.
TSMCube * makeTSMCube(TSMFile *file, const IPosition &cubeShape, const IPosition &tileShape, const Record &values, Int64 fileOffset=-1)
Make the correct TSMCube type (depending on tsmOption()).
virtual Bool canAccessColumn() const
Can the tiled storage manager access an entire column.
uInt nrCoordVector() const
Get the number of coordinate vectors.
void readTile(char *local, const Block< uInt > &localOffset, const char *external, const Block< uInt > &externalOffset, uInt nrpixels)
Read a tile and convert the data to local format.
TiledStMan()
Create a TiledStMan.
virtual TSMCube * getHypercube(rownr_t rownr, IPosition &position)=0
Get the hypercube in which the given row is stored.
const TSMDataColumn * getDataColumn(uInt colnr) const
Get pointer to data column object.
Int getCubeIndex(const Record &idValues) const
Get the index of the hypercube with the given id-values.
void setHypercubeCacheSize(uInt hypercube, uInt nbuckets, Bool forceSmaller)
Sets the cache size using the hypercube instead of the row number.
Bool userSetCache(rownr_t rownr) const
Determine if the user set the cache size (using setCacheSize).
DataManagerColumn * makeIndArrColumn(const String &name, int dataType, const String &dataTypeID)
Create an indirect array column.
PtrBlock< TSMColumn * > coordColSet_p
The assembly of all coordinate columns.
virtual Bool canChangeShape() const
Can the tiled storage manager handle changing array shapes? The default is no (but TiledCellStMan can...
virtual void reopenRW()
Reopen all files used in this storage manager for read/write access.
String hypercolumnName_p
The name of the hypercolumn.
uInt64 getLengthOffset(uInt64 nrPixels, Block< uInt > &dataOffset, Block< uInt > &localOffset, uInt &localTileLength) const
Get the length of the data for the given number of pixels.
virtual IPosition defaultTileShape() const
Get the default tile shape.
static IPosition makeTileShape(const IPosition &hypercubeShape, Double tolerance=0.5, uInt64 maxNrPixelsPerTile=4 *1024 *1024)
Derive the tile shape from the hypercube shape for the given number of pixels per tile.
TiledStMan(const TiledStMan &)
Forbid copy constructor.
void checkValues(const PtrBlock< TSMColumn * > &colSet, const Record &values) const
Check if values are given in the record for all columns in the block.
rownr_t nrrow_p
The number of rows in the columns.
void setup(Int extraNdim=-1)
Set up the TiledStMan variables from the table description.
uInt nrdim_p
The dimensionality of the hypercolumn.
uInt persMaxCacheSize_p
The persistent maximum cache size (in MiB) for a hypercube.
void emptyCaches()
Empty the caches used by the hypercubes in this storage manager.
virtual void setProperties(const Record &spec)
Modify data manager properties.
Bool flushCaches(Bool fsync)
Flush the caches of all hypercubes.
uInt maxCacheSize_p
The actual maximum cache size for a hypercube (in MiB).
void checkCoordinatesShapes(const TSMCube *hypercube, const IPosition &cubeShape) const
Check if the cube shape matches that of defined coordinates.
void checkShapeColumn(const IPosition &shape) const
Check if the shapes of FixedShape data and coordinate columns match.
PtrBlock< TSMColumn * > colSet_p
The assembly of all columns.
void setCacheSize(rownr_t rownr, const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath, Bool forceSmaller)
Set the cache size using the calcCacheSize function mentioned above.
virtual Record dataManagerSpec() const
Return a record containing data manager specifications.
Bool dataChanged_p
Has any data changed since the last flush?
TSMCube * getTSMCube(uInt hypercube)
void setDataManagerName(const String &newHypercolumnName)
void showCacheStatistics(ostream &os) const
Show the statistics of all caches used.
void writeTile(char *external, const Block< uInt > &externalOffset, const char *local, const Block< uInt > &localOffset, uInt nrpixels)
Write a tile after converting the data to external format.
DataManagerColumn * reallocateColumn(DataManagerColumn *column)
Reallocate the column object if it is part of this data manager.
TiledStMan(const String &hypercolumnName, uInt maximumCacheSizeMiB)
Create a TiledStMan storage manager.
void createFile(uInt index)
Create a TSMFile object and store its pointer at the given index in the block.
virtual const TableDesc & getDesc() const
Get the table description needed for the hypercolumn description.
PtrBlock< TSMCube * > cubeSet_p
The assembly of all TSMCube objects.
virtual void readHeader(rownr_t nrrow, Bool firstTime)=0
Let a derived class read the header info.
TSMFile * getFile(uInt sequenceNumber)
Get the TSMFile object with the given sequence number.
uInt cacheSize(rownr_t rownr) const
Get the current cache size (in buckets) for the hypercube in the given row.
Bool canReallocateColumns() const
The TiledStMan wants to do reallocateColumn.
const TSMCube * getTSMCube(uInt hypercube) const
Get the given hypercube.
PtrBlock< TSMDataColumn * > dataCols_p
The assembly of all data columns.
rownr_t nrow() const
Get the nr of rows in this storage manager.
PtrBlock< TSMColumn * > idColSet_p
The assembly of all id columns.
AipsIO * headerFileCreate()
Create the TSM header file.
virtual TSMCube * singleHypercube()
Test if only one hypercube is used by this storage manager.
AipsIO * headerFileOpen()
Open the TSM header file.
DataManagerColumn * makeDirArrColumn(const String &name, int dataType, const String &dataTypeID)
Create a direct array column.
TSMCube * makeHypercube(const IPosition &cubeShape, const IPosition &tileShape, const Record &values)
Make a new TSMCube object.
void setDataChanged()
Set the flag to "data has changed since last flush".
const TSMCube * getHypercube(rownr_t rownr) const
Get the hypercube in which the given row is stored.
uInt nrCoordVector_p
The number of vector coordinates.
int arrayDataType(int dataType) const
Convert the scalar data type to an array data type.
Bool canAddRow() const
Does the storage manager allow to add rows? (yes)
static IPosition makeTileShape(const IPosition &hypercubeShape, const Vector< double > &weight, const Vector< double > &tolerance, uInt64 maxNrPixelsPerTile=4 *1024 *1024)
void headerFilePut(AipsIO &headerFile, uInt64 nrCube)
Write the data into the header file.
const IPosition & hypercubeShape(rownr_t rownr) const
Get the hypercube shape of the data in the given row.
uInt maximumCacheSize() const
Get the current maximum cache size (in MiB (MibiByte)).
virtual Record getProperties() const
Get data manager properties that can be modified.
virtual void setShape(rownr_t rownr, TSMCube *hypercube, const IPosition &shape, const IPosition &tileShape)
Set the shape and tile shape of a hypercube.
void checkAddHypercube(const IPosition &cubeShape, const Record &values) const
Check if the hypercube to be added is correctly defined.
PtrBlock< TSMColumn * > dataColSet_p
virtual Bool hasMultiFileSupport() const
The data manager supports use of MultiFile.
rownr_t addedNrrow(const IPosition &shape, uInt incrInLastDim) const
Determine how many rows need to be added for an extension (in the last dimension) of a hypercube with...
void checkCubeShape(const TSMCube *hypercube, const IPosition &cubeShape) const
Check the shape to be set for a hypercube.
PtrBlock< TSMFile * > fileSet_p
The assembly of all TSMFile objects.
void checkCoordinates(const PtrBlock< TSMColumn * > &coordColSet, const IPosition &cubeShape, const Record &values) const
Check if the coordinate values are correct.
virtual void setupCheck(const TableDesc &tableDesc, const Vector< String > &dataNames) const
Function setup calls this function to allow the derived class to check specific information.
DataManagerColumn * makeScalarColumn(const String &name, int dataType, const String &dataTypeID)
Create a column in the storage manager on behalf of a table column.
void initCoordinates(TSMCube *hypercube)
Initialize the new coordinates for the given cube.
const IPosition & tileShape(rownr_t rownr) const
Get the tile shape of the data in the given row.
virtual rownr_t resync64(rownr_t nrrow)
Resync the storage manager with the new file contents.
this file contains all the compiler specific defines
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
bool Bool
Define the standard types used by Casacore.
uInt64 rownr_t
Define the type of a row number in a table.
unsigned long long uInt64