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
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-09
5
6/*************************************************************************
7 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14#ifndef ROOT_RField
15#define ROOT_RField
16
17#include <ROOT/RError.hxx>
18#include <ROOT/RFieldBase.hxx>
19#include <ROOT/RFieldUtils.hxx>
21#include <ROOT/RNTupleTypes.hxx>
22#include <ROOT/RSpan.hxx>
23#include <string_view>
24#include <ROOT/TypeTraits.hxx>
25
26#include <TGenericClassInfo.h>
27
28#include <algorithm>
29#include <array>
30#include <cstddef>
31#include <iostream>
32#include <memory>
33#include <string>
34#include <type_traits>
35#include <typeinfo>
36#include <vector>
37
38class TClass;
39class TEnum;
40class TObject;
42
43namespace ROOT {
44
45class TSchemaRule;
46class RNTupleCollectionView;
47
48namespace Detail {
49class RFieldVisitor;
50} // namespace Detail
51
52class RFieldZero;
53namespace Internal {
54void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val);
55}
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 {
61
62 /// If field substitutions are allowed, upon connecting to a page source the field hierarchy will replace created
63 /// fields by fields that match the on-disk schema. This happens for
64 /// - Vector fields (RVectorField, RRVecField) that connect to an on-disk fixed-size array
65 /// - Streamer fields that connect to an on-disk class field
66 /// Field substitutions must not be enabled when the field hierarchy already handed out RValue objects because
67 /// they would leave dangling field pointers to the replaced fields. This is used in cases when the field/model
68 /// is created by RNTuple (not imposed), before it is made available to the user.
69 /// This flag is reset on Clone().
71
72 std::unordered_set<std::string> fSubfieldNames; ///< Efficient detection of duplicate field names
73
74protected:
75 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
76 void ConstructValue(void *) const final {}
77
78public:
79 RFieldZero();
80
81 /// A public version of the Attach method that allows piece-wise construction of the zero field.
82 /// Will throw on duplicate subfield names.
83 void Attach(std::unique_ptr<RFieldBase> child);
84 size_t GetValueSize() const final { return 0; }
85 size_t GetAlignment() const final { return 0; }
86
88
90 /// Moves all subfields into the returned vector.
91 std::vector<std::unique_ptr<RFieldBase>> ReleaseSubfields();
92};
93
94/// Used in RFieldBase::Check() to record field creation failures.
95/// Also used when deserializing a field that contains unknown values that may come from
96/// future RNTuple versions (e.g. an unknown Structure)
98public:
99 enum class ECategory {
100 /// Generic unrecoverable error
101 kGeneric,
102 /// The type given to RFieldBase::Create was invalid
104 /// The type given to RFieldBase::Create was unknown
106 /// The field could not be created because its descriptor had an unknown structural role
108 };
109
110 using RCategory R__DEPRECATED(6, 42, "enum renamed to ECategory") = ECategory;
111
112private:
113 std::string fError;
115
116protected:
117 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final
118 {
119 return std::make_unique<RInvalidField>(newName, GetTypeName(), fError, fCategory);
120 }
121 void ConstructValue(void *) const final {}
122
123public:
124 RInvalidField(std::string_view name, std::string_view type, std::string_view error, ECategory category)
125 : RFieldBase(name, type, ROOT::ENTupleStructure::kPlain, false /* isSimple */), fError(error), fCategory(category)
126 {
128 }
129
130 const std::string &GetError() const { return fError; }
131 ECategory GetCategory() const { return fCategory; }
132
133 size_t GetValueSize() const final { return 0; }
134 size_t GetAlignment() const final { return 0; }
135}; // RInvalidField
136
137/// The field for a class with dictionary
138class RClassField : public RFieldBase {
139private:
146 std::size_t fOffset;
147 };
148 // Information to read into the staging area a field that is used as an input to an I/O customization rule
150 /// The field used to read the on-disk data. The fields type may be different from the on-disk type as long
151 /// as the on-disk type can be converted to the fields type (through type cast / schema evolution).
152 std::unique_ptr<RFieldBase> fField;
153 std::size_t fOffset; ///< offset in fStagingArea
154 };
155 /// Prefix used in the subfield names generated for base classes
156 static constexpr const char *kPrefixInherited{":"};
157
158 class RClassDeleter : public RDeleter {
159 private:
161
162 public:
163 explicit RClassDeleter(TClass *cl) : fClass(cl) {}
164 void operator()(void *objPtr, bool dtorOnly) final;
165 };
166
168 /// Additional information kept for each entry in `fSubfields`
169 std::vector<RSubfieldInfo> fSubfieldsInfo;
170
171 /// The staging area stores inputs to I/O rules according to the offsets given by the streamer info of
172 /// "TypeName@@Version". The area is allocated depending on I/O rules resp. the source members of the I/O rules.
173 std::unique_ptr<unsigned char[]> fStagingArea;
174 /// The TClass instance that corresponds to the staging area.
175 /// The staging class exists as <class name>@@<on-disk version> if the on-disk version is different from the
176 /// current in-memory version, or it can be accessed by the first @@alloc streamer element of the current streamer
177 /// info.
179 std::unordered_map<std::string, RStagingItem> fStagingItems; ///< Lookup staging items by member name
180
181private:
182 RClassField(std::string_view fieldName, const RClassField &source); ///< Used by CloneImpl
183 RClassField(std::string_view fieldName, TClass *classp);
184 void Attach(std::unique_ptr<RFieldBase> child, RSubfieldInfo info);
185
186 /// Returns the id of member 'name' in the class field given by 'fieldId', or kInvalidDescriptorId if no such
187 /// member exist. Looks recursively in base classes.
190 /// Sets fStagingClass according to the given name and version
191 void SetStagingClass(const std::string &className, unsigned int classVersion);
192 /// If there are rules with inputs (source members), create the staging area according to the TClass instance
193 /// that corresponds to the on-disk field.
194 void PrepareStagingArea(const std::vector<const TSchemaRule *> &rules, const ROOT::RNTupleDescriptor &desc,
196 /// Register post-read callback corresponding to a ROOT I/O customization rules.
198 /// Given the on-disk information from the page source, find all the I/O customization rules that apply
199 /// to the class field at hand, to which the fieldDesc descriptor, if provided, must correspond.
200 /// Fields may not have an on-disk representation (e.g., when inserted by schema evolution), in which case the passed
201 /// field descriptor is nullptr.
202 std::vector<const TSchemaRule *> FindRules(const ROOT::RFieldDescriptor *fieldDesc);
203
204protected:
205 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
206
207 void ConstructValue(void *where) const final;
208 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RClassDeleter>(fClass); }
209
210 std::size_t AppendImpl(const void *from) final;
211 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
212 void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final;
213
214 std::unique_ptr<RFieldBase> BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final;
215 void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
216
217public:
218 RClassField(std::string_view fieldName, std::string_view className);
221 ~RClassField() override;
222
223 std::vector<RValue> SplitValue(const RValue &value) const final;
224 std::size_t GetValueSize() const final;
225 std::size_t GetAlignment() const final;
226 std::uint32_t GetTypeVersion() const final;
227 std::uint32_t GetTypeChecksum() const final;
228 /// For polymorphic classes (that declare or inherit at least one virtual method), return the expected dynamic type
229 /// of any user object. If the class is not polymorphic, return nullptr.
231 /// Return the TClass instance backing this field.
232 const TClass *GetClass() const { return fClass; }
234};
235
236/// The field for a class using ROOT standard streaming
238private:
240 private:
242
243 public:
244 explicit RStreamerFieldDeleter(TClass *cl) : fClass(cl) {}
245 void operator()(void *objPtr, bool dtorOnly) final;
246 };
247
248 TClass *fClass = nullptr;
249 ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfos; ///< streamer info records seen during writing
250 ROOT::Internal::RColumnIndex fIndex; ///< number of bytes written in the current cluster
251
252private:
253 RStreamerField(std::string_view fieldName, TClass *classp);
254
255protected:
256 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
257
259 void GenerateColumns() final;
261
262 void ConstructValue(void *where) const final;
263 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RStreamerFieldDeleter>(fClass); }
264
265 std::size_t AppendImpl(const void *from) final;
266 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
267
269
270 bool HasExtraTypeInfo() const final { return true; }
271 // Returns the list of seen streamer infos
273
274 std::unique_ptr<RFieldBase> BeforeConnectPageSource(ROOT::Internal::RPageSource &source) final;
276
277public:
278 RStreamerField(std::string_view fieldName, std::string_view className);
282
283 size_t GetValueSize() const final;
284 size_t GetAlignment() const final;
285 std::uint32_t GetTypeVersion() const final;
286 std::uint32_t GetTypeChecksum() const final;
287 TClass *GetClass() const { return fClass; }
289};
290
291/// The field for an unscoped or scoped enum with dictionary
292class REnumField : public RFieldBase {
293private:
294 REnumField(std::string_view fieldName, TEnum *enump);
295 REnumField(std::string_view fieldName, std::string_view enumName, std::unique_ptr<RFieldBase> intField);
296
297protected:
298 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
299
300 void ConstructValue(void *where) const final { CallConstructValueOn(*fSubfields[0], where); }
301
302 std::size_t AppendImpl(const void *from) final { return CallAppendOn(*fSubfields[0], from); }
305
306 void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
307
308public:
309 REnumField(std::string_view fieldName, std::string_view enumName);
312 ~REnumField() override = default;
313
314 std::vector<RValue> SplitValue(const RValue &value) const final;
315 size_t GetValueSize() const final { return fSubfields[0]->GetValueSize(); }
316 size_t GetAlignment() const final { return fSubfields[0]->GetAlignment(); }
318};
319
320/// Classes with dictionaries that can be inspected by TClass
321template <typename T, typename = void>
322class RField final : public RClassField {
323public:
324 static std::string TypeName() { return ROOT::Internal::GetRenormalizedTypeName(typeid(T)); }
325 RField(std::string_view name) : RClassField(name, Internal::GetDemangledTypeName(typeid(T)))
326 {
327 static_assert(std::is_class_v<T>, "no I/O support for this basic C++ type");
328 }
329 RField(RField &&other) = default;
332};
333
335class RField<T, typename std::enable_if<std::is_enum_v<T>>::type> final : public REnumField {
336public:
337 static std::string TypeName() { return ROOT::Internal::GetRenormalizedTypeName(typeid(T)); }
338 RField(std::string_view name) : REnumField(name, TypeName()) {}
339 RField(RField &&other) = default;
340 RField &operator=(RField &&other) = default;
341 ~RField() final = default;
342};
343
344/// An artificial field that transforms an RNTuple column that contains the offset of collections into
345/// collection sizes. It is only used for reading, e.g. as projected field or as an artificial field that provides the
346/// "number of" RDF columns for collections (e.g. `R_rdf_sizeof_jets` for a collection named `jets`).
347/// It is used in the templated RField<RNTupleCardinality<SizeT>> form, which represents the collection sizes either
348/// as 32bit unsigned int (std::uint32_t) or as 64bit unsigned int (std::uint64_t).
350 friend class ROOT::RNTupleCollectionView; // to access GetCollectionInfo()
351
352private:
361
362protected:
363 RCardinalityField(std::string_view fieldName, std::string_view typeName)
364 : RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kPlain, false /* isSimple */)
365 {
366 }
367
368 const RColumnRepresentations &GetColumnRepresentations() const final;
369 // Field is only used for reading
370 void GenerateColumns() final { throw RException(R__FAIL("Cardinality fields must only be used for reading")); }
371 void GenerateColumns(const ROOT::RNTupleDescriptor &) final;
372
373 void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
374
375public:
378 ~RCardinalityField() override = default;
379
380 void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final;
381
382 const RField<RNTupleCardinality<std::uint32_t>> *As32Bit() const;
383 const RField<RNTupleCardinality<std::uint64_t>> *As64Bit() const;
384};
385
386template <typename T>
387class RSimpleField : public RFieldBase {
388 void ReconcileIntegralField(const RNTupleDescriptor &desc);
389 void ReconcileFloatingPointField(const RNTupleDescriptor &desc);
390
391protected:
394
395 void ConstructValue(void *where) const final { new (where) T{0}; }
396
397 void ReconcileOnDiskField(const RNTupleDescriptor &desc) override
398 {
399 if constexpr (std::is_integral_v<T>) {
400 ReconcileIntegralField(desc);
401 } else if constexpr (std::is_floating_point_v<T>) {
402 ReconcileFloatingPointField(desc);
403 } else {
404 RFieldBase::ReconcileOnDiskField(desc);
405 }
406 }
407
408 RSimpleField(std::string_view name, std::string_view type)
409 : RFieldBase(name, type, ROOT::ENTupleStructure::kPlain, true /* isSimple */)
410 {
411 fTraits |= kTraitTrivialType;
412 }
413
414public:
417 ~RSimpleField() override = default;
418
419 T *Map(ROOT::NTupleSize_t globalIndex) { return fPrincipalColumn->Map<T>(globalIndex); }
420 T *Map(RNTupleLocalIndex localIndex) { return fPrincipalColumn->Map<T>(localIndex); }
422 {
423 return fPrincipalColumn->MapV<T>(globalIndex, nItems);
424 }
426 {
427 return fPrincipalColumn->MapV<T>(localIndex, nItems);
428 }
429
430 size_t GetValueSize() const final { return sizeof(T); }
431 size_t GetAlignment() const final { return alignof(T); }
432};
433
434////////////////////////////////////////////////////////////////////////////////
435/// Template specializations for concrete C++ types
436////////////////////////////////////////////////////////////////////////////////
437
438} // namespace ROOT
439
444#include "RField/RFieldSoA.hxx"
446
447namespace ROOT {
448
449template <typename SizeT>
452
453protected:
454 std::unique_ptr<ROOT::RFieldBase> CloneImpl(std::string_view newName) const final
455 {
456 return std::make_unique<RField>(newName);
457 }
458 void ConstructValue(void *where) const final { new (where) CardinalityType(0); }
459
460 /// Get the number of elements of the collection identified by globalIndex
468
469 /// Get the number of elements of the collection identified by clusterIndex
477
478 std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
479 {
483
484 auto typedValues = static_cast<CardinalityType *>(bulkSpec.fValues);
486
487 auto lastOffset = collectionStart.GetIndexInCluster() + collectionSize;
489 std::size_t nEntries = 1;
490 while (nRemainingEntries > 0) {
492 auto offsets =
494 std::size_t nBatch = std::min(nRemainingEntries, nItemsUntilPageEnd);
495 for (std::size_t i = 0; i < nBatch; ++i) {
496 typedValues[nEntries + i] = offsets[i] - lastOffset;
497 lastOffset = offsets[i];
498 }
500 nEntries += nBatch;
501 }
502 return RBulkSpec::kAllSet;
503 }
504
505public:
506 static std::string TypeName() { return "ROOT::RNTupleCardinality<" + RField<SizeT>::TypeName() + ">"; }
507 explicit RField(std::string_view name) : RCardinalityField(name, TypeName()) {}
508 RField(RField &&other) = default;
511
512 size_t GetValueSize() const final { return sizeof(CardinalityType); }
513 size_t GetAlignment() const final { return alignof(CardinalityType); }
514};
515
516/// TObject requires special handling of the fBits and fUniqueID members
517template <>
519 static std::size_t GetOffsetOfMember(const char *name);
520 static std::size_t GetOffsetUniqueID() { return GetOffsetOfMember("fUniqueID"); }
521 static std::size_t GetOffsetBits() { return GetOffsetOfMember("fBits"); }
522
523private:
524 RField(std::string_view fieldName, const RField<TObject> &source); ///< Used by CloneImpl()
525
526protected:
527 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
528
529 void ConstructValue(void *where) const final;
530 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RTypedDeleter<TObject>>(); }
531
532 std::size_t AppendImpl(const void *from) final;
533 void ReadTObject(void *to, UInt_t uniqueID, UInt_t bits);
534 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
535 void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final;
536
537public:
538 static std::string TypeName() { return "TObject"; }
539
540 RField(std::string_view fieldName);
541 RField(RField &&other) = default;
544
546 size_t GetValueSize() const final;
547 size_t GetAlignment() const final;
548 std::uint32_t GetTypeVersion() const final;
549 std::uint32_t GetTypeChecksum() const final;
551};
552
553// Have to be implemented after the definition of all RField<T> types
554
555namespace Internal {
556
557/// Helper to check if a given type name is the one expected of Field<T>. Usually, this check can be done by
558/// type renormalization of the demangled type name T. The failure case, however, needs to additionally check for
559/// ROOT-specific special cases.
560template <class T>
561bool IsMatchingFieldType(const std::string &actualTypeName)
562{
564}
565
566} // namespace Internal
567
568template <typename T>
569std::unique_ptr<T, typename RFieldBase::RCreateObjectDeleter<T>::deleter> RFieldBase::CreateObject() const
570{
571 if (!Internal::IsMatchingFieldType<T>(GetTypeName())) {
572 throw RException(
573 R__FAIL("type mismatch for field " + GetFieldName() + ": " + GetTypeName() + " vs. " + RField<T>::TypeName()));
574 }
575 return std::unique_ptr<T>(static_cast<T *>(CreateObjectRawPtr()));
576}
577
578// The void type is specialized in RField.cxx
579
580template <>
585
586template <>
587std::unique_ptr<void, typename RFieldBase::RCreateObjectDeleter<void>::deleter>
588ROOT::RFieldBase::CreateObject<void>() const;
589
590} // namespace ROOT
591
592#endif
#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:300
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:145
TRObject operator()(const T1 &t1) const
Abstract base class for classes implementing the visitor design pattern.
The in-memory representation of a 32bit or 64bit on-disk index column.
void GetCollectionInfo(const ROOT::NTupleSize_t globalIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *collectionSize)
For offset columns only, look at the two adjacent values that define a collection's coordinates.
Definition RColumn.hxx:283
CppT * MapV(const ROOT::NTupleSize_t globalIndex, ROOT::NTupleSize_t &nItems)
Definition RColumn.hxx:241
std::map< Int_t, TVirtualStreamerInfo * > StreamerInfoMap_t
Abstract interface to read data from an ntuple.
An artificial field that transforms an RNTuple column that contains the offset of collections into co...
Definition RField.hxx:349
RCardinalityField(RCardinalityField &&other)=default
void GetCollectionInfo(ROOT::NTupleSize_t globalIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *size)
Definition RField.hxx:353
RCardinalityField & operator=(RCardinalityField &&other)=default
void GetCollectionInfo(RNTupleLocalIndex localIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *size)
Definition RField.hxx:357
~RCardinalityField() override=default
RCardinalityField(std::string_view fieldName, std::string_view typeName)
Definition RField.hxx:363
void operator()(void *objPtr, bool dtorOnly) final
The field for a class with dictionary.
Definition RField.hxx:138
const TClass * GetClass() const
Return the TClass instance backing this field.
Definition RField.hxx:232
std::unique_ptr< RFieldBase > BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final
Called by ConnectPageSource() before connecting; derived classes may override this as appropriate,...
void AddReadCallbacksFromIORule(const TSchemaRule *rule)
Register post-read callback corresponding to a ROOT I/O customization rules.
TClass * fStagingClass
The TClass instance that corresponds to the staging area.
Definition RField.hxx:178
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
RClassField(RClassField &&other)=default
std::size_t GetAlignment() const final
What alignof(T) for this type returns.
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::vector< RSubfieldInfo > fSubfieldsInfo
Additional information kept for each entry in fSubfields
Definition RField.hxx:169
void Attach(std::unique_ptr< RFieldBase > child, RSubfieldInfo info)
std::unique_ptr< unsigned char[]> fStagingArea
The staging area stores inputs to I/O rules according to the offsets given by the streamer info of "T...
Definition RField.hxx:173
RClassField & operator=(RClassField &&other)=default
std::size_t GetValueSize() const final
What sizeof(T) for this type returns.
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) 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 AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
std::vector< const TSchemaRule * > FindRules(const ROOT::RFieldDescriptor *fieldDesc)
Given the on-disk information from the page source, find all the I/O customization rules that apply t...
ROOT::DescriptorId_t LookupMember(const ROOT::RNTupleDescriptor &desc, std::string_view memberName, ROOT::DescriptorId_t classFieldId)
Returns the id of member 'name' in the class field given by 'fieldId', or kInvalidDescriptorId if no ...
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
TClass * fClass
Definition RField.hxx:167
std::uint32_t GetTypeVersion() const final
Indicates an evolution of the C++ type itself.
RClassField(std::string_view fieldName, const RClassField &source)
Used by CloneImpl.
void PrepareStagingArea(const std::vector< const TSchemaRule * > &rules, const ROOT::RNTupleDescriptor &desc, const ROOT::RFieldDescriptor &classFieldId)
If there are rules with inputs (source members), create the staging area according to the TClass inst...
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
const std::type_info * GetPolymorphicTypeInfo() const
For polymorphic classes (that declare or inherit at least one virtual method), return the expected dy...
~RClassField() override
std::uint32_t GetTypeChecksum() const final
Return the current TClass reported checksum of this class. Only valid if kTraitTypeChecksum is set.
std::unique_ptr< RDeleter > GetDeleter() const final
Definition RField.hxx:208
std::unordered_map< std::string, RStagingItem > fStagingItems
Lookup staging items by member name.
Definition RField.hxx:179
static constexpr const char * kPrefixInherited
Prefix used in the subfield names generated for base classes.
Definition RField.hxx:156
void SetStagingClass(const std::string &className, unsigned int classVersion)
Sets fStagingClass according to the given name and version.
The field for an unscoped or scoped enum with dictionary.
Definition RField.hxx:292
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
size_t GetValueSize() const final
What sizeof(T) for this type returns.
Definition RField.hxx:315
size_t GetAlignment() const final
What alignof(T) for this type returns.
Definition RField.hxx:316
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
~REnumField() override=default
REnumField(REnumField &&other)=default
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:300
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
Definition RField.hxx:304
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
Definition RField.hxx:303
REnumField & operator=(REnumField &&other)=default
REnumField(std::string_view fieldName, TEnum *enump)
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
Definition RField.hxx:302
Base class for all ROOT issued exceptions.
Definition RError.hxx:79
Field specific extra type information from the header / extenstion header.
The list of column representations a field can have.
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.
ROOT::Internal::RColumn * fPrincipalColumn
All fields that have columns have a distinct main column.
std::vector< std::unique_ptr< RFieldBase > > fSubfields
Collections and classes own subfields.
std::unique_ptr< T, typename RCreateObjectDeleter< T >::deleter > CreateObject() const
Generates an object of the field type and allocates new initialized memory according to the type.
Definition RField.hxx:569
@ kTraitInvalidField
This field is an instance of RInvalidField and can be safely static_cast to it.
const std::string & GetFieldName() const
static std::size_t CallAppendOn(RFieldBase &other, const void *from)
Allow derived classes to call Append() and Read() on other (sub)fields.
std::uint32_t fTraits
Properties of the type that allow for optimizations of collections of that type.
const std::string & GetTypeName() const
static void CallReadOn(RFieldBase &other, RNTupleLocalIndex localIndex, void *to)
static void CallConstructValueOn(const RFieldBase &other, void *where)
Allow derived classes to call ConstructValue(void *) and GetDeleter() on other (sub)fields.
void * CreateObjectRawPtr() const
Factory method for the field's type. The caller owns the returned pointer.
Metadata stored for every field of an RNTuple.
The container field for an ntuple model, which itself has no physical representation.
Definition RField.hxx:59
std::unordered_set< std::string > fSubfieldNames
Efficient detection of duplicate field names.
Definition RField.hxx:72
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
Definition RField.cxx:74
size_t GetValueSize() const final
What sizeof(T) for this type returns.
Definition RField.hxx:84
bool GetAllowFieldSubstitutions() const
Definition RField.hxx:89
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:76
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.cxx:55
size_t GetAlignment() const final
What alignof(T) for this type returns.
Definition RField.hxx:85
std::vector< std::unique_ptr< RFieldBase > > ReleaseSubfields()
Moves all subfields into the returned vector.
Definition RField.cxx:65
bool fAllowFieldSubstitutions
If field substitutions are allowed, upon connecting to a page source the field hierarchy will replace...
Definition RField.hxx:70
void Attach(std::unique_ptr< RFieldBase > child)
A public version of the Attach method that allows piece-wise construction of the zero field.
Definition RField.cxx:41
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
Get the number of elements of the collection identified by globalIndex.
Definition RField.hxx:461
RField & operator=(RField &&other)=default
std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
General implementation of bulk read.
Definition RField.hxx:478
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:458
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
Get the number of elements of the collection identified by clusterIndex.
Definition RField.hxx:470
std::unique_ptr< ROOT::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.hxx:454
size_t GetAlignment() const final
What alignof(T) for this type returns.
Definition RField.hxx:513
RField(RField &&other)=default
RField & operator=(RField &&other)=default
~RField() final=default
static std::string TypeName()
Definition RField.hxx:538
std::unique_ptr< RDeleter > GetDeleter() const final
Definition RField.hxx:530
static std::size_t GetOffsetBits()
Definition RField.hxx:521
static std::size_t GetOffsetUniqueID()
Definition RField.hxx:520
Classes with dictionaries that can be inspected by TClass.
Definition RField.hxx:322
~RField() final=default
RField(RField &&other)=default
RField & operator=(RField &&other)=default
static std::string TypeName()
Definition RField.hxx:324
RField(std::string_view name)
Definition RField.hxx:325
Used in RFieldBase::Check() to record field creation failures.
Definition RField.hxx:97
RInvalidField(std::string_view name, std::string_view type, std::string_view error, ECategory category)
Definition RField.hxx:124
@ kGeneric
Generic unrecoverable error.
@ kUnknownType
The type given to RFieldBase::Create was unknown.
@ kTypeError
The type given to RFieldBase::Create was invalid.
@ kUnknownStructure
The field could not be created because its descriptor had an unknown structural role.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.hxx:117
ECategory fCategory
Definition RField.hxx:114
size_t GetAlignment() const final
What alignof(T) for this type returns.
Definition RField.hxx:134
std::string fError
Definition RField.hxx:113
const std::string & GetError() const
Definition RField.hxx:130
ECategory GetCategory() const
Definition RField.hxx:131
size_t GetValueSize() const final
What sizeof(T) for this type returns.
Definition RField.hxx:133
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:121
A view for a collection, that can itself generate new ntuple views for its nested fields.
The on-storage metadata of an RNTuple.
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
void GenerateColumns() override
Implementations in derived classes should create the backing columns corresponding to the field type ...
Definition RField.hxx:392
size_t GetAlignment() const final
What alignof(T) for this type returns.
Definition RField.hxx:431
RSimpleField & operator=(RSimpleField &&other)=default
RSimpleField(std::string_view name, std::string_view type)
Definition RField.hxx:408
T * Map(RNTupleLocalIndex localIndex)
Definition RField.hxx:420
~RSimpleField() override=default
T * Map(ROOT::NTupleSize_t globalIndex)
Definition RField.hxx:419
size_t GetValueSize() const final
What sizeof(T) for this type returns.
Definition RField.hxx:430
void ReconcileOnDiskField(const RNTupleDescriptor &desc) override
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
Definition RField.hxx:397
RSimpleField(RSimpleField &&other)=default
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:395
T * MapV(ROOT::NTupleSize_t globalIndex, ROOT::NTupleSize_t &nItems)
Definition RField.hxx:421
void GenerateColumns(const ROOT::RNTupleDescriptor &desc) override
Implementations in derived classes should create the backing columns corresponding to the field type ...
Definition RField.hxx:393
T * MapV(RNTupleLocalIndex localIndex, ROOT::NTupleSize_t &nItems)
Definition RField.hxx:425
void operator()(void *objPtr, bool dtorOnly) final
The field for a class using ROOT standard streaming.
Definition RField.hxx:237
ROOT::RExtraTypeInfoDescriptor GetExtraTypeInfo() const final
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfos
streamer info records seen during writing
Definition RField.hxx:249
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::uint32_t GetTypeVersion() const final
Indicates an evolution of the C++ type itself.
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
ROOT::Internal::RColumnIndex fIndex
number of bytes written in the current cluster
Definition RField.hxx:250
std::uint32_t GetTypeChecksum() const final
Return the current TClass reported checksum of this class. Only valid if kTraitTypeChecksum is set.
std::unique_ptr< RFieldBase > BeforeConnectPageSource(ROOT::Internal::RPageSource &source) final
Called by ConnectPageSource() before connecting; derived classes may override this as appropriate,...
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
bool HasExtraTypeInfo() const final
Definition RField.hxx:270
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
void CommitClusterImpl() final
Definition RField.hxx:268
RStreamerField(std::string_view fieldName, TClass *classp)
size_t GetAlignment() const final
What alignof(T) for this type returns.
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
std::unique_ptr< RDeleter > GetDeleter() const final
Definition RField.hxx:263
TClass * GetClass() const
Definition RField.hxx:287
size_t GetValueSize() const final
What sizeof(T) for this type returns.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
The TEnum class implements the enum type.
Definition TEnum.h:33
Mother of all ROOT objects.
Definition TObject.h:42
Abstract Interface class describing Streamer information for one class.
void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val)
Definition RField.cxx:36
bool IsMatchingFieldType(const std::string &actualTypeName)
Helper to check if a given type name is the one expected of Field<T>.
Definition RField.hxx:561
std::string GetRenormalizedTypeName(const std::string &metaNormalizedName)
Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix.
std::string GetDemangledTypeName(const std::type_info &t)
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
ENTupleStructure
The fields in the RNTuple data model tree can carry different structural information about the type s...
std::size_t fOffset
offset in fStagingArea
Definition RField.hxx:153
std::unique_ptr< RFieldBase > fField
The field used to read the on-disk data.
Definition RField.hxx:152
Input parameter to RFieldBase::ReadBulk() and RFieldBase::ReadBulkImpl().
Helper types to present an offset column as array of collection sizes.