Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RNTupleInspector Class Reference

Inspect a given RNTuple.

Example usage:

#include <ROOT/RNTuple.hxx>
#include <iostream>
auto file = TFile::Open("data.rntuple");
auto rntuple = file->Get<RNTuple>("NTupleName");
auto inspector = RNTupleInspector::Create(rntuple).Unwrap();
std::cout << "The compression factor is " << std::fixed << std::setprecision(2)
<< inspector->GetCompressionFactor()
<< std::endl;
static std::unique_ptr< RNTupleInspector > Create(std::unique_ptr< Detail::RPageSource > pageSource)
Create a new inspector for a given RNTuple.
Representation of an RNTuple data set in a ROOT file.
Definition RNTuple.hxx:512
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4070
Definition file.py:1

Definition at line 62 of file RNTupleInspector.hxx.

Classes

class  RColumnInfo
 Holds column-level storage information. More...
 
class  RFieldTreeInfo
 Holds field-level storage information. Includes storage information of the sub-fields. More...
 

Public Member Functions

 RNTupleInspector (const RNTupleInspector &other)=delete
 
 RNTupleInspector (RNTupleInspector &&other)=delete
 
 ~RNTupleInspector ()=default
 
size_t GetColumnCountByType (EColumnType colType) const
 Get the number of columns of a given type present in the RNTuple.
 
const RColumnInfoGetColumnInfo (DescriptorId_t physicalColumnId) const
 
const std::vector< DescriptorId_tGetColumnsByType (EColumnType)
 Get the IDs of all columns with the given type.
 
std::uint64_t GetCompressedSize () const
 Get the compressed, on-disk size of the RNTuple being inspected, in bytes.
 
float GetCompressionFactor () const
 Get the compression factor of the RNTuple being inspected.
 
int GetCompressionSettings () const
 Get the compression settings of the RNTuple being inspected.
 
RNTupleDescriptorGetDescriptor () const
 Get the descriptor for 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.
 
size_t GetFieldCountByType (std::string_view typeNamePattern, bool searchInSubFields=true) const
 
const std::vector< DescriptorId_tGetFieldsByName (const std::regex &fieldNamePattern, bool searchInSubFields=true) const
 Get the IDs of (sub-)fields whose name matches the given string.
 
const std::vector< DescriptorId_tGetFieldsByName (std::string_view fieldNamePattern, bool searchInSubFields=true)
 
const RFieldTreeInfoGetFieldTreeInfo (DescriptorId_t fieldId) const
 
const RFieldTreeInfoGetFieldTreeInfo (std::string_view fieldName) const
 
std::uint64_t GetUncompressedSize () const
 Get the uncompressed total size of the RNTuple being inspected, in bytes.
 
RNTupleInspectoroperator= (const RNTupleInspector &other)=delete
 
RNTupleInspectoroperator= (RNTupleInspector &&other)=delete
 
void PrintColumnTypeInfo (ENTupleInspectorPrintFormat format=ENTupleInspectorPrintFormat::kTable, std::ostream &output=std::cout)
 Print the per-column type information, either as a table or in CSV format.
 

Static Public Member Functions

static std::unique_ptr< RNTupleInspectorCreate (RNTuple *sourceNTuple)
 
static std::unique_ptr< RNTupleInspectorCreate (std::string_view ntupleName, std::string_view storage)
 
static std::unique_ptr< RNTupleInspectorCreate (std::unique_ptr< Detail::RPageSource > pageSource)
 Create a new inspector for a given RNTuple.
 

Private Member Functions

 RNTupleInspector (std::unique_ptr< Detail::RPageSource > pageSource)
 
void CollectColumnInfo ()
 Gather column-level, as well as RNTuple-level information.
 
RFieldTreeInfo CollectFieldTreeInfo (DescriptorId_t fieldId)
 Recursively gather field-level information and store it in fFieldTreeInfo.
 
