ATLAS Offline Software
Loading...
Searching...
No Matches
ColumnInfoHelpers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8//
9// includes
10//
11
13
14#include <CxxUtils/crc64.h>
15
16#include <boost/core/demangle.hpp>
17
18#include <stdexcept>
19
20//
21// method implementations
22//
23
24namespace columnar
25{
27 {
28 if (info.accessMode == ColumnAccessMode::input)
29 info.accessMode = accessMode;
30 else if (info.accessMode != accessMode)
31 throw std::runtime_error ("conflicting access modes for column " + info.name);
32 }
33
34
35
36 void mergeColumnInfo (ColumnInfo& target, const ColumnInfo& source)
37 {
38 if (target.name != source.name)
39 throw std::runtime_error ("mismatched column names in mergeColumnInfo: " + target.name + " and " + source.name);
40
41 if (target.index != source.index)
42 throw std::runtime_error ("mismatched column index in mergeColumnInfo: " + std::to_string(target.index) + " and " + std::to_string(source.index));
43
44 if (target.type == nullptr || source.type == nullptr)
45 throw std::runtime_error ("missing type information in mergeColumnInfo for column: " + target.name);
46 if (*target.type != *source.type)
47 throw std::runtime_error ("mismatched column types in mergeColumnInfo for column: " + target.name + ": " + boost::core::demangle(target.type->name()) + " and " + boost::core::demangle(source.type->name()));
48
49 addColumnAccessMode (target, source.accessMode);
50
51 if (target.offsetName != source.offsetName)
52 throw std::runtime_error ("mismatched offset names in mergeColumnInfo for column: " + target.name + ": " + target.offsetName + " and " + source.offsetName);
53
54 if (target.fixedDimensions != source.fixedDimensions)
55 throw std::runtime_error ("mismatched fixed dimensions in mergeColumnInfo for column: " + target.name);
56
57 if (target.isOffset != source.isOffset)
58 throw std::runtime_error ("mismatched isOffset in mergeColumnInfo for column: " + target.name);
59
60 if (target.replacesColumn.empty())
61 target.replacesColumn = source.replacesColumn;
62 else if (!source.replacesColumn.empty() && target.replacesColumn != source.replacesColumn)
63 throw std::runtime_error ("mismatched replacesColumn in mergeColumnInfo for column: " + target.name + ": " + target.replacesColumn + " and " + source.replacesColumn);
64
65 if (!source.isOptional)
66 target.isOptional = false;
67
68 if (target.soleLinkTargetName != source.soleLinkTargetName)
69 throw std::runtime_error ("mismatched soleLinkTargetName in mergeColumnInfo for column: " + target.name);
70
71 if (target.soleLinkTargetClid != source.soleLinkTargetClid)
72 throw std::runtime_error ("mismatched soleLinkTargetClid in mergeColumnInfo for column: " + target.name);
73
74 if (target.isVariantLink != source.isVariantLink)
75 throw std::runtime_error ("mismatched isVariantLink in mergeColumnInfo for column: " + target.name);
76
77 if (target.variantLinkTargetNames != source.variantLinkTargetNames)
78 throw std::runtime_error ("mismatched variantLinkTargetNames in mergeColumnInfo for column: " + target.name);
79
80 if (target.keyColumnForVariantLink != source.keyColumnForVariantLink)
81 throw std::runtime_error ("mismatched keyColumnForVariantLink in mergeColumnInfo for column: " + target.name + ": " + target.keyColumnForVariantLink + " and " + source.keyColumnForVariantLink);
82 }
83
84
85 SG::sgkey_t computeSgKey (const std::string& name, std::uint32_t clid)
86 {
87 std::uint64_t crc = CxxUtils::crc64 (name);
88 if (clid != 0)
89 crc = CxxUtils::crc64addint (crc, clid);
90 // mask to SG::StringPool::sgkey_t_nbits (30) bits
91 return static_cast<SG::sgkey_t> (crc & ((static_cast<std::uint64_t> (1) << 30) - 1));
92 }
93}
A crc-64 implementation, using pclmul where possible.
uint64_t crc64(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string,.
Definition crc64.cxx:696
uint64_t crc64addint(uint64_t crc, uint64_t x)
Extend a previously-calculated CRC to include an int.
Definition crc64.cxx:732
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
void mergeColumnInfo(ColumnInfo &target, const ColumnInfo &source)
void addColumnAccessMode(ColumnInfo &info, ColumnAccessMode accessMode)
ColumnAccessMode
an enum for the different access modes for a column
Definition ColumnInfo.h:20
@ input
an input column
Definition ColumnInfo.h:22
SG::sgkey_t computeSgKey(const std::string &name, std::uint32_t clid)
compute the StoreGate hashed key for a container
a struct that contains meta-information about each column that's needed to interface the column with ...
Definition ColumnInfo.h:36