ATLAS Offline Software
Loading...
Searching...
No Matches
columnar::ColumnVectorData Class Referencefinal

a class that holds the columnar data for a single call More...

#include <ColumnVectorWrapper.h>

Collaboration diagram for columnar::ColumnVectorData:

Public Member Functions

 ColumnVectorData (const ColumnVectorHeader *val_header)
 standard constructor
template<typename CT>
void setColumn (std::size_t columnIndex, std::size_t size, CT *dataPtr)
 set the data for the given column
void setColumnVoid (std::size_t columnIndex, std::size_t size, const void *dataPtr, const std::type_info &type, bool isConst)
template<typename CT>
std::pair< std::size_t, CT * > getColumn (std::size_t columnIndex)
 get the data for the given column
std::pair< std::size_t, const void * > getColumnVoid (std::size_t columnIndex, const std::type_info *type, bool isConst)
void checkData () const
 do a basic check of the data vector
void callNoCheck (const IColumnarTool &tool)
 call the tool with the assembled data, without performing any checks on the data

Private Attributes

const ColumnVectorHeaderm_header = nullptr
std::vector< void * > m_data
std::vector< std::size_t > m_dataSize

Detailed Description

a class that holds the columnar data for a single call

This manages the data pointer and makes sure the data is set and retrieved in a consistent manner to the header information.

Definition at line 157 of file ColumnVectorWrapper.h.

Constructor & Destructor Documentation

◆ ColumnVectorData()

columnar::ColumnVectorData::ColumnVectorData ( const ColumnVectorHeader * val_header)
explicit

standard constructor

Public Members

Definition at line 196 of file ColumnVectorWrapper.cxx.

198 : m_header (val_header),
199 m_data (val_header->numColumns(), nullptr),
200 m_dataSize (val_header->numColumns(), 0u)
201 {
203 }
const ColumnVectorHeader * m_header
void setColumn(std::size_t columnIndex, std::size_t size, CT *dataPtr)
set the data for the given column
std::vector< std::size_t > m_dataSize
static constexpr std::size_t sizeIndex
the index used for the column size column

Member Function Documentation

◆ callNoCheck()

void columnar::ColumnVectorData::callNoCheck ( const IColumnarTool & tool)

call the tool with the assembled data, without performing any checks on the data

Definition at line 260 of file ColumnVectorWrapper.cxx.

262 {
263 tool.callVoid (m_data.data());
264 }

◆ checkData()

void columnar::ColumnVectorData::checkData ( ) const
inline

do a basic check of the data vector

Definition at line 192 of file ColumnVectorWrapper.h.

192 {
193 m_header->checkData (m_data);
194 }

◆ getColumn()

template<typename CT>
std::pair< std::size_t, CT * > columnar::ColumnVectorData::getColumn ( std::size_t columnIndex)
inlinenodiscard

get the data for the given column

Definition at line 179 of file ColumnVectorWrapper.h.

180 {
181 auto [size, ptr] = getColumnVoid (columnIndex, &typeid (std::decay_t<CT>), std::is_const_v<CT>);
182 if constexpr (std::is_const_v<CT>)
183 return std::make_pair (size, static_cast<CT*>(ptr));
184 else
185 return std::make_pair (size, static_cast<CT*>(const_cast<void*>(ptr)));
186 }
std::pair< std::size_t, const void * > getColumnVoid(std::size_t columnIndex, const std::type_info *type, bool isConst)
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ getColumnVoid()

std::pair< std::size_t, const void * > columnar::ColumnVectorData::getColumnVoid ( std::size_t columnIndex,
const std::type_info * type,
bool isConst )
nodiscard

Definition at line 241 of file ColumnVectorWrapper.cxx.

243 {
244 if (columnIndex >= m_header->numColumns())
245 throw std::runtime_error ("invalid column index: " + std::to_string(columnIndex) + " (max is " + std::to_string(m_header->numColumns()-1) + ")");
246
247 auto& header = m_header->getColumn (columnIndex);
248 if (*type != *header.type)
249 throw std::runtime_error ("invalid type for column: " + header.debugName);
250 if (!isConst && header.readOnly)
251 throw std::runtime_error ("retrieving non-const vector from a read-only column: " + header.debugName);
252 if (m_data[columnIndex] != nullptr)
253 return std::make_pair (m_dataSize[columnIndex], m_data[columnIndex]);
254 else
255 return std::make_pair (0u, nullptr);
256 }

◆ setColumn()

template<typename CT>
void columnar::ColumnVectorData::setColumn ( std::size_t columnIndex,
std::size_t size,
CT * dataPtr )
inline

set the data for the given column

Definition at line 169 of file ColumnVectorWrapper.h.

169 {
170 auto voidPtr = reinterpret_cast<const void*>(const_cast<const CT*>(dataPtr));
171 setColumnVoid (columnIndex, size, voidPtr, typeid (std::decay_t<CT>), std::is_const_v<CT>);
172 }
void setColumnVoid(std::size_t columnIndex, std::size_t size, const void *dataPtr, const std::type_info &type, bool isConst)

◆ setColumnVoid()

void columnar::ColumnVectorData::setColumnVoid ( std::size_t columnIndex,
std::size_t size,
const void * dataPtr,
const std::type_info & type,
bool isConst )

Definition at line 207 of file ColumnVectorWrapper.cxx.

209 {
210 if (columnIndex == ColumnVectorHeader::nullIndex)
211 throw std::logic_error ("cannot set the null column");
212 if (columnIndex >= m_header->numColumns())
213 throw std::logic_error ("invalid column index: " + std::to_string(columnIndex) + " (max is " + std::to_string(m_header->numColumns()-1) + ")");
214 auto& header = m_header->getColumn (columnIndex);
215
216 // If dataPtr is null, we use a dummy value to avoid issues in which
217 // we check whether a column exists by checking for a null pointer,
218 // which would return false for columns that were set with a
219 // nullptr.
220 if (dataPtr == nullptr)
221 {
222 if (size != 0) [[unlikely]]
223 throw std::logic_error ("dataPtr is null but size is not zero for column: " + header.debugName);
224 static const unsigned dummyValue = 0;
225 dataPtr = &dummyValue;
226 }
227
228 if (type != *header.type)
229 throw std::runtime_error ("invalid type for column: " + header.debugName);
230 if (isConst && !header.readOnly)
231 throw std::runtime_error ("assigning const vector to a column that is not read-only: " + header.debugName);
232 if (m_data[columnIndex] != nullptr)
233 throw std::runtime_error ("column filled multiple times: " + header.debugName);
234 auto *castDataPtr ATLAS_THREAD_SAFE = const_cast<void*>(dataPtr);
235 m_data[columnIndex] = castDataPtr;
236 m_dataSize[columnIndex] = size;
237 }
#define ATLAS_THREAD_SAFE
static constexpr std::size_t nullIndex
the index used for an invalid index (always has to be 0)
#define unlikely(x)

Member Data Documentation

◆ m_data

std::vector<void*> columnar::ColumnVectorData::m_data
private

Definition at line 206 of file ColumnVectorWrapper.h.

◆ m_dataSize

std::vector<std::size_t> columnar::ColumnVectorData::m_dataSize
private

Definition at line 207 of file ColumnVectorWrapper.h.

◆ m_header

const ColumnVectorHeader* columnar::ColumnVectorData::m_header = nullptr
private

Private Members

Definition at line 205 of file ColumnVectorWrapper.h.


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