std::vector< DescriptorId_tGetColumnsByFieldId (DescriptorId_t fieldId) const
 Get the IDs of the columns that make up the given field, including its sub-fields.
 

Private Attributes

std::map< int, RColumnInfofColumnInfo
 
std::uint64_t fCompressedSize = 0
 
int fCompressionSettings = -1
 
std::unique_ptr< RNTupleDescriptorfDescriptor
 
std::map< int, RFieldTreeInfofFieldTreeInfo
 
std::unique_ptr< Detail::RPageSourcefPageSource
 
std::unique_ptr< TFilefSourceFile
 
std::uint64_t fUncompressedSize = 0
 

#include <ROOT/RNTupleInspector.hxx>

Constructor & Destructor Documentation

◆ RNTupleInspector() [1/3]

ROOT::Experimental::RNTupleInspector::RNTupleInspector ( std::unique_ptr< Detail::RPageSource pageSource)
private

Definition at line 31 of file RNTupleInspector.cxx.

◆ RNTupleInspector() [2/3]

ROOT::Experimental::RNTupleInspector::RNTupleInspector ( const RNTupleInspector other)
delete

◆ RNTupleInspector() [3/3]

ROOT::Experimental::RNTupleInspector::RNTupleInspector ( RNTupleInspector &&  other)
delete

◆ ~RNTupleInspector()

ROOT::Experimental::RNTupleInspector::~RNTupleInspector ( )
default

Member Function Documentation

◆ CollectColumnInfo()

void ROOT::Experimental::RNTupleInspector::CollectColumnInfo ( )
private

Gather column-level, as well as RNTuple-level information.

The column-level information will be stored in fColumnInfo, and the RNTuple-level information in fCompressionSettings, fCompressedSize and fUncompressedSize.

This method is called when the RNTupleInspector is initially created. This means that anything unexpected about the RNTuple itself (e.g. inconsistent compression settings across clusters) will be detected here. Therefore, any related exceptions will be thrown on creation of the inspector.

Definition at line 40 of file RNTupleInspector.cxx.

◆ CollectFieldTreeInfo()

ROOT::Experimental::RNTupleInspector::RFieldTreeInfo ROOT::Experimental::RNTupleInspector::CollectFieldTreeInfo ( DescriptorId_t  fieldId)
private

Recursively gather field-level information and store it in fFieldTreeInfo.

This method is called when the RNTupleInspector is initially created.

Definition at line 88 of file RNTupleInspector.cxx.

◆ Create() [1/3]

std::unique_ptr< ROOT::Experimental::RNTupleInspector > ROOT::Experimental::RNTupleInspector::Create ( RNTuple sourceNTuple)
static

Definition at line 151 of file RNTupleInspector.cxx.

◆ Create() [2/3]

std::unique_ptr< ROOT::Experimental::RNTupleInspector > ROOT::Experimental::RNTupleInspector::Create ( std::string_view  ntupleName,
std::string_view  storage 
)
static

Definition at line 163 of file RNTupleInspector.cxx.

◆ Create() [3/3]

std::unique_ptr< ROOT::Experimental::RNTupleInspector > ROOT::Experimental::RNTupleInspector::Create ( std::unique_ptr< Detail::RPageSource pageSource)
static

Create a new inspector for a given RNTuple.

When this factory method is called, all required static information is collected from the RNTuple's fields and underlying columns are collected at ones. This means that when any inconsistencies are encountered (e.g. inconsistent compression across clusters), it will throw an error here.

Definition at line 140 of file RNTupleInspector.cxx.

◆ GetColumnCountByType()

size_t ROOT::Experimental::RNTupleInspector::GetColumnCountByType ( EColumnType  colType) const

Get the number of columns of a given type present in the RNTuple.

Definition at line 197 of file RNTupleInspector.cxx.

◆ GetColumnInfo()

const ROOT::Experimental::RNTupleInspector::RColumnInfo & ROOT::Experimental::RNTupleInspector::GetColumnInfo ( DescriptorId_t  physicalColumnId) const

