1 #ifndef DataFormats_NanoAOD_FlatTable_h 2 #define DataFormats_NanoAOD_FlatTable_h 11 #include <type_traits> 15 namespace flatTableHelper {
20 template <
typename Span>
27 inline float one(
const float &
val)
const {
30 template <
typename Span>
74 auto begin = beginData<T>(column);
81 auto begin = beginData<T>(column);
89 throw cms::Exception(
"LogicError",
"columnValue works only for singleton tables");
90 return *beginData<T>(column);
112 template <
typename T,
typename C>
118 auto &vec = bigVector<T>();
124 template <
typename T,
typename C>
127 throw cms::Exception(
"LogicError",
"addColumnValue works only for singleton tables");
130 auto &vec = bigVector<T>();
139 template <
typename T>
141 if constexpr (std::is_same<T, float>())
143 else if constexpr (std::is_same<T, int>())
145 else if constexpr (std::is_same<T, uint8_t>())
147 else if constexpr (std::is_same<T, int8_t>())
149 else if constexpr (std::is_same<T, bool>())
151 else if constexpr (std::is_same<T, uint32_t>())
153 else if constexpr (std::is_same<T, double>())
170 template <
typename T>
172 return bigVector<T>().cbegin() +
columns_[column].firstIndex;
174 template <
typename T>
176 return bigVector<T>().begin() +
columns_[column].firstIndex;
179 template <
typename T>
181 return bigVectorImpl<T>(*this);
183 template <
typename T>
185 return bigVectorImpl<T>(*this);
188 template <
typename T,
class This>
191 if constexpr (std::is_same<T, float>())
192 return table.floats_;
193 else if constexpr (std::is_same<T, int>())
195 else if constexpr (std::is_same<T, uint8_t>())
196 return table.uint8s_;
197 else if constexpr (std::is_same<T, int8_t>())
199 else if constexpr (std::is_same<T, bool>())
200 return table.uint8s_;
201 else if constexpr (std::is_same<T, uint32_t>())
202 return table.uint32s_;
203 else if constexpr (std::is_same<T, double>())
204 return table.doubles_;
void addExtension(const FlatTable &extension)
double getAnyValue(const std::string &column) const
auto columnData(unsigned int column)
get a column by index (non-const)
RowView row(unsigned int row) const
const std::string & columnName(unsigned int col) const
void bulk(Span &&data) const
Column(const std::string &aname, const std::string &docString, ColumnType atype, unsigned int anIndex)
auto const & bigVector() const
std::vector< Column > columns_
std::vector< uint8_t > uint8s_
static auto & bigVectorImpl(This &table)
std::vector< uint32_t > uint32s_
T one(const T &val) const
const std::string & name() const
void setDoc(const std::string &doc)
std::vector< float > floats_
double getAnyValue(unsigned int column) const
const FlatTable & table() const
MaybeMantissaReduce(int mantissaBits)
const std::string & doc() const
int columnIndex(const std::string &name) const
unsigned int nRows() const
const auto & columValue(unsigned int column) const
get a column value for singleton (const)
auto beginData(unsigned int column)
RowView(const FlatTable &table, unsigned int row)
auto columnData(unsigned int column) const
get a column by index (const)
double getAnyValue(unsigned int row, unsigned int column) const
float one(const float &val) const
std::vector< int8_t > int8s_
void bulk(Span const &data) const
MaybeMantissaReduce(int mantissaBits)
FlatTable(unsigned int size, const std::string &name, bool singleton, bool extension=false)
static ColumnType defaultColumnType()
static float reduceMantissaToNbitsRounding(const float &f)
char data[epos_bytes_allocation]
ColumnType columnType(unsigned int col) const
void addColumn(const std::string &name, const C &values, const std::string &docString, int mantissaBits=-1)
void addColumnValue(const std::string &name, const C &value, const std::string &docString, int mantissaBits=-1)
unsigned int nColumns() const
const std::string & columnDoc(unsigned int col) const
auto beginData(unsigned int column) const
std::vector< double > doubles_
unsigned int size() const