Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleInspector.hxx
Go to the documentation of this file.
1/// \file ROOT/RNTupleInspector.hxx
2/// \author Florine de Geus <florine.de.geus@cern.ch>
3/// \date 2023-01-09
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-2023, 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#ifndef ROOT7_RNTupleInspector
16#define ROOT7_RNTupleInspector
17
18#include <ROOT/RError.hxx>
20
21#include <TFile.h>
22#include <TH1D.h>
23#include <THStack.h>
24
25#include <cstdlib>
26#include <iostream>
27#include <memory>
28#include <numeric>
29#include <optional>
30#include <regex>
31#include <vector>
32
33namespace ROOT {
34class RNTuple;
35
36namespace Internal {
37class RPageSource;
38} // namespace Internal
39
40namespace Experimental {
41
43 kTable,
44 kCSV
45};
52
54 /// https://www.speedscope.app/file-format-schema.json
56};
57
58// clang-format off
59/**
60\class ROOT::Experimental::RNTupleInspector
61\ingroup NTuple
62\brief Inspect on-disk and storage-related information of an RNTuple.
63
64The RNTupleInspector can be used for studying an RNTuple in terms of its storage efficiency. It provides information on
65the level of the RNTuple itself, on the (sub)field level and on the column level.
66
67Example usage:
68
69~~~ {.cpp}
70#include <ROOT/RNTuple.hxx>
71#include <ROOT/RNTupleInspector.hxx>
72
73#include <iostream>
74
75using ROOT::Experimental::RNTupleInspector;
76
77auto file = TFile::Open("data.rntuple");
78auto rntuple = std::unique_ptr<ROOT::RNTuple>(file->Get<RNTuple>("NTupleName"));
79auto inspector = RNTupleInspector::Create(*rntuple);
80
81std::cout << "The compression factor is " << inspector->GetCompressionFactor()
82 << " using compression settings " << inspector->GetCompressionSettingsAsString()
83 << std::endl;
84~~~
85*/
86// clang-format on
88public:
89 /////////////////////////////////////////////////////////////////////////////
90 /// \brief Provides column-level storage information.
91 ///
92 /// The RColumnInspector class provides storage information for an individual column. This information is partly
93 /// collected during the construction of the RNTupleInspector object, and can partly be accessed using the
94 /// RColumnInspector that belongs to this field.
96 private:
98 const std::vector<std::uint64_t> fCompressedPageSizes = {};
99 std::uint32_t fElementSize = 0;
100 std::uint64_t fNElements = 0;
101
102 public:
103 RColumnInspector(const ROOT::RColumnDescriptor &colDesc, const std::vector<std::uint64_t> &compressedPageSizes,
104 std::uint32_t elemSize, std::uint64_t nElems)
105 : fColumnDescriptor(colDesc),
106 fCompressedPageSizes(compressedPageSizes),
107 fElementSize(elemSize),
108 fNElements(nElems)
109 {
110 }
111 ~RColumnInspector() = default;
112
114 const std::vector<std::uint64_t> &GetCompressedPageSizes() const { return fCompressedPageSizes; }
115 std::uint64_t GetNPages() const { return fCompressedPageSizes.size(); }
116 std::uint64_t GetCompressedSize() const
117 {
118 return std::accumulate(fCompressedPageSizes.begin(), fCompressedPageSizes.end(),
119 static_cast<std::uint64_t>(0));
120 }
121 std::uint64_t GetUncompressedSize() const { return fElementSize * fNElements; }
122 std::uint64_t GetElementSize() const { return fElementSize; }
123 std::uint64_t GetNElements() const { return fNElements; }
125 };
126
127 /////////////////////////////////////////////////////////////////////////////
128 /// \brief Provides field-level storage information.
129 ///
130 /// The RFieldTreeInspector class provides storage information for a field **and** its subfields. This information is
131 /// partly collected during the construction of the RNTupleInspector object, and can partly be accessed using
132 /// the RFieldDescriptor that belongs to this field.
134 private:
136 std::uint64_t fCompressedSize = 0;
137 std::uint64_t fUncompressedSize = 0;
138
139 public:
140 RFieldTreeInspector(const ROOT::RFieldDescriptor &fieldDesc, std::uint64_t onDiskSize, std::uint64_t inMemSize)
141 : fRootFieldDescriptor(fieldDesc), fCompressedSize(onDiskSize), fUncompressedSize(inMemSize)
142 {
143 }
145
147 std::uint64_t GetCompressedSize() const { return fCompressedSize; }
148 std::uint64_t GetUncompressedSize() const { return fUncompressedSize; }
149 };
150
151private:
152 std::unique_ptr<ROOT::Internal::RPageSource> fPageSource;
154 std::optional<std::uint32_t> fCompressionSettings; ///< The compression settings are unknown for an empty ntuple
155 std::uint64_t fCompressedSize = 0;
156 std::uint64_t fUncompressedSize = 0;
157
158 std::unordered_map<int, RColumnInspector> fColumnInfo;
159 std::unordered_map<int, RFieldTreeInspector> fFieldTreeInfo;
160
161 RNTupleInspector(std::unique_ptr<ROOT::Internal::RPageSource> pageSource);
162
163 /////////////////////////////////////////////////////////////////////////////
164 /// \brief Gather column-level and RNTuple-level information.
165 ///
166 /// \note This method is called when the RNTupleInspector is initially created. This means that anything unexpected
167 /// about the RNTuple itself (e.g. inconsistent compression settings across clusters) will be detected here.
168 /// Therefore, any related exceptions will be thrown on creation of the inspector.
169 void CollectColumnInfo();
170
171 /////////////////////////////////////////////////////////////////////////////
172 /// \brief Recursively gather field-level information.
173 ///
174 /// \param[in] fieldId The ID of the field from which to start the recursive traversal. Typically this is the "zero
175 /// ID", i.e. the logical parent of all top-level fields.
176 ///
177 /// \return The RFieldTreeInspector for the provided field ID.
178 ///
179 /// This method is called when the RNTupleInspector is initially created.
181
182public:
183 RNTupleInspector(const RNTupleInspector &other) = delete;
188
189 /////////////////////////////////////////////////////////////////////////////
190 /// \brief Create a new RNTupleInspector.
191 ///
192 /// \param[in] sourceNTuple A pointer to the RNTuple to be inspected.
193 ///
194 /// \return A pointer to the newly created RNTupleInspector.
195 ///
196 /// \note When this factory method is called, all required static information is collected from the RNTuple's fields
197 /// and underlying columns are collected at ones. This means that when any inconsistencies are encountered (e.g.
198 /// inconsistent compression across clusters), it will throw an error here.
199 static std::unique_ptr<RNTupleInspector> Create(const RNTuple &sourceNTuple);
200
201 /////////////////////////////////////////////////////////////////////////////
202 /// \brief Create a new RNTupleInspector.
203 ///
204 /// \param[in] ntupleName The name of the RNTuple to be inspected.
205 /// \param[in] storage The path or URI to the RNTuple to be inspected.
206 ///
207 /// \see Create(RNTuple *sourceNTuple)
208 static std::unique_ptr<RNTupleInspector> Create(std::string_view ntupleName, std::string_view storage);
209
210 /////////////////////////////////////////////////////////////////////////////
211 /// \brief Get the descriptor for the RNTuple being inspected.
212 ///
213 /// \return A static copy of the ROOT::RNTupleDescriptor belonging to the inspected RNTuple.
215
216 /////////////////////////////////////////////////////////////////////////////
217 /// \brief Get the compression settings of the RNTuple being inspected.
218 ///
219 /// \return The integer representation (\f$algorithm * 10 + level\f$, where \f$algorithm\f$ follows
220 /// ROOT::RCompressionSetting::ELevel::EValues) of the compression settings used for the inspected RNTuple.
221 /// Empty for an empty ntuple.
222 ///
223 /// \note Here, we assume that the compression settings are consistent across all clusters and columns. If this is
224 /// not the case, an exception will be thrown when RNTupleInspector::Create is called.
225 std::optional<std::uint32_t> GetCompressionSettings() const { return fCompressionSettings; }
226
227 /////////////////////////////////////////////////////////////////////////////
228 /// \brief Get a string describing compression settings of the RNTuple being inspected.
229 ///
230 /// \return A string describing the compression used for the inspected RNTuple. The format of the string is
231 /// `"A (level L)"`, where `A` is the name of the compression algorithm and `L` the compression level.
232 ///
233 /// \note Here, we assume that the compression settings are consistent across all clusters and columns. If this is
234 /// not the case, an exception will be thrown when RNTupleInspector::Create is called.
235 std::string GetCompressionSettingsAsString() const;
236
237 /////////////////////////////////////////////////////////////////////////////
238 /// \brief Get the compressed, on-disk size of the RNTuple being inspected.
239 ///
240 /// \return The compressed size of the inspected RNTuple, in bytes, excluding the size of the header and footer.
241 std::uint64_t GetCompressedSize() const { return fCompressedSize; }
242
243 /////////////////////////////////////////////////////////////////////////////
244 /// \brief Get the uncompressed total size of the RNTuple being inspected.
245 ///
246 /// \return The uncompressed size of the inspected RNTuple, in bytes, excluding the size of the header and footer.
247 std::uint64_t GetUncompressedSize() const { return fUncompressedSize; }
248
249 /////////////////////////////////////////////////////////////////////////////
250 /// \brief Get the compression factor of the RNTuple being inspected.
251 ///
252 /// \return The compression factor of the inspected RNTuple.
253 ///
254 /// The compression factor shows how well the data present in the RNTuple is compressed by the compression settings
255 /// that were used. The compression factor is calculated as \f$size_{uncompressed} / size_{compressed}\f$.
256 float GetCompressionFactor() const { return (float)fUncompressedSize / (float)fCompressedSize; }
257
258 /////////////////////////////////////////////////////////////////////////////
259 /// \brief Get storage information for a given column.
260 ///
261 /// \param[in] physicalColumnId The physical ID of the column for which to get the information.
262 ///
263 /// \return The storage information for the provided column.
264 const RColumnInspector &GetColumnInspector(ROOT::DescriptorId_t physicalColumnId) const;
265
266 /////////////////////////////////////////////////////////////////////////////
267 /// \brief Get the number of columns of a given type present in the RNTuple.
268 ///
269 /// \param[in] colType The column type to count, as defined by ROOT::ENTupleColumnType.
270 ///
271 /// \return The number of columns present in the inspected RNTuple of the provided type.
272 size_t GetColumnCountByType(ROOT::ENTupleColumnType colType) const;
273
274 /////////////////////////////////////////////////////////////////////////////
275 /// \brief Get the IDs of all columns with the given type.
276 ///
277 /// \param[in] colType The column type to collect, as defined by ROOT::ENTupleColumnType.
278 ///
279 /// \return A vector containing the physical IDs of columns of the provided type.
280 std::vector<ROOT::DescriptorId_t> GetColumnsByType(ROOT::ENTupleColumnType colType);
281
282 /////////////////////////////////////////////////////////////////////////////
283 /// \brief Get the columns that make up the given field, including its subfields.
284 ///
285 /// \param [in] fieldId The ID of the field for which to collect the columns.
286 ///
287 /// \return A vector containing the IDs of all columns for the provided field ID.
288 std::vector<ROOT::DescriptorId_t> GetAllColumnsOfField(ROOT::DescriptorId_t fieldId) const;
289
290 /////////////////////////////////////////////////////////////////////////////
291 /// \brief Get all column types present in the RNTuple being inspected.
292 ///
293 /// \return A vector containing all column types present in the RNTuple.
294 std::vector<ROOT::ENTupleColumnType> GetColumnTypes();
295
296 /////////////////////////////////////////////////////////////////////////////
297 /// \brief Print storage information per column type.
298 ///
299 /// \param[in] format Whether to print the information as a (markdown-parseable) table or in CSV format.
300 /// \param[in] output Where to write the output to. Default is `stdout`.
301 ///
302 /// The output includes for each column type its count, the total number of elements, the compressed size and the
303 /// uncompressed size.
304 ///
305 /// **Example: printing the column type information of an RNTuple as a table**
306 /// ~~~ {.cpp}
307 /// #include <ROOT/RNTupleInspector.hxx>
308 /// using ROOT::Experimental::RNTupleInspector;
309 /// using ROOT::Experimental::ENTupleInspectorPrintFormat;
310 ///
311 /// auto inspector = RNTupleInspector::Create("myNTuple", "some/file.root");
312 /// inspector->PrintColumnTypeInfo();
313 /// ~~~
314 /// Output:
315 /// ~~~
316 /// column type | count | # elements | compressed bytes | uncompressed bytes
317 /// ----------------|---------|-----------------|-------------------|--------------------
318 /// SplitIndex64 | 2 | 150 | 72 | 1200
319 /// SplitReal32 | 4 | 300 | 189 | 1200
320 /// SplitUInt32 | 3 | 225 | 123 | 900
321 /// ~~~
322 ///
323 /// **Example: printing the column type information of an RNTuple in CSV format**
324 /// ~~~ {.cpp}
325 /// #include <ROOT/RNTupleInspector.hxx>
326 /// using ROOT::Experimental::RNTupleInspector;
327 /// using ROOT::Experimental::ENTupleInspectorPrintFormat;
328 ///
329 /// auto inspector = RNTupleInspector::Create("myNTuple", "some/file.root");
330 /// inspector->PrintColumnTypeInfo();
331 /// ~~~
332 /// Output:
333 /// ~~~
334 /// columnType,count,nElements,compressedSize,uncompressedSize
335 /// SplitIndex64,2,150,72,1200
336 /// SplitReal32,4,300,189,1200
337 /// SplitUInt32,3,225,123,900
338 /// ~~~
340 std::ostream &output = std::cout);
341
342 /////////////////////////////////////////////////////////////////////////////
343 /// \brief Get a histogram showing information for each column type present,
344 ///
345 /// \param[in] histKind Which type of information should be returned.
346 /// \param[in] histName The name of the histogram. An empty string means a default name will be used.
347 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
348 ///
349 /// \return A pointer to a `TH1D` containing the specified kind of information.
350 ///
351 /// Get a histogram showing the count, number of elements, size on disk, or size in memory for each column
352 /// type present in the inspected RNTuple.
353 std::unique_ptr<TH1D> GetColumnTypeInfoAsHist(ENTupleInspectorHist histKind, std::string_view histName = "",
354 std::string_view histTitle = "");
355
356 /////////////////////////////////////////////////////////////////////////////
357 /// \brief Get a histogram containing the size distribution of the compressed pages for an individual column.
358 ///
359 /// \param[in] physicalColumnId The physical ID of the column for which to get the page size distribution.
360 /// \param[in] histName The name of the histogram. An empty string means a default name will be used.
361 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
362 /// \param[in] nBins The desired number of histogram bins.
363 ///
364 /// \return A pointer to a `TH1D` containing the page size distribution.
365 ///
366 /// The x-axis will range from the smallest page size, to the largest (inclusive).
367 std::unique_ptr<TH1D> GetPageSizeDistribution(ROOT::DescriptorId_t physicalColumnId, std::string histName = "",
368 std::string histTitle = "", size_t nBins = 64);
369
370 /////////////////////////////////////////////////////////////////////////////
371 /// \brief Get a histogram containing the size distribution of the compressed pages for all columns of a given type.
372 ///
373 /// \param[in] colType The column type for which to get the size distribution, as defined by ROOT::ENTupleColumnType.
374 /// \param[in] histName The name of the histogram. An empty string means a default name will be used.
375 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
376 /// \param[in] nBins The desired number of histogram bins.
377 ///
378 /// \return A pointer to a `TH1D` containing the page size distribution.
379 ///
380 /// The x-axis will range from the smallest page size, to the largest (inclusive).
381 std::unique_ptr<TH1D> GetPageSizeDistribution(ROOT::ENTupleColumnType colType, std::string histName = "",
382 std::string histTitle = "", size_t nBins = 64);
383
384 /////////////////////////////////////////////////////////////////////////////
385 /// \brief Get a histogram containing the size distribution of the compressed pages for a collection columns.
386 ///
387 /// \param[in] colIds The physical IDs of the columns for which to get the page size distribution.
388 /// \param[in] histName The name of the histogram. An empty string means a default name will be used.
389 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
390 /// \param[in] nBins The desired number of histogram bins.
391 ///
392 /// \return A pointer to a `TH1D` containing the (cumulative) page size distribution.
393 ///
394 /// The x-axis will range from the smallest page size, to the largest (inclusive).
395 std::unique_ptr<TH1D> GetPageSizeDistribution(std::initializer_list<ROOT::DescriptorId_t> colIds,
396 std::string histName = "", std::string histTitle = "",
397 size_t nBins = 64);
398
399 /////////////////////////////////////////////////////////////////////////////
400 /// \brief Get a histogram containing the size distribution of the compressed pages for all columns of a given list
401 /// of types.
402 ///
403 /// \param[in] colTypes The column types for which to get the size distribution, as defined by
404 /// ROOT::ENTupleColumnType. The default is an empty vector, which indicates that the distribution
405 /// for *all* physical columns will be returned.
406 /// \param[in] histName The name of the histogram. An empty string means a default name will be used. The name of
407 /// each histogram inside the `THStack` will be `histName + colType`.
408 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
409 /// \param[in] nBins The desired number of histogram bins.
410 ///
411 /// \return A pointer to a `THStack` with one histogram for each column type.
412 ///
413 /// The x-axis will range from the smallest page size, to the largest (inclusive).
414 ///
415 /// **Example: Drawing a non-stacked page size distribution with a legend**
416 /// ~~~ {.cpp}
417 /// auto canvas = std::make_unique<TCanvas>();
418 /// auto inspector = RNTupleInspector::Create("myNTuple", "ntuple.root");
419 ///
420 /// // We want to show the page size distributions of columns with type `kSplitReal32` and `kSplitReal64`.
421 /// auto hist = inspector->GetPageSizeDistribution(
422 /// {ROOT::ENTupleColumnType::kSplitReal32, ROOT::ENTupleColumnType::kSplitReal64});
423 /// // The "PLC" option automatically sets the line color for each histogram in the `THStack`.
424 /// // The "NOSTACK" option will draw the histograms on top of each other instead of stacked.
425 /// hist->DrawClone("PLC NOSTACK");
426 /// canvas->BuildLegend(0.7, 0.8, 0.89, 0.89);
427 /// canvas->DrawClone();
428 /// ~~~
429 std::unique_ptr<THStack> GetPageSizeDistribution(std::initializer_list<ROOT::ENTupleColumnType> colTypes = {},
430 std::string histName = "", std::string histTitle = "",
431 size_t nBins = 64);
432
433 std::unique_ptr<THStack> GetPagesPerClusterDistribution(std::initializer_list<ROOT::ENTupleColumnType> colTypes = {},
434 std::string_view histName = "",
435 std::string_view histTitle = "", size_t nBins = 32);
436
437 /////////////////////////////////////////////////////////////////////////////
438 /// \brief Get storage information for a given (sub)field by ID.
439 ///
440 /// \param[in] fieldId The ID of the (sub)field for which to get the information.
441 ///
442 /// \return The storage information inspector for the provided (sub)field tree.
443 const RFieldTreeInspector &GetFieldTreeInspector(ROOT::DescriptorId_t fieldId) const;
444
445 /////////////////////////////////////////////////////////////////////////////
446 /// \brief Get a storage information inspector for a given (sub)field by name, including its subfields.
447 ///
448 /// \param[in] fieldName The name of the (sub)field for which to get the information.
449 ///
450 /// \return The storage information inspector for the provided (sub)field tree.
451 const RFieldTreeInspector &GetFieldTreeInspector(std::string_view fieldName) const;
452
453 /////////////////////////////////////////////////////////////////////////////
454 /// \brief Get the number of fields of a given type or class present in the RNTuple.
455 ///
456 /// \param[in] typeNamePattern The type or class name to count. May contain regular expression patterns for grouping
457 /// multiple kinds of types or classes.
458 /// \param[in] searchInSubfields If set to `false`, only top-level fields will be considered.
459 ///
460 /// \return The number of fields that matches the provided type.
461 size_t GetFieldCountByType(const std::regex &typeNamePattern, bool searchInSubfields = true) const;
462
463 /////////////////////////////////////////////////////////////////////////////
464 /// \brief Get the number of fields of a given type or class present in the RNTuple.
465 ///
466 /// \see GetFieldCountByType(const std::regex &typeNamePattern, bool searchInSubfields) const
467 size_t GetFieldCountByType(std::string_view typeNamePattern, bool searchInSubfields = true) const
468 {
469 return GetFieldCountByType(std::regex{std::string(typeNamePattern)}, searchInSubfields);
470 }
471
472 /////////////////////////////////////////////////////////////////////////////
473 /// \brief Get the IDs of (sub-)fields whose name matches the given string.
474 ///
475 /// \param[in] fieldNamePattern The name of the field name to get. Because field names are unique by design,
476 /// providing a single field name will return a vector containing just the ID of that field. However, regular
477 /// expression patterns are supported in order to get the IDs of all fields whose name follow a certain structure.
478 /// \param[in] searchInSubfields If set to `false`, only top-level fields will be considered.
479 ///
480 /// \return A vector containing the IDs of fields that match the provided name.
481 std::vector<ROOT::DescriptorId_t>
482 GetFieldsByName(const std::regex &fieldNamePattern, bool searchInSubfields = true) const;
483
484 /////////////////////////////////////////////////////////////////////////////
485 /// \brief Get the IDs of (sub-)fields whose name matches the given string.
486 ///
487 /// \see GetFieldsByName(const std::regex &fieldNamePattern, bool searchInSubfields) const
488 std::vector<ROOT::DescriptorId_t> GetFieldsByName(std::string_view fieldNamePattern, bool searchInSubfields = true)
489 {
490 return GetFieldsByName(std::regex{std::string(fieldNamePattern)}, searchInSubfields);
491 }
492 /////////////////////////////////////////////////////////////////////////////
493 /// \brief Print a .dot string that represents the tree of the (sub)fields of an RNTuple
494 ///
495 /// \param[in] fieldDescriptor The descriptor of the root field (this method works recursively)
496 ///
497
498 void PrintFieldTreeAsDot(const ROOT::RFieldDescriptor &fieldDescriptor, std::ostream &output = std::cout) const;
499
500 /////////////////////////////////////////////////////////////////////////////
501 /// \brief Print the tree of all the (sub)fields of an RNTuple
502 /// \param[in] output
503 ///
504 /// \see PrintFieldTreeAsDot(const ROOT::RFieldDescriptor &fieldDescriptor, std::ostream &output=std::cout) const
505 void PrintFieldTreeAsDot(std::ostream &output = std::cout) const
506 {
507 PrintFieldTreeAsDot(GetDescriptor().GetFieldZero(), output);
508 }
509
510 /////////////////////////////////////////////////////////////////////////////
511 /// \brief Print a string that represents the tree of the (sub)fields and columns of an RNTuple in a format which a
512 /// performance profile visualizer can render
513 void PrintSchemaProfile(std::ostream &output = std::cout,
515
516 ////////////////////////////////////////////////////////////////////////////
517 /// \brief Print a string that represents the on-disk storage of the cluster groups, clusters, column ranges, pages,
518 /// header, footer and page lists on an RNTuple in a format which a performance profile visualizer can render
519 ///
520 /// \warning ntuple must have a file-based backend
521 void PrintDiskProfile(std::ostream &output = std::cout,
523};
524} // namespace Experimental
525} // namespace ROOT
526
527#endif // ROOT7_RNTupleInspector
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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
The available trivial, native content types of a column.
Provides column-level storage information.
RColumnInspector(const ROOT::RColumnDescriptor &colDesc, const std::vector< std::uint64_t > &compressedPageSizes, std::uint32_t elemSize, std::uint64_t nElems)
const ROOT::RColumnDescriptor & GetDescriptor() const
const std::vector< std::uint64_t > fCompressedPageSizes
const std::vector< std::uint64_t > & GetCompressedPageSizes() const
RFieldTreeInspector(const ROOT::RFieldDescriptor &fieldDesc, std::uint64_t onDiskSize, std::uint64_t inMemSize)
Inspect on-disk and storage-related information of an RNTuple.
float GetCompressionFactor() const
Get the compression factor of the RNTuple being inspected.
std::vector< ROOT::DescriptorId_t > GetFieldsByName(const std::regex &fieldNamePattern, bool searchInSubfields=true) const
Get the IDs of (sub-)fields whose name matches the given string.
RNTupleInspector & operator=(RNTupleInspector &&other)=delete
const RFieldTreeInspector & GetFieldTreeInspector(ROOT::DescriptorId_t fieldId) const
Get storage information for a given (sub)field by ID.
std::unique_ptr< TH1D > GetPageSizeDistribution(ROOT::DescriptorId_t physicalColumnId, std::string histName="", std::string histTitle="", size_t nBins=64)
Get a histogram containing the size distribution of the compressed pages for an individual column.
const ROOT::RNTupleDescriptor & GetDescriptor() const
Get the descriptor for the RNTuple being inspected.
RNTupleInspector(const RNTupleInspector &other)=delete
std::uint64_t GetCompressedSize() const
Get the compressed, on-disk size of the RNTuple being inspected.
size_t GetColumnCountByType(ROOT::ENTupleColumnType colType) const
Get the number of columns of a given type present in the RNTuple.
std::uint64_t GetUncompressedSize() const
Get the uncompressed total size of the RNTuple being inspected.
void PrintFieldTreeAsDot(std::ostream &output=std::cout) const
Print the tree of all the (sub)fields of an RNTuple.
RNTupleInspector(RNTupleInspector &&other)=delete
std::optional< std::uint32_t > fCompressionSettings
The compression settings are unknown for an empty ntuple.
std::vector< ROOT::ENTupleColumnType > GetColumnTypes()
Get all column types present in the RNTuple being inspected.
size_t GetFieldCountByType(const std::regex &typeNamePattern, bool searchInSubfields=true) const
Get the number of fields of a given type or class present in the RNTuple.
void PrintSchemaProfile(std::ostream &output=std::cout, ESchemaProfileFormat format=ESchemaProfileFormat::kSpeedscopeJSON) const
Print a string that represents the tree of the (sub)fields and columns of an RNTuple in a format whic...
std::vector< ROOT::DescriptorId_t > GetColumnsByType(ROOT::ENTupleColumnType colType)
Get the IDs of all columns with the given type.
std::string GetCompressionSettingsAsString() const
Get a string describing compression settings of the RNTuple being inspected.
RFieldTreeInspector CollectFieldTreeInfo(ROOT::DescriptorId_t fieldId)
Recursively gather field-level information.
RNTupleInspector(std::unique_ptr< ROOT::Internal::RPageSource > pageSource)
size_t GetFieldCountByType(std::string_view typeNamePattern, bool searchInSubfields=true) const
Get the number of fields of a given type or class present in the RNTuple.
void PrintColumnTypeInfo(ENTupleInspectorPrintFormat format=ENTupleInspectorPrintFormat::kTable, std::ostream &output=std::cout)
Print storage information per column type.
std::optional< std::uint32_t > GetCompressionSettings() const
Get the compression settings of the RNTuple being inspected.
std::unique_ptr< THStack > GetPagesPerClusterDistribution(std::initializer_list< ROOT::ENTupleColumnType > colTypes={}, std::string_view histName="", std::string_view histTitle="", size_t nBins=32)
void PrintDiskProfile(std::ostream &output=std::cout, ESchemaProfileFormat format=ESchemaProfileFormat::kSpeedscopeJSON) const
Print a string that represents the on-disk storage of the cluster groups, clusters,...
const RColumnInspector & GetColumnInspector(ROOT::DescriptorId_t physicalColumnId) const
Get storage information for a given column.
std::unique_ptr< ROOT::Internal::RPageSource > fPageSource
RNTupleInspector & operator=(const RNTupleInspector &other)=delete
static std::unique_ptr< RNTupleInspector > Create(const RNTuple &sourceNTuple)
Create a new RNTupleInspector.
std::unordered_map< int, RFieldTreeInspector > fFieldTreeInfo
void CollectColumnInfo()
Gather column-level and RNTuple-level information.
std::unordered_map< int, RColumnInspector > fColumnInfo
void PrintFieldTreeAsDot(const ROOT::RFieldDescriptor &fieldDescriptor, std::ostream &output=std::cout) const
Print a .dot string that represents the tree of the (sub)fields of an RNTuple.
std::vector< ROOT::DescriptorId_t > GetFieldsByName(std::string_view fieldNamePattern, bool searchInSubfields=true)
Get the IDs of (sub-)fields whose name matches the given string.
std::vector< ROOT::DescriptorId_t > GetAllColumnsOfField(ROOT::DescriptorId_t fieldId) const
Get the columns that make up the given field, including its subfields.
std::unique_ptr< TH1D > GetColumnTypeInfoAsHist(ENTupleInspectorHist histKind, std::string_view histName="", std::string_view histTitle="")
Get a histogram showing information for each column type present,.
Metadata stored for every column of an RNTuple.
ROOT::ENTupleColumnType GetType() const
Metadata stored for every field of an RNTuple.
The on-storage metadata of an RNTuple.
Representation of an RNTuple data set in a ROOT file.
Definition RNTuple.hxx:67
@ kSpeedscopeJSON
https://www.speedscope.app/file-format-schema.json
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.