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, ColumnTypeCategory typeCategory, unsigned sizeOfType, 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, ColumnTypeCategory typeCategory, unsigned sizeOfType, bool isConst) const
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 ColumnVectorHeader * m_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 197 of file ColumnVectorWrapper.h.

Constructor & Destructor Documentation

◆ ColumnVectorData()

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

standard constructor

Public Members

Definition at line 275 of file ColumnVectorWrapper.cxx.

277 : m_header (val_header),
278 m_data (val_header->numColumns(), nullptr),
279 m_dataSize (val_header->numColumns(), 0u)
280 {
282 }
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 337 of file ColumnVectorWrapper.cxx.

339 {
340 tool.callVoid (m_data.data());
341 }

◆ checkData()

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

do a basic check of the data vector

Definition at line 239 of file ColumnVectorWrapper.h.

239 {
240 m_header->checkData (m_data);
241 }

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

227 {
228 auto [size, ptr] = getColumnVoid (columnIndex, &typeid (std::decay_t<CT>), columnTypeCategoryFor<CT>(), sizeof (CT), std::is_const_v<CT>);
229 if constexpr (std::is_const_v<CT>)
230 return std::make_pair (size, static_cast<CT*>(ptr));
231 else
232 return std::make_pair (size, static_cast<CT*>(const_cast<void*>(ptr)));
233 }
size_t size() const
Number of registered mappings.
std::pair< std::size_t, const void * > getColumnVoid(std::size_t columnIndex, const std::type_info *type, ColumnTypeCategory typeCategory, unsigned sizeOfType, bool isConst) const
constexpr ColumnTypeCategory columnTypeCategoryFor() noexcept
the default ColumnTypeCategory for the given C++ type
Definition ColumnInfo.h:208
void * ptr(T *p)
Definition SGImplSvc.cxx:76

◆ getColumnVoid()

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

Definition at line 319 of file ColumnVectorWrapper.cxx.

321 {
322 if (columnIndex >= m_header->numColumns())
323 throw std::runtime_error ("invalid column index: " + std::to_string(columnIndex) + " (max is " + std::to_string(m_header->numColumns()-1) + ")");
324
325 auto& header = m_header->getColumn (columnIndex);
326 checkColumnType (header, type, typeCategory, sizeOfType, isConst);
327 if (!isConst && header.readOnly)
328 throw std::runtime_error ("retrieving non-const vector from a read-only column: " + header.debugName);
329 if (m_data[columnIndex] != nullptr)
330 return std::make_pair (m_dataSize[columnIndex], m_data[columnIndex]);
331 else
332 return std::make_pair (0u, nullptr);
333 }

◆ 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

The type has to match the type of the column, or its category and size have to be compatible with those of the column (see isColumnTypeCompatible). For the void version type can be nullptr, in which case only the category and size are checked, e.g. when the data comes from python and there is no C++ type for it.

Definition at line 216 of file ColumnVectorWrapper.h.

216 {
217 auto voidPtr = reinterpret_cast<const void*>(const_cast<const CT*>(dataPtr));
218 setColumnVoid (columnIndex, size, voidPtr, &typeid (std::decay_t<CT>), columnTypeCategoryFor<CT>(), sizeof (CT), std::is_const_v<CT>);
219 }
void setColumnVoid(std::size_t columnIndex, std::size_t size, const void *dataPtr, const std::type_info *type, ColumnTypeCategory typeCategory, unsigned sizeOfType, bool isConst)

◆ setColumnVoid()

void columnar::ColumnVectorData::setColumnVoid ( std::size_t columnIndex,
std::size_t size,
const void * dataPtr,
const std::type_info * type,
ColumnTypeCategory typeCategory,
unsigned sizeOfType,
bool isConst )

Definition at line 286 of file ColumnVectorWrapper.cxx.

288 {
289 if (columnIndex == ColumnVectorHeader::nullIndex)
290 throw std::logic_error ("cannot set the null column");
291 if (columnIndex >= m_header->numColumns())
292 throw std::logic_error ("invalid column index: " + std::to_string(columnIndex) + " (max is " + std::to_string(m_header->numColumns()-1) + ")");
293 auto& header = m_header->getColumn (columnIndex);
294
295 // If dataPtr is null, we use a dummy value to avoid issues in which
296 // we check whether a column exists by checking for a null pointer,
297 // which would return false for columns that were set with a
298 // nullptr.
299 if (dataPtr == nullptr)
300 {
301 if (size != 0) [[unlikely]]
302 throw std::logic_error ("dataPtr is null but size is not zero for column: " + header.debugName);
303 static const unsigned dummyValue = 0;
304 dataPtr = &dummyValue;
305 }
306
307 checkColumnType (header, type, typeCategory, sizeOfType, isConst);
308 if (isConst && !header.readOnly)
309 throw std::runtime_error ("assigning const vector to a column that is not read-only: " + header.debugName);
310 if (m_data[columnIndex] != nullptr)
311 throw std::runtime_error ("column filled multiple times: " + header.debugName);
312 auto *castDataPtr ATLAS_THREAD_SAFE = const_cast<void*>(dataPtr);
313 m_data[columnIndex] = castDataPtr;
314 m_dataSize[columnIndex] = size;
315 }
#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 253 of file ColumnVectorWrapper.h.

◆ m_dataSize

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

Definition at line 254 of file ColumnVectorWrapper.h.

◆ m_header

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

Private Members

Definition at line 252 of file ColumnVectorWrapper.h.


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