Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RFieldSTLMisc.hxx
Go to the documentation of this file.
1/// \file ROOT/RField/STLMisc.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-09
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef ROOT7_RField_STLMisc
17#define ROOT7_RField_STLMisc
18
19#ifndef ROOT7_RField
20#error "Please include RField.hxx!"
21#endif
22
23#include <ROOT/RFieldBase.hxx>
24#include <ROOT/RNTupleUtil.hxx>
25
26#include <atomic>
27#include <bitset>
28#include <cstddef>
29#include <memory>
30#include <optional>
31#include <string>
32#include <string_view>
33#include <variant>
34
35namespace ROOT {
36namespace Experimental {
37
38namespace Detail {
39class RFieldVisitor;
40} // namespace Detail
41
42////////////////////////////////////////////////////////////////////////////////
43/// Template specializations for C++ std::atomic
44////////////////////////////////////////////////////////////////////////////////
45
46class RAtomicField : public RFieldBase {
47protected:
48 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
49
50 void ConstructValue(void *where) const final { CallConstructValueOn(*fSubFields[0], where); }
51 std::unique_ptr<RDeleter> GetDeleter() const final { return GetDeleterOf(*fSubFields[0]); }
52
53 std::size_t AppendImpl(const void *from) final { return CallAppendOn(*fSubFields[0], from); }
54 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final { CallReadOn(*fSubFields[0], globalIndex, to); }
55 void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final { CallReadOn(*fSubFields[0], clusterIndex, to); }
56
57public:
58 RAtomicField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
59 RAtomicField(RAtomicField &&other) = default;
60 RAtomicField &operator=(RAtomicField &&other) = default;
61 ~RAtomicField() override = default;
62
63 std::vector<RValue> SplitValue(const RValue &value) const final;
64
65 size_t GetValueSize() const final { return fSubFields[0]->GetValueSize(); }
66 size_t GetAlignment() const final { return fSubFields[0]->GetAlignment(); }
67
68 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
69};
70
71template <typename ItemT>
72class RField<std::atomic<ItemT>> final : public RAtomicField {
73public:
74 static std::string TypeName() { return "std::atomic<" + RField<ItemT>::TypeName() + ">"; }
75 explicit RField(std::string_view name) : RAtomicField(name, TypeName(), std::make_unique<RField<ItemT>>("_0")) {}
76 RField(RField &&other) = default;
77 RField &operator=(RField &&other) = default;
78 ~RField() override = default;
79};
80
81////////////////////////////////////////////////////////////////////////////////
82/// Template specializations for C++ std::bitset
83////////////////////////////////////////////////////////////////////////////////
84
85/// The generic field an std::bitset<N>. All compilers we care about store the bits in an array of unsigned long.
86/// TODO(jblomer): reading and writing efficiency should be improved; currently it is one bit at a time
87/// with an array of bools on the page level.
88class RBitsetField : public RFieldBase {
89 using Word_t = unsigned long;
90 static constexpr std::size_t kWordSize = sizeof(Word_t);
91 static constexpr std::size_t kBitsPerWord = kWordSize * 8;
92
93protected:
94 std::size_t fN;
95
96protected:
97 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final
98 {
99 return std::make_unique<RBitsetField>(newName, fN);
100 }
101 const RColumnRepresentations &GetColumnRepresentations() const final;
102 void GenerateColumns() final;
103 void GenerateColumns(const RNTupleDescriptor &desc) final;
104 void ConstructValue(void *where) const final { memset(where, 0, GetValueSize()); }
105 std::size_t AppendImpl(const void *from) final;
106 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final;
107
108public:
109 RBitsetField(std::string_view fieldName, std::size_t N);
110 RBitsetField(RBitsetField &&other) = default;
112 ~RBitsetField() override = default;
113
114 size_t GetValueSize() const final { return kWordSize * ((fN + kBitsPerWord - 1) / kBitsPerWord); }
115 size_t GetAlignment() const final { return alignof(Word_t); }
116 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
117
118 /// Get the number of bits in the bitset, i.e. the N in std::bitset<N>
119 std::size_t GetN() const { return fN; }
120};
121
122template <std::size_t N>
123class RField<std::bitset<N>> final : public RBitsetField {
124public:
125 static std::string TypeName() { return "std::bitset<" + std::to_string(N) + ">"; }
126 explicit RField(std::string_view name) : RBitsetField(name, N) {}
127 RField(RField &&other) = default;
128 RField &operator=(RField &&other) = default;
129 ~RField() override = default;
130};
131
132////////////////////////////////////////////////////////////////////////////////
133/// Template specializations for C++ std::byte
134////////////////////////////////////////////////////////////////////////////////
135
136extern template class RSimpleField<std::byte>;
137
138template <>
139class RField<std::byte> final : public RSimpleField<std::byte> {
140protected:
141 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final
142 {
143 return std::make_unique<RField>(newName);
144 }
145
146 const RColumnRepresentations &GetColumnRepresentations() const final;
147
148public:
149 static std::string TypeName() { return "std::byte"; }
150 explicit RField(std::string_view name) : RSimpleField(name, TypeName()) {}
151 RField(RField &&other) = default;
152 RField &operator=(RField &&other) = default;
153 ~RField() override = default;
154
155 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
156};
157
158////////////////////////////////////////////////////////////////////////////////
159/// Template specializations for C++ std::optional and std::unique_ptr
160////////////////////////////////////////////////////////////////////////////////
161
162/// The field for values that may or may not be present in an entry. Parent class for unique pointer field and
163/// optional field. A nullable field cannot be instantiated itself but only its descendants.
164/// The RNullableField takes care of the on-disk representation. Child classes are responsible for the in-memory
165/// representation. The on-disk representation can be "dense" or "sparse". Dense nullable fields have a bitmask
166/// (true: item available, false: item missing) and serialize a default-constructed item for missing items.
167/// Sparse nullable fields use a (Split)Index[64|32] column to point to the available items.
168/// By default, items whose size is smaller or equal to 4 bytes (size of (Split)Index32 column element) are stored
169/// densely.
171 /// For a dense nullable field, used to write a default-constructed item for missing ones.
172 std::unique_ptr<RValue> fDefaultItemValue;
173 /// For a sparse nullable field, the number of written non-null items in this cluster
174 ClusterSize_t fNWritten{0};
175
176protected:
177 const RFieldBase::RColumnRepresentations &GetColumnRepresentations() const final;
178 void GenerateColumns() final;
179 void GenerateColumns(const RNTupleDescriptor &) final;
180
181 std::size_t AppendNull();
182 std::size_t AppendValue(const void *from);
183 void CommitClusterImpl() final { fNWritten = 0; }
184
185 // The default implementation that translates the request into a call to ReadGlobalImpl() cannot be used
186 // because we don't team up the columns of the different column representations for this field.
187 void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final;
188
189 /// Given the index of the nullable field, returns the corresponding global index of the subfield or,
190 /// if it is null, returns kInvalidClusterIndex
191 RClusterIndex GetItemIndex(NTupleSize_t globalIndex);
192
193 RNullableField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
194
195public:
196 RNullableField(RNullableField &&other) = default;
198 ~RNullableField() override = default;
199
200 void SetDense() { SetColumnRepresentatives({{EColumnType::kBit}}); }
201 void SetSparse() { SetColumnRepresentatives({{EColumnType::kSplitIndex64}}); }
202
203 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
204};
205
207 class ROptionalDeleter : public RDeleter {
208 private:
209 std::unique_ptr<RDeleter> fItemDeleter;
210
211 public:
212 explicit ROptionalDeleter(std::unique_ptr<RDeleter> itemDeleter) : fItemDeleter(std::move(itemDeleter)) {}
213 void operator()(void *objPtr, bool dtorOnly) final;
214 };
215
216 std::unique_ptr<RDeleter> fItemDeleter;
217
218 /// Given a pointer to an std::optional<T> in `optionalPtr`, extract a pointer to the value T* and a pointer
219 /// to the engagement boolean. Assumes that an std::optional<T> is stored as
220 /// `struct { T t; bool engagement; };`
221 std::pair<const void *, const bool *> GetValueAndEngagementPtrs(const void *optionalPtr) const;
222 std::pair<void *, bool *> GetValueAndEngagementPtrs(void *optionalPtr) const;
223
224protected:
225 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
226
227 void ConstructValue(void *where) const final;
228 std::unique_ptr<RDeleter> GetDeleter() const final;
229
230 std::size_t AppendImpl(const void *from) final;
231 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final;
232
233public:
234 ROptionalField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
235 ROptionalField(ROptionalField &&other) = default;
236 ROptionalField &operator=(ROptionalField &&other) = default;
237 ~ROptionalField() override = default;
238
239 std::vector<RValue> SplitValue(const RValue &value) const final;
240 size_t GetValueSize() const final;
241 size_t GetAlignment() const final;
242};
243
244template <typename ItemT>
245class RField<std::optional<ItemT>> final : public ROptionalField {
246public:
247 static std::string TypeName() { return "std::optional<" + RField<ItemT>::TypeName() + ">"; }
248 explicit RField(std::string_view name) : ROptionalField(name, TypeName(), std::make_unique<RField<ItemT>>("_0")) {}
249 RField(RField &&other) = default;
250 RField &operator=(RField &&other) = default;
251 ~RField() override = default;
252};
253
256 private:
257 std::unique_ptr<RDeleter> fItemDeleter;
258
259 public:
260 explicit RUniquePtrDeleter(std::unique_ptr<RDeleter> itemDeleter) : fItemDeleter(std::move(itemDeleter)) {}
261 void operator()(void *objPtr, bool dtorOnly) final;
262 };
263
264 std::unique_ptr<RDeleter> fItemDeleter;
265
266protected:
267 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
268
269 void ConstructValue(void *where) const final { new (where) std::unique_ptr<char>(); }
270 std::unique_ptr<RDeleter> GetDeleter() const final;
271
272 std::size_t AppendImpl(const void *from) final;
273 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final;
274
275public:
276 RUniquePtrField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
278 RUniquePtrField &operator=(RUniquePtrField &&other) = default;
279 ~RUniquePtrField() override = default;
280
281 std::vector<RValue> SplitValue(const RValue &value) const final;
282 size_t GetValueSize() const final { return sizeof(std::unique_ptr<char>); }
283 size_t GetAlignment() const final { return alignof(std::unique_ptr<char>); }
284};
285
286template <typename ItemT>
287class RField<std::unique_ptr<ItemT>> final : public RUniquePtrField {
288public:
289 static std::string TypeName() { return "std::unique_ptr<" + RField<ItemT>::TypeName() + ">"; }
290 explicit RField(std::string_view name) : RUniquePtrField(name, TypeName(), std::make_unique<RField<ItemT>>("_0")) {}
291 RField(RField &&other) = default;
292 RField &operator=(RField &&other) = default;
293 ~RField() override = default;
294};
295
296////////////////////////////////////////////////////////////////////////////////
297/// Template specializations for C++ std::string
298////////////////////////////////////////////////////////////////////////////////
299
300template <>
301class RField<std::string> final : public RFieldBase {
302private:
303 ClusterSize_t fIndex;
304
305 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final
306 {
307 return std::make_unique<RField>(newName);
308 }
309
310 const RColumnRepresentations &GetColumnRepresentations() const final;
311 void GenerateColumns() final;
312 void GenerateColumns(const RNTupleDescriptor &desc) final;
313
314 void ConstructValue(void *where) const final { new (where) std::string(); }
315 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RTypedDeleter<std::string>>(); }
316
317 std::size_t AppendImpl(const void *from) final;
318 void ReadGlobalImpl(ROOT::Experimental::NTupleSize_t globalIndex, void *to) final;
319
320 void CommitClusterImpl() final { fIndex = 0; }
321
322public:
323 static std::string TypeName() { return "std::string"; }
324 explicit RField(std::string_view name)
325 : RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, false /* isSimple */), fIndex(0)
326 {
327 }
328 RField(RField &&other) = default;
329 RField &operator=(RField &&other) = default;
330 ~RField() override = default;
331
332 size_t GetValueSize() const final { return sizeof(std::string); }
333 size_t GetAlignment() const final { return std::alignment_of<std::string>(); }
334 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
335};
336
337////////////////////////////////////////////////////////////////////////////////
338/// Template specializations for C++ std::variant
339////////////////////////////////////////////////////////////////////////////////
340
341/// The generic field for std::variant types
342class RVariantField : public RFieldBase {
343private:
344 // Most compilers support at least 255 variants (256 - 1 value for the empty variant).
345 // Some compilers switch to a two-byte tag field already with 254 variants.
346 // MSVC only supports 163 variants in older versions, 250 in newer ones. It switches to a 2 byte
347 // tag as of 128 variants (at least in debug mode), so for simplicity we set the limit to 125 variants.
348 static constexpr std::size_t kMaxVariants = 125;
349
350 class RVariantDeleter : public RDeleter {
351 private:
352 std::size_t fTagOffset;
353 std::size_t fVariantOffset;
354 std::vector<std::unique_ptr<RDeleter>> fItemDeleters;
355
356 public:
357 RVariantDeleter(std::size_t tagOffset, std::size_t variantOffset,
358 std::vector<std::unique_ptr<RDeleter>> &itemDeleters)
359 : fTagOffset(tagOffset), fVariantOffset(variantOffset), fItemDeleters(std::move(itemDeleters))
360 {
361 }
362 void operator()(void *objPtr, bool dtorOnly) final;
363 };
364
365 size_t fMaxItemSize = 0;
366 size_t fMaxAlignment = 1;
367 /// In the std::variant memory layout, at which byte number is the index stored
368 size_t fTagOffset = 0;
369 /// In the std::variant memory layout, the actual union of types may start at an offset > 0
370 size_t fVariantOffset = 0;
371 std::vector<ClusterSize_t::ValueType> fNWritten;
372
373 static std::string GetTypeList(const std::vector<RFieldBase *> &itemFields);
374 /// Extracts the index from an std::variant and transforms it into the 1-based index used for the switch column
375 /// The implementation supports two memory layouts that are in use: a trailing unsigned byte, zero-indexed,
376 /// having the exception caused empty state encoded by the max tag value,
377 /// or a trailing unsigned int instead of a char.
378 static std::uint8_t GetTag(const void *variantPtr, std::size_t tagOffset);
379 static void SetTag(void *variantPtr, std::size_t tagOffset, std::uint8_t tag);
380
381protected:
382 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
383
385 void GenerateColumns() final;
386 void GenerateColumns(const RNTupleDescriptor &desc) final;
387
388 void ConstructValue(void *where) const override;
389 std::unique_ptr<RDeleter> GetDeleter() const final;
390
391 std::size_t AppendImpl(const void *from) final;
392 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final;
393
394 void CommitClusterImpl() final;
395
396public:
397 // TODO(jblomer): use std::span in signature
398 RVariantField(std::string_view fieldName, const std::vector<RFieldBase *> &itemFields);
399 RVariantField(RVariantField &&other) = default;
400 RVariantField &operator=(RVariantField &&other) = default;
401 ~RVariantField() override = default;
402
403 size_t GetValueSize() const final;
404 size_t GetAlignment() const final;
405};
406
407template <typename... ItemTs>
408class RField<std::variant<ItemTs...>> final : public RVariantField {
409 using ContainerT = typename std::variant<ItemTs...>;
410
411private:
412 template <typename HeadT, typename... TailTs>
413 static std::string BuildItemTypes()
414 {
415 std::string result = RField<HeadT>::TypeName();
416 if constexpr (sizeof...(TailTs) > 0)
417 result += "," + BuildItemTypes<TailTs...>();
418 return result;
419 }
420
421 template <typename HeadT, typename... TailTs>
422 static std::vector<RFieldBase *> BuildItemFields(unsigned int index = 0)
423 {
424 std::vector<RFieldBase *> result;
425 result.emplace_back(new RField<HeadT>("_" + std::to_string(index)));
426 if constexpr (sizeof...(TailTs) > 0) {
427 auto tailFields = BuildItemFields<TailTs...>(index + 1);
428 result.insert(result.end(), tailFields.begin(), tailFields.end());
429 }
430 return result;
431 }
432
433protected:
434 void ConstructValue(void *where) const final { new (where) ContainerT(); }
435
436public:
437 static std::string TypeName() { return "std::variant<" + BuildItemTypes<ItemTs...>() + ">"; }
438 explicit RField(std::string_view name) : RVariantField(name, BuildItemFields<ItemTs...>()) {}
439 RField(RField &&other) = default;
440 RField &operator=(RField &&other) = default;
441 ~RField() override = default;
442};
443
444} // namespace Experimental
445} // namespace ROOT
446
447#endif
#define N
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
TRObject operator()(const T1 &t1) const
Binding & operator=(OUT(*fun)(void))
Abstract base class for classes implementing the visitor design pattern.
Template specializations for C++ std::atomic.
~RAtomicField() override=default
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.cxx:3961
std::unique_ptr< RDeleter > GetDeleter() const final
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
Definition RField.cxx:3968
RAtomicField & operator=(RAtomicField &&other)=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
RAtomicField(RAtomicField &&other)=default
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Definition RField.cxx:3975
Template specializations for C++ std::bitset.
std::size_t GetN() const
Get the number of bits in the bitset, i.e. the N in std::bitset<N>
RBitsetField(RBitsetField &&other)=default
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
static constexpr std::size_t kWordSize
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
Definition RField.cxx:3161
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
Definition RField.cxx:3175
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
static constexpr std::size_t kBitsPerWord
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
Definition RField.cxx:3151
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
Definition RField.cxx:3145
~RBitsetField() override=default
RBitsetField & operator=(RBitsetField &&other)=default
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Definition RField.cxx:3187
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
Definition RField.cxx:1781
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
Definition RField.cxx:1707
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
Definition RField.cxx:1716
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.cxx:1700
void AcceptVisitor(Detail::RFieldVisitor &visitor) const override
Definition RField.cxx:1796
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:151
std::unique_ptr< RDeleter > GetDeleter() const final
Definition RField.hxx:136
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Some fields have multiple possible column representations, e.g.
A functor to release the memory acquired by CreateValue (memory and constructor).
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
A field translates read and write calls from/to underlying columns to/from tree values.
virtual void GenerateColumns()
Implementations in derived classes should create the backing columns corresponsing to the field type ...
static std::size_t CallAppendOn(RFieldBase &other, const void *from)
Allow derived classes to call Append and Read on other (sub) fields.
static std::unique_ptr< RDeleter > GetDeleterOf(const RFieldBase &other)
static void CallReadOn(RFieldBase &other, RClusterIndex clusterIndex, void *to)
static void CallConstructValueOn(const RFieldBase &other, void *where)
Allow derived classes to call ConstructValue(void *) and GetDeleter on other (sub) fields.
std::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
RFieldBase(std::string_view name, std::string_view type, ENTupleStructure structure, bool isSimple, std::size_t nRepetitions=0)
The constructor creates the underlying column objects and connects them to either a sink or a source.
Definition RField.cxx:568
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
Definition RField.cxx:916
Classes with dictionaries that can be inspected by TClass.
Definition RField.hxx:239
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
Definition RField.hxx:241
RField & operator=(RField &&other)=default
static std::string TypeName()
Definition RField.hxx:252
~RField() override=default
The on-storage meta-data of an ntuple.
Template specializations for C++ std::optional and std::unique_ptr.
RNullableField & operator=(RNullableField &&other)=default
~RNullableField() override=default
RNullableField(RNullableField &&other)=default
std::unique_ptr< RValue > fDefaultItemValue
For a dense nullable field, used to write a default-constructed item for missing ones.
ROptionalDeleter(std::unique_ptr< RDeleter > itemDeleter)
std::unique_ptr< RDeleter > fItemDeleter
RUniquePtrDeleter(std::unique_ptr< RDeleter > itemDeleter)
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::unique_ptr< RDeleter > fItemDeleter
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
void operator()(void *objPtr, bool dtorOnly) final
Definition RField.cxx:3321
std::vector< std::unique_ptr< RDeleter > > fItemDeleters
RVariantDeleter(std::size_t tagOffset, std::size_t variantOffset, std::vector< std::unique_ptr< RDeleter > > &itemDeleters)
Template specializations for C++ std::variant.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
Definition RField.cxx:3279
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.cxx:3345
RVariantField & operator=(RVariantField &&other)=default
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
Definition RField.cxx:3298
static void SetTag(void *variantPtr, std::size_t tagOffset, std::uint8_t tag)
Definition RField.cxx:3258
void ConstructValue(void *where) const override
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
Definition RField.cxx:3314
static std::string GetTypeList(const std::vector< RFieldBase * > &itemFields)
Definition RField.cxx:3194
std::vector< ClusterSize_t::ValueType > fNWritten
size_t fTagOffset
In the std::variant memory layout, at which byte number is the index stored.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.cxx:3239
static constexpr std::size_t kMaxVariants
static std::uint8_t GetTag(const void *variantPtr, std::size_t tagOffset)
Extracts the index from an std::variant and transforms it into the 1-based index used for the switch ...
Definition RField.cxx:3251
size_t fVariantOffset
In the std::variant memory layout, the actual union of types may start at an offset > 0.
std::unique_ptr< RDeleter > GetDeleter() const final
Definition RField.cxx:3330
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
Definition RField.cxx:3265
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.cxx:3340
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
Definition RField.cxx:3304
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
RClusterSize ClusterSize_t
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Wrap the integer in a struct in order to avoid template specialization clash with std::uint64_t.