ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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 More...
 
template<typename CT >
void setColumn (std::size_t columnIndex, std::size_t size, CT *dataPtr)
 set the data for the given column More...
 
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 More...
 
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 More...
 
void callNoCheck (const IColumnarTool &tool)
 call the tool with the assembled data, without performing any checks on the data More...
 

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  }

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  {
194  }

◆ getColumn()

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

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  }

◆ getColumnVoid()

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

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  }

◆ 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  }

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:
header
Definition: hcg.cxx:526
columnar::ColumnVectorData::setColumn
void setColumn(std::size_t columnIndex, std::size_t size, CT *dataPtr)
set the data for the given column
Definition: ColumnVectorWrapper.h:169
columnar::ColumnVectorHeader::nullIndex
static constexpr std::size_t nullIndex
the index used for an invalid index (always has to be 0)
Definition: ColumnVectorWrapper.h:103
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
Analysis::dummyValue
const double dummyValue
Definition: CalibrationDataInterfaceBase.h:33
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
columnar::ColumnVectorData::m_data
std::vector< void * > m_data
Definition: ColumnVectorWrapper.h:206
columnar::ColumnVectorData::getColumnVoid
std::pair< std::size_t, const void * > getColumnVoid(std::size_t columnIndex, const std::type_info *type, bool isConst)
Definition: ColumnVectorWrapper.cxx:242
columnar::ColumnVectorData::setColumnVoid
void setColumnVoid(std::size_t columnIndex, std::size_t size, const void *dataPtr, const std::type_info &type, bool isConst)
Definition: ColumnVectorWrapper.cxx:208
columnar::ColumnVectorHeader::numColumns
std::size_t numColumns() const noexcept
the number of columns in the columnar data vector
Definition: ColumnVectorWrapper.h:126
columnar::ColumnVectorData::m_dataSize
std::vector< std::size_t > m_dataSize
Definition: ColumnVectorWrapper.h:207
columnar::size
std::size_t size() const noexcept
Definition: ObjectRange.h:166
columnar::ColumnVectorHeader::sizeIndex
static constexpr std::size_t sizeIndex
the index used for the column size column
Definition: ColumnVectorWrapper.h:106
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:452
unlikely
#define unlikely(x)
Definition: dictionary.h:41
columnar::CT
CT
Definition: ColumnAccessor.h:160
columnar::ColumnVectorHeader::getColumn
const ColumnVectorElementHeader & getColumn(std::size_t index) const
get the column for the given index
Definition: ColumnVectorWrapper.h:131
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
columnar::ColumnVectorHeader::checkData
void checkData(std::span< const void *const > data) const
do a basic check of the data vector
Definition: ColumnVectorWrapper.cxx:137
columnar::ColumnVectorData::m_header
const ColumnVectorHeader * m_header
Definition: ColumnVectorWrapper.h:205