EleFits  4.0.1
A modern C++ API on top of CFitsIO
Public Types | Public Attributes | List of all members
Euclid::Fits::ColumnInfo< T > Struct Template Reference

#include <Column.h>

Class Description

template<typename T>
struct Euclid::Fits::ColumnInfo< T >

Column metadata, i.e. { name, unit, repeatCount } and the value type as the template parameter.

Binary table columns are either scalar (repeatCount = 1) or vector (repeatCount > 1). In the case of vector columns, each cell of the column contains repeatCount values. Here is an example of a 4-row table with a scalar column and a vector column with a repeat count of 3:

RowrepeatCount = 1repeatCount = 3
00000, 01, 02
11010, 11, 12
22020, 21, 22
33030, 31, 32

For performance, the values are stored sequentially in a 1D array as follows:

int repeat1[] = { 00, 10, 20, 30 };
int repeat3[] = { 00, 01, 02, 10, 11, 12, 20, 21, 22, 30, 31, 32 };

The only exception to this is string columns, which are vector columns – they should have a repeat count greater than the maximum number of characters in a cell – but each cell contains only one string:

RowrepeatCount = 6
0"ZERO"
1"ONE"
2"TWO"
3"THREE"

The data array is a simple array of std::strings:

std::string data[] = { "ZERO", "ONE", "TWO", "THREE", };

but the repeat count should be at least 6 (beware of the null terminating character).

Note
Since the values are stored sequentially even for vector columns, a scalar column can be "fold" into a vector column by just setting a repeat count greater than 1, and vice-versa. This trick allows writing scalar columns as vector columns, which is what CFitsIO recommends for performance. Indeed, with CFitsIO, it is much faster to write 1 row with a repeat count of 10.000 than 10.000 rows with a repeat count of 1. This is because binary tables are written row-wise in the Fits file. CFitsIO uses an internal buffer, which can be exploited to optimize reading and writing. This is generally handled through the "iterator function" provided by CFitsIO.
Fortunately, this complexity is already embedded in EleFits internals: the buffer is used optimally when reading and writing several columns. In general, it is nearly as fast to read and write scalar columns as vector columns with EleFits. Therefore, users are encouraged to consider the repeat count as a meaningful value, rather than as an optimization trick.
See also
Optimization and good practices
Data classes

Public Types

using Value = T
 The value type.
 

Public Attributes

std::string name
 Column name.
 
std::string unit = ""
 Column unit.
 
long repeatCount = 1
 Repeat count of the column, i.e., number of values per cell. More...
 

The documentation for this struct was generated from the following file:
std::string
STL class.