ATLAS Offline Software
Loading...
Searching...
No Matches
ColumnarDef.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef COLUMNAR_CORE_COLUMNAR_DEF_H
6#define COLUMNAR_CORE_COLUMNAR_DEF_H
7
8#include <cstdint>
9#include <stdexcept>
10
11namespace columnar
12{
13 // This checks that COLUMNAR_DEFAULT_ACCESS_MODE is indeed defined, plus makes it
14 // available for use with `if constexpr`.
15 constexpr unsigned columnarAccessMode = COLUMNAR_DEFAULT_ACCESS_MODE;
16
18 {
20 static constexpr bool isXAOD = true;
21
27 static constexpr bool inPlaceReplace = true;
28 };
29
30
31
33 {
35 static constexpr bool isXAOD = false;
36
42 static constexpr bool inPlaceReplace = false;
43
44
66
68 using LinkIndexType = std::size_t;
69
71 static constexpr LinkIndexType invalidLinkValue = static_cast<LinkIndexType>(-1);
72
74 static constexpr unsigned linkKeyBits = 8;
75
77 using LinkKeyType = std::uint8_t;
78
80 static_assert (linkKeyBits <= 8 * sizeof(LinkKeyType), "Link key bits exceed key type size");
81 static_assert (linkKeyBits < 8 * sizeof(LinkIndexType), "Link key bits exceed link type size");
82 static constexpr unsigned linkIndexBits = 8 * sizeof(LinkIndexType) - linkKeyBits;
83 static constexpr LinkIndexType linkIndexMask = (static_cast<LinkIndexType>(1) << linkIndexBits) - 1;
84
86 static inline LinkKeyType getLinkKey (LinkIndexType link) {
87 return link >> linkIndexBits;
88 }
89
92 return link & linkIndexMask;
93 }
94
97 if (key >= (static_cast<LinkIndexType>(1) << linkKeyBits))
98 throw std::runtime_error ("link key too large to fit in link: " + std::to_string(key));
99 if (index & ~linkIndexMask)
100 throw std::runtime_error ("index too large to fit in link: " + std::to_string(index));
101 return index | (key << linkIndexBits);
102 }
103 };
104
105
106
107#if COLUMNAR_DEFAULT_ACCESS_MODE == 0
109#elif COLUMNAR_DEFAULT_ACCESS_MODE == 2
111#else
112 #error "COLUMNAR_DEFAULT_ACCESS_MODE must be 0 or 2"
113#endif
114}
115
116#endif
ColumnarModeXAOD ColumnarModeDefault
constexpr unsigned columnarAccessMode
Definition ColumnarDef.h:15
Definition index.py:1
static constexpr unsigned linkKeyBits
the number of bits used for the key inside the link
Definition ColumnarDef.h:74
static constexpr bool isXAOD
Whether this is the xAOD mode.
Definition ColumnarDef.h:35
static constexpr LinkIndexType linkIndexMask
Definition ColumnarDef.h:83
std::size_t LinkIndexType
the type used for columns that represent element links
Definition ColumnarDef.h:68
static constexpr unsigned linkIndexBits
various helper definitions
Definition ColumnarDef.h:82
static LinkKeyType getLinkKey(LinkIndexType link)
get the key value from a link value
Definition ColumnarDef.h:86
static constexpr LinkIndexType invalidLinkValue
the value used for an invalid link (a.k.a. empty/null link)
Definition ColumnarDef.h:71
static LinkIndexType mergeLinkKeyIndex(LinkIndexType key, LinkIndexType index)
merge a key and index value into a link value
Definition ColumnarDef.h:96
static constexpr bool inPlaceReplace
Whether for this columnar mode decorators that replace the original column will also refer to the inp...
Definition ColumnarDef.h:42
std::uint8_t LinkKeyType
the type used for the key column
Definition ColumnarDef.h:77
static LinkIndexType getLinkIndex(LinkIndexType link)
get the index value from a link value
Definition ColumnarDef.h:91
static constexpr bool inPlaceReplace
Whether for this columnar mode decorators that replace the original column will also refer to the inp...
Definition ColumnarDef.h:27
static constexpr bool isXAOD
Whether this is the xAOD mode.
Definition ColumnarDef.h:20