Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleDescriptor.hxx
Go to the documentation of this file.
1/// \file ROOT/RNTupleDescriptor.hxx
2/// \ingroup NTuple
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \author Javier Lopez-Gomez <javier.lopez.gomez@cern.ch>
5/// \date 2018-07-19
6
7/*************************************************************************
8 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
9 * All rights reserved. *
10 * *
11 * For the licensing terms see $ROOTSYS/LICENSE. *
12 * For the list of contributors see $ROOTSYS/README/CREDITS. *
13 *************************************************************************/
14
15#ifndef ROOT_RNTupleDescriptor
16#define ROOT_RNTupleDescriptor
17
19#include <ROOT/RError.hxx>
21#include <ROOT/RNTupleTypes.hxx>
22#include <ROOT/RSpan.hxx>
23
24#include <TError.h>
25
26#include <algorithm>
27#include <chrono>
28#include <cmath>
29#include <functional>
30#include <iterator>
31#include <map>
32#include <memory>
33#include <optional>
34#include <ostream>
35#include <vector>
36#include <set>
37#include <string>
38#include <string_view>
39#include <unordered_map>
40#include <unordered_set>
41
42namespace ROOT {
43
44class RFieldBase;
45class RNTupleModel;
46
47namespace Internal {
48class RColumnElementBase;
49}
50
51class RNTupleDescriptor;
52
53namespace Internal {
54class RColumnDescriptorBuilder;
55class RClusterDescriptorBuilder;
56class RClusterGroupDescriptorBuilder;
57class RExtraTypeInfoDescriptorBuilder;
58class RFieldDescriptorBuilder;
59class RNTupleDescriptorBuilder;
60
61RNTupleDescriptor CloneDescriptorSchema(const RNTupleDescriptor &desc);
66
67std::vector<ROOT::Internal::RNTupleClusterBoundaries> GetClusterBoundaries(const RNTupleDescriptor &desc);
68} // namespace Internal
69
70namespace Experimental {
71
72// clang-format off
73/**
74\class ROOT::Experimental::RNTupleAttrSetDescriptor
75\ingroup NTuple
76\brief Metadata stored for every Attribute Set linked to an RNTuple.
77*/
78// clang-format on
81
82 std::uint16_t fSchemaVersionMajor = 0;
83 std::uint16_t fSchemaVersionMinor = 0;
84 std::uint32_t fAnchorLength = 0; ///< uncompressed size of the linked anchor
85 // The locator of the AttributeSet anchor.
86 // In case of kTypeFile, it points to the beginning of the Anchor's payload.
87 // NOTE: Only kTypeFile is supported at the moment.
89 std::string fName;
90
91public:
97
98 bool operator==(const RNTupleAttrSetDescriptor &other) const;
99 bool operator!=(const RNTupleAttrSetDescriptor &other) const { return !(*this == other); }
100
101 const std::string &GetName() const { return fName; }
102 std::uint16_t GetSchemaVersionMajor() const { return fSchemaVersionMajor; }
103 std::uint16_t GetSchemaVersionMinor() const { return fSchemaVersionMinor; }
104 std::uint32_t GetAnchorLength() const { return fAnchorLength; }
106
108};
109
110class RNTupleAttrSetDescriptorIterable;
111
112} // namespace Experimental
113
114// clang-format off
115/**
116\class ROOT::RFieldDescriptor
117\ingroup NTuple
118\brief Metadata stored for every field of an RNTuple
119*/
120// clang-format on
124
125private:
127 /// The version of the C++-type-to-column translation mechanics
128 std::uint32_t fFieldVersion = 0;
129 /// The version of the C++ type itself
130 std::uint32_t fTypeVersion = 0;
131 /// The leaf name, not including parent fields
132 std::string fFieldName;
133 /// Free text set by the user
134 std::string fFieldDescription;
135 /// The C++ type that was used when writing the field
136 std::string fTypeName;
137 /// A typedef or using directive that resolved to the type name during field creation
138 std::string fTypeAlias;
139 /// The number of elements per entry for fixed-size arrays
140 std::uint64_t fNRepetitions = 0;
141 /// The structural information carried by this field in the data model tree
143 /// Establishes sub field relationships, such as classes and collections
145 /// For projected fields, the source field ID
147 /// The pointers in the other direction from parent to children. They are serialized, too, to keep the
148 /// order of sub fields.
149 std::vector<ROOT::DescriptorId_t> fLinkIds;
150 /// The number of columns in the column representations of the field. The column cardinality helps to navigate the
151 /// list of logical column ids. For example, the second column of the third column representation is
152 /// fLogicalColumnIds[2 * fColumnCardinality + 1]
153 std::uint32_t fColumnCardinality = 0;
154 /// The ordered list of columns attached to this field: first by representation index then by column index.
155 std::vector<ROOT::DescriptorId_t> fLogicalColumnIds;
156 /// For custom classes, we store the ROOT TClass reported checksum to facilitate the use of I/O rules that
157 /// identify types by their checksum
158 std::optional<std::uint32_t> fTypeChecksum;
159
160public:
161 RFieldDescriptor() = default;
166
167 bool operator==(const RFieldDescriptor &other) const;
168 /// Get a copy of the descriptor
169 RFieldDescriptor Clone() const;
170
171 /// In general, we create a field simply from the C++ type name. For untyped fields, however, we potentially need
172 /// access to sub fields, which is provided by the RNTupleDescriptor argument.
173 std::unique_ptr<ROOT::RFieldBase>
174 CreateField(const RNTupleDescriptor &ntplDesc, const ROOT::RCreateFieldOptions &options = {}) const;
175
177 std::uint32_t GetFieldVersion() const { return fFieldVersion; }
178 std::uint32_t GetTypeVersion() const { return fTypeVersion; }
179 const std::string &GetFieldName() const { return fFieldName; }
180 const std::string &GetFieldDescription() const { return fFieldDescription; }
181 const std::string &GetTypeName() const { return fTypeName; }
182 const std::string &GetTypeAlias() const { return fTypeAlias; }
183 std::uint64_t GetNRepetitions() const { return fNRepetitions; }
187 const std::vector<ROOT::DescriptorId_t> &GetLinkIds() const { return fLinkIds; }
188 const std::vector<ROOT::DescriptorId_t> &GetLogicalColumnIds() const { return fLogicalColumnIds; }
189 std::uint32_t GetColumnCardinality() const { return fColumnCardinality; }
190 std::optional<std::uint32_t> GetTypeChecksum() const { return fTypeChecksum; }
192
196};
197
198// clang-format off
199/**
200\class ROOT::RColumnDescriptor
201\ingroup NTuple
202\brief Metadata stored for every column of an RNTuple
203*/
204// clang-format on
208
209public:
210 struct RValueRange {
211 double fMin = 0, fMax = 0;
212
213 RValueRange() = default;
214 RValueRange(double min, double max) : fMin(min), fMax(max) {}
215 RValueRange(std::pair<double, double> range) : fMin(range.first), fMax(range.second) {}
216
217 bool operator==(RValueRange other) const { return fMin == other.fMin && fMax == other.fMax; }
218 bool operator!=(RValueRange other) const { return !(*this == other); }
219 };
220
221private:
222 /// The actual column identifier, which is the link to the corresponding field
224 /// Usually identical to the logical column ID, except for alias columns where it references the shadowed column
226 /// Every column belongs to one and only one field
228 /// The absolute value specifies the index for the first stored element for this column.
229 /// For deferred columns the absolute value is larger than zero.
230 /// Negative values specify a suppressed and deferred column.
231 std::int64_t fFirstElementIndex = 0U;
232 /// A field can be serialized into several columns, which are numbered from zero to $n$
233 std::uint32_t fIndex = 0;
234 /// A field may use multiple column representations, which are numbered from zero to $m$.
235 /// Every representation has the same number of columns.
236 std::uint16_t fRepresentationIndex = 0;
237 /// The size in bits of elements of this column. Most columns have the size fixed by their type
238 /// but low-precision float columns have variable bit widths.
239 std::uint16_t fBitsOnStorage = 0;
240 /// The on-disk column type
242 /// Optional value range (used e.g. by quantized real fields)
243 std::optional<RValueRange> fValueRange;
244
245public:
246 RColumnDescriptor() = default;
251
252 bool operator==(const RColumnDescriptor &other) const;
253 /// Get a copy of the descriptor
254 RColumnDescriptor Clone() const;
255
256 ROOT::DescriptorId_t GetLogicalId() const { return fLogicalColumnId; }
257 ROOT::DescriptorId_t GetPhysicalId() const { return fPhysicalColumnId; }
259 std::uint32_t GetIndex() const { return fIndex; }
260 std::uint16_t GetRepresentationIndex() const { return fRepresentationIndex; }
261 std::uint64_t GetFirstElementIndex() const { return std::abs(fFirstElementIndex); }
262 std::uint16_t GetBitsOnStorage() const { return fBitsOnStorage; }
263 ROOT::ENTupleColumnType GetType() const { return fType; }
264 std::optional<RValueRange> GetValueRange() const { return fValueRange; }
265 bool IsAliasColumn() const { return fPhysicalColumnId != fLogicalColumnId; }
266 bool IsDeferredColumn() const { return fFirstElementIndex != 0; }
267 bool IsSuppressedDeferredColumn() const { return fFirstElementIndex < 0; }
268};
269
270// clang-format off
271/**
272\class ROOT::RClusterDescriptor
273\ingroup NTuple
274\brief Metadata for RNTuple clusters
275
276The cluster descriptor is built in two phases. In a first phase, the descriptor has only an ID.
277In a second phase, the event range, column group, page locations and column ranges are added.
278Both phases are populated by the RClusterDescriptorBuilder.
279Clusters span across all available columns in the RNTuple.
280*/
281// clang-format on
284
285public:
286 // clang-format off
287 /**
288 \class ROOT::RClusterDescriptor::RColumnRange
289 \ingroup NTuple
290 \brief The window of element indexes of a particular column in a particular cluster
291 */
292 // clang-format on
295 /// The global index of the first column element in the cluster
297 /// The number of column elements in the cluster
299 /// The usual format for ROOT compression settings (see Compression.h).
300 /// The pages of a particular column in a particular cluster are all compressed with the same settings.
301 /// If unset, the compression settings are undefined (deferred columns, suppressed columns).
302 std::optional<std::uint32_t> fCompressionSettings;
303 /// Suppressed columns have an empty page range and unknown compression settings.
304 /// Their element index range, however, is aligned with the corresponding column of the
305 /// primary column representation (see Section "Suppressed Columns" in the specification)
306 bool fIsSuppressed = false;
307
308 // TODO(jblomer): we perhaps want to store summary information, such as average, min/max, etc.
309 // Should this be done on the field level?
310
311 public:
312 RColumnRange() = default;
313
315 ROOT::NTupleSize_t nElements, std::optional<std::uint32_t> compressionSettings,
316 bool suppressed = false)
317 : fPhysicalColumnId(physicalColumnId),
318 fFirstElementIndex(firstElementIndex),
319 fNElements(nElements),
320 fCompressionSettings(compressionSettings),
321 fIsSuppressed(suppressed)
322 {
323 }
324
325 ROOT::DescriptorId_t GetPhysicalColumnId() const { return fPhysicalColumnId; }
326 void SetPhysicalColumnId(ROOT::DescriptorId_t id) { fPhysicalColumnId = id; }
327
328 ROOT::NTupleSize_t GetFirstElementIndex() const { return fFirstElementIndex; }
329 void SetFirstElementIndex(ROOT::NTupleSize_t idx) { fFirstElementIndex = idx; }
330 void IncrementFirstElementIndex(ROOT::NTupleSize_t by) { fFirstElementIndex += by; }
331
332 ROOT::NTupleSize_t GetNElements() const { return fNElements; }
333 void SetNElements(ROOT::NTupleSize_t n) { fNElements = n; }
335
336 std::optional<std::uint32_t> GetCompressionSettings() const { return fCompressionSettings; }
337 void SetCompressionSettings(std::optional<std::uint32_t> comp) { fCompressionSettings = comp; }
338
339 bool IsSuppressed() const { return fIsSuppressed; }
340 void SetIsSuppressed(bool suppressed) { fIsSuppressed = suppressed; }
341
342 bool operator==(const RColumnRange &other) const
343 {
344 return fPhysicalColumnId == other.fPhysicalColumnId && fFirstElementIndex == other.fFirstElementIndex &&
345 fNElements == other.fNElements && fCompressionSettings == other.fCompressionSettings &&
346 fIsSuppressed == other.fIsSuppressed;
347 }
348
350 {
351 return (fFirstElementIndex <= index && (fFirstElementIndex + fNElements) > index);
352 }
353 };
354
355 // clang-format off
356 /**
357 \class ROOT::RClusterDescriptor::RPageInfo
358 \ingroup NTuple
359 \brief Information about a single page in the context of a cluster's page range.
360 */
361 // clang-format on
362 // NOTE: We do not need to store the element size / uncompressed page size because we know to which column
363 // the page belongs
364 struct RPageInfo {
365 private:
366 /// The sum of the elements of all the pages must match the corresponding `fNElements` field in `fColumnRanges`
367 std::uint32_t fNElements = std::uint32_t(-1);
368 /// The meaning of `fLocator` depends on the storage backend.
370 /// If true, the 8 bytes following the serialized page are an xxhash of the on-disk page data
371 bool fHasChecksum = false;
372
373 public:
374 RPageInfo() = default;
376 : fNElements(nElements), fLocator(locator), fHasChecksum(hasChecksum)
377 {
378 }
379
380 bool operator==(const RPageInfo &other) const
381 {
382 return fNElements == other.fNElements && fLocator == other.fLocator;
383 }
384
385 std::uint32_t GetNElements() const { return fNElements; }
386 void SetNElements(std::uint32_t n) { fNElements = n; }
387
388 const RNTupleLocator &GetLocator() const { return fLocator; }
389 RNTupleLocator &GetLocator() { return fLocator; }
390 void SetLocator(const RNTupleLocator &locator) { fLocator = locator; }
391
392 bool HasChecksum() const { return fHasChecksum; }
393 void SetHasChecksum(bool hasChecksum) { fHasChecksum = hasChecksum; }
394 };
395
396 // clang-format off
397 /**
398 \class ROOT::RClusterDescriptor::RPageInfoExtended
399 \ingroup NTuple
400 \brief Additional information about a page in an in-memory RPageRange.
401
402 Used by RPageRange::Find() to return information relative to the RPageRange. This information is not stored on disk
403 and we don't need to keep it in memory because it can be easily recomputed.
404 */
405 // clang-format on
407 private:
408 /// Index (in cluster) of the first element in page.
409 ROOT::NTupleSize_t fFirstElementIndex = 0;
410 /// Page number in the corresponding RPageRange.
411 ROOT::NTupleSize_t fPageNumber = 0;
412
413 public:
414 RPageInfoExtended() = default;
419
420 ROOT::NTupleSize_t GetFirstElementIndex() const { return fFirstElementIndex; }
422
423 ROOT::NTupleSize_t GetPageNumber() const { return fPageNumber; }
425 };
426
427 // clang-format off
428 /**
429 \class ROOT::RClusterDescriptor::RPageRange
430 \ingroup NTuple
431 \brief Records the partition of data into pages for a particular column in a particular cluster
432 */
433 // clang-format on
436
437 private:
438 /// \brief Extend this RPageRange to fit the given RColumnRange.
439 ///
440 /// To do so, prepend as many synthetic RPageInfos as needed to cover the range in `columnRange`.
441 /// RPageInfos are constructed to contain as many elements of type `element` given a page size
442 /// limit of `pageSize` (in bytes); the locator for the referenced pages is `kTypePageZero`.
443 /// This function is used to make up RPageRanges for clusters that contain deferred columns.
444 /// \return The number of column elements covered by the synthesized RPageInfos
445 std::size_t ExtendToFitColumnRange(const RColumnRange &columnRange,
447
448 /// Has the same length than fPageInfos and stores the sum of the number of elements of all the pages
449 /// up to and including a given index. Used for binary search in Find().
450 std::vector<ROOT::NTupleSize_t> fCumulativeNElements;
451
453 std::vector<RPageInfo> fPageInfos;
454
455 public:
456 RPageRange() = default;
457 RPageRange(const RPageRange &other) = delete;
461
463 {
464 RPageRange clone;
465 clone.fPhysicalColumnId = fPhysicalColumnId;
466 clone.fPageInfos = fPageInfos;
467 clone.fCumulativeNElements = fCumulativeNElements;
468 return clone;
469 }
470
471 /// Find the page in the RPageRange that contains the given element. The element must exist.
473
474 ROOT::DescriptorId_t GetPhysicalColumnId() const { return fPhysicalColumnId; }
475 void SetPhysicalColumnId(ROOT::DescriptorId_t id) { fPhysicalColumnId = id; }
476
477 const std::vector<RPageInfo> &GetPageInfos() const { return fPageInfos; }
478 std::vector<RPageInfo> &GetPageInfos() { return fPageInfos; }
479
480 bool operator==(const RPageRange &other) const
481 {
482 return fPhysicalColumnId == other.fPhysicalColumnId && fPageInfos == other.fPageInfos;
483 }
484 };
485
486private:
488 /// Clusters can be swapped by adjusting the entry offsets of the cluster and all ranges
491
492 std::unordered_map<ROOT::DescriptorId_t, RColumnRange> fColumnRanges;
493 std::unordered_map<ROOT::DescriptorId_t, RPageRange> fPageRanges;
494
495public:
497
503
504 RClusterDescriptor Clone() const;
505
506 bool operator==(const RClusterDescriptor &other) const;
507
508 ROOT::DescriptorId_t GetId() const { return fClusterId; }
509 ROOT::NTupleSize_t GetFirstEntryIndex() const { return fFirstEntryIndex; }
510 ROOT::NTupleSize_t GetNEntries() const { return fNEntries; }
511 const RColumnRange &GetColumnRange(ROOT::DescriptorId_t physicalId) const { return fColumnRanges.at(physicalId); }
512 const RPageRange &GetPageRange(ROOT::DescriptorId_t physicalId) const { return fPageRanges.at(physicalId); }
513 /// Returns an iterator over pairs { columnId, columnRange }. The iteration order is unspecified.
514 RColumnRangeIterable GetColumnRangeIterable() const;
516 {
517 return fColumnRanges.find(physicalId) != fColumnRanges.end();
518 }
519 std::uint64_t GetNBytesOnStorage() const;
520};
521
523private:
525
526public:
528 private:
529 using Iter_t = std::unordered_map<ROOT::DescriptorId_t, RColumnRange>::const_iterator;
530 /// The wrapped map iterator
532
533 public:
534 using iterator_category = std::forward_iterator_tag;
537 using difference_type = std::ptrdiff_t;
538 using pointer = const RColumnRange *;
539 using reference = const RColumnRange &;
540
541 RIterator(Iter_t iter) : fIter(iter) {}
542 iterator &operator++() /* prefix */
543 {
544 ++fIter;
545 return *this;
546 }
547 iterator operator++(int) /* postfix */
548 {
549 auto old = *this;
550 operator++();
551 return old;
552 }
553 reference operator*() const { return fIter->second; }
554 pointer operator->() const { return &fIter->second; }
555 bool operator!=(const iterator &rh) const { return fIter != rh.fIter; }
556 bool operator==(const iterator &rh) const { return fIter == rh.fIter; }
557 };
558
559 explicit RColumnRangeIterable(const RClusterDescriptor &desc) : fDesc(desc) {}
560
561 RIterator begin() { return RIterator{fDesc.fColumnRanges.cbegin()}; }
562 RIterator end() { return RIterator{fDesc.fColumnRanges.cend()}; }
563 size_t size() { return fDesc.fColumnRanges.size(); }
564};
565
566// clang-format off
567/**
568\class ROOT::RClusterGroupDescriptor
569\ingroup NTuple
570\brief Clusters are bundled in cluster groups.
571
572Very large RNTuples can contain multiple cluster groups to organize cluster metadata.
573Every RNTuple has at least one cluster group. The clusters in a cluster group are ordered
574corresponding to their first entry number.
575*/
576// clang-format on
579
580private:
582 /// The cluster IDs can be empty if the corresponding page list is not loaded.
583 /// Otherwise, cluster ids are sorted by first entry number.
584 std::vector<ROOT::DescriptorId_t> fClusterIds;
585 /// The page list that corresponds to the cluster group
587 /// Uncompressed size of the page list
588 std::uint64_t fPageListLength = 0;
589 /// The minimum first entry number of the clusters in the cluster group
590 std::uint64_t fMinEntry = 0;
591 /// Number of entries that are (partially for sharded clusters) covered by this cluster group.
592 std::uint64_t fEntrySpan = 0;
593 /// Number of clusters is always known even if the cluster IDs are not (yet) populated
594 std::uint32_t fNClusters = 0;
595
596public:
602
603 RClusterGroupDescriptor Clone() const;
604 /// Creates a clone without the cluster IDs
605 RClusterGroupDescriptor CloneSummary() const;
606
607 bool operator==(const RClusterGroupDescriptor &other) const;
608
609 ROOT::DescriptorId_t GetId() const { return fClusterGroupId; }
610 std::uint32_t GetNClusters() const { return fNClusters; }
611 RNTupleLocator GetPageListLocator() const { return fPageListLocator; }
612 std::uint64_t GetPageListLength() const { return fPageListLength; }
613 const std::vector<ROOT::DescriptorId_t> &GetClusterIds() const { return fClusterIds; }
614 std::uint64_t GetMinEntry() const { return fMinEntry; }
615 std::uint64_t GetEntrySpan() const { return fEntrySpan; }
616 /// A cluster group is loaded in two stages. Stage one loads only the summary information.
617 /// Stage two loads the list of cluster IDs.
618 bool HasClusterDetails() const { return !fClusterIds.empty(); }
619};
620
621/// Used in RExtraTypeInfoDescriptor
623 kInvalid,
625};
626
627// clang-format off
628/**
629\class ROOT::RExtraTypeInfoDescriptor
630\ingroup NTuple
631\brief Field specific extra type information from the header / extenstion header
632
633Currently only used by streamer fields to store RNTuple-wide list of streamer info records.
634*/
635// clang-format on
638
639private:
640 /// Specifies the meaning of the extra information
641 EExtraTypeInfoIds fContentId = EExtraTypeInfoIds::kInvalid;
642 /// Type version the extra type information is bound to
643 std::uint32_t fTypeVersion = 0;
644 /// The type name the extra information refers to; empty for RNTuple-wide extra information
645 std::string fTypeName;
646 /// The content format depends on the content ID and may be binary
647 std::string fContent;
648
649public:
655
656 bool operator==(const RExtraTypeInfoDescriptor &other) const;
657
658 RExtraTypeInfoDescriptor Clone() const;
659
660 EExtraTypeInfoIds GetContentId() const { return fContentId; }
661 std::uint32_t GetTypeVersion() const { return fTypeVersion; }
662 const std::string &GetTypeName() const { return fTypeName; }
663 const std::string &GetContent() const { return fContent; }
664};
665
666namespace Internal {
667// Used by the RNTupleReader to activate/deactivate entries. Needs to adapt when we have sharded clusters.
669} // namespace Internal
670
671// clang-format off
672/**
673\class ROOT::RNTupleDescriptor
674\ingroup NTuple
675\brief The on-storage metadata of an RNTuple
676
677Represents the on-disk (on storage) information about an RNTuple. The metadata consists of a header, a footer, and
678potentially multiple page lists.
679The header carries the RNTuple schema, i.e. the fields and the associated columns and their relationships.
680The footer carries information about one or several cluster groups and links to their page lists.
681For every cluster group, a page list envelope stores cluster summaries and page locations.
682For every cluster, it stores for every column the range of element indexes as well as a list of pages and page
683locations.
684
685The descriptor provides machine-independent (de-)serialization of headers and footers, and it provides lookup routines
686for RNTuple objects (pages, clusters, ...). It is supposed to be usable by all RPageStorage implementations.
687
688The serialization does not use standard ROOT streamers in order to not let it depend on libCore. The serialization uses
689the concept of envelopes and frames: header, footer, and page list envelopes have a preamble with a type ID and length.
690Substructures are serialized in frames and have a size and number of items (for list frames). This allows for forward
691and backward compatibility when the metadata evolves.
692*/
693// clang-format on
696 friend RNTupleDescriptor Internal::CloneDescriptorSchema(const RNTupleDescriptor &desc);
697 friend DescriptorId_t Internal::CallFindClusterIdOn(const RNTupleDescriptor &desc, NTupleSize_t entryIdx);
698
699public:
700 class RHeaderExtension;
701
702private:
703 /// The RNTuple name needs to be unique in a given storage location (file)
704 std::string fName;
705 /// Free text from the user
706 std::string fDescription;
707
708 ROOT::DescriptorId_t fFieldZeroId = ROOT::kInvalidDescriptorId; ///< Set by the descriptor builder
709
710 std::uint64_t fNPhysicalColumns = 0; ///< Updated by the descriptor builder when columns are added
711
712 std::set<unsigned int> fFeatureFlags;
713 std::unordered_map<ROOT::DescriptorId_t, RFieldDescriptor> fFieldDescriptors;
714 std::unordered_map<ROOT::DescriptorId_t, RColumnDescriptor> fColumnDescriptors;
715
716 std::vector<RExtraTypeInfoDescriptor> fExtraTypeInfoDescriptors;
717 std::unique_ptr<RHeaderExtension> fHeaderExtension;
718
719 //// All fields above are part of the schema and are cloned when creating a new descriptor from a given one
720 //// (see CloneSchema())
721
722 std::uint16_t fVersionEpoch = 0; ///< Set by the descriptor builder when deserialized
723 std::uint16_t fVersionMajor = 0; ///< Set by the descriptor builder when deserialized
724 std::uint16_t fVersionMinor = 0; ///< Set by the descriptor builder when deserialized
725 std::uint16_t fVersionPatch = 0; ///< Set by the descriptor builder when deserialized
726
727 std::uint64_t fOnDiskHeaderSize = 0; ///< Set by the descriptor builder when deserialized
728 std::uint64_t fOnDiskHeaderXxHash3 = 0; ///< Set by the descriptor builder when deserialized
729 std::uint64_t fOnDiskFooterSize = 0; ///< Like fOnDiskHeaderSize, contains both cluster summaries and page locations
730
731 std::uint64_t fNEntries = 0; ///< Updated by the descriptor builder when the cluster groups are added
732 std::uint64_t fNClusters = 0; ///< Updated by the descriptor builder when the cluster groups are added
733
734 /// \brief The generation of the descriptor
735 ///
736 /// Once constructed by an RNTupleDescriptorBuilder, the descriptor is mostly immutable except for the set of
737 /// active page locations. During the lifetime of the descriptor, page location information for clusters
738 /// can be added or removed. When this happens, the generation should be increased, so that users of the
739 /// descriptor know that the information changed. The generation is increased, e.g., by the page source's
740 /// exclusive lock guard around the descriptor. It is used, e.g., by the descriptor cache in RNTupleReader.
741 std::uint64_t fGeneration = 0;
742
743 std::unordered_map<ROOT::DescriptorId_t, RClusterGroupDescriptor> fClusterGroupDescriptors;
744 /// References cluster groups sorted by entry range and thus allows for binary search.
745 /// Note that this list is empty during the descriptor building process and will only be
746 /// created when the final descriptor is extracted from the builder.
747 std::vector<ROOT::DescriptorId_t> fSortedClusterGroupIds;
748 /// Potentially a subset of all the available clusters
749 std::unordered_map<ROOT::DescriptorId_t, RClusterDescriptor> fClusterDescriptors;
750 /// List of AttributeSets linked to this RNTuple
751 std::vector<Experimental::RNTupleAttrSetDescriptor> fAttributeSets;
752
753 // We don't expose this publicly because when we add sharded clusters, this interface does not make sense anymore
755
756 /// Creates a descriptor containing only the schema information about this RNTuple, i.e. all the information needed
757 /// to create a new RNTuple with the same schema as this one but not necessarily the same clustering. This is used
758 /// when merging two RNTuples.
759 RNTupleDescriptor CloneSchema() const;
760
761public:
762 static constexpr unsigned int kFeatureFlagTest = 137; // Bit reserved for forward-compatibility testing
763
770
771 /// Modifiers passed to CreateModel()
773 private:
774 /// If set to true, projected fields will be reconstructed as such. This will prevent the model to be used
775 /// with an RNTupleReader, but it is useful, e.g., to accurately merge data.
776 bool fReconstructProjections = false;
777 /// By default, creating a model will fail if any of the reconstructed fields contains an unknown column type
778 /// or an unknown field structural role.
779 /// If this option is enabled, the model will be created and all fields containing unknown data (directly
780 /// or indirectly) will be skipped instead.
781 bool fForwardCompatible = false;
782 /// If true, the model will be created without a default entry (bare model).
783 bool fCreateBare = false;
784 /// If true, fields with a user defined type that have no available dictionaries will be reconstructed
785 /// as record fields from the on-disk information; otherwise, they will cause an error.
786 bool fEmulateUnknownTypes = false;
787
788 public:
789 RCreateModelOptions() {} // Work around compiler bug, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165
790
791 void SetReconstructProjections(bool v) { fReconstructProjections = v; }
792 bool GetReconstructProjections() const { return fReconstructProjections; }
793
794 void SetForwardCompatible(bool v) { fForwardCompatible = v; }
795 bool GetForwardCompatible() const { return fForwardCompatible; }
796
797 void SetCreateBare(bool v) { fCreateBare = v; }
798 bool GetCreateBare() const { return fCreateBare; }
799
800 void SetEmulateUnknownTypes(bool v) { fEmulateUnknownTypes = v; }
801 bool GetEmulateUnknownTypes() const { return fEmulateUnknownTypes; }
802 };
803
804 RNTupleDescriptor() = default;
809
810 RNTupleDescriptor Clone() const;
811
812 bool operator==(const RNTupleDescriptor &other) const;
813
814 std::uint64_t GetOnDiskHeaderXxHash3() const { return fOnDiskHeaderXxHash3; }
815 std::uint64_t GetOnDiskHeaderSize() const { return fOnDiskHeaderSize; }
816 std::uint64_t GetOnDiskFooterSize() const { return fOnDiskFooterSize; }
817
819 {
820 return fFieldDescriptors.at(fieldId);
821 }
823 {
824 return fColumnDescriptors.at(columnId);
825 }
827 {
828 return fClusterGroupDescriptors.at(clusterGroupId);
829 }
831 {
832 return fClusterDescriptors.at(clusterId);
833 }
834
835 RFieldDescriptorIterable GetFieldIterable(const RFieldDescriptor &fieldDesc) const;
836 RFieldDescriptorIterable
837 GetFieldIterable(const RFieldDescriptor &fieldDesc,
838 const std::function<bool(ROOT::DescriptorId_t, ROOT::DescriptorId_t)> &comparator) const;
839 RFieldDescriptorIterable GetFieldIterable(ROOT::DescriptorId_t fieldId) const;
840 RFieldDescriptorIterable
841 GetFieldIterable(ROOT::DescriptorId_t fieldId,
842 const std::function<bool(ROOT::DescriptorId_t, ROOT::DescriptorId_t)> &comparator) const;
843
844 RFieldDescriptorIterable GetTopLevelFields() const;
845 RFieldDescriptorIterable
846 GetTopLevelFields(const std::function<bool(ROOT::DescriptorId_t, ROOT::DescriptorId_t)> &comparator) const;
847
848 RColumnDescriptorIterable GetColumnIterable() const;
849 RColumnDescriptorIterable GetColumnIterable(const RFieldDescriptor &fieldDesc) const;
850 RColumnDescriptorIterable GetColumnIterable(ROOT::DescriptorId_t fieldId) const;
851
852 RClusterGroupDescriptorIterable GetClusterGroupIterable() const;
853
854 RClusterDescriptorIterable GetClusterIterable() const;
855
856 RExtraTypeInfoDescriptorIterable GetExtraTypeInfoIterable() const;
857
859
860 const std::string &GetName() const { return fName; }
861 const std::string &GetDescription() const { return fDescription; }
862
863 std::size_t GetNFields() const { return fFieldDescriptors.size(); }
864 std::size_t GetNLogicalColumns() const { return fColumnDescriptors.size(); }
865 std::size_t GetNPhysicalColumns() const { return fNPhysicalColumns; }
866 std::size_t GetNClusterGroups() const { return fClusterGroupDescriptors.size(); }
867 std::size_t GetNClusters() const { return fNClusters; }
868 std::size_t GetNActiveClusters() const { return fClusterDescriptors.size(); }
869 std::size_t GetNExtraTypeInfos() const { return fExtraTypeInfoDescriptors.size(); }
870 std::size_t GetNAttributeSets() const { return fAttributeSets.size(); }
871
872 /// We know the number of entries from adding the cluster summaries
873 ROOT::NTupleSize_t GetNEntries() const { return fNEntries; }
875
876 /// Returns the logical parent of all top-level RNTuple data fields.
877 ROOT::DescriptorId_t GetFieldZeroId() const { return fFieldZeroId; }
878 const RFieldDescriptor &GetFieldZero() const { return GetFieldDescriptor(GetFieldZeroId()); }
879 ROOT::DescriptorId_t FindFieldId(std::string_view fieldName, ROOT::DescriptorId_t parentId) const;
880 /// Searches for a top-level field
881 ROOT::DescriptorId_t FindFieldId(std::string_view fieldName) const;
882 ROOT::DescriptorId_t FindLogicalColumnId(ROOT::DescriptorId_t fieldId, std::uint32_t columnIndex,
883 std::uint16_t representationIndex) const;
884 ROOT::DescriptorId_t FindPhysicalColumnId(ROOT::DescriptorId_t fieldId, std::uint32_t columnIndex,
885 std::uint16_t representationIndex) const;
887 ROOT::DescriptorId_t FindNextClusterId(ROOT::DescriptorId_t clusterId) const;
888 ROOT::DescriptorId_t FindPrevClusterId(ROOT::DescriptorId_t clusterId) const;
889
890 /// Walks up the parents of the field ID and returns a field name of the form a.b.c.d
891 /// In case of invalid field ID, an empty string is returned.
892 std::string GetQualifiedFieldName(ROOT::DescriptorId_t fieldId) const;
893
894 /// Adjust the type name of the passed RFieldDescriptor for comparison with another renormalized type name.
895 std::string GetTypeNameForComparison(const RFieldDescriptor &fieldDesc) const;
896
897 bool HasFeature(unsigned int flag) const { return fFeatureFlags.count(flag) > 0; }
898 std::vector<std::uint64_t> GetFeatureFlags() const;
899
900 /// Return header extension information; if the descriptor does not have a header extension, return `nullptr`
901 const RHeaderExtension *GetHeaderExtension() const { return fHeaderExtension.get(); }
902
903 /// Methods to load and drop cluster group details (cluster IDs and page locations)
905 AddClusterGroupDetails(ROOT::DescriptorId_t clusterGroupId, std::vector<RClusterDescriptor> &clusterDescs);
906 RResult<void> DropClusterGroupDetails(ROOT::DescriptorId_t clusterGroupId);
907
908 std::uint64_t GetGeneration() const { return fGeneration; }
909 void IncGeneration() { fGeneration++; }
910
911 /// Re-create the C++ model from the stored metadata
912 std::unique_ptr<ROOT::RNTupleModel> CreateModel(const RCreateModelOptions &options = RCreateModelOptions()) const;
913 void PrintInfo(std::ostream &output) const;
914};
915
916// clang-format off
917/**
918\class ROOT::RNTupleDescriptor::RColumnDescriptorIterable
919\ingroup NTuple
920\brief Used to loop over a field's associated columns
921*/
922// clang-format on
924private:
925 /// The associated RNTuple for this range.
927 /// The descriptor ids of the columns ordered by field, representation, and column index
928 std::vector<ROOT::DescriptorId_t> fColumns = {};
929
930public:
932 private:
933 /// The enclosing range's RNTuple.
935 /// The enclosing range's descriptor id list.
936 const std::vector<ROOT::DescriptorId_t> &fColumns;
937 std::size_t fIndex = 0;
938
939 public:
940 using iterator_category = std::forward_iterator_tag;
943 using difference_type = std::ptrdiff_t;
944 using pointer = const RColumnDescriptor *;
946
947 RIterator(const RNTupleDescriptor &ntuple, const std::vector<ROOT::DescriptorId_t> &columns, std::size_t index)
948 : fNTuple(ntuple), fColumns(columns), fIndex(index)
949 {
950 }
951 iterator &operator++() /* prefix */
952 {
953 ++fIndex;
954 return *this;
955 }
956 iterator operator++(int) /* postfix */
957 {
958 auto old = *this;
959 operator++();
960 return old;
961 }
962 reference operator*() const { return fNTuple.GetColumnDescriptor(fColumns.at(fIndex)); }
963 pointer operator->() const { return &fNTuple.GetColumnDescriptor(fColumns.at(fIndex)); }
964 bool operator!=(const iterator &rh) const { return fIndex != rh.fIndex; }
965 bool operator==(const iterator &rh) const { return fIndex == rh.fIndex; }
966 };
967
970
971 RIterator begin() { return RIterator(fNTuple, fColumns, 0); }
972 RIterator end() { return RIterator(fNTuple, fColumns, fColumns.size()); }
973 size_t size() { return fColumns.size(); }
974};
975
976// clang-format off
977/**
978\class ROOT::RNTupleDescriptor::RFieldDescriptorIterable
979\ingroup NTuple
980\brief Used to loop over a field's child fields
981*/
982// clang-format on
984private:
985 /// The associated RNTuple for this range.
987 /// The descriptor IDs of the child fields. These may be sorted using
988 /// a comparison function.
989 std::vector<ROOT::DescriptorId_t> fFieldChildren = {};
990
991public:
993 private:
994 /// The enclosing range's RNTuple.
996 /// The enclosing range's descriptor id list.
997 const std::vector<ROOT::DescriptorId_t> &fFieldChildren;
998 std::size_t fIndex = 0;
999
1000 public:
1001 using iterator_category = std::forward_iterator_tag;
1004 using difference_type = std::ptrdiff_t;
1005 using pointer = const RFieldDescriptor *;
1007
1008 RIterator(const RNTupleDescriptor &ntuple, const std::vector<ROOT::DescriptorId_t> &fieldChildren,
1009 std::size_t index)
1010 : fNTuple(ntuple), fFieldChildren(fieldChildren), fIndex(index)
1011 {
1012 }
1013 iterator &operator++() /* prefix */
1014 {
1015 ++fIndex;
1016 return *this;
1017 }
1018 iterator operator++(int) /* postfix */
1019 {
1020 auto old = *this;
1021 operator++();
1022 return old;
1023 }
1024 reference operator*() const { return fNTuple.GetFieldDescriptor(fFieldChildren.at(fIndex)); }
1025 pointer operator->() const { return &fNTuple.GetFieldDescriptor(fFieldChildren.at(fIndex)); }
1026 bool operator!=(const iterator &rh) const { return fIndex != rh.fIndex; }
1027 bool operator==(const iterator &rh) const { return fIndex == rh.fIndex; }
1028 };
1030 : fNTuple(ntuple), fFieldChildren(field.GetLinkIds())
1031 {
1032 }
1033 /// Sort the range using an arbitrary comparison function.
1035 const std::function<bool(ROOT::DescriptorId_t, ROOT::DescriptorId_t)> &comparator)
1036 : fNTuple(ntuple), fFieldChildren(field.GetLinkIds())
1037 {
1038 std::sort(fFieldChildren.begin(), fFieldChildren.end(), comparator);
1039 }
1040 RIterator begin() { return RIterator(fNTuple, fFieldChildren, 0); }
1041 RIterator end() { return RIterator(fNTuple, fFieldChildren, fFieldChildren.size()); }
1042};
1043
1044// clang-format off
1045/**
1046\class ROOT::RNTupleDescriptor::RClusterGroupDescriptorIterable
1047\ingroup NTuple
1048\brief Used to loop over all the cluster groups of an RNTuple (in unspecified order)
1049
1050Enumerate all cluster group IDs from the descriptor. No specific order can be assumed.
1051*/
1052// clang-format on
1054private:
1055 /// The associated RNTuple for this range.
1057
1058public:
1060 private:
1061 using Iter_t = std::unordered_map<ROOT::DescriptorId_t, RClusterGroupDescriptor>::const_iterator;
1062 /// The wrapped map iterator
1064
1065 public:
1066 using iterator_category = std::forward_iterator_tag;
1069 using difference_type = std::ptrdiff_t;
1072
1073 RIterator(Iter_t iter) : fIter(iter) {}
1074 iterator &operator++() /* prefix */
1075 {
1076 ++fIter;
1077 return *this;
1078 }
1079 iterator operator++(int) /* postfix */
1080 {
1081 auto old = *this;
1082 operator++();
1083 return old;
1084 }
1085 reference operator*() const { return fIter->second; }
1086 pointer operator->() const { return &fIter->second; }
1087 bool operator!=(const iterator &rh) const { return fIter != rh.fIter; }
1088 bool operator==(const iterator &rh) const { return fIter == rh.fIter; }
1089 };
1090
1092 RIterator begin() { return RIterator(fNTuple.fClusterGroupDescriptors.cbegin()); }
1093 RIterator end() { return RIterator(fNTuple.fClusterGroupDescriptors.cend()); }
1094};
1095
1096// clang-format off
1097/**
1098\class ROOT::RNTupleDescriptor::RClusterDescriptorIterable
1099\ingroup NTuple
1100\brief Used to loop over all the clusters of an RNTuple (in unspecified order)
1101
1102Enumerate all cluster IDs from all cluster descriptors. No specific order can be assumed, use
1103RNTupleDescriptor::FindNextClusterId() and RNTupleDescriptor::FindPrevClusterId() to traverse
1104clusters by entry number.
1105*/
1106// clang-format on
1108private:
1109 /// The associated RNTuple for this range.
1111
1112public:
1114 private:
1115 using Iter_t = std::unordered_map<ROOT::DescriptorId_t, RClusterDescriptor>::const_iterator;
1116 /// The wrapped map iterator
1118
1119 public:
1120 using iterator_category = std::forward_iterator_tag;
1123 using difference_type = std::ptrdiff_t;
1126
1127 RIterator(Iter_t iter) : fIter(iter) {}
1128 iterator &operator++() /* prefix */
1129 {
1130 ++fIter;
1131 return *this;
1132 }
1133 iterator operator++(int) /* postfix */
1134 {
1135 auto old = *this;
1136 operator++();
1137 return old;
1138 }
1139 reference operator*() const { return fIter->second; }
1140 pointer operator->() const { return &fIter->second; }
1141 bool operator!=(const iterator &rh) const { return fIter != rh.fIter; }
1142 bool operator==(const iterator &rh) const { return fIter == rh.fIter; }
1143 };
1144
1146 RIterator begin() { return RIterator(fNTuple.fClusterDescriptors.cbegin()); }
1147 RIterator end() { return RIterator(fNTuple.fClusterDescriptors.cend()); }
1148};
1149
1150// clang-format off
1151/**
1152\class ROOT::RNTupleDescriptor::RExtraTypeInfoDescriptorIterable
1153\ingroup NTuple
1154\brief Used to loop over all the extra type info record of an RNTuple (in unspecified order)
1155*/
1156// clang-format on
1158private:
1159 /// The associated RNTuple for this range.
1161
1162public:
1164 private:
1165 using Iter_t = std::vector<RExtraTypeInfoDescriptor>::const_iterator;
1166 /// The wrapped vector iterator
1168
1169 public:
1170 using iterator_category = std::forward_iterator_tag;
1173 using difference_type = std::ptrdiff_t;
1176
1177 RIterator(Iter_t iter) : fIter(iter) {}
1178 iterator &operator++() /* prefix */
1179 {
1180 ++fIter;
1181 return *this;
1182 }
1183 iterator operator++(int) /* postfix */
1184 {
1185 auto old = *this;
1186 operator++();
1187 return old;
1188 }
1189 reference operator*() const { return *fIter; }
1190 pointer operator->() const { return &*fIter; }
1191 bool operator!=(const iterator &rh) const { return fIter != rh.fIter; }
1192 bool operator==(const iterator &rh) const { return fIter == rh.fIter; }
1193 };
1194
1196 RIterator begin() { return RIterator(fNTuple.fExtraTypeInfoDescriptors.cbegin()); }
1197 RIterator end() { return RIterator(fNTuple.fExtraTypeInfoDescriptors.cend()); }
1198};
1199
1200namespace Experimental {
1201// clang-format off
1202/**
1203\class ROOT::Experimental::RNTupleAttrSetDescriptorIterable
1204\ingroup NTuple
1205\brief Used to loop over all the Attribute Sets linked to an RNTuple
1206*/
1207// clang-format on
1208// TODO: move this to RNTupleDescriptor::RNTupleAttrSetDescriptorIterable when it moves out of Experimental.
1210private:
1211 /// The associated RNTuple for this range.
1213
1214public:
1216 private:
1217 using Iter_t = std::vector<RNTupleAttrSetDescriptor>::const_iterator;
1218 /// The wrapped vector iterator
1220
1221 public:
1222 using iterator_category = std::forward_iterator_tag;
1225 using difference_type = std::ptrdiff_t;
1226 using pointer = const value_type *;
1227 using reference = const value_type &;
1228
1229 RIterator(Iter_t iter) : fIter(iter) {}
1230 iterator &operator++() /* prefix */
1231 {
1232 ++fIter;
1233 return *this;
1234 }
1235 iterator operator++(int) /* postfix */
1236 {
1237 auto old = *this;
1238 operator++();
1239 return old;
1240 }
1241 reference operator*() const { return *fIter; }
1242 pointer operator->() const { return &*fIter; }
1243 bool operator!=(const iterator &rh) const { return fIter != rh.fIter; }
1244 bool operator==(const iterator &rh) const { return fIter == rh.fIter; }
1245 };
1246
1248 RIterator begin() { return RIterator(fNTuple.fAttributeSets.cbegin()); }
1249 RIterator end() { return RIterator(fNTuple.fAttributeSets.cend()); }
1250};
1251} // namespace Experimental
1252
1253// clang-format off
1254/**
1255\class ROOT::RNTupleDescriptor::RHeaderExtension
1256\ingroup NTuple
1257\brief Summarizes information about fields and the corresponding columns that were added after the header has been serialized
1258*/
1259// clang-format on
1262
1263private:
1264 /// All field IDs of late model extensions, in the order of field addition. This is necessary to serialize the
1265 /// the fields in that order.
1266 std::vector<ROOT::DescriptorId_t> fFieldIdsOrder;
1267 /// All field IDs of late model extensions for efficient lookup. When a column gets added to the extension
1268 /// header, this enables us to determine if the column belongs to a field of the header extension of if it
1269 /// belongs to a field of the regular header that gets extended by additional column representations.
1270 std::unordered_set<ROOT::DescriptorId_t> fFieldIdsLookup;
1271 /// All logical column IDs of columns that extend, with additional column representations, fields of the regular
1272 /// header. During serialization, these columns are not picked up as columns of `fFieldIdsOrder`. But instead
1273 /// these columns need to be serialized in the extension header without re-serializing the field.
1274 std::vector<ROOT::DescriptorId_t> fExtendedColumnRepresentations;
1275 /// Number of logical and physical columns; updated by the descriptor builder when columns are added
1276 std::uint32_t fNLogicalColumns = 0;
1277 std::uint32_t fNPhysicalColumns = 0;
1278
1279 /// Marks `fieldDesc` as an extended field, i.e. a field that appears in the Header Extension (e.g. having been added
1280 /// through late model extension). Note that the field descriptor should also have been added to the RNTuple
1281 /// Descriptor alongside non-extended fields.
1283 {
1284 fFieldIdsOrder.emplace_back(fieldDesc.GetId());
1285 fFieldIdsLookup.insert(fieldDesc.GetId());
1286 }
1287
1288 /// Marks `columnDesc` as an extended column, i.e. a column that appears in the Header Extension (e.g. having been
1289 /// added through late model extension as an additional representation of an existing column). Note that the column
1290 /// descriptor should also have been added to the RNTuple Descriptor alongside non-extended columns.
1292 {
1293 fNLogicalColumns++;
1294 if (!columnDesc.IsAliasColumn())
1295 fNPhysicalColumns++;
1296 if (fFieldIdsLookup.count(columnDesc.GetFieldId()) == 0) {
1297 fExtendedColumnRepresentations.emplace_back(columnDesc.GetLogicalId());
1298 }
1299 }
1300
1301public:
1302 std::size_t GetNFields() const { return fFieldIdsOrder.size(); }
1303 std::size_t GetNLogicalColumns() const { return fNLogicalColumns; }
1304 std::size_t GetNPhysicalColumns() const { return fNPhysicalColumns; }
1305 const std::vector<ROOT::DescriptorId_t> &GetExtendedColumnRepresentations() const
1306 {
1307 return fExtendedColumnRepresentations;
1308 }
1309 /// Return a vector containing the IDs of the top-level fields defined in the extension header, in the order
1310 /// of their addition.
1311 /// We cannot create this vector when building the fFields because at the time when AddExtendedField is called,
1312 /// the field is not yet linked into the schema tree.
1313 std::vector<ROOT::DescriptorId_t> GetTopLevelFields(const RNTupleDescriptor &desc) const;
1314
1316 {
1317 return fFieldIdsLookup.find(fieldId) != fFieldIdsLookup.end();
1318 }
1320 {
1321 return std::find(fExtendedColumnRepresentations.begin(), fExtendedColumnRepresentations.end(), columnId) !=
1322 fExtendedColumnRepresentations.end();
1323 }
1324};
1325
1326namespace Experimental::Internal {
1329
1330public:
1332 {
1333 fDesc.fName = name;
1334 return *this;
1335 }
1337 {
1338 fDesc.fSchemaVersionMajor = major;
1339 fDesc.fSchemaVersionMinor = minor;
1340 return *this;
1341 }
1343 {
1344 fDesc.fAnchorLocator = loc;
1345 return *this;
1346 }
1348 {
1349 fDesc.fAnchorLength = length;
1350 return *this;
1351 }
1352
1353 /// Attempt to make an AttributeSet descriptor. This may fail if the builder
1354 /// was not given enough information to make a proper descriptor.
1356};
1357} // namespace Experimental::Internal
1358
1359namespace Internal {
1360
1361// clang-format off
1362/**
1363\class ROOT::Internal::RColumnDescriptorBuilder
1364\ingroup NTuple
1365\brief A helper class for piece-wise construction of an RColumnDescriptor
1366
1367Dangling column descriptors can become actual descriptors when added to an
1368RNTupleDescriptorBuilder instance and then linked to their fields.
1369*/
1370// clang-format on
1372private:
1374
1375public:
1376 /// Make an empty column descriptor builder.
1378
1390 {
1391 fColumn.fBitsOnStorage = bitsOnStorage;
1392 return *this;
1393 }
1395 {
1396 fColumn.fType = type;
1397 return *this;
1398 }
1400 {
1401 fColumn.fFieldId = fieldId;
1402 return *this;
1403 }
1405 {
1406 fColumn.fIndex = index;
1407 return *this;
1408 }
1410 {
1412 return *this;
1413 }
1415 {
1416 R__ASSERT(fColumn.fFirstElementIndex != 0);
1417 if (fColumn.fFirstElementIndex > 0)
1418 fColumn.fFirstElementIndex = -fColumn.fFirstElementIndex;
1419 return *this;
1420 }
1422 {
1424 return *this;
1425 }
1426 RColumnDescriptorBuilder &ValueRange(double min, double max)
1427 {
1428 fColumn.fValueRange = {min, max};
1429 return *this;
1430 }
1431 RColumnDescriptorBuilder &ValueRange(std::optional<RColumnDescriptor::RValueRange> valueRange)
1432 {
1433 fColumn.fValueRange = valueRange;
1434 return *this;
1435 }
1436 ROOT::DescriptorId_t GetFieldId() const { return fColumn.fFieldId; }
1438 /// Attempt to make a column descriptor. This may fail if the column
1439 /// was not given enough information to make a proper descriptor.
1440 RResult<RColumnDescriptor> MakeDescriptor() const;
1441};
1442
1443// clang-format off
1444/**
1445\class ROOT::Internal::RFieldDescriptorBuilder
1446\ingroup NTuple
1447\brief A helper class for piece-wise construction of an RFieldDescriptor
1448
1449Dangling field descriptors describe a single field in isolation. They are
1450missing the necessary relationship information (parent field, any child fields)
1451required to describe a real RNTuple field.
1452
1453Dangling field descriptors can only become actual descriptors when added to an
1454RNTupleDescriptorBuilder instance and then linked to other fields.
1455*/
1456// clang-format on
1458private:
1460
1461public:
1462 /// Make an empty dangling field descriptor.
1464
1465 /// Make a new RFieldDescriptorBuilder based off a live RNTuple field.
1466 static RFieldDescriptorBuilder FromField(const ROOT::RFieldBase &field);
1467
1469 {
1470 fField.fFieldId = fieldId;
1471 return *this;
1472 }
1474 {
1475 fField.fFieldVersion = fieldVersion;
1476 return *this;
1477 }
1479 {
1480 fField.fTypeVersion = typeVersion;
1481 return *this;
1482 }
1484 {
1485 fField.fParentId = id;
1486 return *this;
1487 }
1489 {
1490 fField.fProjectionSourceId = id;
1491 return *this;
1492 }
1494 {
1495 fField.fFieldName = fieldName;
1496 return *this;
1497 }
1499 {
1501 return *this;
1502 }
1503 RFieldDescriptorBuilder &TypeName(const std::string &typeName)
1504 {
1505 fField.fTypeName = typeName;
1506 return *this;
1507 }
1509 {
1510 fField.fTypeAlias = typeAlias;
1511 return *this;
1512 }
1514 {
1515 fField.fNRepetitions = nRepetitions;
1516 return *this;
1517 }
1519 {
1520 fField.fStructure = structure;
1521 return *this;
1522 }
1523 RFieldDescriptorBuilder &TypeChecksum(const std::optional<std::uint32_t> typeChecksum)
1524 {
1525 fField.fTypeChecksum = typeChecksum;
1526 return *this;
1527 }
1528 ROOT::DescriptorId_t GetParentId() const { return fField.fParentId; }
1529 /// Attempt to make a field descriptor. This may fail if the dangling field
1530 /// was not given enough information to make a proper descriptor.
1531 RResult<RFieldDescriptor> MakeDescriptor() const;
1532};
1533
1534// clang-format off
1535/**
1536\class ROOT::Internal::RClusterDescriptorBuilder
1537\ingroup NTuple
1538\brief A helper class for piece-wise construction of an RClusterDescriptor
1539
1540The cluster descriptor builder starts from a summary-only cluster descriptor and allows for the
1541piecewise addition of page locations.
1542*/
1543// clang-format on
1545private:
1547
1548public:
1550 {
1551 fCluster.fClusterId = clusterId;
1552 return *this;
1553 }
1554
1556 {
1558 return *this;
1559 }
1560
1562 {
1563 fCluster.fNEntries = nEntries;
1564 return *this;
1565 }
1566
1567 RResult<void> CommitColumnRange(ROOT::DescriptorId_t physicalId, std::uint64_t firstElementIndex,
1569
1570 /// Books the given column ID as being suppressed in this cluster. The correct first element index and number of
1571 /// elements need to be set by CommitSuppressedColumnRanges() once all the calls to CommitColumnRange() and
1572 /// MarkSuppressedColumnRange() took place.
1573 RResult<void> MarkSuppressedColumnRange(ROOT::DescriptorId_t physicalId);
1574
1575 /// Sets the first element index and number of elements for all the suppressed column ranges.
1576 /// The information is taken from the corresponding columns from the primary representation.
1577 /// Needs to be called when all the columns (suppressed and regular) where added.
1578 RResult<void> CommitSuppressedColumnRanges(const RNTupleDescriptor &desc);
1579
1580 /// Add column and page ranges for columns created during late model extension missing in this cluster. The locator
1581 /// type for the synthesized page ranges is `kTypePageZero`. All the page sources must be able to populate the
1582 /// 'zero' page from such locator. Any call to CommitColumnRange() and CommitSuppressedColumnRanges()
1583 /// should happen before calling this function.
1584 RClusterDescriptorBuilder &AddExtendedColumnRanges(const RNTupleDescriptor &desc);
1585
1590
1591 /// Move out the full cluster descriptor including page locations
1592 RResult<RClusterDescriptor> MoveDescriptor();
1593};
1594
1595// clang-format off
1596/**
1597\class ROOT::Internal::RClusterGroupDescriptorBuilder
1598\ingroup NTuple
1599\brief A helper class for piece-wise construction of an RClusterGroupDescriptor
1600*/
1601// clang-format on
1603private:
1605
1606public:
1609
1621 {
1622 fClusterGroup.fPageListLength = pageListLength;
1623 return *this;
1624 }
1626 {
1627 fClusterGroup.fMinEntry = minEntry;
1628 return *this;
1629 }
1631 {
1632 fClusterGroup.fEntrySpan = entrySpan;
1633 return *this;
1634 }
1636 {
1637 fClusterGroup.fNClusters = nClusters;
1638 return *this;
1639 }
1640 void AddSortedClusters(const std::vector<ROOT::DescriptorId_t> &clusterIds)
1641 {
1642 if (clusterIds.size() != fClusterGroup.GetNClusters())
1643 throw RException(R__FAIL("mismatch of number of clusters"));
1644 fClusterGroup.fClusterIds = clusterIds;
1645 }
1646
1647 RResult<RClusterGroupDescriptor> MoveDescriptor();
1648};
1649
1650// clang-format off
1651/**
1652\class ROOT::Internal::RExtraTypeInfoDescriptorBuilder
1653\ingroup NTuple
1654\brief A helper class for piece-wise construction of an RExtraTypeInfoDescriptor
1655*/
1656// clang-format on
1658private:
1660
1661public:
1663
1665 {
1666 fExtraTypeInfo.fContentId = contentId;
1667 return *this;
1668 }
1670 {
1671 fExtraTypeInfo.fTypeVersion = typeVersion;
1672 return *this;
1673 }
1674 RExtraTypeInfoDescriptorBuilder &TypeName(const std::string &typeName)
1675 {
1676 fExtraTypeInfo.fTypeName = typeName;
1677 return *this;
1678 }
1680 {
1681 fExtraTypeInfo.fContent = content;
1682 return *this;
1683 }
1684
1685 RResult<RExtraTypeInfoDescriptor> MoveDescriptor();
1686};
1687
1688// clang-format off
1689/**
1690\class ROOT::Internal::RNTupleDescriptorBuilder
1691\ingroup NTuple
1692\brief A helper class for piece-wise construction of an RNTupleDescriptor
1693
1694Used by RPageStorage implementations in order to construct the RNTupleDescriptor from the various header parts.
1695*/
1696// clang-format on
1698private:
1700 RResult<void> EnsureFieldExists(ROOT::DescriptorId_t fieldId) const;
1701
1702public:
1703 /// Checks whether invariants hold:
1704 /// * RNTuple epoch is valid
1705 /// * RNTuple name is valid
1706 /// * Fields have valid parents
1707 /// * Number of columns is constant across column representations
1708 RResult<void> EnsureValidDescriptor() const;
1709 const RNTupleDescriptor &GetDescriptor() const { return fDescriptor; }
1710 RNTupleDescriptor MoveDescriptor();
1711
1712 /// Copies the "schema" part of `descriptor` into the builder's descriptor.
1713 /// This resets the builder's descriptor.
1714 void SetSchemaFromExisting(const RNTupleDescriptor &descriptor);
1715
1716 void SetVersion(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor,
1717 std::uint16_t versionPatch);
1718 void SetVersionForWriting();
1719
1720 void SetNTuple(const std::string_view name, const std::string_view description);
1721 void SetFeature(unsigned int flag);
1722
1723 void SetOnDiskHeaderXxHash3(std::uint64_t xxhash3) { fDescriptor.fOnDiskHeaderXxHash3 = xxhash3; }
1724 void SetOnDiskHeaderSize(std::uint64_t size) { fDescriptor.fOnDiskHeaderSize = size; }
1725 /// The real footer size also include the page list envelopes
1726 void AddToOnDiskFooterSize(std::uint64_t size) { fDescriptor.fOnDiskFooterSize += size; }
1727
1728 void AddField(const RFieldDescriptor &fieldDesc);
1731
1732 // The field that the column belongs to has to be already available. For fields with multiple columns,
1733 // the columns need to be added in order of the column index
1735
1738
1740 void ReplaceExtraTypeInfo(RExtraTypeInfoDescriptor &&extraTypeInfoDesc);
1741
1743
1744 /// Mark the beginning of the header extension; any fields and columns added after a call to this function are
1745 /// annotated as begin part of the header extension.
1746 void BeginHeaderExtension();
1747
1748 /// \brief Shift column IDs of alias columns by `offset`
1749 ///
1750 /// If the descriptor is constructed in pieces consisting of physical and alias columns
1751 /// (regular and projected fields), the natural column order would be
1752 /// - Physical and alias columns of piece one
1753 /// - Physical and alias columns of piece two
1754 /// - etc.
1755 /// What we want, however, are first all physical column IDs and then all alias column IDs.
1756 /// This method adds `offset` to the logical column IDs of all alias columns and fixes up the corresponding
1757 /// column IDs in the projected field descriptors. In this way, a new piece of physical and alias columns can
1758 /// first shift the existing alias columns by the number of new physical columns, resulting in the following order
1759 /// - Physical columns of piece one
1760 /// - Physical columns of piece two
1761 /// - ...
1762 // - Logical columns of piece one
1763 /// - Logical columns of piece two
1764 /// - ...
1765 void ShiftAliasColumns(std::uint32_t offset);
1766};
1767
1769{
1770 return desc.CloneSchema();
1771}
1772
1773/// Tells if the field describes a user-defined enum type.
1774/// The dictionary does not need to be available for this method.
1775/// Needs the full descriptor to look up sub fields.
1777
1778/// Tells if the field describes a std::atomic<T> type
1780
1781} // namespace Internal
1782
1783} // namespace ROOT
1784
1785#endif // ROOT_RNTupleDescriptor
#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
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Bool_t operator==(const TDatime &d1, const TDatime &d2)
Definition TDatime.h:102
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
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 offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void 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 length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
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
The available trivial, native content types of a column.
RNTupleAttrSetDescriptorBuilder & AnchorLocator(const RNTupleLocator &loc)
RNTupleAttrSetDescriptorBuilder & SchemaVersion(std::uint16_t major, std::uint16_t minor)
RNTupleAttrSetDescriptorBuilder & Name(std::string_view name)
RNTupleAttrSetDescriptorBuilder & AnchorLength(std::uint32_t length)
std::vector< RNTupleAttrSetDescriptor >::const_iterator Iter_t
Used to loop over all the Attribute Sets linked to an RNTuple.
const RNTupleDescriptor & fNTuple
The associated RNTuple for this range.
RNTupleAttrSetDescriptorIterable(const RNTupleDescriptor &ntuple)
Metadata stored for every Attribute Set linked to an RNTuple.
RNTupleAttrSetDescriptor & operator=(const RNTupleAttrSetDescriptor &other)=delete
bool operator==(const RNTupleAttrSetDescriptor &other) const
std::uint32_t fAnchorLength
uncompressed size of the linked anchor
RNTupleAttrSetDescriptor(const RNTupleAttrSetDescriptor &other)=delete
RNTupleAttrSetDescriptor & operator=(RNTupleAttrSetDescriptor &&other)=default
const RNTupleLocator & GetAnchorLocator() const
bool operator!=(const RNTupleAttrSetDescriptor &other) const
RNTupleAttrSetDescriptor(RNTupleAttrSetDescriptor &&other)=default
A helper class for piece-wise construction of an RClusterDescriptor.
RClusterDescriptorBuilder & NEntries(std::uint64_t nEntries)
const RClusterDescriptor::RColumnRange & GetColumnRange(ROOT::DescriptorId_t physicalId)
RClusterDescriptorBuilder & ClusterId(ROOT::DescriptorId_t clusterId)
RClusterDescriptorBuilder & FirstEntryIndex(std::uint64_t firstEntryIndex)
A helper class for piece-wise construction of an RClusterGroupDescriptor.
RClusterGroupDescriptorBuilder & EntrySpan(std::uint64_t entrySpan)
RClusterGroupDescriptorBuilder & PageListLocator(const RNTupleLocator &pageListLocator)
RClusterGroupDescriptorBuilder & PageListLength(std::uint64_t pageListLength)
RClusterGroupDescriptorBuilder & MinEntry(std::uint64_t minEntry)
void AddSortedClusters(const std::vector< ROOT::DescriptorId_t > &clusterIds)
RClusterGroupDescriptorBuilder & ClusterGroupId(ROOT::DescriptorId_t clusterGroupId)
RClusterGroupDescriptorBuilder & NClusters(std::uint32_t nClusters)
A helper class for piece-wise construction of an RColumnDescriptor.
ROOT::DescriptorId_t GetRepresentationIndex() const
RColumnDescriptorBuilder & SetSuppressedDeferred()
RColumnDescriptorBuilder & LogicalColumnId(ROOT::DescriptorId_t logicalColumnId)
RColumnDescriptorBuilder & FieldId(ROOT::DescriptorId_t fieldId)
RColumnDescriptorBuilder & BitsOnStorage(std::uint16_t bitsOnStorage)
RColumnDescriptorBuilder & ValueRange(double min, double max)
RColumnDescriptorBuilder()=default
Make an empty column descriptor builder.
RColumnDescriptorBuilder & ValueRange(std::optional< RColumnDescriptor::RValueRange > valueRange)
RColumnDescriptorBuilder & Type(ROOT::ENTupleColumnType type)
RColumnDescriptorBuilder & PhysicalColumnId(ROOT::DescriptorId_t physicalColumnId)
RColumnDescriptorBuilder & FirstElementIndex(std::uint64_t firstElementIdx)
RColumnDescriptorBuilder & Index(std::uint32_t index)
RColumnDescriptorBuilder & RepresentationIndex(std::uint16_t representationIndex)
A column element encapsulates the translation between basic C++ types and their column representation...
A helper class for piece-wise construction of an RExtraTypeInfoDescriptor.
RExtraTypeInfoDescriptorBuilder & ContentId(EExtraTypeInfoIds contentId)
RExtraTypeInfoDescriptorBuilder & TypeName(const std::string &typeName)
RExtraTypeInfoDescriptorBuilder & Content(const std::string &content)
RExtraTypeInfoDescriptorBuilder & TypeVersion(std::uint32_t typeVersion)
A helper class for piece-wise construction of an RFieldDescriptor.
RFieldDescriptorBuilder & NRepetitions(std::uint64_t nRepetitions)
RFieldDescriptorBuilder & Structure(const ROOT::ENTupleStructure &structure)
RFieldDescriptorBuilder()=default
Make an empty dangling field descriptor.
RFieldDescriptorBuilder & TypeAlias(const std::string &typeAlias)
RFieldDescriptorBuilder & ProjectionSourceId(ROOT::DescriptorId_t id)
RFieldDescriptorBuilder & TypeVersion(std::uint32_t typeVersion)
RFieldDescriptorBuilder & TypeChecksum(const std::optional< std::uint32_t > typeChecksum)
RFieldDescriptorBuilder & ParentId(ROOT::DescriptorId_t id)
RFieldDescriptorBuilder & FieldDescription(const std::string &fieldDescription)
RFieldDescriptorBuilder & FieldVersion(std::uint32_t fieldVersion)
RFieldDescriptorBuilder & FieldName(const std::string &fieldName)
RFieldDescriptorBuilder & FieldId(ROOT::DescriptorId_t fieldId)
RFieldDescriptorBuilder & TypeName(const std::string &typeName)
A helper class for piece-wise construction of an RNTupleDescriptor.
const RNTupleDescriptor & GetDescriptor() const
void SetOnDiskHeaderXxHash3(std::uint64_t xxhash3)
void AddToOnDiskFooterSize(std::uint64_t size)
The real footer size also include the page list envelopes.
std::unordered_map< ROOT::DescriptorId_t, RColumnRange >::const_iterator Iter_t
RColumnRangeIterable(const RClusterDescriptor &desc)
The window of element indexes of a particular column in a particular cluster.
void SetCompressionSettings(std::optional< std::uint32_t > comp)
void SetPhysicalColumnId(ROOT::DescriptorId_t id)
ROOT::DescriptorId_t GetPhysicalColumnId() const
bool operator==(const RColumnRange &other) const
void SetFirstElementIndex(ROOT::NTupleSize_t idx)
std::optional< std::uint32_t > GetCompressionSettings() const
std::optional< std::uint32_t > fCompressionSettings
The usual format for ROOT compression settings (see Compression.h).
ROOT::NTupleSize_t GetFirstElementIndex() const
RColumnRange(ROOT::DescriptorId_t physicalColumnId, ROOT::NTupleSize_t firstElementIndex, ROOT::NTupleSize_t nElements, std::optional< std::uint32_t > compressionSettings, bool suppressed=false)
void IncrementFirstElementIndex(ROOT::NTupleSize_t by)
bool Contains(ROOT::NTupleSize_t index) const
void IncrementNElements(ROOT::NTupleSize_t by)
Records the partition of data into pages for a particular column in a particular cluster.
RPageRange & operator=(const RPageRange &other)=delete
RPageRange(RPageRange &&other)=default
RPageRange(const RPageRange &other)=delete
const std::vector< RPageInfo > & GetPageInfos() const
std::vector< ROOT::NTupleSize_t > fCumulativeNElements
Has the same length than fPageInfos and stores the sum of the number of elements of all the pages up ...
bool operator==(const RPageRange &other) const
ROOT::DescriptorId_t GetPhysicalColumnId() const
void SetPhysicalColumnId(ROOT::DescriptorId_t id)
RPageRange & operator=(RPageRange &&other)=default
std::vector< RPageInfo > & GetPageInfos()
Metadata for RNTuple clusters.
ROOT::NTupleSize_t GetNEntries() const
ROOT::NTupleSize_t fFirstEntryIndex
Clusters can be swapped by adjusting the entry offsets of the cluster and all ranges.
RClusterDescriptor & operator=(const RClusterDescriptor &other)=delete
ROOT::DescriptorId_t GetId() const
const RPageRange & GetPageRange(ROOT::DescriptorId_t physicalId) const
RClusterDescriptor(RClusterDescriptor &&other)=default
std::unordered_map< ROOT::DescriptorId_t, RColumnRange > fColumnRanges
ROOT::DescriptorId_t fClusterId
bool ContainsColumn(ROOT::DescriptorId_t physicalId) const
RClusterDescriptor & operator=(RClusterDescriptor &&other)=default
const RColumnRange & GetColumnRange(ROOT::DescriptorId_t physicalId) const
ROOT::NTupleSize_t GetFirstEntryIndex() const
std::unordered_map< ROOT::DescriptorId_t, RPageRange > fPageRanges
RClusterDescriptor(const RClusterDescriptor &other)=delete
Clusters are bundled in cluster groups.
RNTupleLocator fPageListLocator
The page list that corresponds to the cluster group.
RClusterGroupDescriptor & operator=(const RClusterGroupDescriptor &other)=delete
std::vector< ROOT::DescriptorId_t > fClusterIds
The cluster IDs can be empty if the corresponding page list is not loaded.
ROOT::DescriptorId_t GetId() const
RClusterGroupDescriptor(RClusterGroupDescriptor &&other)=default
std::uint64_t fMinEntry
The minimum first entry number of the clusters in the cluster group.
bool HasClusterDetails() const
A cluster group is loaded in two stages.
std::uint32_t fNClusters
Number of clusters is always known even if the cluster IDs are not (yet) populated.
RClusterGroupDescriptor & operator=(RClusterGroupDescriptor &&other)=default
const std::vector< ROOT::DescriptorId_t > & GetClusterIds() const
std::uint64_t fPageListLength
Uncompressed size of the page list.
std::uint64_t GetPageListLength() const
RNTupleLocator GetPageListLocator() const
RClusterGroupDescriptor(const RClusterGroupDescriptor &other)=delete
std::uint64_t fEntrySpan
Number of entries that are (partially for sharded clusters) covered by this cluster group.
Metadata stored for every column of an RNTuple.
std::optional< RValueRange > GetValueRange() const
ROOT::DescriptorId_t fPhysicalColumnId
Usually identical to the logical column ID, except for alias columns where it references the shadowed...
ROOT::DescriptorId_t fLogicalColumnId
The actual column identifier, which is the link to the corresponding field.
RColumnDescriptor(const RColumnDescriptor &other)=delete
std::uint64_t GetFirstElementIndex() const
ROOT::DescriptorId_t fFieldId
Every column belongs to one and only one field.
std::int64_t fFirstElementIndex
The absolute value specifies the index for the first stored element for this column.
ROOT::DescriptorId_t GetFieldId() const
RColumnDescriptor(RColumnDescriptor &&other)=default
std::uint32_t fIndex
A field can be serialized into several columns, which are numbered from zero to $n$.
RColumnDescriptor & operator=(RColumnDescriptor &&other)=default
std::uint32_t GetIndex() const
std::uint16_t fBitsOnStorage
The size in bits of elements of this column.
std::uint16_t fRepresentationIndex
A field may use multiple column representations, which are numbered from zero to $m$.
ROOT::ENTupleColumnType fType
The on-disk column type.
ROOT::ENTupleColumnType GetType() const
ROOT::DescriptorId_t GetPhysicalId() const
std::uint16_t GetRepresentationIndex() const
std::optional< RValueRange > fValueRange
Optional value range (used e.g. by quantized real fields)
std::uint16_t GetBitsOnStorage() const
RColumnDescriptor & operator=(const RColumnDescriptor &other)=delete
ROOT::DescriptorId_t GetLogicalId() const
Base class for all ROOT issued exceptions.
Definition RError.hxx:79
Field specific extra type information from the header / extenstion header.
RExtraTypeInfoDescriptor & operator=(RExtraTypeInfoDescriptor &&other)=default
RExtraTypeInfoDescriptor & operator=(const RExtraTypeInfoDescriptor &other)=delete
RExtraTypeInfoDescriptor(const RExtraTypeInfoDescriptor &other)=delete
EExtraTypeInfoIds fContentId
Specifies the meaning of the extra information.
std::string fTypeName
The type name the extra information refers to; empty for RNTuple-wide extra information.
std::string fContent
The content format depends on the content ID and may be binary.
const std::string & GetContent() const
const std::string & GetTypeName() const
RExtraTypeInfoDescriptor(RExtraTypeInfoDescriptor &&other)=default
EExtraTypeInfoIds GetContentId() const
std::uint32_t fTypeVersion
Type version the extra type information is bound to.
A field translates read and write calls from/to underlying columns to/from tree values.
Metadata stored for every field of an RNTuple.
const std::string & GetTypeAlias() const
std::unique_ptr< ROOT::RFieldBase > CreateField(const RNTupleDescriptor &ntplDesc, const ROOT::RCreateFieldOptions &options={}) const
In general, we create a field simply from the C++ type name.
std::uint32_t fFieldVersion
The version of the C++-type-to-column translation mechanics.
ROOT::DescriptorId_t fFieldId
RFieldDescriptor Clone() const
Get a copy of the descriptor.
ROOT::DescriptorId_t GetId() const
std::uint64_t fNRepetitions
The number of elements per entry for fixed-size arrays.
std::uint32_t GetFieldVersion() const
const std::vector< ROOT::DescriptorId_t > & GetLogicalColumnIds() const
std::uint32_t fColumnCardinality
The number of columns in the column representations of the field.
ROOT::DescriptorId_t fProjectionSourceId
For projected fields, the source field ID.
bool IsCustomEnum(const RNTupleDescriptor &desc) const R__DEPRECATED(6
ROOT::ENTupleStructure GetStructure() const
bool operator==(const RFieldDescriptor &other) const
RFieldDescriptor(const RFieldDescriptor &other)=delete
bool IsCustomClass() const R__DEPRECATED(6
std::uint32_t GetColumnCardinality() const
bool IsStdAtomic() const R__DEPRECATED(6
std::string fFieldDescription
Free text set by the user.
RFieldDescriptor & operator=(const RFieldDescriptor &other)=delete
RFieldDescriptor & operator=(RFieldDescriptor &&other)=default
const std::vector< ROOT::DescriptorId_t > & GetLinkIds() const
ROOT::DescriptorId_t fParentId
Establishes sub field relationships, such as classes and collections.
ROOT::DescriptorId_t GetParentId() const
std::string fTypeAlias
A typedef or using directive that resolved to the type name during field creation.
ROOT::ENTupleStructure fStructure
The structural information carried by this field in the data model tree.
std::uint64_t GetNRepetitions() const
RFieldDescriptor(RFieldDescriptor &&other)=default
std::vector< ROOT::DescriptorId_t > fLinkIds
The pointers in the other direction from parent to children.
std::string fFieldName
The leaf name, not including parent fields.
const std::string & GetFieldDescription() const
std::optional< std::uint32_t > GetTypeChecksum() const
ROOT::DescriptorId_t GetProjectionSourceId() const
std::uint32_t fTypeVersion
The version of the C++ type itself.
std::string fTypeName
The C++ type that was used when writing the field.
std::uint32_t GetTypeVersion() const
const std::string & GetFieldName() const
std::vector< ROOT::DescriptorId_t > fLogicalColumnIds
The ordered list of columns attached to this field: first by representation index then by column inde...
const std::string & GetTypeName() const
std::optional< std::uint32_t > fTypeChecksum
For custom classes, we store the ROOT TClass reported checksum to facilitate the use of I/O rules tha...
std::unordered_map< ROOT::DescriptorId_t, RClusterDescriptor >::const_iterator Iter_t
Used to loop over all the clusters of an RNTuple (in unspecified order)
const RNTupleDescriptor & fNTuple
The associated RNTuple for this range.
RClusterDescriptorIterable(const RNTupleDescriptor &ntuple)
std::unordered_map< ROOT::DescriptorId_t, RClusterGroupDescriptor >::const_iterator Iter_t
Used to loop over all the cluster groups of an RNTuple (in unspecified order)
const RNTupleDescriptor & fNTuple
The associated RNTuple for this range.
const RNTupleDescriptor & fNTuple
The enclosing range's RNTuple.
const std::vector< ROOT::DescriptorId_t > & fColumns
The enclosing range's descriptor id list.
RIterator(const RNTupleDescriptor &ntuple, const std::vector< ROOT::DescriptorId_t > &columns, std::size_t index)
Used to loop over a field's associated columns.
const RNTupleDescriptor & fNTuple
The associated RNTuple for this range.
std::vector< RExtraTypeInfoDescriptor >::const_iterator Iter_t
Used to loop over all the extra type info record of an RNTuple (in unspecified order)
const RNTupleDescriptor & fNTuple
The associated RNTuple for this range.
RIterator(const RNTupleDescriptor &ntuple, const std::vector< ROOT::DescriptorId_t > &fieldChildren, std::size_t index)
const std::vector< ROOT::DescriptorId_t > & fFieldChildren
The enclosing range's descriptor id list.
const RNTupleDescriptor & fNTuple
The enclosing range's RNTuple.
Used to loop over a field's child fields.
const RNTupleDescriptor & fNTuple
The associated RNTuple for this range.
RFieldDescriptorIterable(const RNTupleDescriptor &ntuple, const RFieldDescriptor &field, const std::function< bool(ROOT::DescriptorId_t, ROOT::DescriptorId_t)> &comparator)
Sort the range using an arbitrary comparison function.
RFieldDescriptorIterable(const RNTupleDescriptor &ntuple, const RFieldDescriptor &field)
Summarizes information about fields and the corresponding columns that were added after the header ha...
const std::vector< ROOT::DescriptorId_t > & GetExtendedColumnRepresentations() const
std::unordered_set< ROOT::DescriptorId_t > fFieldIdsLookup
All field IDs of late model extensions for efficient lookup.
std::vector< ROOT::DescriptorId_t > fExtendedColumnRepresentations
All logical column IDs of columns that extend, with additional column representations,...
bool ContainsExtendedColumnRepresentation(ROOT::DescriptorId_t columnId) const
void MarkExtendedField(const RFieldDescriptor &fieldDesc)
Marks fieldDesc as an extended field, i.e.
std::vector< ROOT::DescriptorId_t > fFieldIdsOrder
All field IDs of late model extensions, in the order of field addition.
bool ContainsField(ROOT::DescriptorId_t fieldId) const
void MarkExtendedColumn(const RColumnDescriptor &columnDesc)
Marks columnDesc as an extended column, i.e.
The on-storage metadata of an RNTuple.
std::uint64_t GetGeneration() const
RNTupleDescriptor(RNTupleDescriptor &&other)=default
const RClusterGroupDescriptor & GetClusterGroupDescriptor(ROOT::DescriptorId_t clusterGroupId) const
const RColumnDescriptor & GetColumnDescriptor(ROOT::DescriptorId_t columnId) const
std::set< unsigned int > fFeatureFlags
std::unordered_map< ROOT::DescriptorId_t, RClusterGroupDescriptor > fClusterGroupDescriptors
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
RNTupleDescriptor & operator=(RNTupleDescriptor &&other)=default
std::vector< Experimental::RNTupleAttrSetDescriptor > fAttributeSets
List of AttributeSets linked to this RNTuple.
std::size_t GetNExtraTypeInfos() const
std::uint64_t GetOnDiskFooterSize() const
std::size_t GetNActiveClusters() const
const std::string & GetName() const
std::uint64_t fOnDiskFooterSize
Like fOnDiskHeaderSize, contains both cluster summaries and page locations.
ROOT::NTupleSize_t GetNEntries() const
We know the number of entries from adding the cluster summaries.
ROOT::DescriptorId_t GetFieldZeroId() const
Returns the logical parent of all top-level RNTuple data fields.
std::unordered_map< ROOT::DescriptorId_t, RClusterDescriptor > fClusterDescriptors
Potentially a subset of all the available clusters.
std::size_t GetNAttributeSets() const
std::size_t GetNClusters() const
std::size_t GetNPhysicalColumns() const
const RHeaderExtension * GetHeaderExtension() const
Return header extension information; if the descriptor does not have a header extension,...
std::uint64_t fOnDiskHeaderXxHash3
Set by the descriptor builder when deserialized.
const RClusterDescriptor & GetClusterDescriptor(ROOT::DescriptorId_t clusterId) const
std::string fName
The RNTuple name needs to be unique in a given storage location (file)
RNTupleDescriptor(const RNTupleDescriptor &other)=delete
std::uint64_t fOnDiskHeaderSize
Set by the descriptor builder when deserialized.
std::uint64_t GetOnDiskHeaderXxHash3() const
std::vector< ROOT::DescriptorId_t > fSortedClusterGroupIds
References cluster groups sorted by entry range and thus allows for binary search.
std::unordered_map< ROOT::DescriptorId_t, RColumnDescriptor > fColumnDescriptors
std::unordered_map< ROOT::DescriptorId_t, RFieldDescriptor > fFieldDescriptors
std::size_t GetNFields() const
bool HasFeature(unsigned int flag) const
std::uint64_t GetOnDiskHeaderSize() const
std::string fDescription
Free text from the user.
std::vector< RExtraTypeInfoDescriptor > fExtraTypeInfoDescriptors
std::size_t GetNLogicalColumns() const
RNTupleDescriptor & operator=(const RNTupleDescriptor &other)=delete
std::size_t GetNClusterGroups() const
RNTupleDescriptor CloneSchema() const
Creates a descriptor containing only the schema information about this RNTuple, i....
const std::string & GetDescription() const
std::unique_ptr< RHeaderExtension > fHeaderExtension
const RFieldDescriptor & GetFieldZero() const
Generic information about the physical location of data.
const Int_t n
Definition legend1.C:16
RNTupleDescriptor CloneDescriptorSchema(const RNTupleDescriptor &desc)
bool IsCustomEnumFieldDesc(const RNTupleDescriptor &desc, const RFieldDescriptor &fieldDesc)
Tells if the field describes a user-defined enum type.
std::vector< ROOT::Internal::RNTupleClusterBoundaries > GetClusterBoundaries(const RNTupleDescriptor &desc)
Return the cluster boundaries for each cluster in this RNTuple.
bool IsStdAtomicFieldDesc(const RFieldDescriptor &fieldDesc)
Tells if the field describes a std::atomic<T> type.
EExtraTypeInfoIds
Used in RExtraTypeInfoDescriptor.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr NTupleSize_t kInvalidNTupleIndex
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId
ENTupleStructure
The fields in the RNTuple data model tree can carry different structural information about the type s...
Additional information about a page in an in-memory RPageRange.
RPageInfoExtended(const RPageInfo &pageInfo, ROOT::NTupleSize_t firstElementIndex, ROOT::NTupleSize_t pageNumber)
void SetFirstElementIndex(ROOT::NTupleSize_t firstInPage)
void SetPageNumber(ROOT::NTupleSize_t pageNumber)
Information about a single page in the context of a cluster's page range.
void SetLocator(const RNTupleLocator &locator)
bool operator==(const RPageInfo &other) const
const RNTupleLocator & GetLocator() const
RNTupleLocator fLocator
The meaning of fLocator depends on the storage backend.
RPageInfo(std::uint32_t nElements, const RNTupleLocator &locator, bool hasChecksum)
bool operator==(RValueRange other) const
RValueRange(std::pair< double, double > range)
bool operator!=(RValueRange other) const
static void output()