casacore
|
Class that provides binary table I/O. More...
#include <SimpleColumnarFile.h>
Public Member Functions | |
SimpleColumnarFile () noexcept=default | |
SimpleColumnarFile (const SimpleColumnarFile &rhs)=delete | |
SimpleColumnarFile (SimpleColumnarFile &&rhs) noexcept | |
~SimpleColumnarFile () noexcept=default | |
SimpleColumnarFile & | operator= (SimpleColumnarFile &&rhs) |
void | Read (uint64_t row, uint64_t column_offset, std::complex< float > *data, uint64_t n) |
void | Read (uint64_t row, uint64_t column_offset, float *data, uint64_t n) |
void | Read (uint64_t row, uint64_t column_offset, double *data, uint64_t n) |
void | Read (uint64_t row, uint64_t column_offset, int32_t *data, uint64_t n) |
void | Read (uint64_t row, uint64_t column_offset, bool *data, uint64_t n) |
void | Write (uint64_t row, uint64_t column_offset, const std::complex< float > *data, uint64_t n) |
void | Write (uint64_t row, uint64_t column_offset, const std::complex< double > *data, uint64_t n) |
void | Write (uint64_t row, uint64_t column_offset, const float *data, uint64_t n) |
void | Write (uint64_t row, uint64_t column_offset, const double *data, uint64_t n) |
void | Write (uint64_t row, uint64_t column_offset, const int32_t *data, uint64_t n) |
void | Write (uint64_t row, uint64_t column_offset, const bool *data, uint64_t n) |
void | SetStride (uint64_t new_stride) |
Set the number of bytes per row for this file. | |
void | AddRows (uint64_t n_rows) |
Adds a given number of rows to the back of the file. | |
void | Close () |
Close the file. | |
void | DeleteRow () |
Deletes the last row. | |
const std::string & | Filename () const |
bool | IsOpen () const |
uint64_t | NRows () const |
Total number of rows stored in this file. | |
void | ReadHeader (unsigned char *data) |
Read an optional extra header to the file. | |
uint64_t | Stride () const |
Total number of bytes in one row. | |
void | WriteHeader (const unsigned char *data) |
Write an optional extra header to the file. | |
Static Public Member Functions | |
static SimpleColumnarFile | CreateNew (const std::string &filename, uint64_t header_size, uint64_t stride) |
static SimpleColumnarFile | OpenExisting (const std::string &filename, size_t header_size) |
Private Member Functions | |
SimpleColumnarFile (const std::string &filename, uint64_t header_size, uint64_t stride) | |
Create or overwrite a new columnar file on disk. | |
SimpleColumnarFile (const std::string &filename, size_t header_size) | |
Open an existing columnar file. | |
template<typename ValueType > | |
void | ReadImplementation (uint64_t row, uint64_t column_offset, ValueType *data, uint64_t n) |
template<typename ValueType > | |
void | WriteImplementation (uint64_t row, uint64_t column_offset, const ValueType *data, uint64_t n) |
![]() | |
RowBasedFile ()=default | |
RowBasedFile (const RowBasedFile &rhs)=delete | |
RowBasedFile (RowBasedFile &&rhs) noexcept | |
RowBasedFile (const std::string &filename, uint64_t header_size, uint64_t stride) | |
Create or overwrite a new columnar file on disk. | |
RowBasedFile (const std::string &filename, size_t header_size) | |
Open an existing columnar file. | |
~RowBasedFile () noexcept | |
RowBasedFile & | operator= (RowBasedFile &&rhs) |
void | Close () |
Close the file. | |
void | Truncate (uint64_t n_rows) |
void | Seek (off_t pos, int seek_direction) |
void | ReadData (unsigned char *data, uint64_t size) |
void | WriteData (const unsigned char *data, uint64_t size) |
bool | IsOpen () const |
uint64_t | DataLocation () const |
Offset of the first row in the file. | |
const std::string & | Filename () const |
uint64_t | HeaderSize () const |
Number of bytes reserved for an optional header. | |
void | WriteHeader (const unsigned char *data) |
Write an optional extra header to the file. | |
void | ReadHeader (unsigned char *data) |
Read an optional extra header to the file. | |
uint64_t | NRows () const |
Total number of rows stored in this file. | |
void | SetNRows (uint64_t new_n_rows) |
uint64_t | Stride () const |
Total number of bytes in one row. | |
void | SetStride (uint64_t new_stride) |
Set the number of bytes per row for this file. | |
void | AddRows (uint64_t n_rows) |
Adds a given number of rows to the back of the file. | |
void | DeleteRow () |
Deletes the last row. | |
Private Attributes | |
std::vector< unsigned char > | packed_buffer_ |
This buffer is used temporarily for (un)packing booleans. | |
Class that provides binary table I/O.
It is similar to BufferedColumnarFile, but is a simple implementation to demonstrate the interface and to test the base class RowBasedFile. For documentation, see BufferedColumnarFile.
This class writes the data in a cell directly to file when Write() is called, and always reads it back when Read() is called.
Definition at line 24 of file SimpleColumnarFile.h.
|
defaultnoexcept |
Referenced by CreateNew(), and OpenExisting().
|
delete |
|
inlinenoexcept |
Definition at line 39 of file SimpleColumnarFile.h.
|
defaultnoexcept |
|
inlineprivate |
Create or overwrite a new columnar file on disk.
Definition at line 125 of file SimpleColumnarFile.h.
|
inlineprivate |
Open an existing columnar file.
Definition at line 131 of file SimpleColumnarFile.h.
References packed_buffer_, and Stride().
|
inline |
Adds a given number of rows to the back of the file.
Definition at line 232 of file RowBasedFile.h.
|
inline |
Close the file.
After closing, all calls to I/O functions cause undefined behaviour, until the class is assigned to a new instance.
Truncate failed, still try to close the file to prevent a dangling open file, before throwing the exception.
Definition at line 126 of file RowBasedFile.h.
|
inlinestatic |
Definition at line 50 of file SimpleColumnarFile.h.
References SimpleColumnarFile().
|
inline |
Deletes the last row.
Definition at line 237 of file RowBasedFile.h.
|
inline |
Definition at line 178 of file RowBasedFile.h.
|
inline |
Definition at line 172 of file RowBasedFile.h.
|
inline |
Total number of rows stored in this file.
Definition at line 203 of file RowBasedFile.h.
Referenced by Read(), ReadImplementation(), Write(), and WriteImplementation().
|
inlinestatic |
Definition at line 55 of file SimpleColumnarFile.h.
References SimpleColumnarFile().
|
inline |
Definition at line 44 of file SimpleColumnarFile.h.
References casacore::RowBasedFile::operator=(), and packed_buffer_.
|
inline |
Definition at line 73 of file SimpleColumnarFile.h.
References casacore::RowBasedFile::DataLocation(), NRows(), packed_buffer_, casacore::RowBasedFile::ReadData(), casacore::RowBasedFile::Seek(), Stride(), and UnpackBoolArray().
|
inline |
Definition at line 67 of file SimpleColumnarFile.h.
References ReadImplementation().
|
inline |
Definition at line 64 of file SimpleColumnarFile.h.
References ReadImplementation().
|
inline |
Definition at line 70 of file SimpleColumnarFile.h.
References ReadImplementation().
|
inline |
Definition at line 60 of file SimpleColumnarFile.h.
References ReadImplementation().
|
inline |
Read an optional extra header to the file.
Definition at line 196 of file RowBasedFile.h.
|
inlineprivate |
Definition at line 137 of file SimpleColumnarFile.h.
References casacore::RowBasedFile::DataLocation(), NRows(), casacore::RowBasedFile::ReadData(), casacore::RowBasedFile::Seek(), and Stride().
|
inline |
Set the number of bytes per row for this file.
This changes the format of the file, and because of this the file is emptied.
Definition at line 118 of file SimpleColumnarFile.h.
References packed_buffer_, and casacore::RowBasedFile::SetStride().
|
inline |
Total number of bytes in one row.
This value is also stored in the file, and is read from the file in OpenExisting().
Definition at line 214 of file RowBasedFile.h.
Referenced by Read(), ReadImplementation(), SimpleColumnarFile(), Write(), and WriteImplementation().
|
inline |
Definition at line 104 of file SimpleColumnarFile.h.
References casacore::RowBasedFile::DataLocation(), NRows(), PackBoolArray(), packed_buffer_, casacore::RowBasedFile::Seek(), casacore::RowBasedFile::SetNRows(), Stride(), and casacore::RowBasedFile::WriteData().
|
inline |
Definition at line 96 of file SimpleColumnarFile.h.
References WriteImplementation().
|
inline |
Definition at line 92 of file SimpleColumnarFile.h.
References WriteImplementation().
|
inline |
Definition at line 100 of file SimpleColumnarFile.h.
References WriteImplementation().
|
inline |
Definition at line 88 of file SimpleColumnarFile.h.
References WriteImplementation().
|
inline |
Definition at line 84 of file SimpleColumnarFile.h.
References WriteImplementation().
|
inline |
Write an optional extra header to the file.
When creating the file, the requested space is saved to store this header.
data | An array equal to the size of the header given in the CreateNew() and OpenExisting() calls. |
Definition at line 189 of file RowBasedFile.h.
|
inlineprivate |
Definition at line 149 of file SimpleColumnarFile.h.
References casacore::RowBasedFile::DataLocation(), NRows(), casacore::RowBasedFile::Seek(), casacore::RowBasedFile::SetNRows(), Stride(), and casacore::RowBasedFile::WriteData().
Referenced by Write(), Write(), Write(), Write(), and Write().
|
private |
This buffer is used temporarily for (un)packing booleans.
Storing it as a member avoids memory allocations.
Definition at line 162 of file SimpleColumnarFile.h.
Referenced by operator=(), Read(), SetStride(), SimpleColumnarFile(), and Write().