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
666// clang-format off
667/**
668\class ROOT::RNTupleDescriptor
669\ingroup NTuple
670\brief The on-storage metadata of an RNTuple
671
672Represents the on-disk (on storage) information about an RNTuple. The metadata consists of a header, a footer, and
673potentially multiple page lists.
674The header carries the RNTuple schema, i.e. the fields and the associated columns and their relationships.
675The footer carries information about one or several cluster groups and links to their page lists.
676For every cluster group, a page list envelope stores cluster summaries and page locations.
677For every cluster, it stores for every column the range of element indexes as well as a list of pages and page
678locations.
679
680The descriptor provides machine-independent (de-)serialization of headers and footers, and it provides lookup routines
681for RNTuple objects (pages, clusters, ...). It is supposed to be usable by all RPageStorage implementations.
682
683The serialization does not use standard ROOT streamers in order to not let it depend on libCore. The serialization uses
684the concept of envelopes and frames: header, footer, and page list envelopes have a preamble with a type ID and length.
685Substructures are serialized in frames and have a size and number of items (for list frames). This allows for forward
686and backward compatibility when the metadata evolves.
687*/
688// clang-format on
691 friend RNTupleDescriptor Internal::CloneDescriptorSchema(const RNTupleDescriptor &desc);
692
693public:
694 class RHeaderExtension;
695
696private:
697 /// The RNTuple name needs to be unique in a given storage location (file)
698 std::string fName;
699 /// Free text from the user
700 std::string fDescription;
701
702 ROOT::DescriptorId_t fFieldZeroId = ROOT::kInvalidDescriptorId; ///< Set by the descriptor builder
703
704 std::uint64_t fNPhysicalColumns = 0; ///< Updated by the descriptor builder when columns are added
705
706 std::set<unsigned int> fFeatureFlags;
707 std::unordered_map<ROOT::DescriptorId_t, RFieldDescriptor> fFieldDescriptors;
708 std::unordered_map<ROOT::DescriptorId_t, RColumnDescriptor> fColumnDescriptors;
709
710 std::vector<RExtraTypeInfoDescriptor> fExtraTypeInfoDescriptors;
711 std::unique_ptr<RHeaderExtension> fHeaderExtension;
712
713 //// All fields above are part of the schema and are cloned when creating a new descriptor from a given one
714 //// (see CloneSchema())
715
716 std::uint16_t fVersionEpoch = 0; ///< Set by the descriptor builder when deserialized
717 std::uint16_t fVersionMajor = 0; ///< Set by the descriptor builder when deserialized
718 std::uint16_t fVersionMinor = 0; ///< Set by the descriptor builder when deserialized
719 std::uint16_t fVersionPatch = 0; ///< Set by the descriptor builder when deserialized
720
721 std::uint64_t fOnDiskHeaderSize = 0; ///< Set by the descriptor builder when deserialized
722 std::uint64_t fOnDiskHeaderXxHash3 = 0; ///< Set by the descriptor builder when deserialized
723 std::uint64_t fOnDiskFooterSize = 0; ///< Like fOnDiskHeaderSize, contains both cluster summaries and page locations
724
725 std::uint64_t fNEntries = 0; ///< Updated by the descriptor builder when the cluster groups are added
726 std::uint64_t fNClusters = 0; ///< Updated by the descriptor builder when the cluster groups are added
727
728 /// \brief The generation of the descriptor
729 ///
730 /// Once constructed by an RNTupleDescriptorBuilder, the descriptor is mostly immutable except for the set of
731 /// active page locations. During the lifetime of the descriptor, page location information for clusters
732 /// can be added or removed. When this happens, the generation should be increased, so that users of the
733 /// descriptor know that the information changed. The generation is increased, e.g., by the page source's
734 /// exclusive lock guard around the descriptor. It is used, e.g., by the descriptor cache in RNTupleReader.
735 std::uint64_t fGeneration = 0;
736
737 std::unordered_map<ROOT::DescriptorId_t, RClusterGroupDescriptor> fClusterGroupDescriptors;
738 /// References cluster groups sorted by entry range and thus allows for binary search.
739 /// Note that this list is empty during the descriptor building process and will only be
740 /// created when the final descriptor is extracted from the builder.
741 std::vector<ROOT::DescriptorId_t> fSortedClusterGroupIds;
742 /// Potentially a subset of all the available clusters
743 std::unordered_map<ROOT::DescriptorId_t, RClusterDescriptor> fClusterDescriptors;
744 /// List of AttributeSets linked to this RNTuple
745 std::vector<Experimental::RNTupleAttrSetDescriptor> fAttributeSets;
746
747 // We don't expose this publicly because when we add sharded clusters, this interface does not make sense anymore
749
750 /// Creates a descriptor containing only the schema information about this RNTuple, i.e. all the information needed
751 /// to create a new RNTuple with the same schema as this one but not necessarily the same clustering. This is used
752 /// when merging two RNTuples.
753 RNTupleDescriptor CloneSchema() const;
754
755public:
756 static constexpr unsigned int kFeatureFlagTest = 137; // Bit reserved for forward-compatibility testing
757
764
765 /// Modifiers passed to CreateModel()
767 private:
768 /// If set to true, projected fields will be reconstructed as such. This will prevent the model to be used
769 /// with an RNTupleReader, but it is useful, e.g., to accurately merge data.
770 bool fReconstructProjections = false;
771 /// By default, creating a model will fail if any of the reconstructed fields contains an unknown column type
772 /// or an unknown field structural role.
773 /// If this option is enabled, the model will be created and all fields containing unknown data (directly
774 /// or indirectly) will be skipped instead.
775 bool fForwardCompatible = false;
776 /// If true, the model will be created without a default entry (bare model).
777 bool fCreateBare = false;
778 /// If true, fields with a user defined type that have no available dictionaries will be reconstructed
779 /// as record fields from the on-disk information; otherwise, they will cause an error.
780 bool fEmulateUnknownTypes = false;
781
782 public:
783 RCreateModelOptions() {} // Work around compiler bug, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165
784
785 void SetReconstructProjections(bool v) { fReconstructProjections = v; }
786 bool GetReconstructProjections() const { return fReconstructProjections; }
787
788 void SetForwardCompatible(bool v) { fForwardCompatible = v; }
789 bool GetForwardCompatible() const { return fForwardCompatible; }
790
791 void SetCreateBare(bool v) { fCreateBare = v; }
792 bool GetCreateBare() const { return fCreateBare; }
793
794 void SetEmulateUnknownTypes(bool v) { fEmulateUnknownTypes = v; }
795 bool GetEmulateUnknownTypes() const { return fEmulateUnknownTypes; }
796 };
797
798 RNTupleDescriptor() = default;
803
804 RNTupleDescriptor Clone() const;
805
806 bool operator==(const RNTupleDescriptor &other) const;
807
808 std::uint64_t GetOnDiskHeaderXxHash3() const { return fOnDiskHeaderXxHash3; }
809 std::uint64_t GetOnDiskHeaderSize() const { return fOnDiskHeaderSize; }
810 std::uint64_t GetOnDiskFooterSize() const { return fOnDiskFooterSize; }
811
813 {
814 return fFieldDescriptors.at(fieldId);
815 }
817 {
818 return fColumnDescriptors.at(columnId);
819 }
821 {
822 return fClusterGroupDescriptors.at(clusterGroupId);
823 }
825 {
826 return fClusterDescriptors.at(clusterId);
827 }
828
829 RFieldDescriptorIterable GetFieldIterable(const RFieldDescriptor &fieldDesc) const;
830 RFieldDescriptorIterable
831 GetFieldIterable(const RFieldDescriptor &fieldDesc,
832 const std::function<bool(ROOT::DescriptorId_t, ROOT::DescriptorId_t)> &comparator) const;
833 RFieldDescriptorIterable GetFieldIterable(ROOT::DescriptorId_t fieldId) const;
834 RFieldDescriptorIterable
835 GetFieldIterable(ROOT::DescriptorId_t fieldId,
836 const std::function<bool(ROOT::DescriptorId_t, ROOT::DescriptorId_t)> &comparator) const;
837
838 RFieldDescriptorIterable GetTopLevelFields() const;
839 RFieldDescriptorIterable
840 GetTopLevelFields(const std::function<bool(ROOT::DescriptorId_t, ROOT::DescriptorId_t)> &comparator) const;
841
842 RColumnDescriptorIterable GetColumnIterable() const;
843 RColumnDescriptorIterable GetColumnIterable(const RFieldDescriptor &fieldDesc) const;
844 RColumnDescriptorIterable GetColumnIterable(ROOT::DescriptorId_t fieldId) const;
845
846 RClusterGroupDescriptorIterable GetClusterGroupIterable() const;
847
848 RClusterDescriptorIterable GetClusterIterable() const;
849
850 RExtraTypeInfoDescriptorIterable GetExtraTypeInfoIterable() const;
851
853
854 const std::string &GetName() const { return fName; }
855 const std::string &GetDescription() const { return fDescription; }
856
857 std::size_t GetNFields() const { return fFieldDescriptors.size(); }
858 std::size_t GetNLogicalColumns() const { return fColumnDescriptors.size(); }
859 std::size_t GetNPhysicalColumns() const { return fNPhysicalColumns; }
860 std::size_t GetNClusterGroups() const { return fClusterGroupDescriptors.size(); }
861 std::size_t GetNClusters() const { return fNClusters; }
862 std::size_t GetNActiveClusters() const { return fClusterDescriptors.size(); }
863 std::size_t GetNExtraTypeInfos() const { return fExtraTypeInfoDescriptors.size(); }
864 std::size_t GetNAttributeSets() const { return fAttributeSets.size(); }
865
866 /// We know the number of entries from adding the cluster summaries
867 ROOT::NTupleSize_t GetNEntries() const { return fNEntries; }
869
870 /// Returns the logical parent of all top-level RNTuple data fields.
871 ROOT::DescriptorId_t GetFieldZeroId() const { return fFieldZeroId; }
872 const RFieldDescriptor &GetFieldZero() const { return GetFieldDescriptor(GetFieldZeroId()); }
873 ROOT::DescriptorId_t FindFieldId(std::string_view fieldName, ROOT::DescriptorId_t parentId) const;
874 /// Searches for a top-level field
875 ROOT::DescriptorId_t FindFieldId(std::string_view fieldName) const;
876 ROOT::DescriptorId_t FindLogicalColumnId(ROOT::DescriptorId_t fieldId, std::uint32_t columnIndex,
877 std::uint16_t representationIndex) const;
878 ROOT::DescriptorId_t FindPhysicalColumnId(ROOT::DescriptorId_t fieldId, std::uint32_t columnIndex,
879 std::uint16_t representationIndex) const;
881 ROOT::DescriptorId_t FindNextClusterId(ROOT::DescriptorId_t clusterId) const;
882 ROOT::DescriptorId_t FindPrevClusterId(ROOT::DescriptorId_t clusterId) const;
883
884 /// Walks up the parents of the field ID and returns a field name of the form a.b.c.d
885 /// In case of invalid field ID, an empty string is returned.
886 std::string GetQualifiedFieldName(ROOT::DescriptorId_t fieldId) const;
887
888 /// Adjust the type name of the passed RFieldDescriptor for comparison with another renormalized type name.
889 std::string GetTypeNameForComparison(const RFieldDescriptor &fieldDesc) const;
890
891 bool HasFeature(unsigned int flag) const { return fFeatureFlags.count(flag) > 0; }
892 std::vector<std::uint64_t> GetFeatureFlags() const;
893
894 /// Return header extension information; if the descriptor does not have a header extension, return `nullptr`
895 const RHeaderExtension *GetHeaderExtension() const { return fHeaderExtension.get(); }
896
897 /// Methods to load and drop cluster group details (cluster IDs and page locations)
899 AddClusterGroupDetails(ROOT::DescriptorId_t clusterGroupId, std::vector<RClusterDescriptor> &clusterDescs);
900 RResult<void> DropClusterGroupDetails(ROOT::DescriptorId_t clusterGroupId);
901
902 std::uint64_t GetGeneration() const { return fGeneration; }
903 void IncGeneration() { fGeneration++; }
904
905 /// Re-create the C++ model from the stored metadata
906 std::unique_ptr<ROOT::RNTupleModel> CreateModel(const RCreateModelOptions &options = RCreateModelOptions()) const;
907 void PrintInfo(std::ostream &output) const;
908};
909
910// clang-format off
911/**
912\class ROOT::RNTupleDescriptor::RColumnDescriptorIterable
913\ingroup NTuple
914\brief Used to loop over a field's associated columns
915*/
916// clang-format on
918private:
919 /// The associated RNTuple for this range.
921 /// The descriptor ids of the columns ordered by field, representation, and column index
922 std::vector<ROOT::DescriptorId_t> fColumns = {};
923
924public:
926 private:
927 /// The enclosing range's RNTuple.
929 /// The enclosing range's descriptor id list.
930 const std::vector<ROOT::DescriptorId_t> &fColumns;
931 std::size_t fIndex = 0;
932
933 public:
934 using iterator_category = std::forward_iterator_tag;
937 using difference_type = std::ptrdiff_t;
938 using pointer = const RColumnDescriptor *;
940
941 RIterator(const RNTupleDescriptor &ntuple, const std::vector<ROOT::DescriptorId_t> &columns, std::size_t index)
942 : fNTuple(ntuple), fColumns(columns), fIndex(index)
943 {
944 }
945 iterator &operator++() /* prefix */
946 {
947 ++fIndex;
948 return *this;
949 }
950 iterator operator++(int) /* postfix */
951 {
952 auto old = *this;
953 operator++();
954 return old;
955 }
956 reference operator*() const { return fNTuple.GetColumnDescriptor(fColumns.at(fIndex)); }
957 pointer operator->() const { return &fNTuple.GetColumnDescriptor(fColumns.at(fIndex)); }
958 bool operator!=(const iterator &rh) const { return fIndex != rh.fIndex; }
959 bool operator==(const iterator &rh) const { return fIndex == rh.fIndex; }
960 };
961
964
965 RIterator begin() { return RIterator(fNTuple, fColumns, 0); }
966 RIterator end() { return RIterator(fNTuple, fColumns, fColumns.size()); }
967 size_t size() { return fColumns.size(); }
968};
969
970// clang-format off
971/**
972\class ROOT::RNTupleDescriptor::RFieldDescriptorIterable
973\ingroup NTuple
974\brief Used to loop over a field's child fields
975*/
976// clang-format on
978private:
979 /// The associated RNTuple for this range.
981 /// The descriptor IDs of the child fields. These may be sorted using
982 /// a comparison function.
983 std::vector<ROOT::DescriptorId_t> fFieldChildren = {};
984
985public:
987 private:
988 /// The enclosing range's RNTuple.
990 /// The enclosing range's descriptor id list.
991 const std::vector<ROOT::DescriptorId_t> &fFieldChildren;
992 std::size_t fIndex = 0;
993
994 public:
995 using iterator_category = std::forward_iterator_tag;
998 using difference_type = std::ptrdiff_t;
999 using pointer = const RFieldDescriptor *;
1001
1002 RIterator(const RNTupleDescriptor &ntuple, const std::vector<ROOT::DescriptorId_t> &fieldChildren,
1003 std::size_t index)
1004 : fNTuple(ntuple), fFieldChildren(fieldChildren), fIndex(index)
1005 {
1006 }
1007 iterator &operator++() /* prefix */
1008 {
1009 ++fIndex;
1010 return *this;
1011 }
1012 iterator operator++(int) /* postfix */
1013 {
1014 auto old = *this;
1015 operator++();
1016 return old;
1017 }
1018 reference operator*() const { return fNTuple.GetFieldDescriptor(fFieldChildren.at(fIndex)); }
1019 pointer operator->() const { return &fNTuple.GetFieldDescriptor(fFieldChildren.at(fIndex)); }
1020 bool operator!=(const iterator &rh) const { return fIndex != rh.fIndex; }
1021 bool operator==(const iterator &rh) const { return fIndex == rh.fIndex; }
1022 };
1024 : fNTuple(ntuple), fFieldChildren(field.GetLinkIds())
1025 {
1026 }
1027 /// Sort the range using an arbitrary comparison function.
1029 const std::function<bool(ROOT::DescriptorId_t, ROOT::DescriptorId_t)> &comparator)
1030 : fNTuple(ntuple), fFieldChildren(field.GetLinkIds())
1031 {
1032 std::sort(fFieldChildren.begin(), fFieldChildren.end(), comparator);
1033 }
1034 RIterator begin() { return RIterator(fNTuple, fFieldChildren, 0); }
1035 RIterator end() { return RIterator(fNTuple, fFieldChildren, fFieldChildren.size()); }
1036};
1037
1038// clang-format off
1039/**
1040\class ROOT::RNTupleDescriptor::RClusterGroupDescriptorIterable
1041\ingroup NTuple
1042\brief Used to loop over all the cluster groups of an RNTuple (in unspecified order)
1043
1044Enumerate all cluster group IDs from the descriptor. No specific order can be assumed.
1045*/
1046// clang-format on
1048private:
1049 /// The associated RNTuple for this range.
1051
1052public:
1054 private:
1055 using Iter_t = std::unordered_map<ROOT::DescriptorId_t, RClusterGroupDescriptor>::const_iterator;
1056 /// The wrapped map iterator
1058
1059 public:
1060 using iterator_category = std::forward_iterator_tag;
1063 using difference_type = std::ptrdiff_t;
1066
1067 RIterator(Iter_t iter) : fIter(iter) {}
1068 iterator &operator++() /* prefix */
1069 {
1070 ++fIter;
1071 return *this;
1072 }
1073 iterator operator++(int) /* postfix */
1074 {
1075 auto old = *this;
1076 operator++();
1077 return old;
1078 }
1079 reference operator*() const { return fIter->second; }
1080 pointer operator->() const { return &fIter->second; }
1081 bool operator!=(const iterator &rh) const { return fIter != rh.fIter; }
1082 bool operator==(const iterator &rh) const { return fIter == rh.fIter; }
1083 };
1084
1086 RIterator begin() { return RIterator(fNTuple.fClusterGroupDescriptors.cbegin()); }
1087 RIterator end() { return RIterator(fNTuple.fClusterGroupDescriptors.cend()); }
1088};
1089
1090// clang-format off
1091/**
1092\class ROOT::RNTupleDescriptor::RClusterDescriptorIterable
1093\ingroup NTuple
1094\brief Used to loop over all the clusters of an RNTuple (in unspecified order)
1095
1096Enumerate all cluster IDs from all cluster descriptors. No specific order can be assumed, use
1097RNTupleDescriptor::FindNextClusterId() and RNTupleDescriptor::FindPrevClusterId() to traverse
1098clusters by entry number.
1099*/
1100// clang-format on
1102private:
1103 /// The associated RNTuple for this range.
1105
1106public:
1108 private:
1109 using Iter_t = std::unordered_map<ROOT::DescriptorId_t, RClusterDescriptor>::const_iterator;
1110 /// The wrapped map iterator
1112
1113 public:
1114 using iterator_category = std::forward_iterator_tag;
1117 using difference_type = std::ptrdiff_t;
1120
1121 RIterator(Iter_t iter) : fIter(iter) {}
1122 iterator &operator++() /* prefix */
1123 {
1124 ++fIter;
1125 return *this;
1126 }
1127 iterator operator++(int) /* postfix */
1128 {
1129 auto old = *this;
1130 operator++();
1131 return old;
1132 }
1133 reference operator*() const { return fIter->second; }
1134 pointer operator->() const { return &fIter->second; }
1135 bool operator!=(const iterator &rh) const { return fIter != rh.fIter; }
1136 bool operator==(const iterator &rh) const { return fIter == rh.fIter; }
1137 };
1138
1140 RIterator begin() { return RIterator(fNTuple.fClusterDescriptors.cbegin()); }
1141 RIterator end() { return RIterator(fNTuple.fClusterDescriptors.cend()); }
1142};
1143
1144// clang-format off
1145/**
1146\class ROOT::RNTupleDescriptor::RExtraTypeInfoDescriptorIterable
1147\ingroup NTuple
1148\brief Used to loop over all the extra type info record of an RNTuple (in unspecified order)
1149*/
1150// clang-format on
1152private:
1153 /// The associated RNTuple for this range.
1155
1156public:
1158 private:
1159 using Iter_t = std::vector<RExtraTypeInfoDescriptor>::const_iterator;
1160 /// The wrapped vector iterator
1162
1163 public:
1164 using iterator_category = std::forward_iterator_tag;
1167 using difference_type = std::ptrdiff_t;
1170
1171 RIterator(Iter_t iter) : fIter(iter) {}
1172 iterator &operator++() /* prefix */
1173 {
1174 ++fIter;
1175 return *this;
1176 }
1177 iterator operator++(int) /* postfix */
1178 {
1179 auto old = *this;
1180 operator++();
1181 return old;
1182 }
1183 reference operator*() const { return *fIter; }
1184 pointer operator->() const { return &*fIter; }
1185 bool operator!=(const iterator &rh) const { return fIter != rh.fIter; }
1186 bool operator==(const iterator &rh) const { return fIter == rh.fIter; }
1187 };
1188
1190 RIterator begin() { return RIterator(fNTuple.fExtraTypeInfoDescriptors.cbegin()); }
1191 RIterator end() { return RIterator(fNTuple.fExtraTypeInfoDescriptors.cend()); }
1192};
1193
1194namespace Experimental {
1195// clang-format off
1196/**
1197\class ROOT::Experimental::RNTupleAttrSetDescriptorIterable
1198\ingroup NTuple
1199\brief Used to loop over all the Attribute Sets linked to an RNTuple
1200*/
1201// clang-format on
1202// TODO: move this to RNTupleDescriptor::RNTupleAttrSetDescriptorIterable when it moves out of Experimental.
1204private:
1205 /// The associated RNTuple for this range.
1207
1208public:
1210 private:
1211 using Iter_t = std::vector<RNTupleAttrSetDescriptor>::const_iterator;
1212 /// The wrapped vector iterator
1214
1215 public:
1216 using iterator_category = std::forward_iterator_tag;
1219 using difference_type = std::ptrdiff_t;
1220 using pointer = const value_type *;
1221 using reference = const value_type &;
1222
1223 RIterator(Iter_t iter) : fIter(iter) {}
1224 iterator &operator++() /* prefix */
1225 {
1226 ++fIter;
1227 return *this;
1228 }
1229 iterator operator++(int) /* postfix */
1230 {
1231 auto old = *this;
1232 operator++();
1233 return old;
1234 }
1235 reference operator*() const { return *fIter; }
1236 pointer operator->() const { return &*fIter; }
1237 bool operator!=(const iterator &rh) const { return fIter != rh.fIter; }
1238 bool operator==(const iterator &rh) const { return fIter == rh.fIter; }
1239 };
1240
1242 RIterator begin() { return RIterator(fNTuple.fAttributeSets.cbegin()); }
1243 RIterator end() { return RIterator(fNTuple.fAttributeSets.cend()); }
1244};
1245} // namespace Experimental
1246
1247// clang-format off
1248/**
1249\class ROOT::RNTupleDescriptor::RHeaderExtension
1250\ingroup NTuple
1251\brief Summarizes information about fields and the corresponding columns that were added after the header has been serialized
1252*/
1253// clang-format on
1256
1257private:
1258 /// All field IDs of late model extensions, in the order of field addition. This is necessary to serialize the
1259 /// the fields in that order.
1260 std::vector<ROOT::DescriptorId_t> fFieldIdsOrder;
1261 /// All field IDs of late model extensions for efficient lookup. When a column gets added to the extension
1262 /// header, this enables us to determine if the column belongs to a field of the header extension of if it
1263 /// belongs to a field of the regular header that gets extended by additional column representations.
1264 std::unordered_set<ROOT::DescriptorId_t> fFieldIdsLookup;
1265 /// All logical column IDs of columns that extend, with additional column representations, fields of the regular
1266 /// header. During serialization, these columns are not picked up as columns of `fFieldIdsOrder`. But instead
1267 /// these columns need to be serialized in the extension header without re-serializing the field.
1268 std::vector<ROOT::DescriptorId_t> fExtendedColumnRepresentations;
1269 /// Number of logical and physical columns; updated by the descriptor builder when columns are added
1270 std::uint32_t fNLogicalColumns = 0;
1271 std::uint32_t fNPhysicalColumns = 0;
1272
1273 /// Marks `fieldDesc` as an extended field, i.e. a field that appears in the Header Extension (e.g. having been added
1274 /// through late model extension). Note that the field descriptor should also have been added to the RNTuple
1275 /// Descriptor alongside non-extended fields.
1277 {
1278 fFieldIdsOrder.emplace_back(fieldDesc.GetId());
1279 fFieldIdsLookup.insert(fieldDesc.GetId());
1280 }
1281
1282 /// Marks `columnDesc` as an extended column, i.e. a column that appears in the Header Extension (e.g. having been
1283 /// added through late model extension as an additional representation of an existing column). Note that the column
1284 /// descriptor should also have been added to the RNTuple Descriptor alongside non-extended columns.
1286 {
1287 fNLogicalColumns++;
1288 if (!columnDesc.IsAliasColumn())
1289 fNPhysicalColumns++;
1290 if (fFieldIdsLookup.count(columnDesc.GetFieldId()) == 0) {
1291 fExtendedColumnRepresentations.emplace_back(columnDesc.GetLogicalId());
1292 }
1293 }
1294
1295public:
1296 std::size_t GetNFields() const { return fFieldIdsOrder.size(); }
1297 std::size_t GetNLogicalColumns() const { return fNLogicalColumns; }
1298 std::size_t GetNPhysicalColumns() const { return fNPhysicalColumns; }
1299 const std::vector<ROOT::DescriptorId_t> &GetExtendedColumnRepresentations() const
1300 {
1301 return fExtendedColumnRepresentations;
1302 }
1303 /// Return a vector containing the IDs of the top-level fields defined in the extension header, in the order
1304 /// of their addition.
1305 /// We cannot create this vector when building the fFields because at the time when AddExtendedField is called,
1306 /// the field is not yet linked into the schema tree.
1307 std::vector<ROOT::DescriptorId_t> GetTopLevelFields(const RNTupleDescriptor &desc) const;
1308
1310 {
1311 return fFieldIdsLookup.find(fieldId) != fFieldIdsLookup.end();
1312 }
1314 {
1315 return std::find(fExtendedColumnRepresentations.begin(), fExtendedColumnRepresentations.end(), columnId) !=
1316 fExtendedColumnRepresentations.end();
1317 }
1318};
1319
1320namespace Experimental::Internal {
1323
1324public:
1326 {
1327 fDesc.fName = name;
1328 return *this;
1329 }
1331 {
1332 fDesc.fSchemaVersionMajor = major;
1333 fDesc.fSchemaVersionMinor = minor;
1334 return *this;
1335 }
1337 {
1338 fDesc.fAnchorLocator = loc;
1339 return *this;
1340 }
1342 {
1343 fDesc.fAnchorLength = length;
1344 return *this;
1345 }
1346
1347 /// Attempt to make an AttributeSet descriptor. This may fail if the builder
1348 /// was not given enough information to make a proper descriptor.
1350};
1351} // namespace Experimental::Internal
1352
1353namespace Internal {
1354
1355// clang-format off
1356/**
1357\class ROOT::Internal::RColumnDescriptorBuilder
1358\ingroup NTuple
1359\brief A helper class for piece-wise construction of an RColumnDescriptor
1360
1361Dangling column descriptors can become actual descriptors when added to an
1362RNTupleDescriptorBuilder instance and then linked to their fields.
1363*/
1364// clang-format on
1366private:
1368
1369public:
1370 /// Make an empty column descriptor builder.
1372
1384 {
1385 fColumn.fBitsOnStorage = bitsOnStorage;
1386 return *this;
1387 }
1389 {
1390 fColumn.fType = type;
1391 return *this;
1392 }
1394 {
1395 fColumn.fFieldId = fieldId;
1396 return *this;
1397 }
1399 {
1400 fColumn.fIndex = index;
1401 return *this;
1402 }
1404 {
1406 return *this;
1407 }
1409 {
1410 R__ASSERT(fColumn.fFirstElementIndex != 0);
1411 if (fColumn.fFirstElementIndex > 0)
1412 fColumn.fFirstElementIndex = -fColumn.fFirstElementIndex;
1413 return *this;
1414 }
1416 {
1418 return *this;
1419 }
1420 RColumnDescriptorBuilder &ValueRange(double min, double max)
1421 {
1422 fColumn.fValueRange = {min, max};
1423 return *this;
1424 }
1425 RColumnDescriptorBuilder &ValueRange(std::optional<RColumnDescriptor::RValueRange> valueRange)
1426 {
1427 fColumn.fValueRange = valueRange;
1428 return *this;
1429 }
1430 ROOT::DescriptorId_t GetFieldId() const { return fColumn.fFieldId; }
1432 /// Attempt to make a column descriptor. This may fail if the column
1433 /// was not given enough information to make a proper descriptor.
1434 RResult<RColumnDescriptor> MakeDescriptor() const;
1435};
1436
1437// clang-format off
1438/**
1439\class ROOT::Internal::RFieldDescriptorBuilder
1440\ingroup NTuple
1441\brief A helper class for piece-wise construction of an RFieldDescriptor
1442
1443Dangling field descriptors describe a single field in isolation. They are
1444missing the necessary relationship information (parent field, any child fields)
1445required to describe a real RNTuple field.
1446
1447Dangling field descriptors can only become actual descriptors when added to an
1448RNTupleDescriptorBuilder instance and then linked to other fields.
1449*/
1450// clang-format on
1452private:
1454
1455public:
1456 /// Make an empty dangling field descriptor.
1458
1459 /// Make a new RFieldDescriptorBuilder based off a live RNTuple field.
1460 static RFieldDescriptorBuilder FromField(const ROOT::RFieldBase &field);
1461
1463 {
1464 fField.fFieldId = fieldId;
1465 return *this;
1466 }
1468 {
1469 fField.fFieldVersion = fieldVersion;
1470 return *this;
1471 }
1473 {
1474 fField.fTypeVersion = typeVersion;
1475 return *this;
1476 }
1478 {
1479 fField.fParentId = id;
1480 return *this;
1481 }
1483 {
1484 fField.fProjectionSourceId = id;
1485 return *this;
1486 }
1488 {
1489 fField.fFieldName = fieldName;
1490 return *this;
1491 }
1493 {
1495 return *this;
1496 }
1497 RFieldDescriptorBuilder &TypeName(const std::string &typeName)
1498 {
1499 fField.fTypeName = typeName;
1500 return *this;
1501 }
1503 {
1504 fField.fTypeAlias = typeAlias;
1505 return *this;
1506 }
1508 {
1509 fField.fNRepetitions = nRepetitions;
1510 return *this;
1511 }
1513 {
1514 fField.fStructure = structure;
1515 return *this;
1516 }
1517 RFieldDescriptorBuilder &TypeChecksum(const std::optional<std::uint32_t> typeChecksum)
1518 {
1519 fField.fTypeChecksum = typeChecksum;
1520 return *this;
1521 }
1522 ROOT::DescriptorId_t GetParentId() const { return fField.fParentId; }
1523 /// Attempt to make a field descriptor. This may fail if the dangling field
1524 /// was not given enough information to make a proper descriptor.
1525 RResult<RFieldDescriptor> MakeDescriptor() const;
1526};
1527
1528// clang-format off
1529/**
1530\class ROOT::Internal::RClusterDescriptorBuilder
1531\ingroup NTuple
1532\brief A helper class for piece-wise construction of an RClusterDescriptor
1533
1534The cluster descriptor builder starts from a summary-only cluster descriptor and allows for the
1535piecewise addition of page locations.
1536*/
1537// clang-format on
1539private:
1541
1542public:
1544 {
1545 fCluster.fClusterId = clusterId;
1546 return *this;
1547 }
1548
1550 {
1552 return *this;
1553 }
1554
1556 {
1557 fCluster.fNEntries = nEntries;
1558 return *this;
1559 }
1560
1561 RResult<void> CommitColumnRange(ROOT::DescriptorId_t physicalId, std::uint64_t firstElementIndex,
1563
1564 /// Books the given column ID as being suppressed in this cluster. The correct first element index and number of
1565 /// elements need to be set by CommitSuppressedColumnRanges() once all the calls to CommitColumnRange() and
1566 /// MarkSuppressedColumnRange() took place.
1567 RResult<void> MarkSuppressedColumnRange(ROOT::DescriptorId_t physicalId);
1568
1569 /// Sets the first element index and number of elements for all the suppressed column ranges.
1570 /// The information is taken from the corresponding columns from the primary representation.
1571 /// Needs to be called when all the columns (suppressed and regular) where added.
1572 RResult<void> CommitSuppressedColumnRanges(const RNTupleDescriptor &desc);
1573
1574 /// Add column and page ranges for columns created during late model extension missing in this cluster. The locator
1575 /// type for the synthesized page ranges is `kTypePageZero`. All the page sources must be able to populate the
1576 /// 'zero' page from such locator. Any call to CommitColumnRange() and CommitSuppressedColumnRanges()
1577 /// should happen before calling this function.
1578 RClusterDescriptorBuilder &AddExtendedColumnRanges(const RNTupleDescriptor &desc);
1579
1584
1585 /// Move out the full cluster descriptor including page locations
1586 RResult<RClusterDescriptor> MoveDescriptor();
1587};
1588
1589// clang-format off
1590/**
1591\class ROOT::Internal::RClusterGroupDescriptorBuilder
1592\ingroup NTuple
1593\brief A helper class for piece-wise construction of an RClusterGroupDescriptor
1594*/
1595// clang-format on
1597private:
1599
1600public:
1603
1615 {
1616 fClusterGroup.fPageListLength = pageListLength;
1617 return *this;
1618 }
1620 {
1621 fClusterGroup.fMinEntry = minEntry;
1622 return *this;
1623 }
1625 {
1626 fClusterGroup.fEntrySpan = entrySpan;
1627 return *this;
1628 }
1630 {
1631 fClusterGroup.fNClusters = nClusters;
1632 return *this;
1633 }
1634 void AddSortedClusters(const std::vector<ROOT::DescriptorId_t> &clusterIds)
1635 {
1636 if (clusterIds.size() != fClusterGroup.GetNClusters())
1637 throw RException(R__FAIL("mismatch of number of clusters"));
1638 fClusterGroup.fClusterIds = clusterIds;
1639 }
1640
1641 RResult<RClusterGroupDescriptor> MoveDescriptor();
1642};
1643
1644// clang-format off
1645/**
1646\class ROOT::Internal::RExtraTypeInfoDescriptorBuilder
1647\ingroup NTuple
1648\brief A helper class for piece-wise construction of an RExtraTypeInfoDescriptor
1649*/
1650// clang-format on
1652private:
1654
1655public:
1657
1659 {
1660 fExtraTypeInfo.fContentId = contentId;
1661 return *this;
1662 }
1664 {
1665 fExtraTypeInfo.fTypeVersion = typeVersion;
1666 return *this;
1667 }
1668 RExtraTypeInfoDescriptorBuilder &TypeName(const std::string &typeName)
1669 {
1670 fExtraTypeInfo.fTypeName = typeName;
1671 return *this;
1672 }
1674 {
1675 fExtraTypeInfo.fContent = content;
1676 return *this;
1677 }
1678
1679 RResult<RExtraTypeInfoDescriptor> MoveDescriptor();
1680};
1681
1682// clang-format off
1683/**
1684\class ROOT::Internal::RNTupleDescriptorBuilder
1685\ingroup NTuple
1686\brief A helper class for piece-wise construction of an RNTupleDescriptor
1687
1688Used by RPageStorage implementations in order to construct the RNTupleDescriptor from the various header parts.
1689*/
1690// clang-format on
1692private:
1694 RResult<void> EnsureFieldExists(ROOT::DescriptorId_t fieldId) const;
1695
1696public:
1697 /// Checks whether invariants hold:
1698 /// * RNTuple epoch is valid
1699 /// * RNTuple name is valid
1700 /// * Fields have valid parents
1701 /// * Number of columns is constant across column representations
1702 RResult<void> EnsureValidDescriptor() const;
1703 const RNTupleDescriptor &GetDescriptor() const { return fDescriptor; }
1704 RNTupleDescriptor MoveDescriptor();
1705
1706 /// Copies the "schema" part of `descriptor` into the builder's descriptor.
1707 /// This resets the builder's descriptor.
1708 void SetSchemaFromExisting(const RNTupleDescriptor &descriptor);
1709
1710 void SetVersion(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor,
1711 std::uint16_t versionPatch);
1712 void SetVersionForWriting();
1713
1714 void SetNTuple(const std::string_view name, const std::string_view description);
1715 void SetFeature(unsigned int flag);
1716
1717 void SetOnDiskHeaderXxHash3(std::uint64_t xxhash3) { fDescriptor.fOnDiskHeaderXxHash3 = xxhash3; }
1718 void SetOnDiskHeaderSize(std::uint64_t size) { fDescriptor.fOnDiskHeaderSize = size; }
1719 /// The real footer size also include the page list envelopes
1720 void AddToOnDiskFooterSize(std::uint64_t size) { fDescriptor.fOnDiskFooterSize += size; }
1721
1722 void AddField(const RFieldDescriptor &fieldDesc);
1725
1726 // The field that the column belongs to has to be already available. For fields with multiple columns,
1727 // the columns need to be added in order of the column index
1729
1732
1734 void ReplaceExtraTypeInfo(RExtraTypeInfoDescriptor &&extraTypeInfoDesc);
1735
1737
1738 /// Mark the beginning of the header extension; any fields and columns added after a call to this function are
1739 /// annotated as begin part of the header extension.
1740 void BeginHeaderExtension();
1741
1742 /// \brief Shift column IDs of alias columns by `offset`
1743 ///
1744 /// If the descriptor is constructed in pieces consisting of physical and alias columns
1745 /// (regular and projected fields), the natural column order would be
1746 /// - Physical and alias columns of piece one
1747 /// - Physical and alias columns of piece two
1748 /// - etc.
1749 /// What we want, however, are first all physical column IDs and then all alias column IDs.
1750 /// This method adds `offset` to the logical column IDs of all alias columns and fixes up the corresponding
1751 /// column IDs in the projected field descriptors. In this way, a new piece of physical and alias columns can
1752 /// first shift the existing alias columns by the number of new physical columns, resulting in the following order
1753 /// - Physical columns of piece one
1754 /// - Physical columns of piece two
1755 /// - ...
1756 // - Logical columns of piece one
1757 /// - Logical columns of piece two
1758 /// - ...
1759 void ShiftAliasColumns(std::uint32_t offset);
1760};
1761
1763{
1764 return desc.CloneSchema();
1765}
1766
1767/// Tells if the field describes a user-defined enum type.
1768/// The dictionary does not need to be available for this method.
1769/// Needs the full descriptor to look up sub fields.
1771
1772/// Tells if the field describes a std::atomic<T> type
1774
1775} // namespace Internal
1776
1777} // namespace ROOT
1778
1779#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()