Definition at line 188 of file RNTupleInspector.cxx.

◆ GetColumnsByFieldId()

std::vector< ROOT::Experimental::DescriptorId_t > ROOT::Experimental::RNTupleInspector::GetColumnsByFieldId ( DescriptorId_t  fieldId) const
private

Get the IDs of the columns that make up the given field, including its sub-fields.

Definition at line 114 of file RNTupleInspector.cxx.

◆ GetColumnsByType()

const std::vector< ROOT::Experimental::DescriptorId_t > ROOT::Experimental::RNTupleInspector::GetColumnsByType ( EColumnType  )

Get the IDs of all columns with the given type.

Definition at line 211 of file RNTupleInspector.cxx.

◆ GetCompressedSize()

std::uint64_t ROOT::Experimental::RNTupleInspector::GetCompressedSize ( ) const
inline

Get the compressed, on-disk size of the RNTuple being inspected, in bytes.

Does not include the size of the header and footer.

Definition at line 157 of file RNTupleInspector.hxx.

◆ GetCompressionFactor()

float ROOT::Experimental::RNTupleInspector::GetCompressionFactor ( ) const
inline

Get the compression factor of the RNTuple being inspected.

Definition at line 164 of file RNTupleInspector.hxx.

◆ GetCompressionSettings()

int ROOT::Experimental::RNTupleInspector::GetCompressionSettings ( ) const
inline

Get the compression settings of the RNTuple being inspected.

Here, we assume that the compression settings are consistent across all clusters and columns. If this is not the case, an exception will be thrown upon RNTupleInspector::Create.

Definition at line 153 of file RNTupleInspector.hxx.

◆ GetDescriptor()

RNTupleDescriptor * ROOT::Experimental::RNTupleInspector::GetDescriptor ( ) const
inline

Get the descriptor for the RNTuple being inspected.

Definition at line 148 of file RNTupleInspector.hxx.

◆ GetFieldCountByType() [1/2]

size_t ROOT::Experimental::RNTupleInspector::GetFieldCountByType ( const std::regex &  typeNamePattern,
bool  searchInSubFields = true 
) const

Get the number of fields of a given type or class present in the RNTuple.

The type name may contain regular expression patterns in order to be able to group multiple kinds of types or classes.

Definition at line 289 of file RNTupleInspector.cxx.

◆ GetFieldCountByType() [2/2]

size_t ROOT::Experimental::RNTupleInspector::GetFieldCountByType ( std::string_view  typeNamePattern,
bool  searchInSubFields = true 
) const
inline

Definition at line 220 of file RNTupleInspector.hxx.

◆ GetFieldsByName() [1/2]

const std::vector< ROOT::Experimental::DescriptorId_t > ROOT::Experimental::RNTupleInspector::GetFieldsByName ( const std::regex &  fieldNamePattern,
bool  searchInSubFields = true 
) const

Get the IDs of (sub-)fields whose name matches the given string.

Because field names are unique by design, providing a single field name will return a vector containing just the ID of that field. However, regular expression patterns are supported in order to get the IDs of all fields whose name follow a certain structure.

Definition at line 308 of file RNTupleInspector.cxx.

◆ GetFieldsByName() [2/2]

const std::vector< DescriptorId_t > ROOT::Experimental::RNTupleInspector::GetFieldsByName ( std::string_view  fieldNamePattern,
bool  searchInSubFields = true 
)
inline

Definition at line 230 of file RNTupleInspector.hxx.

◆ GetFieldTreeInfo() [1/2]

const ROOT::Experimental::RNTupleInspector::RFieldTreeInfo & ROOT::Experimental::RNTupleInspector::GetFieldTreeInfo ( DescriptorId_t  fieldId) const

Definition at line 268 of file RNTupleInspector.cxx.

◆ GetFieldTreeInfo() [2/2]

