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 187 of file ColumnVectorWrapper.h.

Constructor & Destructor Documentation

◆ ColumnVectorData()

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

standard constructor

Public Members

Definition at line 235 of file ColumnVectorWrapper.cxx.

237 : m_header (val_header),
238 m_data (val_header->numColumns(), nullptr),
239 m_dataSize (val_header->numColumns(), 0u)
240 {
242 }
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 299 of file ColumnVectorWrapper.cxx.

301 {
302 tool.callVoid (m_data.data());
303 }

◆ checkData()

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

do a basic check of the data vector

Definition at line 222 of file ColumnVectorWrapper.h.

222 {
223 m_header->checkData (m_data);
224 }

◆ 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 209 of file ColumnVectorWrapper.h.

210 {
211 auto [size, ptr] = getColumnVoid (columnIndex, &typeid (std::decay_t<CT>), std::is_const_v<CT>);
212 if constexpr (std::is_const_v<CT>)
213 return std::make_pair (size, static_cast<CT*>(ptr));
214 else
215 return std::make_pair (size, static_cast<CT*>(const_cast<void*>(ptr)));
216 }
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 280 of file ColumnVectorWrapper.cxx.

282 {
283 if (columnIndex >= m_header->numColumns())
284 throw std::runtime_error ("invalid column index: " + std::to_string(columnIndex) + " (max is " + std::to_string(m_header->numColumns()-1) + ")");
285
286 auto& header = m_header->getColumn (columnIndex);
287 if (*type != *header.type)
288 throw std::runtime_error ("invalid type for column: " + header.debugName);
289 if (!isConst && header.readOnly)
290 throw std::runtime_error ("retrieving non-const vector from a read-only column: " + header.debugName);
291 if (m_data[columnIndex] != nullptr)
292 return std::make_pair (m_dataSize[columnIndex], m_data[columnIndex]);
293 else
294 return std::make_pair (0u, nullptr);
295 }

◆ 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 199 of file ColumnVectorWrapper.h.

199 {
200 auto voidPtr = reinterpret_cast<const void*>(const_cast<const CT*>(dataPtr));
201 setColumnVoid (columnIndex, size, voidPtr, typeid (std::decay_t<CT>), std::is_const_v<CT>);
202 }
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 246 of file ColumnVectorWrapper.cxx.

248 {
249 if (columnIndex == ColumnVectorHeader::nullIndex)
250 throw std::logic_error ("cannot set the null column");
251 if (columnIndex >= m_header->numColumns())
252 throw std::logic_error ("invalid column index: " + std::to_string(columnIndex) + " (max is " + std::to_string(m_header->numColumns()-1) + ")");
253 auto& header = m_header->getColumn (columnIndex);
254
255 // If dataPtr is null, we use a dummy value to avoid issues in which
256 // we check whether a column exists by checking for a null pointer,
257 // which would return false for columns that were set with a
258 // nullptr.
259 if (dataPtr == nullptr)
260 {
261 if (size != 0) [[unlikely]]
262 throw std::logic_error ("dataPtr is null but size is not zero for column: " + header.debugName);
263 static const unsigned dummyValue = 0;
264 dataPtr = &dummyValue;
265 }
266
267 if (type != *header.type)
268 throw std::runtime_error ("invalid type for column: " + header.debugName);
269 if (isConst && !header.readOnly)
270 throw std::runtime_error ("assigning const vector to a column that is not read-only: " + header.debugName);
271 if (m_data[columnIndex] != nullptr)
272 throw std::runtime_error ("column filled multiple times: " + header.debugName);
273 auto *castDataPtr ATLAS_THREAD_SAFE = const_cast<void*>(dataPtr);
274 m_data[columnIndex] = castDataPtr;
275 m_dataSize[columnIndex] = size;
276 }
#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 236 of file ColumnVectorWrapper.h.

◆ m_dataSize

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

Definition at line 237 of file ColumnVectorWrapper.h.

◆ m_header

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

Private Members

Definition at line 235 of file ColumnVectorWrapper.h.


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