Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleTreeMap.cxx
Go to the documentation of this file.
1/// \file ROOT/RNTupleTreeMap.cxx
2/// \author Patryk Tymoteusz Pilichowski <patryk.tymoteusz.pilichowski@cern.ch>
3/// \date 2025-09-15
4/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
5/// is welcome!
6
7/*************************************************************************
8 * Copyright (C) 1995-2025, 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
17
18#include <queue>
19
22 std::uint64_t childrenIdx, std::uint64_t nChildren, ROOT::DescriptorId_t rootId, size_t rootSize)
23{
24 uint64_t size =
25 (rootId != fldDesc.GetId()) ? insp.GetFieldTreeInspector(fldDesc.GetId()).GetCompressedSize() : rootSize;
26 return {fldDesc.GetFieldName(), "", size, childrenIdx, nChildren};
27}
28
35
36std::unique_ptr<ROOT::Experimental::RTreeMapPainter>
38{
39 auto treemap = std::make_unique<ROOT::Experimental::RTreeMapPainter>();
40 const auto &descriptor = insp.GetDescriptor();
41 const auto rootId = descriptor.GetFieldZero().GetId();
42 size_t rootSize = 0;
43 for (const auto &childId : descriptor.GetFieldDescriptor(rootId).GetLinkIds()) {
44 rootSize += insp.GetFieldTreeInspector(childId).GetCompressedSize();
45 }
46
47 std::queue<std::pair<uint64_t, bool>> queue; // (columnid/fieldid, isfield)
48 queue.emplace(rootId, true);
49 while (!queue.empty()) {
50 size_t levelSize = queue.size();
51 size_t levelChildrenStart = treemap->fNodes.size() + levelSize;
52 for (size_t i = 0; i < levelSize; ++i) {
53 const auto &current = queue.front();
54 queue.pop();
55
56 size_t nChildren = 0;
57 if (current.second) {
58 std::vector<uint64_t> children;
59 const auto &fldDesc = descriptor.GetFieldDescriptor(current.first);
60 children = fldDesc.GetLinkIds();
61 for (const auto childId : children) {
62 queue.emplace(childId, 1);
63 }
64 for (const auto &columnDesc : descriptor.GetColumnIterable(fldDesc.GetId())) {
65 const auto &columnId = columnDesc.GetPhysicalId();
66 children.push_back(columnId);
67 queue.emplace(columnId, 0);
68 }
69 nChildren = children.size();
71 treemap->fNodes.push_back(node);
72 } else {
73 const auto &colInsp = insp.GetColumnInspector(current.first);
74 const auto &node = CreateNode(colInsp, levelChildrenStart);
75 treemap->fNodes.push_back(node);
76 }
77
79 }
80 }
81 return treemap;
82}
83
84std::unique_ptr<ROOT::Experimental::RTreeMapPainter>
static ROOT::Experimental::RTreeMapBase::Node CreateNode(const ROOT::Experimental::RNTupleInspector &insp, const ROOT::RFieldDescriptor &fldDesc, std::uint64_t childrenIdx, std::uint64_t nChildren, ROOT::DescriptorId_t rootId, size_t rootSize)
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.
Provides column-level storage information.
Inspect on-disk and storage-related information of an RNTuple.
static std::unique_ptr< RNTupleInspector > Create(const RNTuple &sourceNTuple)
Create a new RNTupleInspector.
static const char * GetColumnTypeName(ROOT::ENTupleColumnType type)
Metadata stored for every field of an RNTuple.
std::unique_ptr< RTreeMapPainter > CreateTreeMapFromRNTuple(const RNTupleInspector &insp)
Logic for converting an RNTuple to RTreeMapPainter given RNTupleInspector.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.