EleFits  5.0.0
A modern C++ API on top of CFITSIO
List of all members
BintableColumns Class Reference

#include <BintableColumns.h>

Detailed Description

Column-wise reader-writer for the binary table data unit.

For flexibility, this handler class provides many methods to read and write data, but they are just different flavors of the following few services:

For reading, new columns can be either returned, or existing columns can be filled. Columns can be specified either by their name or index; using index is faster because names are internally converted to indices anyway, via a read operation. When filling an existing column, the name of the column can also be used to specify the column to be read.

When writing, if more rows are needed, they are automatically filled with zeros.

In the FITS file, binary tables are written row-wise, i.e. values of a row are contiguous in the file. As of today, in memory, values are stored column-wise (in Column) for convenience, to avoid heterogeneous containers as much as possible. This implies that read and write functions jump from one disk or memory adress to another all the time, which costs a lot of resources. To save on I/Os, an internal buffer is instantiated by CFITSIO. As opposed to methods to read and write a single column, methods to read and write several columns take advantage of the internal buffer. It is therefore much more efficient to use those than to chain several calls to methods for single columns. Depending on the table width, the speed-up can reach several orders of magnitude.

Method to read and write columns conform to the following naming convention:

For example, readSegmentSeqTo() is a method to read a sequence of segments into existing Column objects.

For working with segments, row indices are specified as Segments or FileMemSegments.

For example, assume we want to concatenate rows 11 to 50 of a 3-column binary table into some std::vector. Here is an option:

// Specs
const Segment rows {11, 50};
const long columnCount = 3;
const long rowCount = rows.size();
// Data container for all columns
std::vector<float> data(rowCount * columnCount);
// Contiguous views
PtrColumn<float> one({"ONE", "", 1}, rowCount, &data[0]);
PtrColumn<float> two({"TWO", "", 1}, rowCount, &data[rowCount]);
PtrColumn<float> three({"THREE", "", 1}, rowCount, &data[rowCount * 2]);
// In-place reading
columnCount.readSegmentSeqTo(rows, one, two, three);

Public Member Functions

Column metadata.
long readColumnCount () const
 Get the current number of columns.
 
long readRowCount () const
 Get the current number of rows.
 
long readBufferRowCount () const
 Get the number of rows in the internal buffer. More...
 
bool has (const std::string &name) const
 Check whether the HDU contains a given column. More...
 
long readIndex (const std::string &name) const
 Get the index of the column with given name.
 
std::vector< long > readIndices (const std::vector< std::string > &names) const
 Get the indices of the columns with given names.
 
std::string readName (long index) const
 Get the name of the column with given index.
 
std::vector< std::stringreadAllNames () const
 Get the names of all the columns.
 
void rename (ColumnKey key, const std::string &newName) const
 Rename the column with given name or index. More...
 
Read a single column.
template<typename T , long N = 1>
ColumnInfo< T, N > readInfo (ColumnKey key) const
 Read the info of a column. More...
 
template<typename T , long N = 1>
VecColumn< T, N > read (ColumnKey key) const
 Read the column with given name or index. More...
 
template<typename TColumn >
void readTo (TColumn &column) const
 Read a column into an existing Column. More...
 
template<typename TColumn >
void readTo (ColumnKey key, TColumn &column) const
 Read the column with given name or index into an existing Column. More...
 
Read a single column segment.
template<typename T , long N = 1>
VecColumn< T, N > readSegment (const Segment &rows, ColumnKey key) const
 Read the segment of a column specified by its name or index. More...
 
template<typename TColumn >
void readSegmentTo (FileMemSegments rows, TColumn &column) const
 Read the segment of a column into an existing Column. More...
 
template<typename TColumn >
void readSegmentTo (FileMemSegments rows, ColumnKey key, TColumn &column) const
 Read the segment of a column specified by its name or index into an existing Column. More...
 
Read a sequence of columns.
template<typename TKey , typename... Ts>
std::tuple< VecColumn< Ts, 1 >... > readSeq (const TypedKey< Ts, TKey > &... keys) const
 Read a tuple of columns with given names or indices. More...
 
template<typename T , long N = 1>
std::vector< VecColumn< T, N > > readSeq (std::vector< ColumnKey > keys) const
 Read a vector of columns with given names or indices. More...
 
template<typename TSeq >
void readSeqTo (TSeq &&columns) const
 Read a sequence of columns into existing Columns. More...
 
template<typename... TColumns>
void readSeqTo (TColumns &... columns) const
 Read a sequence of columns into existing Columns. More...
 
template<typename TSeq >
void readSeqTo (std::vector< ColumnKey > keys, TSeq &&columns) const
 Read a sequence of columns with given names or indices into existing Columns. More...
 
template<typename... TColumns>
void readSeqTo (std::vector< ColumnKey > keys, TColumns &... columns) const
 Read a sequence of columns with given names or indices into existing Columns. More...
 
Read a sequence of column segments.
template<typename TKey , typename... Ts>
std::tuple< VecColumn< Ts, 1 >... > readSegmentSeq (Segment rows, const TypedKey< Ts, TKey > &... keys) const
 Read segments of columns specified by their names or indices. More...
 
template<typename T , long N = 1>
std::vector< VecColumn< T, N > > readSegmentSeq (Segment rows, std::vector< ColumnKey > keys) const
 Read segments of columns specified by their names or indices. More...
 
template<typename TSeq >
void readSegmentSeqTo (FileMemSegments rows, TSeq &&columns) const
 Read segments of columns into existing Columns. More...
 
template<typename... TColumns>
void readSegmentSeqTo (FileMemSegments rows, TColumns &... columns) const
 Read segments of columns into existing Columns. More...
 
template<typename TSeq >
void readSegmentSeqTo (FileMemSegments rows, std::vector< ColumnKey > keys, TSeq &&columns) const
 Read segments of columns specified by their names or indices into existing Columns. More...
 
template<typename... TColumns>
void readSegmentSeqTo (FileMemSegments rows, std::vector< ColumnKey > keys, TColumns &... columns) const
 Read segments of columns specified by their names or indices into existing Columns. More...
 
Write a single column.
template<typename TColumn >
void write (const TColumn &column) const
 Write a column.
 
template<typename TInfo >
void init (const TInfo &info, long index=-1) const
 Append or insert a column, which was not previously initialized. More...
 
void remove (ColumnKey key) const
 Remove a column specified by its name or index.
 
Write a single column segment.
template<typename TColumn >
void writeSegment (FileMemSegments rows, const TColumn &column) const
 Write a column segment. More...
 
Write a sequence of columns.
template<typename TSeq >
void writeSeq (TSeq &&columns) const
 Write several columns.
 
template<typename... TColumns>
void writeSeq (const TColumns &... columns) const
 Write several columns. More...
 
template<typename TSeq >
void initSeq (long index, TSeq &&infos) const
 Append or insert a sequence of columns, which were not previously initialized. More...
 
template<typename... TInfos>
void initSeq (long index, const TInfos &... infos) const
 Append or insert a sequence of columns, which were not previously initialized. More...
 
void removeSeq (std::vector< ColumnKey > keys) const
 Remove a sequence of columns specified by their names or indices.
 
Write a sequence of column segments.
template<typename TSeq >
void writeSegmentSeq (FileMemSegments rows, TSeq &&columns) const
 Write a sequence of segments. More...
 
template<typename... TColumns>
void writeSegmentSeq (FileMemSegments rows, const TColumns &... columns) const
 Write a sequence of segments. More...
 

The documentation for this class was generated from the following file: