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
52/// The container field for an ntuple model, which itself has no physical representation.
53/// Therefore, the zero field must not be connected to a page source or sink.
54class RFieldZero final : public RFieldBase {
55protected:
56 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
57 void ConstructValue(void *) const final {}
58
59public:
60 RFieldZero() : RFieldBase("", "", ROOT::ENTupleStructure::kRecord, false /* isSimple */) {}
61
63 size_t GetValueSize() const final { return 0; }
64 size_t GetAlignment() const final { return 0; }
65
67};
68
69/// Used in RFieldBase::Check() to record field creation failures.
70/// Also used when deserializing a field that contains unknown values that may come from
71/// future RNTuple versions (e.g. an unknown Structure)
73public:
74 enum class ECategory {
75 /// Generic unrecoverable error
77 /// The type given to RFieldBase::Create was invalid
79 /// The type given to RFieldBase::Create was unknown
81 /// The field could not be created because its descriptor had an unknown structural role
83 };
84
85 using RCategory R__DEPRECATED(6, 42, "enum renamed to ECategory") = ECategory;
86
87private:
88 std::string fError;
90
91protected:
92 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final
93 {
94 return std::make_unique<RInvalidField>(newName, GetTypeName(), fError, fCategory);
95 }
96 void ConstructValue(void *) const final {}
97
98public:
99 RInvalidField(std::string_view name, std::string_view type, std::string_view error, ECategory category)
101 {
103 }
104
105 const std::string &GetError() const { return fError; }
106 ECategory GetCategory() const { return fCategory; }
107
108 size_t GetValueSize() const final { return 0; }
109 size_t GetAlignment() const final { return 0; }
110}; // RInvalidField
111
112/// The field for a class with dictionary
113class RClassField : public RFieldBase {
114private:
121 std::size_t fOffset;
122 };
123 // Information to read into the staging area a field that is used as an input to an I/O customization rule
125 /// The field used to read the on-disk data. The fields type may be different from the on-disk type as long
126 /// as the on-disk type can be converted to the fields type (through type cast / schema evolution).
127 std::unique_ptr<RFieldBase> fField;
128 std::size_t fOffset; ///< offset in fStagingArea
129 };
130 /// Prefix used in the subfield names generated for base classes
131 static constexpr const char *kPrefixInherited{":"};
132
133 class RClassDeleter : public RDeleter {
134 private:
136
137 public:
138 explicit RClassDeleter(TClass *cl) : fClass(cl) {}
139 void operator()(void *objPtr, bool dtorOnly) final;
140 };
141
143 /// Additional information kept for each entry in `fSubfields`
144 std::vector<RSubFieldInfo> fSubfieldsInfo;
145 std::size_t fMaxAlignment = 1;
146
147 /// The staging area stores inputs to I/O rules according to the offsets given by the streamer info of
148 /// "TypeName@@Version". The area is allocated depending on I/O rules resp. the source members of the I/O rules.
149 std::unique_ptr<unsigned char[]> fStagingArea;
150 /// The TClass instance that corresponds to the staging area.
151 /// The staging class exists as <class name>@@<on-disk version> if the on-disk version is different from the
152 /// current in-memory version, or it can be accessed by the first @@alloc streamer element of the current streamer
153 /// info.
155 std::unordered_map<std::string, RStagingItem> fStagingItems; ///< Lookup staging items by member name
156
157private:
158 RClassField(std::string_view fieldName, const RClassField &source); ///< Used by CloneImpl
159 RClassField(std::string_view fieldName, TClass *classp);
160 void Attach(std::unique_ptr<RFieldBase> child, RSubFieldInfo info);
161
162 /// Returns the id of member 'name' in the class field given by 'fieldId', or kInvalidDescriptorId if no such
163 /// member exist. Looks recursively in base classes.
166 /// Sets fStagingClass according to the given name and version
167 void SetStagingClass(const std::string &className, unsigned int classVersion);
168 /// If there are rules with inputs (source members), create the staging area according to the TClass instance
169 /// that corresponds to the on-disk field.
170 void PrepareStagingArea(const std::vector<const TSchemaRule *> &rules, const ROOT::RNTupleDescriptor &desc,
172 /// Register post-read callback corresponding to a ROOT I/O customization rules.
174 /// Given the on-disk information from the page source, find all the I/O customization rules that apply
175 /// to the class field at hand, to which the fieldDesc descriptor, if provided, must correspond.
176 /// Fields may not have an on-disk representation (e.g., when inserted by schema evolution), in which case the passed
177 /// field descriptor is nullptr.
178 std::vector<const TSchemaRule *> FindRules(const ROOT::RFieldDescriptor *fieldDesc);
179
180protected:
181 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
182
183 void ConstructValue(void *where) const final;
184 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RClassDeleter>(fClass); }
185
186 std::size_t AppendImpl(const void *from) final;
187 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
188 void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final;
189
191 void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
192
193public:
194 RClassField(std::string_view fieldName, std::string_view className);
197 ~RClassField() override;
198
199 std::vector<RValue> SplitValue(const RValue &value) const final;
200 size_t GetValueSize() const final;
202 std::uint32_t GetTypeVersion() const final;
203 std::uint32_t GetTypeChecksum() const final;
205};
206
207/// The field for a class using ROOT standard streaming
209private:
211 private:
213
214 public:
215 explicit RStreamerFieldDeleter(TClass *cl) : fClass(cl) {}
216 void operator()(void *objPtr, bool dtorOnly) final;
217 };
218
219 TClass *fClass = nullptr;
220 ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfos; ///< streamer info records seen during writing
221 ROOT::Internal::RColumnIndex fIndex; ///< number of bytes written in the current cluster
222
223private:
224 RStreamerField(std::string_view fieldName, TClass *classp);
225
226protected:
227 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
228
230 void GenerateColumns() final;
232
233 void ConstructValue(void *where) const final;
234 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RStreamerFieldDeleter>(fClass); }
235
236 std::size_t AppendImpl(const void *from) final;
237 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
238
239 void CommitClusterImpl() final { fIndex = 0; }
240
241 bool HasExtraTypeInfo() const final { return true; }
242 // Returns the list of seen streamer infos
244
247
248public:
249 RStreamerField(std::string_view fieldName, std::string_view className, std::string_view typeAlias = "");
253
254 size_t GetValueSize() const final;
255 size_t GetAlignment() const final;
256 std::uint32_t GetTypeVersion() const final;
257 std::uint32_t GetTypeChecksum() const final;
259};
260
261/// The field for an unscoped or scoped enum with dictionary
263private:
264 REnumField(std::string_view fieldName, TEnum *enump);
265 REnumField(std::string_view fieldName, std::string_view enumName, std::unique_ptr<RFieldBase> intField);
266
267protected:
268 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
269
270 void ConstructValue(void *where) const final { CallConstructValueOn(*fSubfields[0], where); }
271
272 std::size_t AppendImpl(const void *from) final { return CallAppendOn(*fSubfields[0], from); }
275
276 void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
277
278public:
279 REnumField(std::string_view fieldName, std::string_view enumName);
282 ~REnumField() override = default;
283
284 std::vector<RValue> SplitValue(const RValue &value) const final;
285 size_t GetValueSize() const final { return fSubfields[0]->GetValueSize(); }
286 size_t GetAlignment() const final { return fSubfields[0]->GetAlignment(); }
288};
289
290/// Classes with dictionaries that can be inspected by TClass
291template <typename T, typename = void>
292class RField final : public RClassField {
293public:
294 static std::string TypeName() { return ROOT::Internal::GetRenormalizedTypeName(typeid(T)); }
295 RField(std::string_view name) : RClassField(name, TypeName())
296 {
297 static_assert(std::is_class_v<T>, "no I/O support for this basic C++ type");
298 }
299 RField(RField &&other) = default;
302};
303
306public:
307 static std::string TypeName() { return ROOT::Internal::GetRenormalizedTypeName(typeid(T)); }
308 RField(std::string_view name) : REnumField(name, TypeName()) {}
309 RField(RField &&other) = default;
310 RField &operator=(RField &&other) = default;
311 ~RField() final = default;
312};
313
314/// An artificial field that transforms an RNTuple column that contains the offset of collections into
315/// collection sizes. It is only used for reading, e.g. as projected field or as an artificial field that provides the
316/// "number of" RDF columns for collections (e.g. `R_rdf_sizeof_jets` for a collection named `jets`).
317/// It is used in the templated RField<RNTupleCardinality<SizeT>> form, which represents the collection sizes either
318/// as 32bit unsigned int (std::uint32_t) or as 64bit unsigned int (std::uint64_t).
320 friend class ROOT::RNTupleCollectionView; // to access GetCollectionInfo()
321
322private:
331
332protected:
333 RCardinalityField(std::string_view fieldName, std::string_view typeName)
334 : RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kPlain, false /* isSimple */)
335 {
336 }
337
338 const RColumnRepresentations &GetColumnRepresentations() const final;
339 // Field is only used for reading
340 void GenerateColumns() final { throw RException(R__FAIL("Cardinality fields must only be used for reading")); }
341 void GenerateColumns(const ROOT::RNTupleDescriptor &) final;
342
343 void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
344
345public:
348 ~RCardinalityField() override = default;
349
350 void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final;
351
352 const RField<RNTupleCardinality<std::uint32_t>> *As32Bit() const;
353 const RField<RNTupleCardinality<std::uint64_t>> *As64Bit() const;
354};
355
356template <typename T>
357class RSimpleField : public RFieldBase {
358protected:
361
362 void ConstructValue(void *where) const final { new (where) T{0}; }
363
365 {
366 // Differences in the type name don't matter for simple fields; the valid column representations take
367 // care of (allowed) schema differences.
368 EnsureMatchingOnDiskField(desc.GetFieldDescriptor(GetOnDiskId()), kDiffTypeName);
369 }
370
371 RSimpleField(std::string_view name, std::string_view type)
372 : RFieldBase(name, type, ROOT::ENTupleStructure::kPlain, true /* isSimple */)
373 {
374 fTraits |= kTraitTrivialType;
375 }
376
377public:
380 ~RSimpleField() override = default;
381
382 T *Map(ROOT::NTupleSize_t globalIndex) { return fPrincipalColumn->Map<T>(globalIndex); }
383 T *Map(RNTupleLocalIndex localIndex) { return fPrincipalColumn->Map<T>(localIndex); }
385 {
386 return fPrincipalColumn->MapV<T>(globalIndex, nItems);
387 }
389 {
390 return fPrincipalColumn->MapV<T>(localIndex, nItems);
391 }
392
393 size_t GetValueSize() const final { return sizeof(T); }
394 size_t GetAlignment() const final { return alignof(T); }
395};
396
397////////////////////////////////////////////////////////////////////////////////
398/// Template specializations for concrete C++ types
399////////////////////////////////////////////////////////////////////////////////
400
401} // namespace ROOT
402
408
409namespace ROOT {
410
411template <typename SizeT>
414
415protected:
416 std::unique_ptr<ROOT::RFieldBase> CloneImpl(std::string_view newName) const final
417 {
418 return std::make_unique<RField>(newName);
419 }
420 void ConstructValue(void *where) const final { new (where) CardinalityType(0); }
421
422 /// Get the number of elements of the collection identified by globalIndex
424 {
427 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &size);
428 *static_cast<CardinalityType *>(to) = size;
429 }
430
431 /// Get the number of elements of the collection identified by clusterIndex
433 {
436 fPrincipalColumn->GetCollectionInfo(localIndex, &collectionStart, &size);
437 *static_cast<CardinalityType *>(to) = size;
438 }
439
440 std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
441 {
444 fPrincipalColumn->GetCollectionInfo(bulkSpec.fFirstIndex, &collectionStart, &collectionSize);
445
446 auto typedValues = static_cast<CardinalityType *>(bulkSpec.fValues);
448
449 auto lastOffset = collectionStart.GetIndexInCluster() + collectionSize;
451 std::size_t nEntries = 1;
452 while (nRemainingEntries > 0) {
454 auto offsets =
455 fPrincipalColumn->MapV<ROOT::Internal::RColumnIndex>(bulkSpec.fFirstIndex + nEntries, nItemsUntilPageEnd);
456 std::size_t nBatch = std::min(nRemainingEntries, nItemsUntilPageEnd);
457 for (std::size_t i = 0; i < nBatch; ++i) {
458 typedValues[nEntries + i] = offsets[i] - lastOffset;
459 lastOffset = offsets[i];
460 }
462 nEntries += nBatch;
463 }
464 return RBulkSpec::kAllSet;
465 }
466
467public:
468 static std::string TypeName() { return "ROOT::RNTupleCardinality<" + RField<SizeT>::TypeName() + ">"; }
469 explicit RField(std::string_view name) : RCardinalityField(name, TypeName()) {}
470 RField(RField &&other) = default;
473
474 size_t GetValueSize() const final { return sizeof(CardinalityType); }
475 size_t GetAlignment() const final { return alignof(CardinalityType); }
476};
477
478/// TObject requires special handling of the fBits and fUniqueID members
479template <>
481 static std::size_t GetOffsetOfMember(const char *name);
482 static std::size_t GetOffsetUniqueID() { return GetOffsetOfMember("fUniqueID"); }
483 static std::size_t GetOffsetBits() { return GetOffsetOfMember("fBits"); }
484
485private:
486 RField(std::string_view fieldName, const RField<TObject> &source); ///< Used by CloneImpl()
487
488protected:
489 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
490
491 void ConstructValue(void *where) const final;
492 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RTypedDeleter<TObject>>(); }
493
494 std::size_t AppendImpl(const void *from) final;
495 void ReadTObject(void *to, UInt_t uniqueID, UInt_t bits);
496 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
497 void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final;
498
499public:
500 static std::string TypeName() { return "TObject"; }
501
502 RField(std::string_view fieldName);
503 RField(RField &&other) = default;
506
507 std::vector<RValue> SplitValue(const RValue &value) const final;
508 size_t GetValueSize() const final;
509 size_t GetAlignment() const final;
510 std::uint32_t GetTypeVersion() const final;
511 std::uint32_t GetTypeChecksum() const final;
512 void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final;
513};
514
515// Have to be implemented after the definition of all RField<T> types
516
517namespace Internal {
518
519/// Helper to check if a given type name is the one expected of Field<T>. Usually, this check can be done by
520/// type renormalization of the demangled type name T. The failure case, however, needs to additionally check for
521/// ROOT-specific special cases.
522template <class T>
523bool IsMatchingFieldType(const std::string &actualTypeName)
524{
526}
527
528} // namespace Internal
529
530template <typename T>
531std::unique_ptr<T, typename RFieldBase::RCreateObjectDeleter<T>::deleter> RFieldBase::CreateObject() const
532{
533 if (!Internal::IsMatchingFieldType<T>(GetTypeName())) {
534 throw RException(
535 R__FAIL("type mismatch for field " + GetFieldName() + ": " + GetTypeName() + " vs. " + RField<T>::TypeName()));
536 }
537 return std::unique_ptr<T>(static_cast<T *>(CreateObjectRawPtr()));
538}
539
540// The void type is specialized in RField.cxx
541
542template <>
547
548template <>
549std::unique_ptr<void, typename RFieldBase::RCreateObjectDeleter<void>::deleter>
550ROOT::RFieldBase::CreateObject<void>() const;
551
552} // namespace ROOT
553
554#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:319
RCardinalityField(RCardinalityField &&other)=default
void GetCollectionInfo(ROOT::NTupleSize_t globalIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *size)
Definition RField.hxx:323
RCardinalityField & operator=(RCardinalityField &&other)=default
void GetCollectionInfo(RNTupleLocalIndex localIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *size)
Definition RField.hxx:327
~RCardinalityField() override=default
RCardinalityField(std::string_view fieldName, std::string_view typeName)
Definition RField.hxx:333
void operator()(void *objPtr, bool dtorOnly) final
The field for a class with dictionary.
Definition RField.hxx:113
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:154
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:144
std::size_t fMaxAlignment
Definition RField.hxx:145
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:149
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:201
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:142
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:184
std::unordered_map< std::string, RStagingItem > fStagingItems
Lookup staging items by member name.
Definition RField.hxx:155
static constexpr const char * kPrefixInherited
Prefix used in the subfield names generated for base classes.
Definition RField.hxx:131
void SetStagingClass(const std::string &className, unsigned int classVersion)
Sets fStagingClass according to the given name and version.
void BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final
Called by ConnectPageSource() before connecting; derived classes may override this as appropriate,...
The field for an unscoped or scoped enum with dictionary.
Definition RField.hxx:262
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:285
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:286
~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:270
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
Definition RField.hxx:274
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
Definition RField.hxx:273
REnumField & operator=(REnumField &&other)=default
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
Definition RField.hxx:272
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:54
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
Definition RField.cxx:42
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:63
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:57
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition RField.cxx:34
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:64
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
Get the number of elements of the collection identified by globalIndex.
Definition RField.hxx:423
RField & operator=(RField &&other)=default
std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
General implementation of bulk read.
Definition RField.hxx:440
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:420
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
Get the number of elements of the collection identified by clusterIndex.
Definition RField.hxx:432
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:416
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:475
RField(RField &&other)=default
RField & operator=(RField &&other)=default
~RField() final=default
static std::string TypeName()
Definition RField.hxx:500
std::unique_ptr< RDeleter > GetDeleter() const final
Definition RField.hxx:492
static std::size_t GetOffsetBits()
Definition RField.hxx:483
static std::size_t GetOffsetUniqueID()
Definition RField.hxx:482
Classes with dictionaries that can be inspected by TClass.
Definition RField.hxx:292
~RField() final=default
RField(RField &&other)=default
RField & operator=(RField &&other)=default
static std::string TypeName()
Definition RField.hxx:294
RField(std::string_view name)
Definition RField.hxx:295
Used in RFieldBase::Check() to record field creation failures.
Definition RField.hxx:72
RInvalidField(std::string_view name, std::string_view type, std::string_view error, ECategory category)
Definition RField.hxx:99
@ 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:92
ECategory fCategory
Definition RField.hxx:89
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:109
std::string fError
Definition RField.hxx:88
const std::string & GetError() const
Definition RField.hxx:105
ECategory GetCategory() const
Definition RField.hxx:106
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:108
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:96
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:359
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
Definition RField.hxx:394
RSimpleField & operator=(RSimpleField &&other)=default
RSimpleField(std::string_view name, std::string_view type)
Definition RField.hxx:371
T * Map(RNTupleLocalIndex localIndex)
Definition RField.hxx:383
~RSimpleField() override=default
T * Map(ROOT::NTupleSize_t globalIndex)
Definition RField.hxx:382
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
Definition RField.hxx:364
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition RField.hxx:393
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:362
T * MapV(ROOT::NTupleSize_t globalIndex, ROOT::NTupleSize_t &nItems)
Definition RField.hxx:384
void GenerateColumns(const ROOT::RNTupleDescriptor &desc) override
Implementations in derived classes should create the backing columns corresponding to the field type ...
Definition RField.hxx:360
T * MapV(RNTupleLocalIndex localIndex, ROOT::NTupleSize_t &nItems)
Definition RField.hxx:388
The field for a class using ROOT standard streaming.
Definition RField.hxx:208
ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfos
streamer info records seen during writing
Definition RField.hxx:220
ROOT::Internal::RColumnIndex fIndex
number of bytes written in the current cluster
Definition RField.hxx:221
bool HasExtraTypeInfo() const final
Definition RField.hxx:241
void CommitClusterImpl() final
Definition RField.hxx:239
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.
bool IsMatchingFieldType(const std::string &actualTypeName)
Helper to check if a given type name is the one expected of Field<T>.
Definition RField.hxx:523
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:128
std::unique_ptr< RFieldBase > fField
The field used to read the on-disk data.
Definition RField.hxx:127
Input parameter to RFieldBase::ReadBulk() and RFieldBase::ReadBulkImpl().
Helper types to present an offset column as array of collection sizes.