Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleDescriptor.cxx
Go to the documentation of this file.
1/// \file RNTupleDescriptor.cxx
2/// \ingroup NTuple
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \author Javier Lopez-Gomez <javier.lopez.gomez@cern.ch>
5/// \date 2018-10-04
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#include <ROOT/RError.hxx>
16#include <ROOT/RFieldBase.hxx>
17#include <ROOT/RNTuple.hxx>
19#include <ROOT/RNTupleModel.hxx>
20#include <ROOT/RNTupleTypes.hxx>
21#include <ROOT/RNTupleUtils.hxx>
22#include <ROOT/RPage.hxx>
23#include <string_view>
24
25#include <RZip.h>
26#include <TError.h>
27
28#include <algorithm>
29#include <cstdint>
30#include <deque>
31#include <functional>
32#include <iostream>
33#include <set>
34#include <utility>
35
37
39{
40 return fFieldId == other.fFieldId && fFieldVersion == other.fFieldVersion && fTypeVersion == other.fTypeVersion &&
41 fFieldName == other.fFieldName && fFieldDescription == other.fFieldDescription &&
42 fTypeName == other.fTypeName && fTypeAlias == other.fTypeAlias && fNRepetitions == other.fNRepetitions &&
43 fStructure == other.fStructure && fParentId == other.fParentId &&
44 fProjectionSourceId == other.fProjectionSourceId && fLinkIds == other.fLinkIds &&
45 fLogicalColumnIds == other.fLogicalColumnIds && fTypeChecksum == other.fTypeChecksum &&
46 fIsSoACollection == other.fIsSoACollection;
47}
48
50{
51 RFieldDescriptor clone;
52 clone.fFieldId = fFieldId;
53 clone.fFieldVersion = fFieldVersion;
54 clone.fTypeVersion = fTypeVersion;
55 clone.fFieldName = fFieldName;
56 clone.fFieldDescription = fFieldDescription;
57 clone.fTypeName = fTypeName;
58 clone.fTypeAlias = fTypeAlias;
59 clone.fNRepetitions = fNRepetitions;
60 clone.fStructure = fStructure;
61 clone.fParentId = fParentId;
62 clone.fProjectionSourceId = fProjectionSourceId;
63 clone.fLinkIds = fLinkIds;
64 clone.fColumnCardinality = fColumnCardinality;
65 clone.fLogicalColumnIds = fLogicalColumnIds;
66 clone.fTypeChecksum = fTypeChecksum;
67 clone.fIsSoACollection = fIsSoACollection;
68 return clone;
69}
70
71std::unique_ptr<ROOT::RFieldBase>
73{
74 if (GetStructure() == ROOT::ENTupleStructure::kStreamer) {
75 auto streamerField = std::make_unique<ROOT::RStreamerField>(GetFieldName(), GetTypeName());
76 streamerField->SetOnDiskId(fFieldId);
77 return streamerField;
78 }
79
80 // The structure may be unknown if the descriptor comes from a deserialized field with an unknown structural role.
81 // For forward compatibility, we allow this case and return an InvalidField.
82 if (GetStructure() == ROOT::ENTupleStructure::kUnknown) {
83 if (options.GetReturnInvalidOnError()) {
84 auto invalidField = std::make_unique<ROOT::RInvalidField>(GetFieldName(), GetTypeName(), "",
86 invalidField->SetOnDiskId(fFieldId);
87 return invalidField;
88 } else {
89 throw RException(R__FAIL("unexpected on-disk field structure value for field \"" + GetFieldName() + "\""));
90 }
91 }
92
93 // Untyped records and collections
94 if (GetTypeName().empty()) {
95 switch (GetStructure()) {
97 std::vector<std::unique_ptr<ROOT::RFieldBase>> memberFields;
98 memberFields.reserve(fLinkIds.size());
99 for (auto id : fLinkIds) {
100 const auto &memberDesc = ntplDesc.GetFieldDescriptor(id);
101 auto field = memberDesc.CreateField(ntplDesc, options);
103 return field;
104 memberFields.emplace_back(std::move(field));
105 }
106 auto recordField = std::make_unique<ROOT::RRecordField>(GetFieldName(), std::move(memberFields));
107 recordField->SetOnDiskId(fFieldId);
108 return recordField;
109 }
111 if (fLinkIds.size() != 1) {
112 throw RException(R__FAIL("unsupported untyped collection for field \"" + GetFieldName() + "\""));
113 }
114 auto itemField = ntplDesc.GetFieldDescriptor(fLinkIds[0]).CreateField(ntplDesc, options);
116 return itemField;
117 auto collectionField = ROOT::RVectorField::CreateUntyped(GetFieldName(), std::move(itemField));
118 collectionField->SetOnDiskId(fFieldId);
119 return collectionField;
120 }
121 default: throw RException(R__FAIL("unsupported untyped field structure for field \"" + GetFieldName() + "\""));
122 }
123 }
124
125 try {
126 const auto &fieldName = GetFieldName();
127 const auto &typeName = GetTypeAlias().empty() ? GetTypeName() : GetTypeAlias();
128 // NOTE: Unwrap() here may throw an exception, hence the try block.
129 // If options.fReturnInvalidOnError is false we just rethrow it, otherwise we return an InvalidField wrapping the
130 // error.
131 auto field = ROOT::Internal::CallFieldBaseCreate(fieldName, typeName, options, &ntplDesc, fFieldId).Unwrap();
132 field->SetOnDiskId(fFieldId);
133
134 for (auto &subfield : *field) {
135 const auto subfieldId = ntplDesc.FindFieldId(subfield.GetFieldName(), subfield.GetParent()->GetOnDiskId());
136 subfield.SetOnDiskId(subfieldId);
138 auto &invalidField = static_cast<ROOT::RInvalidField &>(subfield);
139 // A subfield being invalid "infects" its entire ancestry.
140 return invalidField.Clone(fieldName);
141 }
142 }
143
144 return field;
145 } catch (const RException &ex) {
146 if (options.GetReturnInvalidOnError())
147 return std::make_unique<ROOT::RInvalidField>(GetFieldName(), GetTypeName(), ex.GetError().GetReport(),
149 else
150 throw ex;
151 }
152}
153
155{
157 return false;
158
159 // Skip untyped structs
160 if (fTypeName.empty())
161 return false;
162
163 if (fStructure == ROOT::ENTupleStructure::kRecord) {
164 if (fTypeName.compare(0, 10, "std::pair<") == 0)
165 return false;
166 if (fTypeName.compare(0, 11, "std::tuple<") == 0)
167 return false;
168 }
169
170 return true;
171}
172
174{
175 return Internal::IsCustomEnumFieldDesc(desc, *this);
176}
177
182
183////////////////////////////////////////////////////////////////////////////////
184
186{
187 return fLogicalColumnId == other.fLogicalColumnId && fPhysicalColumnId == other.fPhysicalColumnId &&
188 fBitsOnStorage == other.fBitsOnStorage && fType == other.fType && fFieldId == other.fFieldId &&
189 fIndex == other.fIndex && fRepresentationIndex == other.fRepresentationIndex &&
190 fValueRange == other.fValueRange;
191}
192
194{
195 RColumnDescriptor clone;
196 clone.fLogicalColumnId = fLogicalColumnId;
197 clone.fPhysicalColumnId = fPhysicalColumnId;
198 clone.fBitsOnStorage = fBitsOnStorage;
199 clone.fType = fType;
200 clone.fFieldId = fFieldId;
201 clone.fIndex = fIndex;
202 clone.fFirstElementIndex = fFirstElementIndex;
203 clone.fRepresentationIndex = fRepresentationIndex;
204 clone.fValueRange = fValueRange;
205 return clone;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209
212{
213 if (!fCumulativeNElements) {
214 // Small range, just iterate through fPageInfos
217 for (const auto &pi : fPageInfos) {
218 if (firstInPage + pi.GetNElements() > idxInCluster) {
220 }
221 pageNumber++;
222 firstInPage += pi.GetNElements();
223 }
224 R__ASSERT(false);
225 }
226
227 const auto N = fCumulativeNElements->size();
228 R__ASSERT(N > 0);
229 R__ASSERT(N == fPageInfos.size());
230
231 std::size_t left = 0;
232 std::size_t right = N - 1;
233 std::size_t midpoint = N;
234 while (left <= right) {
235 midpoint = (left + right) / 2;
236 if ((*fCumulativeNElements)[midpoint] <= idxInCluster) {
237 left = midpoint + 1;
238 continue;
239 }
240
241 if ((midpoint == 0) || ((*fCumulativeNElements)[midpoint - 1] <= idxInCluster))
242 break;
243
244 right = midpoint - 1;
245 }
247
248 auto pageInfo = fPageInfos[midpoint];
249 decltype(idxInCluster) firstInPage = (midpoint == 0) ? 0 : (*fCumulativeNElements)[midpoint - 1];
251 R__ASSERT((firstInPage + pageInfo.GetNElements()) > idxInCluster);
253}
254
255std::size_t
258 std::size_t pageSize)
259{
260 R__ASSERT(fPhysicalColumnId == columnRange.GetPhysicalColumnId());
261 R__ASSERT(!columnRange.IsSuppressed());
262
263 const auto nElements =
264 std::accumulate(fPageInfos.begin(), fPageInfos.end(), 0U,
265 [](std::size_t n, const auto &pageInfo) { return n + pageInfo.GetNElements(); });
266 const auto nElementsRequired = static_cast<std::uint64_t>(columnRange.GetNElements());
267
269 return 0U;
270 R__ASSERT((nElementsRequired > nElements) && "invalid attempt to shrink RPageRange");
271
272 std::vector<RPageInfo> pageInfos;
273 // Synthesize new `RPageInfo`s as needed
274 const std::uint64_t nElementsPerPage = pageSize / element.GetSize();
278 pageInfo.SetNElements(std::min(nElementsPerPage, nRemainingElements));
281 locator.SetNBytesOnStorage(element.GetPackedSize(pageInfo.GetNElements()));
282 pageInfo.SetLocator(locator);
283 pageInfos.emplace_back(pageInfo);
284 nRemainingElements -= pageInfo.GetNElements();
285 }
286
287 pageInfos.insert(pageInfos.end(), std::make_move_iterator(fPageInfos.begin()),
288 std::make_move_iterator(fPageInfos.end()));
289 std::swap(fPageInfos, pageInfos);
291}
292
294{
295 return fClusterId == other.fClusterId && fFirstEntryIndex == other.fFirstEntryIndex &&
296 fNEntries == other.fNEntries && fColumnRanges == other.fColumnRanges && fPageRanges == other.fPageRanges;
297}
298
300{
301 std::uint64_t nbytes = 0;
302 for (const auto &pr : fPageRanges) {
303 for (const auto &pi : pr.second.GetPageInfos()) {
304 nbytes += pi.GetLocator().GetNBytesOnStorage();
305 }
306 }
307 return nbytes;
308}
309
311{
312 RClusterDescriptor clone;
313 clone.fClusterId = fClusterId;
314 clone.fFirstEntryIndex = fFirstEntryIndex;
315 clone.fNEntries = fNEntries;
316 clone.fColumnRanges = fColumnRanges;
317 for (const auto &d : fPageRanges)
318 clone.fPageRanges.emplace(d.first, d.second.Clone());
319 return clone;
320}
321
322////////////////////////////////////////////////////////////////////////////////
323
325{
326 return fContentId == other.fContentId && fTypeName == other.fTypeName && fTypeVersion == other.fTypeVersion;
327}
328
330{
332 clone.fContentId = fContentId;
333 clone.fTypeVersion = fTypeVersion;
334 clone.fTypeName = fTypeName;
335 clone.fContent = fContent;
336 return clone;
337}
338
339////////////////////////////////////////////////////////////////////////////////
340
345
347{
348 // clang-format off
349 return fName == other.fName &&
350 fDescription == other.fDescription &&
351 fNEntries == other.fNEntries &&
352 fGeneration == other.fGeneration &&
353 fFieldZeroId == other.fFieldZeroId &&
354 fFieldDescriptors == other.fFieldDescriptors &&
355 fColumnDescriptors == other.fColumnDescriptors &&
356 fClusterGroupDescriptors == other.fClusterGroupDescriptors &&
357 fClusterDescriptors == other.fClusterDescriptors;
358 // clang-format on
359}
360
362{
364 for (const auto &cd : fClusterDescriptors) {
365 if (!cd.second.ContainsColumn(physicalColumnId))
366 continue;
367 auto columnRange = cd.second.GetColumnRange(physicalColumnId);
368 result = std::max(result, columnRange.GetFirstElementIndex() + columnRange.GetNElements());
369 }
370 return result;
371}
372
373////////////////////////////////////////////////////////////////////////////////
374/// Return the cluster boundaries for each cluster in this RNTuple.
375std::vector<ROOT::Internal::RNTupleClusterBoundaries>
377{
378 std::vector<Internal::RNTupleClusterBoundaries> boundaries;
379 boundaries.reserve(desc.GetNClusters());
380 auto clusterId = desc.FindClusterId(0, 0);
382 const auto &clusterDesc = desc.GetClusterDescriptor(clusterId);
383 R__ASSERT(clusterDesc.GetNEntries() > 0);
384 boundaries.emplace_back(ROOT::Internal::RNTupleClusterBoundaries{
385 clusterDesc.GetFirstEntryIndex(), clusterDesc.GetFirstEntryIndex() + clusterDesc.GetNEntries()});
387 }
388 return boundaries;
389}
390
393{
394 std::string leafName(fieldName);
395 auto posDot = leafName.find_last_of('.');
396 if (posDot != std::string::npos) {
397 auto parentName = leafName.substr(0, posDot);
398 leafName = leafName.substr(posDot + 1);
399 parentId = FindFieldId(parentName, parentId);
400 }
401 auto itrFieldDesc = fFieldDescriptors.find(parentId);
402 if (itrFieldDesc == fFieldDescriptors.end())
404 for (const auto linkId : itrFieldDesc->second.GetLinkIds()) {
405 if (fFieldDescriptors.at(linkId).GetFieldName() == leafName)
406 return linkId;
407 }
409}
410
412{
414 return "";
415
416 const auto &fieldDescriptor = fFieldDescriptors.at(fieldId);
417 auto prefix = GetQualifiedFieldName(fieldDescriptor.GetParentId());
418 if (prefix.empty())
419 return fieldDescriptor.GetFieldName();
420 return prefix + "." + fieldDescriptor.GetFieldName();
421}
422
424{
425 std::string typeName = fieldDesc.GetTypeName();
426
427 // ROOT v6.34, with spec versions before 1.0.0.1, did not properly renormalize the type name.
428 R__ASSERT(fVersionEpoch == 1);
429 if (fVersionMajor == 0 && fVersionMinor == 0 && fVersionPatch < 1) {
430 typeName = ROOT::Internal::GetRenormalizedTypeName(typeName);
431 }
432
433 return typeName;
434}
435
437{
438 return FindFieldId(fieldName, GetFieldZeroId());
439}
440
442 std::uint32_t columnIndex,
443 std::uint16_t representationIndex) const
444{
445 auto itr = fFieldDescriptors.find(fieldId);
446 if (itr == fFieldDescriptors.cend())
448 if (columnIndex >= itr->second.GetColumnCardinality())
450 const auto idx = representationIndex * itr->second.GetColumnCardinality() + columnIndex;
451 if (itr->second.GetLogicalColumnIds().size() <= idx)
453 return itr->second.GetLogicalColumnIds()[idx];
454}
455
457 std::uint32_t columnIndex,
458 std::uint16_t representationIndex) const
459{
460 auto logicalId = FindLogicalColumnId(fieldId, columnIndex, representationIndex);
463 return GetColumnDescriptor(logicalId).GetPhysicalId();
464}
465
468{
469 if (GetNClusterGroups() == 0)
471
472 // Binary search in the cluster group list, followed by a binary search in the clusters of that cluster group
473
474 std::size_t cgLeft = 0;
475 std::size_t cgRight = GetNClusterGroups() - 1;
476 while (cgLeft <= cgRight) {
477 const std::size_t cgMidpoint = (cgLeft + cgRight) / 2;
478 const auto &clusterIds = GetClusterGroupDescriptor(fSortedClusterGroupIds[cgMidpoint]).GetClusterIds();
479 R__ASSERT(!clusterIds.empty());
480
481 const auto &clusterDesc = GetClusterDescriptor(clusterIds.front());
482 // this may happen if the RNTuple has an empty schema
483 if (!clusterDesc.ContainsColumn(physicalColumnId))
485
486 const auto firstElementInGroup = clusterDesc.GetColumnRange(physicalColumnId).GetFirstElementIndex();
488 // Look into the lower half of cluster groups
490 cgRight = cgMidpoint - 1;
491 continue;
492 }
493
494 const auto &lastColumnRange = GetClusterDescriptor(clusterIds.back()).GetColumnRange(physicalColumnId);
495 if ((lastColumnRange.GetFirstElementIndex() + lastColumnRange.GetNElements()) <= index) {
496 // Look into the upper half of cluster groups
497 cgLeft = cgMidpoint + 1;
498 continue;
499 }
500
501 // Binary search in the current cluster group; since we already checked the element range boundaries,
502 // the element must be in that cluster group.
503 std::size_t clusterLeft = 0;
504 std::size_t clusterRight = clusterIds.size() - 1;
505 while (clusterLeft <= clusterRight) {
506 const std::size_t clusterMidpoint = (clusterLeft + clusterRight) / 2;
508 const auto &columnRange = GetClusterDescriptor(clusterId).GetColumnRange(physicalColumnId);
509
510 if (columnRange.Contains(index))
511 return clusterId;
512
513 if (columnRange.GetFirstElementIndex() > index) {
516 continue;
517 }
518
519 if (columnRange.GetFirstElementIndex() + columnRange.GetNElements() <= index) {
521 continue;
522 }
523 }
524 R__ASSERT(false);
525 }
527}
528
530{
531 if (GetNClusterGroups() == 0)
533
534 // Binary search in the cluster group list, followed by a binary search in the clusters of that cluster group
535
536 std::size_t cgLeft = 0;
537 std::size_t cgRight = GetNClusterGroups() - 1;
538 while (cgLeft <= cgRight) {
539 const std::size_t cgMidpoint = (cgLeft + cgRight) / 2;
540 const auto &cgDesc = GetClusterGroupDescriptor(fSortedClusterGroupIds[cgMidpoint]);
541
542 if (cgDesc.GetMinEntry() > entryIdx) {
544 cgRight = cgMidpoint - 1;
545 continue;
546 }
547
548 if (cgDesc.GetMinEntry() + cgDesc.GetEntrySpan() <= entryIdx) {
549 cgLeft = cgMidpoint + 1;
550 continue;
551 }
552
553 // Binary search in the current cluster group; since we already checked the element range boundaries,
554 // the element must be in that cluster group.
555 const auto &clusterIds = cgDesc.GetClusterIds();
556 R__ASSERT(!clusterIds.empty());
557 std::size_t clusterLeft = 0;
558 std::size_t clusterRight = clusterIds.size() - 1;
559 while (clusterLeft <= clusterRight) {
560 const std::size_t clusterMidpoint = (clusterLeft + clusterRight) / 2;
561 const auto &clusterDesc = GetClusterDescriptor(clusterIds[clusterMidpoint]);
562
563 if (clusterDesc.GetFirstEntryIndex() > entryIdx) {
566 continue;
567 }
568
569 if (clusterDesc.GetFirstEntryIndex() + clusterDesc.GetNEntries() <= entryIdx) {
571 continue;
572 }
573
575 }
576 R__ASSERT(false);
577 }
579}
580
582{
583 // TODO(jblomer): we may want to shortcut the common case and check if clusterId + 1 contains
584 // firstEntryInNextCluster. This shortcut would currently always trigger. We do not want, however, to depend
585 // on the linearity of the descriptor IDs, so we should only enable the shortcut if we can ensure that the
586 // binary search code path remains tested.
587 const auto &clusterDesc = GetClusterDescriptor(clusterId);
588 const auto firstEntryInNextCluster = clusterDesc.GetFirstEntryIndex() + clusterDesc.GetNEntries();
589 return FindClusterId(firstEntryInNextCluster);
590}
591
593{
594 // TODO(jblomer): we may want to shortcut the common case and check if clusterId - 1 contains
595 // firstEntryInNextCluster. This shortcut would currently always trigger. We do not want, however, to depend
596 // on the linearity of the descriptor IDs, so we should only enable the shortcut if we can ensure that the
597 // binary search code path remains tested.
598 const auto &clusterDesc = GetClusterDescriptor(clusterId);
599 if (clusterDesc.GetFirstEntryIndex() == 0)
601 return FindClusterId(clusterDesc.GetFirstEntryIndex() - 1);
602}
603
604std::vector<ROOT::DescriptorId_t>
606{
607 std::vector<ROOT::DescriptorId_t> fields;
608 for (const auto fieldId : fFieldIdsOrder) {
609 if (fFieldIdsLookup.count(desc.GetFieldDescriptor(fieldId).GetParentId()) == 0)
610 fields.emplace_back(fieldId);
611 }
612 return fields;
613}
614
620
622 : fNTuple(ntuple)
623{
624 std::deque<ROOT::DescriptorId_t> fieldIdQueue{ntuple.GetFieldZeroId()};
625
626 while (!fieldIdQueue.empty()) {
627 auto currFieldId = fieldIdQueue.front();
628 fieldIdQueue.pop_front();
629
630 const auto &columns = ntuple.GetFieldDescriptor(currFieldId).GetLogicalColumnIds();
631 fColumns.insert(fColumns.end(), columns.begin(), columns.end());
632
633 for (const auto &field : ntuple.GetFieldIterable(currFieldId)) {
634 auto fieldId = field.GetId();
635 fieldIdQueue.push_back(fieldId);
636 }
637 }
638}
639
640std::vector<std::uint64_t> ROOT::RNTupleDescriptor::GetFeatureFlags() const
641{
642 std::vector<std::uint64_t> result;
643 unsigned int base = 0;
644 std::uint64_t flags = 0;
645 for (auto f : fFeatureFlags) {
646 if ((f > 0) && ((f % 64) == 0))
647 throw RException(R__FAIL("invalid feature flag: " + std::to_string(f)));
648 while (f > base + 64) {
649 result.emplace_back(flags);
650 flags = 0;
651 base += 64;
652 }
653 f -= base;
654 flags |= std::uint64_t(1) << f;
655 }
656 result.emplace_back(flags);
657 return result;
658}
659
661 std::vector<RClusterDescriptor> &clusterDescs)
662{
664 if (iter == fClusterGroupDescriptors.end())
665 return R__FAIL("invalid attempt to add details of unknown cluster group");
666 if (iter->second.HasClusterDetails())
667 return R__FAIL("invalid attempt to re-populate cluster group details");
668 if (iter->second.GetNClusters() != clusterDescs.size())
669 return R__FAIL("mismatch of number of clusters");
670
671 std::vector<ROOT::DescriptorId_t> clusterIds;
672 for (unsigned i = 0; i < clusterDescs.size(); ++i) {
673 clusterIds.emplace_back(clusterDescs[i].GetId());
674 auto [_, success] = fClusterDescriptors.emplace(clusterIds.back(), std::move(clusterDescs[i]));
675 if (!success) {
676 return R__FAIL("invalid attempt to re-populate existing cluster");
677 }
678 }
680 return fClusterDescriptors[a].GetFirstEntryIndex() < fClusterDescriptors[b].GetFirstEntryIndex();
681 });
683 cgBuilder.AddSortedClusters(clusterIds);
684 iter->second = cgBuilder.MoveDescriptor().Unwrap();
685 return RResult<void>::Success();
686}
687
689{
691 if (iter == fClusterGroupDescriptors.end())
692 return R__FAIL("invalid attempt to drop cluster details of unknown cluster group");
693 if (!iter->second.HasClusterDetails())
694 return R__FAIL("invalid attempt to drop details of cluster group summary");
695
696 for (auto clusterId : iter->second.GetClusterIds())
698 iter->second = iter->second.CloneSummary();
699 return RResult<void>::Success();
700}
701
702std::unique_ptr<ROOT::RNTupleModel> ROOT::RNTupleDescriptor::CreateModel(const RCreateModelOptions &options) const
703{
704 // Collect all top-level fields that have invalid columns (recursively): by default if we find any we throw an
705 // exception; if we are in ForwardCompatible mode, we proceed but skip of all those top-level fields.
706 std::unordered_set<ROOT::DescriptorId_t> invalidFields;
707 for (const auto &colDesc : GetColumnIterable()) {
709 auto fieldId = colDesc.GetFieldId();
710 while (1) {
711 const auto &field = GetFieldDescriptor(fieldId);
712 if (field.GetParentId() == GetFieldZeroId())
713 break;
714 fieldId = field.GetParentId();
715 }
716 invalidFields.insert(fieldId);
717
718 // No need to look for all invalid fields if we're gonna error out anyway
719 if (!options.GetForwardCompatible())
720 break;
721 }
722 }
723
724 if (!options.GetForwardCompatible() && !invalidFields.empty())
726 "cannot create Model: descriptor contains unknown column types. Use 'SetForwardCompatible(true)' on the "
727 "RCreateModelOptions to create a partial model containing only the fields made up by known columns."));
728
729 auto fieldZero = std::make_unique<ROOT::RFieldZero>();
730 fieldZero->SetOnDiskId(GetFieldZeroId());
731 auto model = options.GetCreateBare() ? RNTupleModel::CreateBare(std::move(fieldZero))
732 : RNTupleModel::Create(std::move(fieldZero));
734 createFieldOpts.SetReturnInvalidOnError(options.GetForwardCompatible());
735 createFieldOpts.SetEmulateUnknownTypes(options.GetEmulateUnknownTypes());
736 for (const auto &topDesc : GetTopLevelFields()) {
737 if (invalidFields.count(topDesc.GetId()) > 0) {
738 // Field contains invalid columns: skip it
739 continue;
740 }
741
742 auto field = topDesc.CreateField(*this, createFieldOpts);
743
744 // If we got an InvalidField here, figure out if it's a hard error or if the field must simply be skipped.
745 // The only case where it's not a hard error is if the field has an unknown structure, as that case is
746 // covered by the ForwardCompatible flag (note that if the flag is off we would not get here
747 // in the first place, so we don't need to check for that flag again).
748 if (field->GetTraits() & ROOT::RFieldBase::kTraitInvalidField) {
749 const auto &invalid = static_cast<const RInvalidField &>(*field);
750 const auto cat = invalid.GetCategory();
752 if (mustThrow)
753 throw invalid.GetError();
754
755 // Not a hard error: skip the field and go on.
756 continue;
757 }
758
759 if (options.GetReconstructProjections() && topDesc.IsProjectedField()) {
760 model->AddProjectedField(std::move(field), [this](const std::string &targetName) -> std::string {
761 return GetQualifiedFieldName(GetFieldDescriptor(FindFieldId(targetName)).GetProjectionSourceId());
762 });
763 } else {
764 model->AddField(std::move(field));
765 }
766 }
767 model->Freeze();
768 return model;
769}
770
772{
773 RNTupleDescriptor clone;
774 clone.fName = fName;
779 // OnDiskHeaderSize, OnDiskHeaderXxHash3 not copied because they may come from a merged header + extension header
780 // and therefore not represent the actual sources's header.
781 // OnDiskFooterSize not copied because it contains information beyond the schema, for example the clustering.
782
783 for (const auto &d : fFieldDescriptors)
784 clone.fFieldDescriptors.emplace(d.first, d.second.Clone());
785 for (const auto &d : fColumnDescriptors)
786 clone.fColumnDescriptors.emplace(d.first, d.second.Clone());
787
788 for (const auto &d : fExtraTypeInfoDescriptors)
789 clone.fExtraTypeInfoDescriptors.emplace_back(d.Clone());
791 clone.fHeaderExtension = std::make_unique<RHeaderExtension>(*fHeaderExtension);
792
793 return clone;
794}
795
797{
799
804
808 clone.fNEntries = fNEntries;
809 clone.fNClusters = fNClusters;
810 clone.fGeneration = fGeneration;
811 for (const auto &d : fClusterGroupDescriptors)
812 clone.fClusterGroupDescriptors.emplace(d.first, d.second.Clone());
814 for (const auto &d : fClusterDescriptors)
815 clone.fClusterDescriptors.emplace(d.first, d.second.Clone());
816 for (const auto &d : fAttributeSets)
817 clone.fAttributeSets.emplace_back(d.Clone());
818 return clone;
819}
820
821////////////////////////////////////////////////////////////////////////////////
822
824{
825 return fClusterGroupId == other.fClusterGroupId && fClusterIds == other.fClusterIds &&
826 fMinEntry == other.fMinEntry && fEntrySpan == other.fEntrySpan && fNClusters == other.fNClusters;
827}
828
830{
832 clone.fClusterGroupId = fClusterGroupId;
833 clone.fPageListLocator = fPageListLocator;
834 clone.fPageListLength = fPageListLength;
835 clone.fMinEntry = fMinEntry;
836 clone.fEntrySpan = fEntrySpan;
837 clone.fNClusters = fNClusters;
838 return clone;
839}
840
842{
843 RClusterGroupDescriptor clone = CloneSummary();
844 clone.fClusterIds = fClusterIds;
845 return clone;
846}
847
848////////////////////////////////////////////////////////////////////////////////
849
852 std::uint64_t firstElementIndex,
853 std::uint32_t compressionSettings,
855{
856 if (physicalId != pageRange.fPhysicalColumnId)
857 return R__FAIL("column ID mismatch");
858 if (fCluster.fColumnRanges.count(physicalId) > 0)
859 return R__FAIL("column ID conflict");
861 for (const auto &pi : pageRange.fPageInfos) {
862 columnRange.IncrementNElements(pi.GetNElements());
863 }
864 fCluster.fPageRanges[physicalId] = pageRange.Clone();
865 fCluster.fColumnRanges[physicalId] = columnRange;
866 return RResult<void>::Success();
867}
868
871{
872 if (fCluster.fColumnRanges.count(physicalId) > 0)
873 return R__FAIL("column ID conflict");
874
876 columnRange.SetPhysicalColumnId(physicalId);
877 columnRange.SetIsSuppressed(true);
878 fCluster.fColumnRanges[physicalId] = columnRange;
879 return RResult<void>::Success();
880}
881
884{
885 for (auto &[_, columnRange] : fCluster.fColumnRanges) {
886 if (!columnRange.IsSuppressed())
887 continue;
888 R__ASSERT(columnRange.GetFirstElementIndex() == ROOT::kInvalidNTupleIndex);
889
890 const auto &columnDesc = desc.GetColumnDescriptor(columnRange.GetPhysicalColumnId());
891 const auto &fieldDesc = desc.GetFieldDescriptor(columnDesc.GetFieldId());
892 // We expect only few columns and column representations per field, so we do a linear search
893 for (const auto otherColumnLogicalId : fieldDesc.GetLogicalColumnIds()) {
895 if (otherColumnDesc.GetRepresentationIndex() == columnDesc.GetRepresentationIndex())
896 continue;
897 if (otherColumnDesc.GetIndex() != columnDesc.GetIndex())
898 continue;
899
900 // Found corresponding column of a different column representation
901 const auto &otherColumnRange = fCluster.GetColumnRange(otherColumnDesc.GetPhysicalId());
902 if (otherColumnRange.IsSuppressed())
903 continue;
904
905 columnRange.SetFirstElementIndex(otherColumnRange.GetFirstElementIndex());
906 columnRange.SetNElements(otherColumnRange.GetNElements());
907 break;
908 }
909
910 if (columnRange.GetFirstElementIndex() == ROOT::kInvalidNTupleIndex) {
911 return R__FAIL(std::string("cannot find non-suppressed column for column ID ") +
912 std::to_string(columnRange.GetPhysicalColumnId()) +
913 ", cluster ID: " + std::to_string(fCluster.GetId()));
914 }
915 }
916 return RResult<void>::Success();
917}
918
921{
922 /// Carries out a depth-first traversal of a field subtree rooted at `rootFieldId`. For each field, `visitField` is
923 /// called passing the field ID and the number of overall repetitions, taking into account the repetitions of each
924 /// parent field in the hierarchy.
926 const auto &visitField, const auto &enterSubtree) -> void {
928 for (const auto &f : desc.GetFieldIterable(rootFieldId)) {
929 const std::uint64_t nRepetitions = std::max(f.GetNRepetitions(), std::uint64_t{1U}) * nRepetitionsAtThisLevel;
931 }
932 };
933
934 // Extended columns can only be part of the header extension
935 if (!desc.GetHeaderExtension())
936 return *this;
937
938 // Ensure that all columns in the header extension have their associated `R(Column|Page)Range`
939 // Extended columns can be attached both to fields of the regular header and to fields of the extension header
940 for (const auto &topLevelField : desc.GetTopLevelFields()) {
942 topLevelField.GetId(), std::max(topLevelField.GetNRepetitions(), std::uint64_t{1U}),
943 [&](ROOT::DescriptorId_t fieldId, std::uint64_t nRepetitions) {
944 for (const auto &c : desc.GetColumnIterable(fieldId)) {
945 const ROOT::DescriptorId_t physicalId = c.GetPhysicalId();
946 auto &columnRange = fCluster.fColumnRanges[physicalId];
947
948 // Initialize a RColumnRange for `physicalId` if it was not there. Columns that were created during model
949 // extension won't have on-disk metadata for the clusters that were already committed before the model
950 // was extended. Therefore, these need to be synthetically initialized upon reading.
951 if (columnRange.GetPhysicalColumnId() == ROOT::kInvalidDescriptorId) {
952 columnRange.SetPhysicalColumnId(physicalId);
953 columnRange.SetFirstElementIndex(0);
954 columnRange.SetNElements(0);
955 columnRange.SetIsSuppressed(c.IsSuppressedDeferredColumn());
956 }
957 // Fixup the RColumnRange and RPageRange in deferred columns. We know what the first element index and
958 // number of elements should have been if the column was not deferred; fix those and let
959 // `ExtendToFitColumnRange()` synthesize RPageInfos accordingly.
960 // Note that a deferred column (i.e, whose first element index is > 0) already met the criteria of
961 // `ROOT::RFieldBase::EntryToColumnElementIndex()`, i.e. it is a principal column reachable from the
962 // field zero excluding subfields of collection and variant fields.
963 if (c.IsDeferredColumn()) {
964 if (c.GetRepresentationIndex() == 0) {
965 columnRange.SetFirstElementIndex(fCluster.GetFirstEntryIndex() * nRepetitions);
966 columnRange.SetNElements(fCluster.GetNEntries() * nRepetitions);
967 } else {
968 // Deferred representations which are not the first cannot count on the number of elements being
969 // equal to Entries * nRepetitions because they might have been added in a later cluster. But they
970 // can rely on the first representation having the correct FirstElement/NElements (by definition
971 // the first representation cannot be an "extended" one), therefore they can just copy the value
972 // from it.
973 const auto &field = desc.GetFieldDescriptor(fieldId);
974 const auto firstReprColumnId = field.GetLogicalColumnIds()[c.GetIndex()];
975 const auto &firstReprColumnRange = fCluster.fColumnRanges[firstReprColumnId];
976 columnRange.SetFirstElementIndex(firstReprColumnRange.GetFirstElementIndex());
977 columnRange.SetNElements(firstReprColumnRange.GetNElements());
978 }
979 if (!columnRange.IsSuppressed()) {
980 auto &pageRange = fCluster.fPageRanges[physicalId];
981 pageRange.fPhysicalColumnId = physicalId;
982 const auto element = ROOT::Internal::RColumnElementBase::Generate<void>(c.GetType());
983 pageRange.ExtendToFitColumnRange(columnRange, *element, ROOT::Internal::RPage::kPageZeroSize);
984 }
985 } else if (!columnRange.IsSuppressed()) {
986 fCluster.fPageRanges[physicalId].fPhysicalColumnId = physicalId;
987 }
988 }
989 },
991 }
992 return *this;
993}
994
996{
997 if (fCluster.fClusterId == ROOT::kInvalidDescriptorId)
998 return R__FAIL("unset cluster ID");
999 if (fCluster.fNEntries == 0)
1000 return R__FAIL("empty cluster");
1001 for (auto &pr : fCluster.fPageRanges) {
1002 if (fCluster.fColumnRanges.count(pr.first) == 0) {
1003 return R__FAIL("missing column range");
1004 }
1005 pr.second.fCumulativeNElements.reset();
1006 const auto nPages = pr.second.fPageInfos.size();
1008 pr.second.fCumulativeNElements = std::make_unique<std::vector<NTupleSize_t>>();
1009 pr.second.fCumulativeNElements->reserve(nPages);
1011 for (const auto &pi : pr.second.fPageInfos) {
1012 sum += pi.GetNElements();
1013 pr.second.fCumulativeNElements->emplace_back(sum);
1014 }
1015 }
1016 }
1018 std::swap(result, fCluster);
1019 return result;
1020}
1021
1022////////////////////////////////////////////////////////////////////////////////
1023
1026{
1028 builder.ClusterGroupId(clusterGroupDesc.GetId())
1029 .PageListLocator(clusterGroupDesc.GetPageListLocator())
1030 .PageListLength(clusterGroupDesc.GetPageListLength())
1031 .MinEntry(clusterGroupDesc.GetMinEntry())
1032 .EntrySpan(clusterGroupDesc.GetEntrySpan())
1033 .NClusters(clusterGroupDesc.GetNClusters());
1034 return builder;
1035}
1036
1038{
1039 if (fClusterGroup.fClusterGroupId == ROOT::kInvalidDescriptorId)
1040 return R__FAIL("unset cluster group ID");
1042 std::swap(result, fClusterGroup);
1043 return result;
1044}
1045
1046////////////////////////////////////////////////////////////////////////////////
1047
1049{
1050 if (fExtraTypeInfo.fContentId == EExtraTypeInfoIds::kInvalid)
1051 throw RException(R__FAIL("invalid extra type info content id"));
1053 std::swap(result, fExtraTypeInfo);
1054 return result;
1055}
1056
1057////////////////////////////////////////////////////////////////////////////////
1058
1060{
1061 if (fDescriptor.fFieldDescriptors.count(fieldId) == 0)
1062 return R__FAIL("field with id '" + std::to_string(fieldId) + "' doesn't exist");
1063 return RResult<void>::Success();
1064}
1065
1067{
1068 if (fDescriptor.fVersionEpoch != RNTuple::kVersionEpoch) {
1069 return R__FAIL("unset or unsupported RNTuple epoch version");
1070 }
1071
1072 // Reuse field name validity check
1073 auto validName = ROOT::Internal::EnsureValidNameForRNTuple(fDescriptor.GetName(), "Field");
1074 if (!validName) {
1076 }
1077
1078 for (const auto &[fieldId, fieldDesc] : fDescriptor.fFieldDescriptors) {
1079 // parent not properly set?
1080 if (fieldId != fDescriptor.GetFieldZeroId() && fieldDesc.GetParentId() == ROOT::kInvalidDescriptorId) {
1081 return R__FAIL("field with id '" + std::to_string(fieldId) + "' has an invalid parent id");
1082 }
1083
1084 // Same number of columns in every column representation?
1085 const auto columnCardinality = fieldDesc.GetColumnCardinality();
1086 if (columnCardinality == 0)
1087 continue;
1088
1089 // In AddColumn, we already checked that all but the last representation are complete.
1090 // Check that the last column representation is complete, i.e. has all columns.
1091 const auto &logicalColumnIds = fieldDesc.GetLogicalColumnIds();
1092 const auto nColumns = logicalColumnIds.size();
1093 // If we have only a single column representation, the following condition is true by construction
1094 if ((nColumns + 1) == columnCardinality)
1095 continue;
1096
1097 const auto &lastColumn = fDescriptor.GetColumnDescriptor(logicalColumnIds.back());
1098 if (lastColumn.GetIndex() + 1 != columnCardinality)
1099 return R__FAIL("field with id '" + std::to_string(fieldId) + "' has incomplete column representations");
1100 }
1101
1102 return RResult<void>::Success();
1103}
1104
1106{
1107 EnsureValidDescriptor().ThrowOnError();
1108 fDescriptor.fSortedClusterGroupIds.reserve(fDescriptor.fClusterGroupDescriptors.size());
1109 for (const auto &[id, _] : fDescriptor.fClusterGroupDescriptors)
1110 fDescriptor.fSortedClusterGroupIds.emplace_back(id);
1111 std::sort(fDescriptor.fSortedClusterGroupIds.begin(), fDescriptor.fSortedClusterGroupIds.end(),
1113 return fDescriptor.fClusterGroupDescriptors[a].GetMinEntry() <
1114 fDescriptor.fClusterGroupDescriptors[b].GetMinEntry();
1115 });
1117 std::swap(result, fDescriptor);
1118 return result;
1119}
1120
1122 std::uint16_t versionMinor, std::uint16_t versionPatch)
1123{
1125 throw RException(R__FAIL("unsupported RNTuple epoch version: " + std::to_string(versionEpoch)));
1126 }
1127 fDescriptor.fVersionEpoch = versionEpoch;
1128 fDescriptor.fVersionMajor = versionMajor;
1129 fDescriptor.fVersionMinor = versionMinor;
1130 fDescriptor.fVersionPatch = versionPatch;
1131}
1132
1134{
1135 fDescriptor.fVersionEpoch = RNTuple::kVersionEpoch;
1136 fDescriptor.fVersionMajor = RNTuple::kVersionMajor;
1137 fDescriptor.fVersionMinor = RNTuple::kVersionMinor;
1138 fDescriptor.fVersionPatch = RNTuple::kVersionPatch;
1139}
1140
1142 const std::string_view description)
1143{
1144 fDescriptor.fName = std::string(name);
1145 fDescriptor.fDescription = std::string(description);
1146}
1147
1149{
1150 if (flag % 64 == 0)
1151 throw RException(R__FAIL("invalid feature flag: " + std::to_string(flag)));
1152 fDescriptor.fFeatureFlags.insert(flag);
1153}
1154
1157{
1158 if (fDesc.fName.empty())
1159 return R__FAIL("attribute set name cannot be empty");
1160 if (fDesc.fAnchorLength == 0)
1161 return R__FAIL("invalid anchor length");
1162 if (fDesc.fAnchorLocator.GetType() == RNTupleLocator::kTypeUnknown)
1163 return R__FAIL("invalid locator type");
1164
1165 return std::move(fDesc);
1166}
1167
1169{
1170 if (fColumn.GetLogicalId() == ROOT::kInvalidDescriptorId)
1171 return R__FAIL("invalid logical column id");
1172 if (fColumn.GetPhysicalId() == ROOT::kInvalidDescriptorId)
1173 return R__FAIL("invalid physical column id");
1174 if (fColumn.GetFieldId() == ROOT::kInvalidDescriptorId)
1175 return R__FAIL("invalid field id, dangling column");
1176
1177 // NOTE: if the column type is unknown we don't want to fail, as we might be reading an RNTuple
1178 // created with a future version of ROOT. In this case we just skip the valid bit range check,
1179 // as we have no idea what the valid range is.
1180 // In general, reading the metadata of an unknown column is fine, it becomes an error only when
1181 // we try to read the actual data contained in it.
1182 if (fColumn.GetType() != ENTupleColumnType::kUnknown) {
1183 const auto [minBits, maxBits] = ROOT::Internal::RColumnElementBase::GetValidBitRange(fColumn.GetType());
1184 if (fColumn.GetBitsOnStorage() < minBits || fColumn.GetBitsOnStorage() > maxBits)
1185 return R__FAIL("invalid column bit width");
1186 }
1187
1188 return fColumn.Clone();
1189}
1190
1193{
1195 fieldDesc.FieldVersion(field.GetFieldVersion())
1196 .TypeVersion(field.GetTypeVersion())
1197 .FieldName(field.GetFieldName())
1198 .FieldDescription(field.GetDescription())
1199 .TypeName(field.GetTypeName())
1200 .TypeAlias(field.GetTypeAlias())
1201 .Structure(field.GetStructure())
1202 .NRepetitions(field.GetNRepetitions());
1204 fieldDesc.TypeChecksum(field.GetTypeChecksum());
1205 if (field.GetTraits() & ROOT::RFieldBase::kTraitSoACollection) {
1206 assert(field.GetStructure() == ENTupleStructure::kCollection);
1207 fieldDesc.IsSoACollection(true);
1208 }
1209 return fieldDesc;
1210}
1211
1213{
1214 if (fField.GetId() == ROOT::kInvalidDescriptorId) {
1215 return R__FAIL("invalid field id");
1216 }
1217 if (fField.GetStructure() == ROOT::ENTupleStructure::kInvalid) {
1218 return R__FAIL("invalid field structure");
1219 }
1220 if (fField.IsSoACollection() && (fField.GetStructure() != ROOT::ENTupleStructure::kCollection)) {
1221 return R__FAIL("invalid SoA flag on non-collection field");
1222 }
1223 // FieldZero is usually named "" and would be a false positive here
1224 if (fField.GetParentId() != ROOT::kInvalidDescriptorId) {
1225 auto validName = ROOT::Internal::EnsureValidNameForRNTuple(fField.GetFieldName(), "Field");
1226 if (!validName) {
1228 }
1229 if (fField.GetFieldName().empty()) {
1230 return R__FAIL("name cannot be empty string \"\"");
1231 }
1232 }
1233 return fField.Clone();
1234}
1235
1237{
1238 fDescriptor.fFieldDescriptors.emplace(fieldDesc.GetId(), fieldDesc.Clone());
1239 if (fDescriptor.fHeaderExtension)
1240 fDescriptor.fHeaderExtension->MarkExtendedField(fieldDesc);
1241 if (fieldDesc.GetFieldName().empty() && fieldDesc.GetParentId() == ROOT::kInvalidDescriptorId) {
1242 fDescriptor.fFieldZeroId = fieldDesc.GetId();
1243 }
1244}
1245
1248{
1250 if (!(fieldExists = EnsureFieldExists(fieldId)))
1252 if (!(fieldExists = EnsureFieldExists(linkId)))
1253 return R__FAIL("child field with id '" + std::to_string(linkId) + "' doesn't exist in NTuple");
1254
1255 if (linkId == fDescriptor.GetFieldZeroId()) {
1256 return R__FAIL("cannot make FieldZero a child field");
1257 }
1258 // fail if field already has another valid parent
1259 auto parentId = fDescriptor.fFieldDescriptors.at(linkId).GetParentId();
1261 return R__FAIL("field '" + std::to_string(linkId) + "' already has a parent ('" + std::to_string(parentId) + ")");
1262 }
1263 if (fieldId == linkId) {
1264 return R__FAIL("cannot make field '" + std::to_string(fieldId) + "' a child of itself");
1265 }
1266 fDescriptor.fFieldDescriptors.at(linkId).fParentId = fieldId;
1267 fDescriptor.fFieldDescriptors.at(fieldId).fLinkIds.push_back(linkId);
1268 return RResult<void>::Success();
1269}
1270
1273{
1275 if (!(fieldExists = EnsureFieldExists(sourceId)))
1277 if (!(fieldExists = EnsureFieldExists(targetId)))
1278 return R__FAIL("projected field with id '" + std::to_string(targetId) + "' doesn't exist in NTuple");
1279
1280 if (targetId == fDescriptor.GetFieldZeroId()) {
1281 return R__FAIL("cannot make FieldZero a projected field");
1282 }
1283 if (sourceId == targetId) {
1284 return R__FAIL("cannot make field '" + std::to_string(targetId) + "' a projection of itself");
1285 }
1286 if (fDescriptor.fFieldDescriptors.at(sourceId).IsProjectedField()) {
1287 return R__FAIL("cannot make field '" + std::to_string(targetId) + "' a projection of an already projected field");
1288 }
1289 // fail if target field already has another valid projection source
1290 auto &targetDesc = fDescriptor.fFieldDescriptors.at(targetId);
1291 if (targetDesc.IsProjectedField() && targetDesc.GetProjectionSourceId() != sourceId) {
1292 return R__FAIL("field '" + std::to_string(targetId) + "' has already a projection source ('" +
1293 std::to_string(targetDesc.GetProjectionSourceId()) + ")");
1294 }
1295 fDescriptor.fFieldDescriptors.at(targetId).fProjectionSourceId = sourceId;
1296 return RResult<void>::Success();
1297}
1298
1300{
1301 const auto fieldId = columnDesc.GetFieldId();
1302 const auto columnIndex = columnDesc.GetIndex();
1303 const auto representationIndex = columnDesc.GetRepresentationIndex();
1304
1305 auto fieldExists = EnsureFieldExists(fieldId);
1306 if (!fieldExists) {
1308 }
1309 auto &fieldDesc = fDescriptor.fFieldDescriptors.find(fieldId)->second;
1310
1311 if (columnDesc.IsAliasColumn()) {
1312 if (columnDesc.GetType() != fDescriptor.GetColumnDescriptor(columnDesc.GetPhysicalId()).GetType())
1313 return R__FAIL("alias column type mismatch");
1314 }
1315 if (fDescriptor.FindLogicalColumnId(fieldId, columnIndex, representationIndex) != ROOT::kInvalidDescriptorId) {
1316 return R__FAIL("column index clash");
1317 }
1318 if (columnIndex > 0) {
1319 if (fDescriptor.FindLogicalColumnId(fieldId, columnIndex - 1, representationIndex) == ROOT::kInvalidDescriptorId)
1320 return R__FAIL("out of bounds column index");
1321 }
1322 if (representationIndex > 0) {
1323 if (fDescriptor.FindLogicalColumnId(fieldId, 0, representationIndex - 1) == ROOT::kInvalidDescriptorId) {
1324 return R__FAIL("out of bounds representation index");
1325 }
1326 if (columnIndex == 0) {
1327 assert(fieldDesc.fColumnCardinality > 0);
1328 if (fDescriptor.FindLogicalColumnId(fieldId, fieldDesc.fColumnCardinality - 1, representationIndex - 1) ==
1330 return R__FAIL("incomplete column representations");
1331 }
1332 } else {
1333 if (columnIndex >= fieldDesc.fColumnCardinality)
1334 return R__FAIL("irregular column representations");
1335 }
1336 } else {
1337 // This will set the column cardinality to the number of columns of the first representation
1338 fieldDesc.fColumnCardinality = columnIndex + 1;
1339 }
1340
1341 const auto logicalId = columnDesc.GetLogicalId();
1342 fieldDesc.fLogicalColumnIds.emplace_back(logicalId);
1343
1344 if (!columnDesc.IsAliasColumn())
1345 fDescriptor.fNPhysicalColumns++;
1346 fDescriptor.fColumnDescriptors.emplace(logicalId, std::move(columnDesc));
1347 if (fDescriptor.fHeaderExtension)
1348 fDescriptor.fHeaderExtension->MarkExtendedColumn(columnDesc);
1349
1350 return RResult<void>::Success();
1351}
1352
1354{
1355 const auto id = clusterGroup.GetId();
1356 if (fDescriptor.fClusterGroupDescriptors.count(id) > 0)
1357 return R__FAIL("cluster group id clash");
1358 fDescriptor.fNEntries = std::max(fDescriptor.fNEntries, clusterGroup.GetMinEntry() + clusterGroup.GetEntrySpan());
1359 fDescriptor.fNClusters += clusterGroup.GetNClusters();
1360 fDescriptor.fClusterGroupDescriptors.emplace(id, std::move(clusterGroup));
1361 return RResult<void>::Success();
1362}
1363
1368
1370{
1371 if (!fDescriptor.fHeaderExtension)
1372 fDescriptor.fHeaderExtension = std::make_unique<RNTupleDescriptor::RHeaderExtension>();
1373}
1374
1376{
1377 if (fDescriptor.GetNLogicalColumns() == 0)
1378 return;
1379 R__ASSERT(fDescriptor.GetNPhysicalColumns() > 0);
1380
1381 for (ROOT::DescriptorId_t id = fDescriptor.GetNLogicalColumns() - 1; id >= fDescriptor.GetNPhysicalColumns(); --id) {
1382 auto c = fDescriptor.fColumnDescriptors[id].Clone();
1383 R__ASSERT(c.IsAliasColumn());
1384 R__ASSERT(id == c.GetLogicalId());
1385 fDescriptor.fColumnDescriptors.erase(id);
1386 for (auto &link : fDescriptor.fFieldDescriptors[c.fFieldId].fLogicalColumnIds) {
1387 if (link == c.fLogicalColumnId) {
1388 link += offset;
1389 break;
1390 }
1391 }
1392 c.fLogicalColumnId += offset;
1393 R__ASSERT(fDescriptor.fColumnDescriptors.count(c.fLogicalColumnId) == 0);
1394 fDescriptor.fColumnDescriptors.emplace(c.fLogicalColumnId, std::move(c));
1395 }
1396
1397 // Patch up column ids in the header extension
1398 if (auto &xHeader = fDescriptor.fHeaderExtension) {
1399 for (auto &columnId : xHeader->fExtendedColumnRepresentations) {
1400 if (columnId >= fDescriptor.GetNPhysicalColumns())
1401 columnId += offset;
1402 }
1403 }
1404}
1405
1407{
1408 auto clusterId = clusterDesc.GetId();
1409 if (fDescriptor.fClusterDescriptors.count(clusterId) > 0)
1410 return R__FAIL("cluster id clash");
1411 fDescriptor.fClusterDescriptors.emplace(clusterId, std::move(clusterDesc));
1412 return RResult<void>::Success();
1413}
1414
1417{
1418 // Make sure we have no duplicates
1419 if (std::find(fDescriptor.fExtraTypeInfoDescriptors.begin(), fDescriptor.fExtraTypeInfoDescriptors.end(),
1420 extraTypeInfoDesc) != fDescriptor.fExtraTypeInfoDescriptors.end()) {
1421 return R__FAIL("extra type info duplicates");
1422 }
1423 fDescriptor.fExtraTypeInfoDescriptors.emplace_back(std::move(extraTypeInfoDesc));
1424 return RResult<void>::Success();
1425}
1426
1428{
1429 auto it = std::find(fDescriptor.fExtraTypeInfoDescriptors.begin(), fDescriptor.fExtraTypeInfoDescriptors.end(),
1431 if (it != fDescriptor.fExtraTypeInfoDescriptors.end())
1432 *it = std::move(extraTypeInfoDesc);
1433 else
1434 fDescriptor.fExtraTypeInfoDescriptors.emplace_back(std::move(extraTypeInfoDesc));
1435}
1436
1439{
1440 auto &attrSets = fDescriptor.fAttributeSets;
1441 if (std::find_if(attrSets.begin(), attrSets.end(), [&name = attrSetDesc.GetName()](const auto &desc) {
1442 return desc.GetName() == name;
1443 }) != attrSets.end()) {
1444 return R__FAIL("attribute sets with duplicate names");
1445 }
1446 attrSets.push_back(std::move(attrSetDesc));
1447 return RResult<void>::Success();
1448}
1449
1454
1460
1467
1473
1480
1485
1491
1496
1502
1508
1513
1518
1523
1528
1530{
1531 return fAnchorLength == other.fAnchorLength && fSchemaVersionMajor == other.fSchemaVersionMajor &&
1532 fSchemaVersionMinor == other.fSchemaVersionMinor && fAnchorLocator == other.fAnchorLocator &&
1533 fName == other.fName;
1534};
1535
1537{
1539 desc.fAnchorLength = fAnchorLength;
1540 desc.fSchemaVersionMajor = fSchemaVersionMajor;
1541 desc.fSchemaVersionMinor = fSchemaVersionMinor;
1542 desc.fAnchorLocator = fAnchorLocator;
1543 desc.fName = fName;
1544 return desc;
1545}
1546
1548{
1549 if (fieldDesc.GetStructure() != ROOT::ENTupleStructure::kPlain)
1550 return false;
1551 if (fieldDesc.GetTypeName().rfind("std::", 0) == 0)
1552 return false;
1553
1554 auto subFieldId = desc.FindFieldId("_0", fieldDesc.GetId());
1556 return false;
1557
1558 static const std::string gIntTypeNames[] = {"bool", "char", "std::int8_t", "std::uint8_t",
1559 "std::int16_t", "std::uint16_t", "std::int32_t", "std::uint32_t",
1560 "std::int64_t", "std::uint64_t"};
1561 return std::find(std::begin(gIntTypeNames), std::end(gIntTypeNames),
1562 desc.GetFieldDescriptor(subFieldId).GetTypeName()) != std::end(gIntTypeNames);
1563}
1564
1566{
1567 if (fieldDesc.GetStructure() != ROOT::ENTupleStructure::kPlain)
1568 return false;
1569 return (fieldDesc.GetTypeName().rfind("std::atomic<", 0) == 0);
1570}
#define R__FORWARD_ERROR(res)
Short-hand to return an RResult<T> in an error state (i.e. after checking)
Definition RError.hxx:304
#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
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
#define N
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 Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
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 id
char name[80]
Definition TGX11.cxx:145
#define _(A, B)
Definition cfortran.h:108
RResult< ROOT::Experimental::RNTupleAttrSetDescriptor > MoveDescriptor()
Attempt to make an AttributeSet descriptor.
Used to loop over all the Attribute Sets linked to an RNTuple.
Metadata stored for every Attribute Set linked to an RNTuple.
bool operator==(const RNTupleAttrSetDescriptor &other) const
std::uint32_t fAnchorLength
uncompressed size of the linked anchor
A helper class for piece-wise construction of an RClusterDescriptor.
RResult< void > MarkSuppressedColumnRange(ROOT::DescriptorId_t physicalId)
Books the given column ID as being suppressed in this cluster.
RResult< void > CommitColumnRange(ROOT::DescriptorId_t physicalId, std::uint64_t firstElementIndex, std::uint32_t compressionSettings, const RClusterDescriptor::RPageRange &pageRange)
RClusterDescriptorBuilder & AddExtendedColumnRanges(const RNTupleDescriptor &desc)
Add column and page ranges for columns created during late model extension missing in this cluster.
RResult< void > CommitSuppressedColumnRanges(const RNTupleDescriptor &desc)
Sets the first element index and number of elements for all the suppressed column ranges.
RResult< RClusterDescriptor > MoveDescriptor()
Move out the full cluster descriptor including page locations.
A helper class for piece-wise construction of an RClusterGroupDescriptor.
RClusterGroupDescriptorBuilder & EntrySpan(std::uint64_t entrySpan)
RClusterGroupDescriptorBuilder & PageListLocator(const RNTupleLocator &pageListLocator)
static RClusterGroupDescriptorBuilder FromSummary(const RClusterGroupDescriptor &clusterGroupDesc)
RClusterGroupDescriptorBuilder & PageListLength(std::uint64_t pageListLength)
RClusterGroupDescriptorBuilder & MinEntry(std::uint64_t minEntry)
RResult< RClusterGroupDescriptor > MoveDescriptor()
RClusterGroupDescriptorBuilder & ClusterGroupId(ROOT::DescriptorId_t clusterGroupId)
RClusterGroupDescriptorBuilder & NClusters(std::uint32_t nClusters)
RResult< RColumnDescriptor > MakeDescriptor() const
Attempt to make a column descriptor.
A column element encapsulates the translation between basic C++ types and their column representation...
static std::pair< std::uint16_t, std::uint16_t > GetValidBitRange(ROOT::ENTupleColumnType type)
Most types have a fixed on-disk bit width.
RResult< RExtraTypeInfoDescriptor > MoveDescriptor()
A helper class for piece-wise construction of an RFieldDescriptor.
RResult< RFieldDescriptor > MakeDescriptor() const
Attempt to make a field descriptor.
static RFieldDescriptorBuilder FromField(const ROOT::RFieldBase &field)
Make a new RFieldDescriptorBuilder based off a live RNTuple field.
void SetNTuple(const std::string_view name, const std::string_view description)
void SetSchemaFromExisting(const RNTupleDescriptor &descriptor)
Copies the "schema" part of descriptor into the builder's descriptor.
RResult< void > AddColumn(RColumnDescriptor &&columnDesc)
RResult< void > AddAttributeSet(Experimental::RNTupleAttrSetDescriptor &&attrSetDesc)
RResult< void > AddFieldProjection(ROOT::DescriptorId_t sourceId, ROOT::DescriptorId_t targetId)
void ReplaceExtraTypeInfo(RExtraTypeInfoDescriptor &&extraTypeInfoDesc)
RResult< void > AddExtraTypeInfo(RExtraTypeInfoDescriptor &&extraTypeInfoDesc)
void ShiftAliasColumns(std::uint32_t offset)
Shift column IDs of alias columns by offset
void SetVersion(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor, std::uint16_t versionPatch)
void BeginHeaderExtension()
Mark the beginning of the header extension; any fields and columns added after a call to this functio...
RResult< void > AddCluster(RClusterDescriptor &&clusterDesc)
RResult< void > EnsureValidDescriptor() const
Checks whether invariants hold:
RResult< void > AddFieldLink(ROOT::DescriptorId_t fieldId, ROOT::DescriptorId_t linkId)
void AddField(const RFieldDescriptor &fieldDesc)
RResult< void > AddClusterGroup(RClusterGroupDescriptor &&clusterGroup)
RResult< void > EnsureFieldExists(ROOT::DescriptorId_t fieldId) const
A helper class for serializing and deserialization of the RNTuple binary format.
The window of element indexes of a particular column in a particular cluster.
Records the partition of data into pages for a particular column in a particular cluster.
static constexpr std::size_t kLargeRangeThreshold
Create the fCumulativeNElements only when its needed, i.e. when there are many pages to search throug...
RPageInfoExtended Find(ROOT::NTupleSize_t idxInCluster) const
Find the page in the RPageRange that contains the given element. The element must exist.
std::size_t ExtendToFitColumnRange(const RColumnRange &columnRange, const ROOT::Internal::RColumnElementBase &element, std::size_t pageSize)
Extend this RPageRange to fit the given RColumnRange.
Metadata for RNTuple clusters.
ROOT::NTupleSize_t fFirstEntryIndex
Clusters can be swapped by adjusting the entry offsets of the cluster and all ranges.
std::unordered_map< ROOT::DescriptorId_t, RColumnRange > fColumnRanges
ROOT::DescriptorId_t fClusterId
RClusterDescriptor Clone() const
bool operator==(const RClusterDescriptor &other) const
RColumnRangeIterable GetColumnRangeIterable() const
Returns an iterator over pairs { columnId, columnRange }. The iteration order is unspecified.
std::unordered_map< ROOT::DescriptorId_t, RPageRange > fPageRanges
std::uint64_t GetNBytesOnStorage() const
Clusters are bundled in cluster groups.
RNTupleLocator fPageListLocator
The page list that corresponds to the cluster group.
RClusterGroupDescriptor Clone() const
std::vector< ROOT::DescriptorId_t > fClusterIds
The cluster IDs can be empty if the corresponding page list is not loaded.
std::uint64_t fMinEntry
The minimum first entry number of the clusters in the cluster group.
std::uint32_t fNClusters
Number of clusters is always known even if the cluster IDs are not (yet) populated.
std::uint64_t fPageListLength
Uncompressed size of the page list.
std::uint64_t fEntrySpan
Number of entries that are (partially for sharded clusters) covered by this cluster group.
bool operator==(const RClusterGroupDescriptor &other) const
RClusterGroupDescriptor CloneSummary() const
Creates a clone without the cluster IDs.
Metadata stored for every column of an RNTuple.
ROOT::DescriptorId_t fPhysicalColumnId
Usually identical to the logical column ID, except for alias columns where it references the shadowed...
bool operator==(const RColumnDescriptor &other) const
ROOT::DescriptorId_t fLogicalColumnId
The actual column identifier, which is the link to the corresponding field.
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.
std::uint32_t fIndex
A field can be serialized into several columns, which are numbered from zero to $n$.
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.
std::optional< RValueRange > fValueRange
Optional value range (used e.g. by quantized real fields)
RColumnDescriptor Clone() const
Get a copy of the descriptor.
Base class for all ROOT issued exceptions.
Definition RError.hxx:79
Field specific extra type information from the header / extenstion header.
bool operator==(const RExtraTypeInfoDescriptor &other) const
RExtraTypeInfoDescriptor Clone() const
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.
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.
@ kTraitSoACollection
The field represents a collection in SoA layout.
@ kTraitInvalidField
This field is an instance of RInvalidField and can be safely static_cast to it.
@ kTraitTypeChecksum
The TClass checksum is set and valid.
Metadata stored for every field of an RNTuple.
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.
std::uint64_t fNRepetitions
The number of elements per entry for fixed-size arrays.
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
bool operator==(const RFieldDescriptor &other) const
bool IsCustomClass() const R__DEPRECATED(6
bool IsStdAtomic() const R__DEPRECATED(6
std::string fFieldDescription
Free text set by the user.
ROOT::DescriptorId_t fParentId
Establishes sub field relationships, such as classes and collections.
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::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.
bool fIsSoACollection
Indicates if this is a collection that should be represented in memory by a SoA layout.
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::vector< ROOT::DescriptorId_t > fLogicalColumnIds
The ordered list of columns attached to this field: first by representation index then by column inde...
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...
Used in RFieldBase::Check() to record field creation failures.
Definition RField.hxx:97
@ kGeneric
Generic unrecoverable error.
@ kUnknownStructure
The field could not be created because its descriptor had an unknown structural role.
Used to loop over all the clusters of an RNTuple (in unspecified order)
Used to loop over all the cluster groups of an RNTuple (in unspecified order)
Used to loop over a field's associated columns.
std::vector< ROOT::DescriptorId_t > fColumns
The descriptor ids of the columns ordered by field, representation, and column index.
RColumnDescriptorIterable(const RNTupleDescriptor &ntuple, const RFieldDescriptor &fieldDesc)
Used to loop over all the extra type info record of an RNTuple (in unspecified order)
Used to loop over a field's child fields.
std::vector< ROOT::DescriptorId_t > GetTopMostFields(const RNTupleDescriptor &desc) const
Return a vector containing the IDs of the top-level fields defined in the extension header,...
The on-storage metadata of an RNTuple.
const RColumnDescriptor & GetColumnDescriptor(ROOT::DescriptorId_t columnId) const
ROOT::DescriptorId_t FindNextClusterId(ROOT::DescriptorId_t clusterId) const
RFieldDescriptorIterable GetFieldIterable(const RFieldDescriptor &fieldDesc) const
std::set< unsigned int > fFeatureFlags
std::unordered_map< ROOT::DescriptorId_t, RClusterGroupDescriptor > fClusterGroupDescriptors
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
std::uint64_t fNPhysicalColumns
Updated by the descriptor builder when columns are added.
std::vector< Experimental::RNTupleAttrSetDescriptor > fAttributeSets
List of AttributeSets linked to this RNTuple.
ROOT::DescriptorId_t fFieldZeroId
Set by the descriptor builder.
std::uint64_t fNEntries
Updated by the descriptor builder when the cluster groups are added.
RClusterGroupDescriptorIterable GetClusterGroupIterable() const
RColumnDescriptorIterable GetColumnIterable() const
bool operator==(const RNTupleDescriptor &other) const
std::uint64_t fOnDiskFooterSize
Like fOnDiskHeaderSize, contains both cluster summaries and page locations.
std::uint16_t fVersionMinor
Set by the descriptor builder when deserialized.
ROOT::DescriptorId_t FindClusterId(ROOT::NTupleSize_t entryIdx) const
std::vector< std::uint64_t > GetFeatureFlags() const
ROOT::DescriptorId_t GetFieldZeroId() const
Returns the logical parent of all top-level RNTuple data fields.
std::unique_ptr< ROOT::RNTupleModel > CreateModel(const RCreateModelOptions &options=RCreateModelOptions()) const
Re-create the C++ model from the stored metadata.
std::string GetTypeNameForComparison(const RFieldDescriptor &fieldDesc) const
Adjust the type name of the passed RFieldDescriptor for comparison with another renormalized type nam...
std::unordered_map< ROOT::DescriptorId_t, RClusterDescriptor > fClusterDescriptors
Potentially a subset of all the available clusters.
std::size_t GetNClusters() const
ROOT::DescriptorId_t FindPhysicalColumnId(ROOT::DescriptorId_t fieldId, std::uint32_t columnIndex, std::uint16_t representationIndex) const
RExtraTypeInfoDescriptorIterable GetExtraTypeInfoIterable() const
const RHeaderExtension * GetHeaderExtension() const
Return header extension information; if the descriptor does not have a header extension,...
std::uint64_t fNClusters
Updated by the descriptor builder when the cluster groups are added.
std::uint64_t fOnDiskHeaderXxHash3
Set by the descriptor builder when deserialized.
const RClusterDescriptor & GetClusterDescriptor(ROOT::DescriptorId_t clusterId) const
ROOT::DescriptorId_t FindFieldId(std::string_view fieldName, ROOT::DescriptorId_t parentId) const
std::string fName
The RNTuple name needs to be unique in a given storage location (file)
std::uint64_t fOnDiskHeaderSize
Set by the descriptor builder when deserialized.
RResult< void > DropClusterGroupDetails(ROOT::DescriptorId_t clusterGroupId)
std::uint16_t fVersionMajor
Set by the descriptor builder when deserialized.
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
ROOT::DescriptorId_t FindLogicalColumnId(ROOT::DescriptorId_t fieldId, std::uint32_t columnIndex, std::uint16_t representationIndex) const
std::unordered_map< ROOT::DescriptorId_t, RFieldDescriptor > fFieldDescriptors
ROOT::NTupleSize_t GetNElements(ROOT::DescriptorId_t physicalColumnId) const
RResult< void > AddClusterGroupDetails(ROOT::DescriptorId_t clusterGroupId, std::vector< RClusterDescriptor > &clusterDescs)
Methods to load and drop cluster group details (cluster IDs and page locations)
std::uint16_t fVersionPatch
Set by the descriptor builder when deserialized.
std::string fDescription
Free text from the user.
ROOT::Experimental::RNTupleAttrSetDescriptorIterable GetAttrSetIterable() const
RFieldDescriptorIterable GetTopLevelFields() const
std::uint16_t fVersionEpoch
Set by the descriptor builder when deserialized.
std::vector< RExtraTypeInfoDescriptor > fExtraTypeInfoDescriptors
RNTupleDescriptor Clone() const
std::string GetQualifiedFieldName(ROOT::DescriptorId_t fieldId) const
Walks up the parents of the field ID and returns a field name of the form a.b.c.d In case of invalid ...
RClusterDescriptorIterable GetClusterIterable() const
RNTupleDescriptor CloneSchema() const
Creates a descriptor containing only the schema information about this RNTuple, i....
std::uint64_t fGeneration
The generation of the descriptor.
ROOT::DescriptorId_t FindPrevClusterId(ROOT::DescriptorId_t clusterId) const
std::unique_ptr< RHeaderExtension > fHeaderExtension
Generic information about the physical location of data.
static std::unique_ptr< RNTupleModel > Create()
static std::unique_ptr< RNTupleModel > CreateBare()
Creates a "bare model", i.e. an RNTupleModel with no default entry.
static constexpr std::uint16_t kVersionPatch
Definition RNTuple.hxx:82
static constexpr std::uint16_t kVersionMajor
Definition RNTuple.hxx:80
static constexpr std::uint16_t kVersionEpoch
Definition RNTuple.hxx:79
static constexpr std::uint16_t kVersionMinor
Definition RNTuple.hxx:81
const_iterator begin() const
const_iterator end() const
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Definition RError.hxx:198
static std::unique_ptr< RVectorField > CreateUntyped(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField)
const Int_t n
Definition legend1.C:16
Double_t ex[n]
Definition legend1.C:17
ROOT::DescriptorId_t CallFindClusterIdOn(const ROOT::RNTupleDescriptor &desc, ROOT::NTupleSize_t entryIdx)
RResult< void > EnsureValidNameForRNTuple(std::string_view name, std::string_view where)
Check whether a given string is a valid name according to the RNTuple specification.
ROOT::RResult< std::unique_ptr< ROOT::RFieldBase > > CallFieldBaseCreate(const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
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.
std::string GetRenormalizedTypeName(const std::string &metaNormalizedName)
Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix.
bool IsStdAtomicFieldDesc(const RFieldDescriptor &fieldDesc)
Tells if the field describes a std::atomic<T> type.
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
Additional information about a page in an in-memory RPageRange.
Information about a single page in the context of a cluster's page range.
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2338