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

Constructor & Destructor Documentation

◆ ColumnVectorData()

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

standard constructor

Public Members

Definition at line 256 of file ColumnVectorWrapper.cxx.

258 : m_header (val_header),
259 m_data (val_header->numColumns(), nullptr),
260 m_dataSize (val_header->numColumns(), 0u)
261 {
263 }
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 320 of file ColumnVectorWrapper.cxx.

322 {
323 tool.callVoid (m_data.data());
324 }

◆ checkData()

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

do a basic check of the data vector

Definition at line 228 of file ColumnVectorWrapper.h.

228 {
229 m_header->checkData (m_data);
230 }

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

216 {
217 auto [size, ptr] = getColumnVoid (columnIndex, &typeid (std::decay_t<CT>), std::is_const_v<CT>);
218 if constexpr (std::is_const_v<CT>)
219 return std::make_pair (size, static_cast<CT*>(ptr));
220 else
221 return std::make_pair (size, static_cast<CT*>(const_cast<void*>(ptr)));
222 }
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, bool isConst) const
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 ) const
nodiscard

Definition at line 301 of file ColumnVectorWrapper.cxx.

303 {
304 if (columnIndex >= m_header->numColumns())
305 throw std::runtime_error ("invalid column index: " + std::to_string(columnIndex) + " (max is " + std::to_string(m_header->numColumns()-1) + ")");
306
307 auto& header = m_header->getColumn (columnIndex);
308 if (*type != *header.type)
309 throw std::runtime_error ("invalid type for column: " + header.debugName);
310 if (!isConst && header.readOnly)
311 throw std::runtime_error ("retrieving non-const vector from a read-only column: " + header.debugName);
312 if (m_data[columnIndex] != nullptr)
313 return std::make_pair (m_dataSize[columnIndex], m_data[columnIndex]);
314 else
315 return std::make_pair (0u, nullptr);
316 }

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

205 {
206 auto voidPtr = reinterpret_cast<const void*>(const_cast<const CT*>(dataPtr));
207 setColumnVoid (columnIndex, size, voidPtr, typeid (std::decay_t<CT>), std::is_const_v<CT>);
208 }
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 267 of file ColumnVectorWrapper.cxx.

269 {
270 if (columnIndex == ColumnVectorHeader::nullIndex)
271 throw std::logic_error ("cannot set the null column");
272 if (columnIndex >= m_header->numColumns())
273 throw std::logic_error ("invalid column index: " + std::to_string(columnIndex) + " (max is " + std::to_string(m_header->numColumns()-1) + ")");
274 auto& header = m_header->getColumn (columnIndex);
275
276 // If dataPtr is null, we use a dummy value to avoid issues in which
277 // we check whether a column exists by checking for a null pointer,
278 // which would return false for columns that were set with a
279 // nullptr.
280 if (dataPtr == nullptr)
281 {
282 if (size != 0) [[unlikely]]
283 throw std::logic_error ("dataPtr is null but size is not zero for column: " + header.debugName);
284 static const unsigned dummyValue = 0;
285 dataPtr = &dummyValue;
286 }
287
288 if (type != *header.type)
289 throw std::runtime_error ("invalid type for column: " + header.debugName);
290 if (isConst && !header.readOnly)
291 throw std::runtime_error ("assigning const vector to a column that is not read-only: " + header.debugName);
292 if (m_data[columnIndex] != nullptr)
293 throw std::runtime_error ("column filled multiple times: " + header.debugName);
294 auto *castDataPtr ATLAS_THREAD_SAFE = const_cast<void*>(dataPtr);
295 m_data[columnIndex] = castDataPtr;
296 m_dataSize[columnIndex] = size;
297 }
#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 242 of file ColumnVectorWrapper.h.

◆ m_dataSize

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

Definition at line 243 of file ColumnVectorWrapper.h.

◆ m_header

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

Private Members

Definition at line 241 of file ColumnVectorWrapper.h.


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