casacore
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 
7 #include <casacore/tables/DataMan/StManColumnBase.h>
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)
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 
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
StManColumnBase(int dataType)
Default constructor.
Base class for columns of the DyscoStMan.
Definition: dyscostmancol.h:22
virtual void InitializeAfterNRowsPerBlockIsKnown()=0
void writeCompressedData(size_t blockIndex, const unsigned char *data, size_t size)
Write a row of compressed data to the stman file.
uint64_t getRowIndex(size_t block) const
uint64_t nBlocksInFile() const
Get the actual number of blocks in the file.
virtual size_t CalculateBlockSize(size_t nRowsInBlock, size_t nAntennae) const =0
virtual void SerializeExtraHeader(std::ostream &stream) const =0
void operator=(const DyscoStManColumn &source)=delete
virtual size_t ExtraHeaderSize() const
Get number of bytes needed for column header of this column.
Definition: dyscostmancol.h:60
void readCompressedData(size_t blockIndex, unsigned char *dest, size_t size)
Read a row of compressed data from the stman file.
size_t getRowWithinBlock(uint64_t row) const
void SetOffsetInBlock(size_t offsetInBlock)
Definition: dyscostmancol.h:68
virtual void Prepare(DyscoDistribution distribution, Normalization normalization, double studentsTNu, double distributionTruncation)=0
DyscoStManColumn(const DyscoStManColumn &source)=delete
virtual casacore::Bool isWritable() const override
Whether this column is writable.
Definition: dyscostmancol.h:44
virtual ~DyscoStManColumn()
Destructor.
Definition: dyscostmancol.h:35
DyscoStManColumn(DyscoStMan *parent, int dtype)
Constructor, to be overloaded by subclass.
Definition: dyscostmancol.h:29
virtual void UnserializeExtraHeader(std::istream &stream)=0
virtual void shutdown()=0
To be called before destructing the class.
void initializeRowsPerBlock(size_t rowsPerBlock, size_t antennaCount)
size_t getBlockIndex(uint64_t row) const
DyscoStMan & storageManager() const
Get the storage manager for this column.
Definition: dyscostmancol.h:74
The main class for the Dysco storage manager.
Definition: dyscostman.h:46
void writeCompressedData(size_t blockIndex, const DyscoStManColumn *column, const unsigned char *data, size_t size)
void readCompressedData(size_t blockIndex, const DyscoStManColumn *column, unsigned char *dest, size_t size)
size_t nAntennae() const
Number of antennae used in a time block.
Definition: dyscostman.h:260
void initializeRowsPerBlock(size_t rowsPerBlock, size_t antennaCount, bool writeToHeader)
To be called by a column once it determines rowsPerBlock and antennaCount.
uint64_t nBlocksInFile() const
The number of rows that are actually stored in the file.
Definition: dyscostman.h:239
size_t nRowsInBlock() const
Number of rows in one "time-block", i.e.
Definition: dyscostman.h:251
uint64_t getRowIndex(size_t block) const
Calculate first measurement set row index of a given block index.
Definition: dyscostman.h:286
size_t getRowWithinBlock(uint64_t row) const
Return the offset of the row within the block.
Definition: dyscostman.h:279
size_t getBlockIndex(uint64_t row) const
Return index of block that contains the given measurement set row.
Definition: dyscostman.h:269
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
Contains DyscoStMan and its global register function register_dyscostman().
this file contains all the compiler specific defines
Definition: mainpage.dox:28
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42