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:
109 ~RColumnInspector() = default;
110
112 const std::vector<std::uint64_t> &GetCompressedPageSizes() const { return fCompressedPageSizes; }
113 std::uint64_t GetNPages() const { return fCompressedPageSizes.size(); }
114 std::uint64_t GetCompressedSize() const
115 {
116 return std::accumulate(fCompressedPageSizes.begin(), fCompressedPageSizes.end(),
117 static_cast<std::uint64_t>(0));
118 }
119 std::uint64_t GetUncompressedSize() const { return fElementSize * fNElements; }
120 std::uint64_t GetElementSize() const { return fElementSize; }
121 std::uint64_t GetNElements() const { return fNElements; }
123 };
124
125 /////////////////////////////////////////////////////////////////////////////
126 /// \brief Provides field-level storage information.
127 ///
128 /// The RFieldTreeInspector class provides storage information for a field **and** its subfields. This information is
129 /// partly collected during the construction of the RNTupleInspector object, and can partly be accessed using
130 /// the RFieldDescriptor that belongs to this field.
146
147private:
148 std::unique_ptr<ROOT::Internal::RPageSource> fPageSource;
150 std::optional<std::uint32_t> fCompressionSettings; ///< The compression settings are unknown for an empty ntuple
151 std::uint64_t fCompressedSize = 0;
152 std::uint64_t fUncompressedSize = 0;
153
154 std::unordered_map<int, RColumnInspector> fColumnInfo;
155 std::unordered_map<int, RFieldTreeInspector> fFieldTreeInfo;
156
157 RNTupleInspector(std::unique_ptr<ROOT::Internal::RPageSource> pageSource);
158
159 /////////////////////////////////////////////////////////////////////////////
160 /// \brief Gather column-level and RNTuple-level information.
161 ///
162 /// \note This method is called when the RNTupleInspector is initially created. This means that anything unexpected
163 /// about the RNTuple itself (e.g. inconsistent compression settings across clusters) will be detected here.
164 /// Therefore, any related exceptions will be thrown on creation of the inspector.
165 void CollectColumnInfo();
166
167 /////////////////////////////////////////////////////////////////////////////
168 /// \brief Recursively gather field-level information.
169 ///
170 /// \param[in] fieldId The ID of the field from which to start the recursive traversal. Typically this is the "zero
171 /// ID", i.e. the logical parent of all top-level fields.
172 ///
173 /// \return The RFieldTreeInspector for the provided field ID.
174 ///
175 /// This method is called when the RNTupleInspector is initially created.
177
178public:
184
185 /////////////////////////////////////////////////////////////////////////////
186 /// \brief Create a new RNTupleInspector.
187 ///
188 /// \param[in] sourceNTuple A pointer to the RNTuple to be inspected.
189 ///
190 /// \return A pointer to the newly created RNTupleInspector.
191 ///
192 /// \note When this factory method is called, all required static information is collected from the RNTuple's fields
193 /// and underlying columns are collected at ones. This means that when any inconsistencies are encountered (e.g.
194 /// inconsistent compression across clusters), it will throw an error here.
195 static std::unique_ptr<RNTupleInspector> Create(const RNTuple &sourceNTuple);
196
197 /////////////////////////////////////////////////////////////////////////////
198 /// \brief Create a new RNTupleInspector.
199 ///
200 /// \param[in] ntupleName The name of the RNTuple to be inspected.
201 /// \param[in] storage The path or URI to the RNTuple to be inspected.
202 ///
203 /// \see Create(RNTuple *sourceNTuple)
204 static std::unique_ptr<RNTupleInspector> Create(std::string_view ntupleName, std::string_view storage);
205
206 /////////////////////////////////////////////////////////////////////////////
207 /// \brief Get the descriptor for the RNTuple being inspected.
208 ///
209 /// \return A static copy of the ROOT::RNTupleDescriptor belonging to the inspected RNTuple.
211
212 /////////////////////////////////////////////////////////////////////////////
213 /// \brief Get the compression settings of the RNTuple being inspected.
214 ///
215 /// \return The integer representation (\f$algorithm * 10 + level\f$, where \f$algorithm\f$ follows
216 /// ROOT::RCompressionSetting::ELevel::EValues) of the compression settings used for the inspected RNTuple.
217 /// Empty for an empty ntuple.
218 ///
219 /// \note Here, we assume that the compression settings are consistent across all clusters and columns. If this is
220 /// not the case, an exception will be thrown when RNTupleInspector::Create is called.
221 std::optional<std::uint32_t> GetCompressionSettings() const { return fCompressionSettings; }
222
223 /////////////////////////////////////////////////////////////////////////////
224 /// \brief Get a string describing compression settings of the RNTuple being inspected.
225 ///
226 /// \return A string describing the compression used for the inspected RNTuple. The format of the string is
227 /// `"A (level L)"`, where `A` is the name of the compression algorithm and `L` the compression level.
228 ///
229 /// \note Here, we assume that the compression settings are consistent across all clusters and columns. If this is
230 /// not the case, an exception will be thrown when RNTupleInspector::Create is called.
231 std::string GetCompressionSettingsAsString() const;
232
233 /////////////////////////////////////////////////////////////////////////////
234 /// \brief Get the compressed, on-disk size of the RNTuple being inspected.
235 ///
236 /// \return The compressed size of the inspected RNTuple, in bytes, excluding the size of the header and footer.
237 std::uint64_t GetCompressedSize() const { return fCompressedSize; }
238
239 /////////////////////////////////////////////////////////////////////////////
240 /// \brief Get the uncompressed total size of the RNTuple being inspected.
241 ///
242 /// \return The uncompressed size of the inspected RNTuple, in bytes, excluding the size of the header and footer.
243 std::uint64_t GetUncompressedSize() const { return fUncompressedSize; }
244
245 /////////////////////////////////////////////////////////////////////////////
246 /// \brief Get the compression factor of the RNTuple being inspected.
247 ///
248 /// \return The compression factor of the inspected RNTuple.
249 ///
250 /// The compression factor shows how well the data present in the RNTuple is compressed by the compression settings
251 /// that were used. The compression factor is calculated as \f$size_{uncompressed} / size_{compressed}\f$.
252 float GetCompressionFactor() const { return (float)fUncompressedSize / (float)fCompressedSize; }
253
254 /////////////////////////////////////////////////////////////////////////////
255 /// \brief Get storage information for a given column.
256 ///
257 /// \param[in] physicalColumnId The physical ID of the column for which to get the information.
258 ///
259 /// \return The storage information for the provided column.
260 const RColumnInspector &GetColumnInspector(ROOT::DescriptorId_t physicalColumnId) const;
261
262 /////////////////////////////////////////////////////////////////////////////
263 /// \brief Get the number of columns of a given type present in the RNTuple.
264 ///
265 /// \param[in] colType The column type to count, as defined by ROOT::ENTupleColumnType.
266 ///
267 /// \return The number of columns present in the inspected RNTuple of the provided type.
269
270 /////////////////////////////////////////////////////////////////////////////
271 /// \brief Get the IDs of all columns with the given type.
272 ///
273 /// \param[in] colType The column type to collect, as defined by ROOT::ENTupleColumnType.
274 ///
275 /// \return A vector containing the physical IDs of columns of the provided type.
276 std::vector<ROOT::DescriptorId_t> GetColumnsByType(ROOT::ENTupleColumnType colType);
277
278 /////////////////////////////////////////////////////////////////////////////
279 /// \brief Get the columns that make up the given field, including its subfields.
280 ///
281 /// \param [in] fieldId The ID of the field for which to collect the columns.
282 ///
283 /// \return A vector containing the IDs of all columns for the provided field ID.
284 std::vector<ROOT::DescriptorId_t> GetAllColumnsOfField(ROOT::DescriptorId_t fieldId) const;
285
286 /////////////////////////////////////////////////////////////////////////////
287 /// \brief Get all column types present in the RNTuple being inspected.
288 ///
289 /// \return A vector containing all column types present in the RNTuple.
290 std::vector<ROOT::ENTupleColumnType> GetColumnTypes();
291
292 /////////////////////////////////////////////////////////////////////////////
293 /// \brief Print storage information per column type.
294 ///
295 /// \param[in] format Whether to print the information as a (markdown-parseable) table or in CSV format.
296 /// \param[in] output Where to write the output to. Default is `stdout`.
297 ///
298 /// The output includes for each column type its count, the total number of elements, the compressed size and the
299 /// uncompressed size.
300 ///
301 /// **Example: printing the column type information of an RNTuple as a table**
302 /// ~~~ {.cpp}
303 /// #include <ROOT/RNTupleInspector.hxx>
304 /// using ROOT::Experimental::RNTupleInspector;
305 /// using ROOT::Experimental::ENTupleInspectorPrintFormat;
306 ///
307 /// auto inspector = RNTupleInspector::Create("myNTuple", "some/file.root");
308 /// inspector->PrintColumnTypeInfo();
309 /// ~~~
310 /// Output:
311 /// ~~~
312 /// column type | count | # elements | compressed bytes | uncompressed bytes
313 /// ----------------|---------|-----------------|-------------------|--------------------
314 /// SplitIndex64 | 2 | 150 | 72 | 1200
315 /// SplitReal32 | 4 | 300 | 189 | 1200
316 /// SplitUInt32 | 3 | 225 | 123 | 900
317 /// ~~~
318 ///
319 /// **Example: printing the column type information of an RNTuple in CSV format**
320 /// ~~~ {.cpp}
321 /// #include <ROOT/RNTupleInspector.hxx>
322 /// using ROOT::Experimental::RNTupleInspector;
323 /// using ROOT::Experimental::ENTupleInspectorPrintFormat;
324 ///
325 /// auto inspector = RNTupleInspector::Create("myNTuple", "some/file.root");
326 /// inspector->PrintColumnTypeInfo();
327 /// ~~~
328 /// Output:
329 /// ~~~
330 /// columnType,count,nElements,compressedSize,uncompressedSize
331 /// SplitIndex64,2,150,72,1200
332 /// SplitReal32,4,300,189,1200
333 /// SplitUInt32,3,225,123,900
334 /// ~~~
336 std::ostream &output = std::cout);
337
338 /////////////////////////////////////////////////////////////////////////////
339 /// \brief Get a histogram showing information for each column type present,
340 ///
341 /// \param[in] histKind Which type of information should be returned.
342 /// \param[in] histName The name of the histogram. An empty string means a default name will be used.
343 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
344 ///
345 /// \return A pointer to a `TH1D` containing the specified kind of information.
346 ///
347 /// Get a histogram showing the count, number of elements, size on disk, or size in memory for each column
348 /// type present in the inspected RNTuple.
349 std::unique_ptr<TH1D> GetColumnTypeInfoAsHist(ENTupleInspectorHist histKind, std::string_view histName = "",
350 std::string_view histTitle = "");
351
352 /////////////////////////////////////////////////////////////////////////////
353 /// \brief Get a histogram containing the size distribution of the compressed pages for an individual column.
354 ///
355 /// \param[in] physicalColumnId The physical ID of the column for which to get the page size distribution.
356 /// \param[in] histName The name of the histogram. An empty string means a default name will be used.
357 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
358 /// \param[in] nBins The desired number of histogram bins.
359 ///
360 /// \return A pointer to a `TH1D` containing the page size distribution.
361 ///
362 /// The x-axis will range from the smallest page size, to the largest (inclusive).
363 std::unique_ptr<TH1D> GetPageSizeDistribution(ROOT::DescriptorId_t physicalColumnId, std::string histName = "",
364 std::string histTitle = "", size_t nBins = 64);
365
366 /////////////////////////////////////////////////////////////////////////////
367 /// \brief Get a histogram containing the size distribution of the compressed pages for all columns of a given type.
368 ///
369 /// \param[in] colType The column type for which to get the size distribution, as defined by ROOT::ENTupleColumnType.
370 /// \param[in] histName The name of the histogram. An empty string means a default name will be used.
371 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
372 /// \param[in] nBins The desired number of histogram bins.
373 ///
374 /// \return A pointer to a `TH1D` containing the page size distribution.
375 ///
376 /// The x-axis will range from the smallest page size, to the largest (inclusive).
377 std::unique_ptr<TH1D> GetPageSizeDistribution(ROOT::ENTupleColumnType colType, std::string histName = "",
378 std::string histTitle = "", size_t nBins = 64);
379
380 /////////////////////////////////////////////////////////////////////////////
381 /// \brief Get a histogram containing the size distribution of the compressed pages for a collection columns.
382 ///
383 /// \param[in] colIds The physical IDs of the columns for which to get the page size distribution.
384 /// \param[in] histName The name of the histogram. An empty string means a default name will be used.
385 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
386 /// \param[in] nBins The desired number of histogram bins.
387 ///
388 /// \return A pointer to a `TH1D` containing the (cumulative) page size distribution.
389 ///
390 /// The x-axis will range from the smallest page size, to the largest (inclusive).
391 std::unique_ptr<TH1D> GetPageSizeDistribution(std::initializer_list<ROOT::DescriptorId_t> colIds,
392 std::string histName = "", std::string histTitle = "",
393 size_t nBins = 64);
394
395 /////////////////////////////////////////////////////////////////////////////
396 /// \brief Get a histogram containing the size distribution of the compressed pages for all columns of a given list
397 /// of types.
398 ///
399 /// \param[in] colTypes The column types for which to get the size distribution, as defined by
400 /// ROOT::ENTupleColumnType. The default is an empty vector, which indicates that the distribution
401 /// for *all* physical columns will be returned.
402 /// \param[in] histName The name of the histogram. An empty string means a default name will be used. The name of
403 /// each histogram inside the `THStack` will be `histName + colType`.
404 /// \param[in] histTitle The title of the histogram. An empty string means a default title will be used.
405 /// \param[in] nBins The desired number of histogram bins.
406 ///
407 /// \return A pointer to a `THStack` with one histogram for each column type.
408 ///
409 /// The x-axis will range from the smallest page size, to the largest (inclusive).
410 ///
411 /// **Example: Drawing a non-stacked page size distribution with a legend**
412 /// ~~~ {.cpp}
413 /// auto canvas = std::make_unique<TCanvas>();
414 /// auto inspector = RNTupleInspector::Create("myNTuple", "ntuple.root");
415 ///
416 /// // We want to show the page size distributions of columns with type `kSplitReal32` and `kSplitReal64`.
417 /// auto hist = inspector->GetPageSizeDistribution(
418 /// {ROOT::ENTupleColumnType::kSplitReal32, ROOT::ENTupleColumnType::kSplitReal64});
419 /// // The "PLC" option automatically sets the line color for each histogram in the `THStack`.
420 /// // The "NOSTACK" option will draw the histograms on top of each other instead of stacked.
421 /// hist->DrawClone("PLC NOSTACK");
422 /// canvas->BuildLegend(0.7, 0.8, 0.89, 0.89);
423 /// canvas->DrawClone();
424 /// ~~~
425 std::unique_ptr<THStack> GetPageSizeDistribution(std::initializer_list<ROOT::ENTupleColumnType> colTypes = {},
426 std::string histName = "", std::string histTitle = "",
427 size_t nBins = 64);
428
429 /////////////////////////////////////////////////////////////////////////////
430 /// \brief Get storage information for a given (sub)field by ID.
431 ///
432 /// \param[in] fieldId The ID of the (sub)field for which to get the information.
433 ///
434 /// \return The storage information inspector for the provided (sub)field tree.
435 const RFieldTreeInspector &GetFieldTreeInspector(ROOT::DescriptorId_t fieldId) const;
436
437 /////////////////////////////////////////////////////////////////////////////
438 /// \brief Get a storage information inspector for a given (sub)field by name, including its subfields.
439 ///
440 /// \param[in] fieldName The name 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(std::string_view fieldName) const;
444
445 /////////////////////////////////////////////////////////////////////////////
446 /// \brief Get the number of fields of a given type or class present in the RNTuple.
447 ///
448 /// \param[in] typeNamePattern The type or class name to count. May contain regular expression patterns for grouping
449 /// multiple kinds of types or classes.
450 /// \param[in] searchInSubfields If set to `false`, only top-level fields will be considered.
451 ///
452 /// \return The number of fields that matches the provided type.
453 size_t GetFieldCountByType(const std::regex &typeNamePattern, bool searchInSubfields = true) const;
454
455 /////////////////////////////////////////////////////////////////////////////
456 /// \brief Get the number of fields of a given type or class present in the RNTuple.
457 ///
458 /// \see GetFieldCountByType(const std::regex &typeNamePattern, bool searchInSubfields) const
459 size_t GetFieldCountByType(std::string_view typeNamePattern, bool searchInSubfields = true) const
460 {
461 return GetFieldCountByType(std::regex{std::string(typeNamePattern)}, searchInSubfields);
462 }
463
464 /////////////////////////////////////////////////////////////////////////////
465 /// \brief Get the IDs of (sub-)fields whose name matches the given string.
466 ///
467 /// \param[in] fieldNamePattern The name of the field name to get. Because field names are unique by design,
468 /// providing a single field name will return a vector containing just the ID of that field. However, regular
469 /// expression patterns are supported in order to get the IDs of all fields whose name follow a certain structure.
470 /// \param[in] searchInSubfields If set to `false`, only top-level fields will be considered.
471 ///
472 /// \return A vector containing the IDs of fields that match the provided name.
473 std::vector<ROOT::DescriptorId_t>
474 GetFieldsByName(const std::regex &fieldNamePattern, bool searchInSubfields = true) const;
475
476 /////////////////////////////////////////////////////////////////////////////
477 /// \brief Get the IDs of (sub-)fields whose name matches the given string.
478 ///
479 /// \see GetFieldsByName(const std::regex &fieldNamePattern, bool searchInSubfields) const
480 std::vector<ROOT::DescriptorId_t> GetFieldsByName(std::string_view fieldNamePattern, bool searchInSubfields = true)
481 {
482 return GetFieldsByName(std::regex{std::string(fieldNamePattern)}, searchInSubfields);
483 }
484 /////////////////////////////////////////////////////////////////////////////
485 /// \brief Print a .dot string that represents the tree of the (sub)fields of an RNTuple
486 ///
487 /// \param[in] fieldDescriptor The descriptor of the root field (this method works recursively)
488 ///
489
490 void PrintFieldTreeAsDot(const ROOT::RFieldDescriptor &fieldDescriptor, std::ostream &output = std::cout) const;
491
492 /////////////////////////////////////////////////////////////////////////////
493 /// \brief Print the tree of all the (sub)fields of an RNTuple
494 /// \param[in] output
495 ///
496 /// \see PrintFieldTreeAsDot(const ROOT::RFieldDescriptor &fieldDescriptor, std::ostream &output=std::cout) const
497 void PrintFieldTreeAsDot(std::ostream &output = std::cout) const
498 {
499 PrintFieldTreeAsDot(GetDescriptor().GetFieldZero(), output);
500 }
501
502 /////////////////////////////////////////////////////////////////////////////
503 /// \brief Print a string that represents the tree of the (sub)fields and columns of an RNTuple in a format which a
504 /// performance profile visualizer can render
505 void PrintSchemaProfile([[maybe_unused]] ESchemaProfileFormat format, std::ostream &output = std::cout) const;
506};
507} // namespace Experimental
508} // namespace ROOT
509
510#endif // ROOT7_RNTupleInspector
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
void PrintSchemaProfile(ESchemaProfileFormat format, std::ostream &output=std::cout) const
Print a string that represents the tree of the (sub)fields and columns of an RNTuple in a format whic...
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.
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.
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.
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
const_iterator begin() const
const_iterator end() const
@ 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.