Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RTreeMapImporter.cxx
Go to the documentation of this file.
1/// \file RTreeMapImporter.cxx
2/// \ingroup TreeMap ROOT7
3/// \author Patryk Tymoteusz Pilichowski <patryk.tymoteusz.pilichowski@cern.ch>
4/// \date 2025-08-21
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2025, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
19
20#include <queue>
21
22using namespace ROOT::Experimental;
23
25 std::uint64_t childrenIdx, std::uint64_t nChildren, ROOT::DescriptorId_t rootId,
26 size_t rootSize)
27{
28 uint64_t size =
29 (rootId != fldDesc.GetId()) ? insp.GetFieldTreeInspector(fldDesc.GetId()).GetCompressedSize() : rootSize;
30 return {fldDesc.GetFieldName(), "", size, childrenIdx, nChildren};
31}
32
38
40{
41 auto treemap = std::make_unique<RTreeMapPainter>();
42 const auto &descriptor = insp.GetDescriptor();
43 const auto rootId = descriptor.GetFieldZero().GetId();
44 size_t rootSize = 0;
45 for (const auto &childId : descriptor.GetFieldDescriptor(rootId).GetLinkIds()) {
46 rootSize += insp.GetFieldTreeInspector(childId).GetCompressedSize();
47 }
48
49 std::queue<std::pair<uint64_t, bool>> queue; // (columnid/fieldid, isfield)
50 queue.emplace(rootId, true);
51 while (!queue.empty()) {
52 size_t levelSize = queue.size();
53 size_t levelChildrenStart = treemap->fNodes.size() + levelSize;
54 for (size_t i = 0; i < levelSize; ++i) {
55 const auto &current = queue.front();
56 queue.pop();
57
58 size_t nChildren = 0;
59 if (current.second) {
60 std::vector<uint64_t> children;
61 const auto &fldDesc = descriptor.GetFieldDescriptor(current.first);
62 children = fldDesc.GetLinkIds();
63 for (const auto childId : children) {
64 queue.emplace(childId, 1);
65 }
66 for (const auto &columnDesc : descriptor.GetColumnIterable(fldDesc.GetId())) {
67 const auto &columnId = columnDesc.GetPhysicalId();
68 children.push_back(columnId);
69 queue.emplace(columnId, 0);
70 }
71 nChildren = children.size();
73 treemap->fNodes.push_back(node);
74 } else {
75 const auto &colInsp = insp.GetColumnInspector(current.first);
76 const auto &node = CreateNode(colInsp, levelChildrenStart);
77 treemap->fNodes.push_back(node);
78 }
79
81 }
82 }
83 return treemap;
84}
85
86std::unique_ptr<RTreeMapPainter> RTreeMapPainter::ImportRNTuple(std::string_view sourceFileName, std::string_view tupleName)
87{
90}
static RTreeMapBase::Node CreateNode(const 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 std::unique_ptr< RTreeMapPainter > ImportRNTuple(const ROOT::Experimental::RNTupleInspector &insp)
Logic for converting an RNTuple to RTreeMapPainter given RNTupleInspector.
static const char * GetColumnTypeName(ROOT::ENTupleColumnType type)
Metadata stored for every field of an RNTuple.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.