casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dyscostmancol.h
Go to the documentation of this file.
1 #ifndef DYSCO_STORAGE_MAN_COLUMN_H
2 #define DYSCO_STORAGE_MAN_COLUMN_H
3 
4 #include "dyscodistribution.h"
5 #include "dysconormalization.h"
6 
8 
10 
11 #include <cstdint>
12 #include <map>
13 
14 namespace dyscostman {
15 
16 class DyscoStMan;
17 
23  public:
29  explicit DyscoStManColumn(DyscoStMan *parent, int dtype)
30  : casacore::StManColumnBase(dtype),
31  _offsetInBlock(0),
32  _storageManager(parent) {}
33 
35  virtual ~DyscoStManColumn() {}
36 
38  virtual void shutdown() = 0;
39 
44  virtual casacore::Bool isWritable() const override { return true; }
45 
46  virtual void Prepare(DyscoDistribution distribution,
47  Normalization normalization, double studentsTNu,
48  double distributionTruncation) = 0;
49 
50  virtual void InitializeAfterNRowsPerBlockIsKnown() = 0;
51 
52  virtual size_t CalculateBlockSize(size_t nRowsInBlock,
53  size_t nAntennae) const = 0;
54 
60  virtual size_t ExtraHeaderSize() const { return 0; }
61 
62  virtual void SerializeExtraHeader(std::ostream &stream) const = 0;
63 
64  virtual void UnserializeExtraHeader(std::istream &stream) = 0;
65 
66  size_t OffsetInBlock() const { return _offsetInBlock; }
67 
68  void SetOffsetInBlock(size_t offsetInBlock) {
69  _offsetInBlock = offsetInBlock;
70  }
71 
72  protected:
75 
82  void readCompressedData(size_t blockIndex, unsigned char *dest, size_t size);
83 
90  void writeCompressedData(size_t blockIndex, const unsigned char *data,
91  size_t size);
92 
96  uint64_t nBlocksInFile() const;
97 
98  size_t getBlockIndex(uint64_t row) const;
99 
100  size_t getRowWithinBlock(uint64_t row) const;
101 
102  size_t nRowsInBlock() const;
103 
104  size_t nAntennae() const;
105 
106  uint64_t getRowIndex(size_t block) const;
107 
108  bool areOffsetsInitialized() const;
109 
110  void initializeRowsPerBlock(size_t rowsPerBlock, size_t antennaCount);
111 
112  private:
113  DyscoStManColumn(const DyscoStManColumn &source) = delete;
114  void operator=(const DyscoStManColumn &source) = delete;
115 
118 };
119 
120 } // namespace dyscostman
121 
122 #include "dyscostman.h"
123 
124 namespace dyscostman {
125 
126 inline void DyscoStManColumn::readCompressedData(size_t blockIndex,
127  unsigned char *dest,
128  size_t size) {
129  _storageManager->readCompressedData(blockIndex, this, dest, size);
130 }
131 
132 inline void DyscoStManColumn::writeCompressedData(size_t blockIndex,
133  const unsigned char *data,
134  size_t size) {
135  _storageManager->writeCompressedData(blockIndex, this, data, size);
136 }
137 
138 inline uint64_t DyscoStManColumn::nBlocksInFile() const {
139  return _storageManager->nBlocksInFile();
140 }
141 
142 inline size_t DyscoStManColumn::getBlockIndex(uint64_t row) const {
143  return _storageManager->getBlockIndex(row);
144 }
145 
146 inline size_t DyscoStManColumn::nRowsInBlock() const {
147  return _storageManager->nRowsInBlock();
148 }
149 
150 inline size_t DyscoStManColumn::nAntennae() const {
151  return _storageManager->nAntennae();
152 }
153 
154 inline uint64_t DyscoStManColumn::getRowIndex(size_t block) const {
155  return _storageManager->getRowIndex(block);
156 }
157 
158 inline size_t DyscoStManColumn::getRowWithinBlock(uint64_t rowIndex) const {
159  return _storageManager->getRowWithinBlock(rowIndex);
160 }
161 
164 }
165 
166 inline void DyscoStManColumn::initializeRowsPerBlock(size_t rowsPerBlock,
167  size_t antennaCount) {
168  _storageManager->initializeRowsPerBlock(rowsPerBlock, antennaCount, true);
169 }
170 
171 } // namespace dyscostman
172 
173 #endif
size_t OffsetInBlock() const
Definition: dyscostmancol.h:66
DyscoStManColumn(DyscoStMan *parent, int dtype)
Constructor, to be overloaded by subclass.
Definition: dyscostmancol.h:29
DyscoStMan & storageManager() const
Get the storage manager for this column.
Definition: dyscostmancol.h:74
Contains DyscoStMan and its global register function register_dyscostman().
bool areOffsetsInitialized() const
uint64_t nBlocksInFile() const
Get the actual number of blocks in the file.
size_t getRowWithinBlock(uint64_t row) const
virtual casacore::Bool isWritable() const override
Whether this column is writable.
Definition: dyscostmancol.h:44
void readCompressedData(size_t blockIndex, const DyscoStManColumn *column, unsigned char *dest, size_t size)
virtual size_t ExtraHeaderSize() const
Get number of bytes needed for column header of this column.
Definition: dyscostmancol.h:60
size_t getBlockIndex(uint64_t row) const
Return index of block that contains the given measurement set row.
Definition: dyscostman.h:269
void operator=(const DyscoStManColumn &source)=delete
void initializeRowsPerBlock(size_t rowsPerBlock, size_t antennaCount)
StManColumnBase(int dataType)
Default constructor.
Base table column storage manager class.
size_t nRowsInBlock() const
Number of rows in one &quot;time-block&quot;, i.e.
Definition: dyscostman.h:251
size_t getBlockIndex(uint64_t row) const
size_t nAntennae() const
Number of antennae used in a time block.
Definition: dyscostman.h:260
size_t getRowWithinBlock(uint64_t row) const
Return the offset of the row within the block.
Definition: dyscostman.h:279
uint64_t getRowIndex(size_t block) const
Calculate first measurement set row index of a given block index.
Definition: dyscostman.h:286
virtual void shutdown()=0
To be called before destructing the class.
void writeCompressedData(size_t blockIndex, const DyscoStManColumn *column, const unsigned char *data, size_t size)
uint64_t getRowIndex(size_t block) const
virtual void InitializeAfterNRowsPerBlockIsKnown()=0
DataType dtype() const
uint64_t nBlocksInFile() const
The number of rows that are actually stored in the file.
Definition: dyscostman.h:239
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Base class for columns of the DyscoStMan.
Definition: dyscostmancol.h:22
virtual void SerializeExtraHeader(std::ostream &stream) const =0
virtual void UnserializeExtraHeader(std::istream &stream)=0
virtual size_t CalculateBlockSize(size_t nRowsInBlock, size_t nAntennae) const =0
bool areOffsetsInitialized() const
This method returns true when the number of rows per block and the number of antennae per block are k...
Definition: dyscostman.h:296
virtual void Prepare(DyscoDistribution distribution, Normalization normalization, double studentsTNu, double distributionTruncation)=0
virtual ~DyscoStManColumn()
Destructor.
Definition: dyscostmancol.h:35
void readCompressedData(size_t blockIndex, unsigned char *dest, size_t size)
Read a row of compressed data from the stman file.
void writeCompressedData(size_t blockIndex, const unsigned char *data, size_t size)
Write a row of compressed data to the stman file.
void initializeRowsPerBlock(size_t rowsPerBlock, size_t antennaCount, bool writeToHeader)
To be called by a column once it determines rowsPerBlock and antennaCount.
void SetOffsetInBlock(size_t offsetInBlock)
Definition: dyscostmancol.h:68
The main class for the Dysco storage manager.
Definition: dyscostman.h:46