Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RField.hxx
Go to the documentation of this file.
1/// \file ROOT/RField.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
17#define ROOT7_RField
18
19#include <ROOT/RError.hxx>
20#include <ROOT/RFieldBase.hxx>
22#include <ROOT/RNTupleUtil.hxx>
23#include <ROOT/RSpan.hxx>
24#include <string_view>
25#include <ROOT/TypeTraits.hxx>
26
27#include <TGenericClassInfo.h>
28
29#include <algorithm>
30#include <array>
31#include <cstddef>
32#include <iostream>
33#include <memory>
34#include <string>
35#include <type_traits>
36#include <typeinfo>
37#include <vector>
38
39class TClass;
40class TEnum;
41class TObject;
43
44namespace ROOT {
45
46class TSchemaRule;
47
48namespace Experimental {
49
50class RNTupleCollectionWriter;
51class REntry;
52
53namespace Detail {
54class RFieldVisitor;
55} // namespace Detail
56
57/// The container field for an ntuple model, which itself has no physical representation.
58/// Therefore, the zero field must not be connected to a page source or sink.
59class RFieldZero final : public RFieldBase {
60protected:
61 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const override;
62 void ConstructValue(void *) const final {}
63
64public:
65 RFieldZero() : RFieldBase("", "", ENTupleStructure::kRecord, false /* isSimple */) {}
66
68 size_t GetValueSize() const final { return 0; }
69 size_t GetAlignment() const final { return 0; }
70
71 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
72};
73
74/// Used in RFieldBase::Check() to record field creation failures.
75class RInvalidField final : public RFieldBase {
76 std::string fError;
77
78protected:
79 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final
80 {
81 return std::make_unique<RInvalidField>(newName, GetTypeName(), fError);
82 }
83 void ConstructValue(void *) const final {}
84
85public:
86 RInvalidField(std::string_view name, std::string_view type, std::string_view error)
87 : RFieldBase(name, type, ENTupleStructure::kLeaf, false /* isSimple */), fError(error)
88 {
89 }
90
91 const std::string &GetError() const { return fError; }
92
93 size_t GetValueSize() const final { return 0; }
94 size_t GetAlignment() const final { return 0; }
95}; // RInvalidField
96
97/// The field for a class with dictionary
98class RClassField : public RFieldBase {
99private:
103 };
106 std::size_t fOffset;
107 };
108 /// Prefix used in the subfield names generated for base classes
109 static constexpr const char *kPrefixInherited{":"};
110
111 class RClassDeleter : public RDeleter {
112 private:
114
115 public:
116 explicit RClassDeleter(TClass *cl) : fClass(cl) {}
117 void operator()(void *objPtr, bool dtorOnly) final;
118 };
119
121 /// Additional information kept for each entry in `fSubFields`
122 std::vector<RSubFieldInfo> fSubFieldsInfo;
123 std::size_t fMaxAlignment = 1;
124
125private:
126 RClassField(std::string_view fieldName, std::string_view className, TClass *classp);
127 void Attach(std::unique_ptr<RFieldBase> child, RSubFieldInfo info);
128 /// Register post-read callbacks corresponding to a list of ROOT I/O customization rules. `classp` is used to
129 /// fill the `TVirtualObject` instance passed to the user function.
130 void AddReadCallbacksFromIORules(const std::span<const TSchemaRule *> rules, TClass *classp = nullptr);
131
132protected:
133 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
134
135 void ConstructValue(void *where) const override;
136 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RClassDeleter>(fClass); }
137
138 std::size_t AppendImpl(const void *from) final;
139 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final;
140 void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final;
141 void OnConnectPageSource() final;
142
143public:
144 RClassField(std::string_view fieldName, std::string_view className);
145 RClassField(RClassField &&other) = default;
146 RClassField &operator=(RClassField &&other) = default;
147 ~RClassField() override = default;
148
149 std::vector<RValue> SplitValue(const RValue &value) const final;
150 size_t GetValueSize() const override;
151 size_t GetAlignment() const final { return fMaxAlignment; }
152 std::uint32_t GetTypeVersion() const final;
153 std::uint32_t GetTypeChecksum() const final;
154 void AcceptVisitor(Detail::RFieldVisitor &visitor) const override;
155};
156
157/// The field for a class in unsplit mode, which is using ROOT standard streaming
158class RUnsplitField final : public RFieldBase {
159private:
160 class RUnsplitDeleter : public RDeleter {
161 private:
163
164 public:
165 explicit RUnsplitDeleter(TClass *cl) : fClass(cl) {}
166 void operator()(void *objPtr, bool dtorOnly) final;
167 };
168
169 TClass *fClass = nullptr;
170 Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfos; ///< streamer info records seen during writing
171 ClusterSize_t fIndex; ///< number of bytes written in the current cluster
172
173private:
174 // Note that className may be different from classp->GetName(), e.g. through different canonicalization of RNTuple
175 // vs. TClass. Also, classp may be nullptr for types unsupported by the ROOT I/O.
176 RUnsplitField(std::string_view fieldName, std::string_view className, TClass *classp);
177
178protected:
179 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
180
182 void GenerateColumns() final;
183 void GenerateColumns(const RNTupleDescriptor &) final;
184
185 void ConstructValue(void *where) const final;
186 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RUnsplitDeleter>(fClass); }
187
188 std::size_t AppendImpl(const void *from) final;
189 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final;
190
191 void CommitClusterImpl() final { fIndex = 0; }
192
193 bool HasExtraTypeInfo() const final { return true; }
194 // Returns the list of seen streamer infos
196
197public:
198 RUnsplitField(std::string_view fieldName, std::string_view className, std::string_view typeAlias = "");
199 RUnsplitField(RUnsplitField &&other) = default;
200 RUnsplitField &operator=(RUnsplitField &&other) = default;
201 ~RUnsplitField() override = default;
202
203 size_t GetValueSize() const final;
204 size_t GetAlignment() const final;
205 std::uint32_t GetTypeVersion() const final;
206 std::uint32_t GetTypeChecksum() const final;
207 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
208};
209
210/// The field for an unscoped or scoped enum with dictionary
211class REnumField : public RFieldBase {
212private:
213 REnumField(std::string_view fieldName, std::string_view enumName, TEnum *enump);
214 REnumField(std::string_view fieldName, std::string_view enumName, std::unique_ptr<RFieldBase> intField);
215
216protected:
217 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
218
219 void ConstructValue(void *where) const final { CallConstructValueOn(*fSubFields[0], where); }
220
221 std::size_t AppendImpl(const void *from) final { return CallAppendOn(*fSubFields[0], from); }
222 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final { CallReadOn(*fSubFields[0], globalIndex, to); }
223 void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final { CallReadOn(*fSubFields[0], clusterIndex, to); }
224
225public:
226 REnumField(std::string_view fieldName, std::string_view enumName);
227 REnumField(REnumField &&other) = default;
228 REnumField &operator=(REnumField &&other) = default;
229 ~REnumField() override = default;
230
231 std::vector<RValue> SplitValue(const RValue &value) const final;
232 size_t GetValueSize() const final { return fSubFields[0]->GetValueSize(); }
233 size_t GetAlignment() const final { return fSubFields[0]->GetAlignment(); }
234 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
235};
236
237/// Classes with dictionaries that can be inspected by TClass
238template <typename T, typename = void>
239class RField final : public RClassField {
240protected:
241 void ConstructValue(void *where) const final
242 {
243 if constexpr (std::is_default_constructible_v<T>) {
244 new (where) T();
245 } else {
246 // If there is no default constructor, try with the IO constructor
247 new (where) T(static_cast<TRootIOCtor *>(nullptr));
248 }
249 }
250
251public:
252 static std::string TypeName() { return ROOT::Internal::GetDemangledTypeName(typeid(T)); }
253 RField(std::string_view name) : RClassField(name, TypeName())
254 {
255 static_assert(std::is_class_v<T>, "no I/O support for this basic C++ type");
256 }
257 RField(RField &&other) = default;
258 RField &operator=(RField &&other) = default;
259 ~RField() override = default;
260};
261
262template <typename T>
263class RField<T, typename std::enable_if<std::is_enum_v<T>>::type> : public REnumField {
264public:
265 static std::string TypeName() { return ROOT::Internal::GetDemangledTypeName(typeid(T)); }
266 RField(std::string_view name) : REnumField(name, TypeName()) {}
267 RField(RField &&other) = default;
268 RField &operator=(RField &&other) = default;
269 ~RField() override = default;
270};
271
272/// The collection field is only used for writing; when reading, untyped collections are projected to an std::vector
274private:
275 /// Save the link to the collection ntuple in order to reset the offset counter when committing the cluster
276 std::shared_ptr<RNTupleCollectionWriter> fCollectionWriter;
277
278protected:
279 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
281 void GenerateColumns() final;
282 void GenerateColumns(const RNTupleDescriptor &desc) final;
283 void ConstructValue(void *) const final {}
284
285 std::size_t AppendImpl(const void *from) final;
286 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final;
287
288 void CommitClusterImpl() final;
289
290public:
291 static std::string TypeName() { return ""; }
292 RCollectionField(std::string_view name, std::shared_ptr<RNTupleCollectionWriter> collectionWriter,
293 std::unique_ptr<RFieldZero> collectionParent);
296 ~RCollectionField() override = default;
297
298 size_t GetValueSize() const final { return sizeof(ClusterSize_t); }
299 size_t GetAlignment() const final { return alignof(ClusterSize_t); }
300};
301
302/// An artificial field that transforms an RNTuple column that contains the offset of collections into
303/// collection sizes. It is only used for reading, e.g. as projected field or as an artificial field that provides the
304/// "number of" RDF columns for collections (e.g. `R_rdf_sizeof_jets` for a collection named `jets`).
305/// It is used in the templated RField<RNTupleCardinality<SizeT>> form, which represents the collection sizes either
306/// as 32bit unsigned int (std::uint32_t) or as 64bit unsigned int (std::uint64_t).
308protected:
309 RCardinalityField(std::string_view fieldName, std::string_view typeName)
310 : RFieldBase(fieldName, typeName, ENTupleStructure::kLeaf, false /* isSimple */)
311 {
312 }
313
314 const RColumnRepresentations &GetColumnRepresentations() const final;
315 // Field is only used for reading
316 void GenerateColumns() final { throw RException(R__FAIL("Cardinality fields must only be used for reading")); }
317 void GenerateColumns(const RNTupleDescriptor &) final;
318
319public:
322 ~RCardinalityField() override = default;
323
324 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
325
326 const RField<RNTupleCardinality<std::uint32_t>> *As32Bit() const;
327 const RField<RNTupleCardinality<std::uint64_t>> *As64Bit() const;
328};
329
330template <typename T>
331class RSimpleField : public RFieldBase {
332protected:
333 void GenerateColumns() final { GenerateColumnsImpl<T>(); }
334 void GenerateColumns(const RNTupleDescriptor &desc) final { GenerateColumnsImpl<T>(desc); }
335
336 void ConstructValue(void *where) const final { new (where) T{0}; }
337
338public:
339 RSimpleField(std::string_view name, std::string_view type)
340 : RFieldBase(name, type, ENTupleStructure::kLeaf, true /* isSimple */)
341 {
342 fTraits |= kTraitTrivialType;
343 }
344 RSimpleField(RSimpleField &&other) = default;
346 ~RSimpleField() override = default;
347
348 T *Map(NTupleSize_t globalIndex) { return fPrincipalColumn->Map<T>(globalIndex); }
349 T *Map(RClusterIndex clusterIndex) { return fPrincipalColumn->Map<T>(clusterIndex); }
350 T *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) { return fPrincipalColumn->MapV<T>(globalIndex, nItems); }
351 T *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems) { return fPrincipalColumn->MapV<T>(clusterIndex, nItems); }
352
353 size_t GetValueSize() const final { return sizeof(T); }
354 size_t GetAlignment() const final { return alignof(T); }
355};
356
357////////////////////////////////////////////////////////////////////////////////
358/// Template specializations for concrete C++ types
359////////////////////////////////////////////////////////////////////////////////
360
361} // namespace Experimental
362} // namespace ROOT
363
369
370namespace ROOT {
371namespace Experimental {
372
373template <>
374class RField<ClusterSize_t> final : public RSimpleField<ClusterSize_t> {
375protected:
376 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final
377 {
378 return std::make_unique<RField>(newName);
379 }
380
382
383public:
384 static std::string TypeName() { return "ROOT::Experimental::ClusterSize_t"; }
385 explicit RField(std::string_view name) : RSimpleField(name, TypeName()) {}
386 RField(RField &&other) = default;
387 RField &operator=(RField &&other) = default;
388 ~RField() override = default;
389
390 /// Special help for offset fields
391 void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size)
392 {
393 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart, size);
394 }
395 void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size)
396 {
397 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart, size);
398 }
399 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
400};
401
402template <typename SizeT>
403class RField<RNTupleCardinality<SizeT>> final : public RCardinalityField {
404protected:
405 std::unique_ptr<ROOT::Experimental::RFieldBase> CloneImpl(std::string_view newName) const final
406 {
407 return std::make_unique<RField<RNTupleCardinality<SizeT>>>(newName);
408 }
409 void ConstructValue(void *where) const final { new (where) RNTupleCardinality<SizeT>(0); }
410
411public:
412 static std::string TypeName() { return "ROOT::Experimental::RNTupleCardinality<" + RField<SizeT>::TypeName() + ">"; }
413 explicit RField(std::string_view name) : RCardinalityField(name, TypeName()) {}
414 RField(RField &&other) = default;
415 RField &operator=(RField &&other) = default;
416 ~RField() override = default;
417
418 size_t GetValueSize() const final { return sizeof(RNTupleCardinality<SizeT>); }
419 size_t GetAlignment() const final { return alignof(RNTupleCardinality<SizeT>); }
420
421 /// Get the number of elements of the collection identified by globalIndex
422 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
423 {
424 RClusterIndex collectionStart;
426 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &size);
427 *static_cast<RNTupleCardinality<SizeT> *>(to) = size;
428 }
429
430 /// Get the number of elements of the collection identified by clusterIndex
431 void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
432 {
433 RClusterIndex collectionStart;
435 fPrincipalColumn->GetCollectionInfo(clusterIndex, &collectionStart, &size);
436 *static_cast<RNTupleCardinality<SizeT> *>(to) = size;
437 }
438
439 std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
440 {
441 RClusterIndex collectionStart;
442 ClusterSize_t collectionSize;
443 fPrincipalColumn->GetCollectionInfo(bulkSpec.fFirstIndex, &collectionStart, &collectionSize);
444
445 auto typedValues = static_cast<RNTupleCardinality<SizeT> *>(bulkSpec.fValues);
446 typedValues[0] = collectionSize;
447
448 auto lastOffset = collectionStart.GetIndex() + collectionSize;
449 ClusterSize_t::ValueType nRemainingEntries = bulkSpec.fCount - 1;
450 std::size_t nEntries = 1;
451 while (nRemainingEntries > 0) {
452 NTupleSize_t nItemsUntilPageEnd;
453 auto offsets = fPrincipalColumn->MapV<ClusterSize_t>(bulkSpec.fFirstIndex + nEntries, nItemsUntilPageEnd);
454 std::size_t nBatch = std::min(nRemainingEntries, nItemsUntilPageEnd);
455 for (std::size_t i = 0; i < nBatch; ++i) {
456 typedValues[nEntries + i] = offsets[i] - lastOffset;
457 lastOffset = offsets[i];
458 }
459 nRemainingEntries -= nBatch;
460 nEntries += nBatch;
461 }
462 return RBulkSpec::kAllSet;
463 }
464};
465
466/// TObject requires special handling of the fBits and fUniqueID members
467template <>
468class RField<TObject> final : public RFieldBase {
469 static std::size_t GetOffsetOfMember(const char *name);
470 static std::size_t GetOffsetUniqueID() { return GetOffsetOfMember("fUniqueID"); }
471 static std::size_t GetOffsetBits() { return GetOffsetOfMember("fBits"); }
472
473protected:
474 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
475
476 void ConstructValue(void *where) const override;
477 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RTypedDeleter<TObject>>(); }
478
479 std::size_t AppendImpl(const void *from) final;
480 void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final;
481
482 void OnConnectPageSource() final;
483
484public:
485 static std::string TypeName() { return "TObject"; }
486
487 RField(std::string_view fieldName);
488 RField(RField &&other) = default;
489 RField &operator=(RField &&other) = default;
490 ~RField() override = default;
491
492 std::vector<RValue> SplitValue(const RValue &value) const final;
493 size_t GetValueSize() const final;
494 size_t GetAlignment() const final;
495 std::uint32_t GetTypeVersion() const final;
496 std::uint32_t GetTypeChecksum() const final;
497 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
498};
499
500// Has to be implemented after the definition of all RField<T> types
501// The void type is specialized in RField.cxx
502
503template <typename T>
504std::unique_ptr<T, typename RFieldBase::RCreateObjectDeleter<T>::deleter> RFieldBase::CreateObject() const
505{
506 if (GetTypeName() != RField<T>::TypeName()) {
507 throw RException(
508 R__FAIL("type mismatch for field " + GetFieldName() + ": " + GetTypeName() + " vs. " + RField<T>::TypeName()));
509 }
510 return std::unique_ptr<T>(static_cast<T *>(CreateObjectRawPtr()));
511}
512
513template <>
516 void operator()(void *);
517};
518
519template <>
520std::unique_ptr<void, typename RFieldBase::RCreateObjectDeleter<void>::deleter>
521ROOT::Experimental::RFieldBase::CreateObject<void>() const;
522
523} // namespace Experimental
524} // namespace ROOT
525
526#endif
Cppyy::TCppType_t fClass
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:290
ROOT::Experimental::RField< T > RField
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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 Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
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.
std::unordered_map< Int_t, TVirtualStreamerInfo * > StreamerInfoMap_t
An artificial field that transforms an RNTuple column that contains the offset of collections into co...
Definition RField.hxx:307
RCardinalityField & operator=(RCardinalityField &&other)=default
RCardinalityField(RCardinalityField &&other)=default
RCardinalityField(std::string_view fieldName, std::string_view typeName)
Definition RField.hxx:309
void operator()(void *objPtr, bool dtorOnly) final
Definition RField.cxx:1762
The field for a class with dictionary.
Definition RField.hxx:98
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
Definition RField.cxx:1723
static constexpr const char * kPrefixInherited
Prefix used in the subfield names generated for base classes.
Definition RField.hxx:109
void Attach(std::unique_ptr< RFieldBase > child, RSubFieldInfo info)
Definition RField.cxx:1672
void OnConnectPageSource() final
Called by ConnectPageSource() once connected; derived classes may override this as appropriate.
Definition RField.cxx:1730
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
Definition RField.cxx:1781
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:1757
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::uint32_t GetTypeChecksum() const final
Return the current TClass reported checksum of this class. Only valid if kTraitTypeChecksum is set.
Definition RField.cxx:1791
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 AddReadCallbacksFromIORules(const std::span< const TSchemaRule * > rules, TClass *classp=nullptr)
Register post-read callbacks corresponding to a list of ROOT I/O customization rules.
Definition RField.cxx:1679
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::uint32_t GetTypeVersion() const final
Indicates an evolution of the C++ type itself.
Definition RField.cxx:1786
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:1769
std::vector< RSubFieldInfo > fSubFieldsInfo
Additional information kept for each entry in fSubFields
Definition RField.hxx:122
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...
ClusterSize_t::ValueType GetIndex() const
The collection field is only used for writing; when reading, untyped collections are projected to an ...
Definition RField.hxx:273
RCollectionField & operator=(RCollectionField &&other)=default
std::shared_ptr< RNTupleCollectionWriter > fCollectionWriter
Save the link to the collection ntuple in order to reset the offset counter when committing the clust...
Definition RField.hxx:276
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:299
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:298
RCollectionField(RCollectionField &&other)=default
The field for an unscoped or scoped enum with dictionary.
Definition RField.hxx:211
~REnumField() override=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:232
REnumField & operator=(REnumField &&other)=default
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
Definition RField.hxx:223
REnumField(REnumField &&other)=default
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:233
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
Definition RField.hxx:221
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
Definition RField.hxx:222
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:219
Base class for all ROOT issued exceptions.
Definition RError.hxx:78
Field specific extra type information from the header / extenstion header.
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 ...
void Attach(std::unique_ptr< RFieldBase > child)
Add a new subfield to the list of nested fields.
Definition RField.cxx:984
const std::string & GetTypeName() const
friend class ROOT::Experimental::RCollectionField
static std::size_t CallAppendOn(RFieldBase &other, const void *from)
Allow derived classes to call Append and Read on other (sub) fields.
virtual std::size_t AppendImpl(const void *from)
Operations on values of complex types, e.g.
Definition RField.cxx:933
virtual RExtraTypeInfoDescriptor GetExtraTypeInfo() const
virtual std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const =0
Called by Clone(), which additionally copies the on-disk ID.
static void CallReadOn(RFieldBase &other, RClusterIndex clusterIndex, void *to)
virtual void ConstructValue(void *where) const =0
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
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.
virtual void ReadGlobalImpl(NTupleSize_t globalIndex, void *to)
Definition RField.cxx:939
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
Definition RField.cxx:916
The container field for an ntuple model, which itself has no physical representation.
Definition RField.hxx:59
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Definition RField.cxx:1248
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:69
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:68
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.cxx:1240
void ConstructValue(void *) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
Definition RField.hxx:62
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.hxx:376
RField & operator=(RField &&other)=default
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size)
Special help for offset fields.
Definition RField.hxx:391
void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size)
Definition RField.hxx:395
std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
General implementation of bulk read.
Definition RField.hxx:439
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:409
std::unique_ptr< ROOT::Experimental::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.hxx:405
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
Get the number of elements of the collection identified by clusterIndex.
Definition RField.hxx:431
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
Get the number of elements of the collection identified by globalIndex.
Definition RField.hxx:422
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:418
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:419
std::unique_ptr< RDeleter > GetDeleter() const final
Definition RField.hxx:477
static std::size_t GetOffsetUniqueID()
Definition RField.hxx:470
RField(RField &&other)=default
static std::size_t GetOffsetBits()
Definition RField.hxx:471
RField & operator=(RField &&other)=default
Classes with dictionaries that can be inspected by TClass.
Definition RField.hxx:239
RField(std::string_view name)
Definition RField.hxx:253
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
RField(RField &&other)=default
static std::string TypeName()
Definition RField.hxx:252
~RField() override=default
Used in RFieldBase::Check() to record field creation failures.
Definition RField.hxx:75
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:93
const std::string & GetError() const
Definition RField.hxx:91
RInvalidField(std::string_view name, std::string_view type, std::string_view error)
Definition RField.hxx:86
void ConstructValue(void *) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
Definition RField.hxx:83
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.hxx:79
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:94
The on-storage meta-data of an ntuple.
T * Map(RClusterIndex clusterIndex)
Definition RField.hxx:349
T * MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
Definition RField.hxx:351
RSimpleField & operator=(RSimpleField &&other)=default
T * Map(NTupleSize_t globalIndex)
Definition RField.hxx:348
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:336
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
Definition RField.hxx:333
~RSimpleField() override=default
T * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
Definition RField.hxx:350
void GenerateColumns(const RNTupleDescriptor &desc) final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
Definition RField.hxx:334
RSimpleField(RSimpleField &&other)=default
RSimpleField(std::string_view name, std::string_view type)
Definition RField.hxx:339
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:354
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:353
The field for a class in unsplit mode, which is using ROOT standard streaming.
Definition RField.hxx:158
Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfos
streamer info records seen during writing
Definition RField.hxx:170
bool HasExtraTypeInfo() const final
Definition RField.hxx:193
ClusterSize_t fIndex
number of bytes written in the current cluster
Definition RField.hxx:171
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
The TEnum class implements the enum type.
Definition TEnum.h:33
Mother of all ROOT objects.
Definition TObject.h:41
Abstract Interface class describing Streamer information for one class.
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.
std::string GetDemangledTypeName(const std::type_info &t)
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.
Input parameter to ReadBulk() and ReadBulkImpl(). See RBulk class for more information.
Helper types to present an offset column as array of collection sizes.