const ROOT::Experimental::RNTupleInspector::RFieldTreeInfo & ROOT::Experimental::RNTupleInspector::GetFieldTreeInfo ( std::string_view  fieldName) const

Definition at line 278 of file RNTupleInspector.cxx.

◆ GetUncompressedSize()

std::uint64_t ROOT::Experimental::RNTupleInspector::GetUncompressedSize ( ) const
inline

Get the uncompressed total size of the RNTuple being inspected, in bytes.

Does not include the size of the header and footer.

Definition at line 161 of file RNTupleInspector.hxx.

◆ operator=() [1/2]

RNTupleInspector & ROOT::Experimental::RNTupleInspector::operator= ( const RNTupleInspector other)
delete

◆ operator=() [2/2]

RNTupleInspector & ROOT::Experimental::RNTupleInspector::operator= ( RNTupleInspector &&  other)
delete

◆ PrintColumnTypeInfo()

void ROOT::Experimental::RNTupleInspector::PrintColumnTypeInfo ( ENTupleInspectorPrintFormat  format = ENTupleInspectorPrintFormat::kTable,
std::ostream &  output = std::cout 
)

Print the per-column type information, either as a table or in CSV format.

The output includes the column type, its count, the total number of elements, the compressed size and the uncompressed size.

Example: printing the column type information of an RNTuple as a table

auto inspector = RNTupleInspector::Create("myNTuple", "some/file.root");
inspector->PrintColumnTypeInfo();

Ouput:

column type | count | # elements | compressed bytes | uncompressed bytes
----------------|---------|-----------------|-------------------|--------------------
SplitIndex64 | 2 | 150 | 72 | 1200
SplitReal32 | 4 | 300 | 189 | 1200
SplitUInt32 | 3 | 225 | 123 | 900
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 bytes
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 type

Example: printing the column type information of an RNTuple in CSV format

auto inspector = RNTupleInspector::Create("myNTuple", "some/file.root");
inspector->PrintColumnTypeInfo();

Ouput:

columnType,count,nElements,compressedSize,uncompressedSize
SplitIndex64,2,150,72,1200
SplitReal32,4,300,189,1200
SplitUInt32,3,225,123,900

Definition at line 223 of file RNTupleInspector.cxx.

Member Data Documentation

◆ fColumnInfo

std::map<int, RColumnInfo> ROOT::Experimental::RNTupleInspector::fColumnInfo
private

Definition at line 111 of file RNTupleInspector.hxx.

◆ fCompressedSize

std::uint64_t ROOT::Experimental::RNTupleInspector::fCompressedSize = 0
private

Definition at line 108 of file RNTupleInspector.hxx.

◆ fCompressionSettings

int ROOT::Experimental::RNTupleInspector::fCompressionSettings = -1
private

Definition at line 107 of file RNTupleInspector.hxx.

◆ fDescriptor

std::unique_ptr<RNTupleDescriptor> ROOT::Experimental::RNTupleInspector::fDescriptor
private

Definition at line 106 of file RNTupleInspector.hxx.

◆ fFieldTreeInfo

std::map<int, RFieldTreeInfo> ROOT::Experimental::RNTupleInspector::fFieldTreeInfo
private

Definition at line 112 of file RNTupleInspector.hxx.

◆ fPageSource

std::unique_ptr<Detail::RPageSource> ROOT::Experimental::RNTupleInspector::fPageSource
private

Definition at line 105 of file RNTupleInspector.hxx.

◆ fSourceFile

std::unique_ptr<TFile> ROOT::Experimental::RNTupleInspector::fSourceFile
private

Definition at line 104 of file RNTupleInspector.hxx.

◆ fUncompressedSize

std::uint64_t ROOT::Experimental::RNTupleInspector::fUncompressedSize = 0
private

Definition at line 109 of file RNTupleInspector.hxx.

Libraries for ROOT::Experimental::RNTupleInspector:

The documentation for this class was generated from the following files: