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 const auto &desc = pageSource.GetSharedDescriptorGuard().GetRef();
25
26 auto fnGetPrincipalColumnId = [&desc](ROOT::DescriptorId_t fieldId) -> ROOT::DescriptorId_t {
28 auto columnIterable = desc.GetColumnIterable(fieldId);
29 return (columnIterable.size() > 0) ? columnIterable.begin()->GetPhysicalId() : ROOT::kInvalidDescriptorId;
30 };
31
32 auto columnId = fnGetPrincipalColumnId(field.GetOnDiskId());
33 if (columnId == ROOT::kInvalidDescriptorId) {
34 // We need to iterate the field descriptor tree, not the sub fields of `field`, because in the presence of
35 // read rules, the in-memory sub fields may be artificial and not have valid on-disk IDs.
36 const auto &linkIds = desc.GetFieldDescriptor(field.GetOnDiskId()).GetLinkIds();
37 std::deque<ROOT::DescriptorId_t> subFields(linkIds.begin(), linkIds.end());
38 while (!subFields.empty()) {
39 auto subFieldId = subFields.front();
40 subFields.pop_front();
41 columnId = fnGetPrincipalColumnId(subFieldId);
42 if (columnId != ROOT::kInvalidDescriptorId)
43 break;
44
45 const auto &subLinkIds = desc.GetFieldDescriptor(subFieldId).GetLinkIds();
46 subFields.insert(subFields.end(), subLinkIds.begin(), subLinkIds.end());
47 }
48 }
49
50 if (columnId == ROOT::kInvalidDescriptorId) {
52 }
53
54 auto arraySize = std::max(std::uint64_t(1), desc.GetFieldDescriptor(field.GetOnDiskId()).GetNRepetitions());
55 return ROOT::RNTupleGlobalRange(0, desc.GetNElements(columnId) / arraySize);
56}
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
const ROOT::RNTupleDescriptor & GetRef() const
Abstract interface to read data from an ntuple.
const RSharedDescriptorGuard GetSharedDescriptorGuard() const
Takes the read lock for the descriptor.
A field translates read and write calls from/to underlying columns to/from tree values.
ROOT::DescriptorId_t GetOnDiskId() const
Used to loop over indexes (entries or collections) between start and end.
ROOT::RNTupleGlobalRange GetFieldRange(const ROOT::RFieldBase &field, const 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