Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleView.cxx
Go to the documentation of this file.
1/// \file RNTupleView.cxx
2/// \author Jakob Blomer <jblomer@cern.ch>
3/// \date 2024-10-28
4
5/*************************************************************************
6 * Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#include <ROOT/RError.hxx>
14#include <ROOT/RFieldBase.hxx>
16#include <ROOT/RNTupleView.hxx>
17#include <ROOT/RPageStorage.hxx>
18
19#include <deque>
20
23{
24 std::uint64_t arraySize = 1;
26
27 {
28 auto descGuard = pageSource.GetSharedDescriptorGuard();
29 const auto &desc = descGuard.GetRef();
30
31 auto parentId = desc.GetFieldDescriptor(field.GetOnDiskId()).GetParentId();
32 while (parentId != desc.GetFieldZeroId()) {
33 const auto &fd = desc.GetFieldDescriptor(parentId);
34 if ((fd.GetStructure() != ROOT::ENTupleStructure::kPlain) &&
35 (fd.GetStructure() != ROOT::ENTupleStructure::kRecord)) {
36 break;
37 }
38 parentId = fd.GetParentId();
39 }
40 if (parentId == desc.GetFieldZeroId()) {
41 // This field is structurally a top-level field, hence we can avoid the calculation of column elements
42 // and instead return the number of entries.
43 return ROOT::RNTupleGlobalRange(0, desc.GetNEntries());
44 }
45
48 auto columnIterable = desc.GetColumnIterable(fieldId);
49 return (columnIterable.size() > 0) ? columnIterable.begin()->GetPhysicalId() : ROOT::kInvalidDescriptorId;
50 };
51
52 columnId = fnGetPrincipalColumnId(field.GetOnDiskId());
54 // We need to iterate the field descriptor tree, not the sub fields of `field`, because in the presence of
55 // read rules, the in-memory sub fields may be artificial and not have valid on-disk IDs.
56 const auto &linkIds = desc.GetFieldDescriptor(field.GetOnDiskId()).GetLinkIds();
57 std::deque<ROOT::DescriptorId_t> subFields(linkIds.begin(), linkIds.end());
58 while (!subFields.empty()) {
59 auto subFieldId = subFields.front();
60 subFields.pop_front();
63 break;
64
65 const auto &subLinkIds = desc.GetFieldDescriptor(subFieldId).GetLinkIds();
67 }
68 }
69
72 }
73
74 arraySize = std::max(arraySize, desc.GetFieldDescriptor(field.GetOnDiskId()).GetNRepetitions());
75 }
76
77 return ROOT::RNTupleGlobalRange(0, pageSource.GetNElements(columnId) / arraySize);
78}
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:130
Abstract interface to read data from an ntuple.
A field translates read and write calls from/to underlying columns to/from tree values.
Used to loop over indexes (entries or collections) between start and end.
const_iterator begin() const
const_iterator end() const
ROOT::RNTupleGlobalRange GetFieldRange(const ROOT::RFieldBase &field, ROOT::Internal::RPageSource &pageSource)
Helper to get the iteration space of the given field that needs to be connected to the given page sou...
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr NTupleSize_t kInvalidNTupleIndex
constexpr DescriptorId_t kInvalidDescriptorId