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
72protected:
73 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
74 void ConstructValue(void *) const final {}
75
76public:
77 RFieldZero() : RFieldBase("", "", ROOT::ENTupleStructure::kRecord, false /* isSimple */) {}
78
80 size_t GetValueSize() const final { return 0; }
81 size_t GetAlignment() const final { return 0; }
82
84
86 /// Moves all subfields into the returned vector.
87 std::vector<std::unique_ptr<RFieldBase>> ReleaseSubfields();
88};
89
90/// Used in RFieldBase::Check() to record field creation failures.
91/// Also used when deserializing a field that contains unknown values that may come from
92/// future RNTuple versions (e.g. an unknown Structure)
94public:
95 enum class ECategory {
96 /// Generic unrecoverable error
98 /// The type given to RFieldBase::Create was invalid
100 /// The type given to RFieldBase::Create was unknown
102 /// The field could not be created because its descriptor had an unknown structural role
104 };
105
106 using RCategory R__DEPRECATED(6, 42, "enum renamed to ECategory") = ECategory;
107
108private:
109 std::string fError;
111
112protected:
113 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final
114 {
115 return std::make_unique<RInvalidField>(newName, GetTypeName(), fError, fCategory);
116 }
117 void ConstructValue(void *) const final {}
118
119public:
120 RInvalidField(std::string_view name, std::string_view type, std::string_view error, ECategory category)
121 : RFieldBase(name, type, ROOT::ENTupleStructure::kPlain, false /* isSimple */), fError(error), fCategory(category)
122 {
124 }
125
126 const std::string &GetError() const { return fError; }
127 ECategory GetCategory() const { return fCategory; }
128
129 size_t GetValueSize() const final { return 0; }
130 size_t GetAlignment() const final { return 0; }
131}; // RInvalidField
132
133/// The field for a class with dictionary
134class RClassField : public RFieldBase {
135private:
142 std::size_t fOffset;
143 };
144 // Information to read into the staging area a field that is used as an input to an I/O customization rule
146 /// The field used to read the on-disk data. The fields type may be different from the on-disk type as long
147 /// as the on-disk type can be converted to the fields type (through type cast / schema evolution).
148 std::unique_ptr<RFieldBase> fField;
149 std::size_t fOffset; ///< offset in fStagingArea
150 };
151 /// Prefix used in the subfield names generated for base classes
152 static constexpr const char *kPrefixInherited{":"};
153
154 class RClassDeleter : public RDeleter {
155 private:
157
158 public:
159 explicit RClassDeleter(TClass *cl) : fClass(cl) {}
160 void operator()(void *objPtr, bool dtorOnly) final;
161 };
162
164 /// Additional information kept for each entry in `fSubfields`
165 std::vector<RSubFieldInfo> fSubfieldsInfo;
166 std::size_t fMaxAlignment = 1;
167
168 /// The staging area stores inputs to I/O rules according to the offsets given by the streamer info of
169 /// "TypeName@@Version". The area is allocated depending on I/O rules resp. the source members of the I/O rules.
170 std::unique_ptr<unsigned char[]> fStagingArea;
171 /// The TClass instance that corresponds to the staging area.
172 /// The staging class exists as <class name>@@<on-disk version> if the on-disk version is different from the
173 /// current in-memory version, or it can be accessed by the first @@alloc streamer element of the current streamer
174 /// info.
176 std::unordered_map<std::string, RStagingItem> fStagingItems; ///< Lookup staging items by member name
177
178private:
179 RClassField(std::string_view fieldName, const RClassField &source); ///< Used by CloneImpl
180 RClassField(std::string_view fieldName, TClass *classp);
181 void Attach(std::unique_ptr<RFieldBase> child, RSubFieldInfo info);
182
183 /// Returns the id of member 'name' in the class field given by 'fieldId', or kInvalidDescriptorId if no such
184 /// member exist. Looks recursively in base classes.
187 /// Sets fStagingClass according to the given name and version
188 void SetStagingClass(const std::string &className, unsigned int classVersion);
189 /// If there are rules with inputs (source members), create the staging area according to the TClass instance
190 /// that corresponds to the on-disk field.
191 void PrepareStagingArea(const std::vector<const TSchemaRule *> &rules, const ROOT::RNTupleDescriptor &desc,
193 /// Register post-read callback corresponding to a ROOT I/O customization rules.
195 /// Given the on-disk information from the page source, find all the I/O customization rules that apply
196 /// to the class field at hand, to which the fieldDesc descriptor, if provided, must correspond.
197 /// Fields may not have an on-disk representation (e.g., when inserted by schema evolution), in which case the passed
198 /// field descriptor is nullptr.
199 std::vector<const TSchemaRule *> FindRules(const ROOT::RFieldDescriptor *fieldDesc);
200
201protected:
202 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
203
204 void ConstructValue(void *where) const final;
205 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RClassDeleter>(fClass); }
206
207 std::size_t AppendImpl(const void *from) final;
208 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
209 void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final;
210
211 std::unique_ptr<RFieldBase> BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final;
212 void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
213
214public:
215 RClassField(std::string_view fieldName, std::string_view className);
218 ~RClassField() override;
219
220 std::vector<RValue> SplitValue(const RValue &value) const final;
221 size_t GetValueSize() const final;
223 std::uint32_t GetTypeVersion() const final;
224 std::uint32_t GetTypeChecksum() const final;
226};
227
228/// The field for a class using ROOT standard streaming
230private:
232 private:
234
235 public:
236 explicit RStreamerFieldDeleter(TClass *cl) : fClass(cl) {}
237 void operator()(void *objPtr, bool dtorOnly) final;
238 };
239
240 TClass *fClass = nullptr;
241 ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfos; ///< streamer info records seen during writing
242 ROOT::Internal::RColumnIndex fIndex; ///< number of bytes written in the current cluster
243
244private:
245 RStreamerField(std::string_view fieldName, TClass *classp);
246
247protected:
248 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
249
251 void GenerateColumns() final;
253
254 void ConstructValue(void *where) const final;
255 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RStreamerFieldDeleter>(fClass); }
256
257 std::size_t AppendImpl(const void *from) final;
258 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
259
260 void CommitClusterImpl() final { fIndex = 0; }
261
262 bool HasExtraTypeInfo() const final { return true; }
263 // Returns the list of seen streamer infos
265
266 std::unique_ptr<RFieldBase> BeforeConnectPageSource(ROOT::Internal::RPageSource &source) final;
268
269public:
270 RStreamerField(std::string_view fieldName, std::string_view className, std::string_view typeAlias = "");
274
275 size_t GetValueSize() const final;
276 size_t GetAlignment() const final;
277 std::uint32_t GetTypeVersion() const final;
278 std::uint32_t GetTypeChecksum() const final;
280};
281
282/// The field for an unscoped or scoped enum with dictionary
284private:
285 REnumField(std::string_view fieldName, TEnum *enump);
286 REnumField(std::string_view fieldName, std::string_view enumName, std::unique_ptr<RFieldBase> intField);
287
288protected:
289 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
290
291 void ConstructValue(void *where) const final { CallConstructValueOn(*fSubfields[0], where); }
292
293 std::size_t AppendImpl(const void *from) final { return CallAppendOn(*fSubfields[0], from); }
296
297 void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
298
299public:
300 REnumField(std::string_view fieldName, std::string_view enumName);
303 ~REnumField() override = default;
304
305 std::vector<RValue> SplitValue(const RValue &value) const final;
306 size_t GetValueSize() const final { return fSubfields[0]->GetValueSize(); }
307 size_t GetAlignment() const final { return fSubfields[0]->GetAlignment(); }
309};
310
311/// Classes with dictionaries that can be inspected by TClass
312template <typename T, typename = void>
313class RField final : public RClassField {
314public:
315 static std::string TypeName() { return ROOT::Internal::GetRenormalizedTypeName(typeid(T)); }
316 RField(std::string_view name) : RClassField(name, TypeName())
317 {
318 static_assert(std::is_class_v<T>, "no I/O support for this basic C++ type");
319 }
320 RField(RField &&other) = default;
323};
324
327public:
328 static std::string TypeName() { return ROOT::Internal::GetRenormalizedTypeName(typeid(T)); }
329 RField(std::string_view name) : REnumField(name, TypeName()) {}
330 RField(RField &&other) = default;
331 RField &operator=(RField &&other) = default;
332 ~RField() final = default;
333};
334
335/// An artificial field that transforms an RNTuple column that contains the offset of collections into
336/// collection sizes. It is only used for reading, e.g. as projected field or as an artificial field that provides the
337/// "number of" RDF columns for collections (e.g. `R_rdf_sizeof_jets` for a collection named `jets`).
338/// It is used in the templated RField<RNTupleCardinality<SizeT>> form, which represents the collection sizes either
339/// as 32bit unsigned int (std::uint32_t) or as 64bit unsigned int (std::uint64_t).
341 friend class ROOT::RNTupleCollectionView; // to access GetCollectionInfo()
342
343private:
352
353protected:
354 RCardinalityField(std::string_view fieldName, std::string_view typeName)
355 : RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kPlain, false /* isSimple */)
356 {
357 }
358
359 const RColumnRepresentations &GetColumnRepresentations() const final;
360 // Field is only used for reading
361 void GenerateColumns() final { throw RException(R__FAIL("Cardinality fields must only be used for reading")); }
362 void GenerateColumns(const ROOT::RNTupleDescriptor &) final;
363
364 void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
365
366public:
369 ~RCardinalityField() override = default;
370
371 void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final;
372
373 const RField<RNTupleCardinality<std::uint32_t>> *As32Bit() const;
374 const RField<RNTupleCardinality<std::uint64_t>> *As64Bit() const;
375};
376
377template <typename T>
378class RSimpleField : public RFieldBase {
379 void ReconcileIntegralField(const RNTupleDescriptor &desc);
380 void ReconcileFloatingPointField(const RNTupleDescriptor &desc);
381
382protected:
385
386 void ConstructValue(void *where) const final { new (where) T{0}; }
387
388 void ReconcileOnDiskField(const RNTupleDescriptor &desc) override
389 {
390 if constexpr (std::is_integral_v<T>) {
391 ReconcileIntegralField(desc);
392 } else if constexpr (std::is_floating_point_v<T>) {
393 ReconcileFloatingPointField(desc);
394 } else {
395 RFieldBase::ReconcileOnDiskField(desc);
396 }
397 }
398
399 RSimpleField(std::string_view name, std::string_view type)
400 : RFieldBase(name, type, ROOT::ENTupleStructure::kPlain, true /* isSimple */)
401 {
402 fTraits |= kTraitTrivialType;
403 }
404
405public:
408 ~RSimpleField() override = default;
409
410 T *Map(ROOT::NTupleSize_t globalIndex) { return fPrincipalColumn->Map<T>(globalIndex); }
411 T *Map(RNTupleLocalIndex localIndex) { return fPrincipalColumn->Map<T>(localIndex); }
413 {
414 return fPrincipalColumn->MapV<T>(globalIndex, nItems);
415 }
417 {
418 return fPrincipalColumn->MapV<T>(localIndex, nItems);
419 }
420
421 size_t GetValueSize() const final { return sizeof(T); }
422 size_t GetAlignment() const final { return alignof(T); }
423};
424
425////////////////////////////////////////////////////////////////////////////////
426/// Template specializations for concrete C++ types
427////////////////////////////////////////////////////////////////////////////////
428
429} // namespace ROOT
430
436
437namespace ROOT {
438
439template <typename SizeT>
442
443protected:
444 std::unique_ptr<ROOT::RFieldBase> CloneImpl(std::string_view newName) const final
445 {
446 return std::make_unique<RField>(newName);
447 }
448 void ConstructValue(void *where) const final { new (where) CardinalityType(0); }
449
450 /// Get the number of elements of the collection identified by globalIndex
452 {
455 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &size);
456 *static_cast<CardinalityType *>(to) = size;
457 }
458
459 /// Get the number of elements of the collection identified by clusterIndex
461 {
464 fPrincipalColumn->GetCollectionInfo(localIndex, &collectionStart, &size);
465 *static_cast<CardinalityType *>(to) = size;
466 }
467
468 std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
469 {
472 fPrincipalColumn->GetCollectionInfo(bulkSpec.fFirstIndex, &collectionStart, &collectionSize);
473
474 auto typedValues = static_cast<CardinalityType *>(bulkSpec.fValues);
476
477 auto lastOffset = collectionStart.GetIndexInCluster() + collectionSize;
479 std::size_t nEntries = 1;
480 while (nRemainingEntries > 0) {
482 auto offsets =
483 fPrincipalColumn->MapV<ROOT::Internal::RColumnIndex>(bulkSpec.fFirstIndex + nEntries, nItemsUntilPageEnd);
484 std::size_t nBatch = std::min(nRemainingEntries, nItemsUntilPageEnd);
485 for (std::size_t i = 0; i < nBatch; ++i) {
486 typedValues[nEntries + i] = offsets[i] - lastOffset;
487 lastOffset = offsets[i];
488 }
490 nEntries += nBatch;
491 }
492 return RBulkSpec::kAllSet;
493 }
494
495public:
496 static std::string TypeName() { return "ROOT::RNTupleCardinality<" + RField<SizeT>::TypeName() + ">"; }
497 explicit RField(std::string_view name) : RCardinalityField(name, TypeName()) {}
498 RField(RField &&other) = default;
501
502 size_t GetValueSize() const final { return sizeof(CardinalityType); }
503 size_t GetAlignment() const final { return alignof(CardinalityType); }
504};
505
506/// TObject requires special handling of the fBits and fUniqueID members
507template <>
509 static std::size_t GetOffsetOfMember(const char *name);
510 static std::size_t GetOffsetUniqueID() { return GetOffsetOfMember("fUniqueID"); }
511 static std::size_t GetOffsetBits() { return GetOffsetOfMember("fBits"); }
512
513private:
514 RField(std::string_view fieldName, const RField<TObject> &source); ///< Used by CloneImpl()
515
516protected:
517 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
518
519 void ConstructValue(void *where) const final;
520 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RTypedDeleter<TObject>>(); }
521
522 std::size_t AppendImpl(const void *from) final;
523 void ReadTObject(void *to, UInt_t uniqueID, UInt_t bits);
524 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
525 void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final;
526
527public:
528 static std::string TypeName() { return "TObject"; }
529
530 RField(std::string_view fieldName);
531 RField(RField &&other) = default;
534
535 std::vector<RValue> SplitValue(const RValue &value) const final;
536 size_t GetValueSize() const final;
537 size_t GetAlignment() const final;
538 std::uint32_t GetTypeVersion() const final;
539 std::uint32_t GetTypeChecksum() const final;
540 void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final;
541};
542
543// Have to be implemented after the definition of all RField<T> types
544
545namespace Internal {
546
547/// Helper to check if a given type name is the one expected of Field<T>. Usually, this check can be done by
548/// type renormalization of the demangled type name T. The failure case, however, needs to additionally check for
549/// ROOT-specific special cases.
550template <class T>
551bool IsMatchingFieldType(const std::string &actualTypeName)
552{
554}
555
556} // namespace Internal
557
558template <typename T>
559std::unique_ptr<T, typename RFieldBase::RCreateObjectDeleter<T>::deleter> RFieldBase::CreateObject() const
560{
561 if (!Internal::IsMatchingFieldType<T>(GetTypeName())) {
562 throw RException(
563 R__FAIL("type mismatch for field " + GetFieldName() + ": " + GetTypeName() + " vs. " + RField<T>::TypeName()));
564 }
565 return std::unique_ptr<T>(static_cast<T *>(CreateObjectRawPtr()));
566}
567
568// The void type is specialized in RField.cxx
569
570template <>
575
576template <>
577std::unique_ptr<void, typename RFieldBase::RCreateObjectDeleter<void>::deleter>
578ROOT::RFieldBase::CreateObject<void>() const;
579
580} // namespace ROOT
581
582#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: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:110
TRObject operator()(const T1 &t1) const
Binding & operator=(OUT(*fun)(void))
Abstract base class for classes implementing the visitor design pattern.
The in-memory representation of a 32bit or 64bit on-disk index column.
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:340
RCardinalityField(RCardinalityField &&other)=default
void GetCollectionInfo(ROOT::NTupleSize_t globalIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *size)
Definition RField.hxx:344
RCardinalityField & operator=(RCardinalityField &&other)=default
void GetCollectionInfo(RNTupleLocalIndex localIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *size)
Definition RField.hxx:348
~RCardinalityField() override=default
RCardinalityField(std::string_view fieldName, std::string_view typeName)
Definition RField.hxx:354
void operator()(void *objPtr, bool dtorOnly) final
The field for a class with dictionary.
Definition RField.hxx:134
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:175
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::vector< RSubFieldInfo > fSubfieldsInfo
Additional information kept for each entry in fSubfields
Definition RField.hxx:165
std::size_t fMaxAlignment
Definition RField.hxx:166
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
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:170
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:222
RClassField & operator=(RClassField &&other)=default
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
void Attach(std::unique_ptr< RFieldBase > child, RSubFieldInfo info)
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:163
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.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
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.
~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:205
std::unordered_map< std::string, RStagingItem > fStagingItems
Lookup staging items by member name.
Definition RField.hxx:176
static constexpr const char * kPrefixInherited
Prefix used in the subfield names generated for base classes.
Definition RField.hxx:152
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:283
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:306
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:307
~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:291
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
Definition RField.hxx:295
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
Definition RField.hxx:294
REnumField & operator=(REnumField &&other)=default
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
Definition RField.hxx:293
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.
void Attach(std::unique_ptr< RFieldBase > child)
Add a new subfield to the list of nested fields.
std::vector< std::unique_ptr< RFieldBase > > fSubfields
Collections and classes own subfields.
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
virtual void GenerateColumns()
Implementations in derived classes should create the backing columns corresponding 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.
std::uint32_t fTraits
Properties of the type that allow for optimizations of collections of that type.
const std::string & GetTypeName() const
@ kTraitInvalidField
This field is an instance of RInvalidField and can be safely static_cast to it.
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.
virtual ROOT::RExtraTypeInfoDescriptor GetExtraTypeInfo() const
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
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
Definition RField.cxx:56
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:80
bool GetAllowFieldSubstitutions() const
Definition RField.hxx:85
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:74
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.cxx:39
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:81
std::vector< std::unique_ptr< RFieldBase > > ReleaseSubfields()
Moves all subfields into the returned vector.
Definition RField.cxx:47
bool fAllowFieldSubstitutions
If field substitutions are allowed, upon connecting to a page source the field hierarchy will replace...
Definition RField.hxx:70
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
Get the number of elements of the collection identified by globalIndex.
Definition RField.hxx:451
RField & operator=(RField &&other)=default
std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
General implementation of bulk read.
Definition RField.hxx:468
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:448
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
Get the number of elements of the collection identified by clusterIndex.
Definition RField.hxx:460
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:444
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:503
RField(RField &&other)=default
RField & operator=(RField &&other)=default
~RField() final=default
static std::string TypeName()
Definition RField.hxx:528
std::unique_ptr< RDeleter > GetDeleter() const final
Definition RField.hxx:520
static std::size_t GetOffsetBits()
Definition RField.hxx:511
static std::size_t GetOffsetUniqueID()
Definition RField.hxx:510
Classes with dictionaries that can be inspected by TClass.
Definition RField.hxx:313
~RField() final=default
RField(RField &&other)=default
RField & operator=(RField &&other)=default
static std::string TypeName()
Definition RField.hxx:315
RField(std::string_view name)
Definition RField.hxx:316
Used in RFieldBase::Check() to record field creation failures.
Definition RField.hxx:93
RInvalidField(std::string_view name, std::string_view type, std::string_view error, ECategory category)
Definition RField.hxx:120
@ 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:113
ECategory fCategory
Definition RField.hxx:110
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:130
std::string fError
Definition RField.hxx:109
const std::string & GetError() const
Definition RField.hxx:126
ECategory GetCategory() const
Definition RField.hxx:127
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:129
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:117
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:383
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:422
RSimpleField & operator=(RSimpleField &&other)=default
RSimpleField(std::string_view name, std::string_view type)
Definition RField.hxx:399
T * Map(RNTupleLocalIndex localIndex)
Definition RField.hxx:411
~RSimpleField() override=default
T * Map(ROOT::NTupleSize_t globalIndex)
Definition RField.hxx:410
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:421
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:388
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:386
T * MapV(ROOT::NTupleSize_t globalIndex, ROOT::NTupleSize_t &nItems)
Definition RField.hxx:412
void GenerateColumns(const ROOT::RNTupleDescriptor &desc) override
Implementations in derived classes should create the backing columns corresponding to the field type ...
Definition RField.hxx:384
T * MapV(RNTupleLocalIndex localIndex, ROOT::NTupleSize_t &nItems)
Definition RField.hxx:416
The field for a class using ROOT standard streaming.
Definition RField.hxx:229
ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfos
streamer info records seen during writing
Definition RField.hxx:241
ROOT::Internal::RColumnIndex fIndex
number of bytes written in the current cluster
Definition RField.hxx:242
bool HasExtraTypeInfo() const final
Definition RField.hxx:262
void CommitClusterImpl() final
Definition RField.hxx:260
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:41
Abstract Interface class describing Streamer information for one class.
void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val)
Definition RField.cxx:34
bool IsMatchingFieldType(const std::string &actualTypeName)
Helper to check if a given type name is the one expected of Field<T>.
Definition RField.hxx:551
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::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:149
std::unique_ptr< RFieldBase > fField
The field used to read the on-disk data.
Definition RField.hxx:148
Input parameter to RFieldBase::ReadBulk() and RFieldBase::ReadBulkImpl().
Helper types to present an offset column as array of collection sizes.