Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::RDF::RDisplay Class Reference

This class is the textual representation of the content of a columnar dataset.

This class is provided to the user, and it can be used to print on screen the entries of the dataset requested through the Display action in a compact representation or to return the full representation of the events as a string. In order to apply proper formatting the content is buffered in memory as strings.

Definition at line 65 of file RDisplay.hxx.

Classes

struct  RPrintOptions
 

Public Types

enum class  EPrintFormat { kMarkdown , kHtml }
 

Public Member Functions

 RDisplay (const VecStr_t &columnNames, const VecStr_t &types, size_t nMaxCollectionElements)
 Creates an RDisplay to print the event values.
 
std::string AsString (const RPrintOptions &options={EPrintFormat::kMarkdown}) const
 Returns the representation as a string.
 
void Print (const RPrintOptions &options={EPrintFormat::kMarkdown}) const
 Prints the representation to the standard output.
 

Private Types

using DElement_t = ROOT::Internal::RDF::RDisplayElement
 
using VecStr_t = std::vector< std::string >
 

Private Member Functions

void AddCollectionToRow (const VecStr_t &collection)
 Adds a collection to the table.
 
bool AddInterpreterString (std::stringstream &, bool &element, const int &index)
 Appends a string if the T type is boolean.
 
bool AddInterpreterString (std::stringstream &, ROOT::RVec< char > &charArr, const int &index)
 AddInterpreterString overload for arrays of chars.
 
template<typename T , std::enable_if_t< ROOT::Internal::RDF::IsDataContainer< T >::value &&std::is_arithmetic_v< typename T::value_type > &&!std::is_same_v< typename T::value_type, bool >, int > = 0>
bool AddInterpreterString (std::stringstream &, T &collection, const int &index)
 Represent a collection of values as a collection of strings.
 
template<typename T , std::enable_if_t< ROOT::Internal::RDF::IsDataContainer< T >::value &&std::is_same_v< typename T::value_type, bool >, int > = 0>
bool AddInterpreterString (std::stringstream &, T &collection, const int &index)
 Represent a collection of booleans as a collection of strings.
 
template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
bool AddInterpreterString (std::stringstream &, T &element, const int &index)
 Appends a string if the T type is an arithmetic type.
 
template<typename T , std::enable_if_t< ROOT::Internal::RDF::IsDataContainer< T >::value &&!std::is_arithmetic_v< typename T::value_type >, int > = 0>
bool AddInterpreterString (std::stringstream &stream, T &collection, const int &index)
 Appends collection.size() cling::printValue calls to the stringstream.
 
template<typename T , std::enable_if_t<!std::is_arithmetic_v< T > &&!ROOT::Internal::RDF::IsDataContainer< T >::value, int > = 0>
bool AddInterpreterString (std::stringstream &stream, T &element, const int &index)
 Appends a cling::printValue call to the stringstream This overload works for non-collection data types which are also not trivially representable as strings.
 
template<typename... Columns>
void AddRow (Columns &... columns)
 Adds a row of events to the table.
 
void AddToRow (const std::string &stringEle)
 Adds a single element to the next slot in the table.
 
std::string AsStringHtml () const
 
std::string AsStringInternal (bool considerDots, const RPrintOptions &options={EPrintFormat::kMarkdown}) const
 
std::string AsStringMarkdown (bool considerDots) const
 
std::string DashesBetweenLines (size_t lastColToPrint, bool allColumnsFit) const
 Generate dashes between entries in Print() and AsString() Methods.
 
void EnsureCurrentColumnWidth (size_t w)
 
size_t GetNColumnsToShorten () const
 Get the number of columns that do NOT fit in the characters limit.
 
void MovePosition ()
 Moves to the next cell.
 

Private Attributes

std::vector< VecStr_tfCollectionsRepresentations
 Used by the JITted code to store the string representation of the data in case of collection.
 
size_t fCurrentColumn = 0
 Column that is being filled.
 
size_t fCurrentRow = 0
 Row that is being filled.
 
std::vector< boolfIsCollection
 True if the column contains a collection.
 
size_t fNColumns
 Number of columns to be printed.
 
size_t fNextRow = 1
 Next row to be filled.
 
size_t fNMaxCollectionElements = 10
 
VecStr_t fRepresentations
 Used by the JITted code to store the string representation of the data.
 
std::vector< std::vector< DElement_t > > fTable
 String representation of the data to be printed.
 
VecStr_t fTypes
 This attribute stores the type of each column. It is needed by the interpreter to print it.
 
std::vector< unsigned short > fWidths
 Tracks the maximum width of each column, based on the largest element.
 

Static Private Attributes

static constexpr unsigned fgMaxWidth = 100
 Maximum width of the table that Print() displays.
 
static constexpr char fgSeparator = ' '
 Spacing used to align the table entries.
 

Friends

template<typename T >
class ROOT::Internal::RDF::DisplayHelper
 

#include <ROOT/RDF/RDisplay.hxx>

Member Typedef Documentation

◆ DElement_t

◆ VecStr_t

using ROOT::RDF::RDisplay::VecStr_t = std::vector<std::string>
private

Definition at line 80 of file RDisplay.hxx.

Member Enumeration Documentation

◆ EPrintFormat

Enumerator
kMarkdown 
kHtml 

Definition at line 70 of file RDisplay.hxx.

Constructor & Destructor Documentation

◆ RDisplay()

ROOT::RDF::RDisplay::RDisplay ( const VecStr_t columnNames,
const VecStr_t types,
size_t  nMaxCollectionElements 
)

Creates an RDisplay to print the event values.

Parameters
[in]columnNamesColumns to print
[in]typesThe type of each column
[in]nMaxCollectionElementsNumber of maximum elements in collection.

Definition at line 178 of file RDFDisplay.cxx.

Member Function Documentation

◆ AddCollectionToRow()

void ROOT::RDF::RDisplay::AddCollectionToRow ( const VecStr_t collection)
private

Adds a collection to the table.

Starting from the slot, the elements are added one under the other, each one using a single cell of an entire row

Definition at line 128 of file RDFDisplay.cxx.

◆ AddInterpreterString() [1/7]

bool ROOT::RDF::RDisplay::AddInterpreterString ( std::stringstream &  ,
bool element,
const int index 
)
inlineprivate

Appends a string if the T type is boolean.

Parameters
[in]elementThe event to convert to its string representation
[in]indexTo which column the event belongs to
Returns
false, the event is not a collection

Definition at line 145 of file RDisplay.hxx.

◆ AddInterpreterString() [2/7]

bool ROOT::RDF::RDisplay::AddInterpreterString ( std::stringstream &  ,
ROOT::RVec< char > &  charArr,
const int index 
)
inlineprivate

AddInterpreterString overload for arrays of chars.

Parameters
[in]charArrThe character array to convert to string representation
[in]indexTo which column the event belongs
Returns
false, the event is not a collection

This specialization for arrays of characters skips the cling::printValue (i.e. appends nothing to the stream) and directly writes to fRepresentations the string representation of the array of chars.

Definition at line 242 of file RDisplay.hxx.

◆ AddInterpreterString() [3/7]

template<typename T , std::enable_if_t< ROOT::Internal::RDF::IsDataContainer< T >::value &&std::is_arithmetic_v< typename T::value_type > &&!std::is_same_v< typename T::value_type, bool >, int > = 0>
bool ROOT::RDF::RDisplay::AddInterpreterString ( std::stringstream &  ,
T &  collection,
const int index 
)
inlineprivate

Represent a collection of values as a collection of strings.

Template Parameters
Tthe type of the event to convert. This must be a collection of values of arithmetic type, but not boolean.
Parameters
[in]collectionThe event to convert to its string representation
[in]indexTo which column the event belongs to
Returns
true, the event is a collection

Definition at line 196 of file RDisplay.hxx.

◆ AddInterpreterString() [4/7]

template<typename T , std::enable_if_t< ROOT::Internal::RDF::IsDataContainer< T >::value &&std::is_same_v< typename T::value_type, bool >, int > = 0>
bool ROOT::RDF::RDisplay::AddInterpreterString ( std::stringstream &  ,
T &  collection,
const int index 
)
inlineprivate

Represent a collection of booleans as a collection of strings.

Template Parameters
Tthe type of the event to convert. This must be a collection of boolean values.
Parameters
[in]collectionThe event to convert to its string representation
[in]indexTo which column the event belongs to
Returns
true, the event is a collection

Definition at line 219 of file RDisplay.hxx.

◆ AddInterpreterString() [5/7]

template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
bool ROOT::RDF::RDisplay::AddInterpreterString ( std::stringstream &  ,
T &  element,
const int index 
)
inlineprivate

Appends a string if the T type is an arithmetic type.

This overload works for arithmetic data types that are trivially convertible to string.

Template Parameters
Tthe type of the event to convert
Parameters
[in]elementThe event to convert to its string representation
[in]indexTo which column the event belongs to
Returns
false, the event is not a collection

Definition at line 132 of file RDisplay.hxx.

◆ AddInterpreterString() [6/7]

template<typename T , std::enable_if_t< ROOT::Internal::RDF::IsDataContainer< T >::value &&!std::is_arithmetic_v< typename T::value_type >, int > = 0>
bool ROOT::RDF::RDisplay::AddInterpreterString ( std::stringstream &  stream,
T &  collection,
const int index 
)
inlineprivate

Appends collection.size() cling::printValue calls to the stringstream.

Template Parameters
Tthe type of the event to convert
Parameters
[in]streamWhere the conversion function call will be chained.
[in]collectionThe event to convert to its string representation
[in]indexTo which column the event belongs to
Returns
true, the event is a collection This function chains a sequence of call to cling::printValue, one for each element of the collection.

Definition at line 164 of file RDisplay.hxx.

◆ AddInterpreterString() [7/7]

template<typename T , std::enable_if_t<!std::is_arithmetic_v< T > &&!ROOT::Internal::RDF::IsDataContainer< T >::value, int > = 0>
bool ROOT::RDF::RDisplay::AddInterpreterString ( std::stringstream &  stream,
T &  element,
const int index 
)
inlineprivate

Appends a cling::printValue call to the stringstream This overload works for non-collection data types which are also not trivially representable as strings.

Template Parameters
Tthe type of the event to convert
Parameters
[in]streamWhere the conversion function call will be chained.
[in]elementThe event to convert to its string representation
[in]indexTo which column the event belongs to
Returns
false, the event is not a collection

Definition at line 115 of file RDisplay.hxx.

◆ AddRow()

template<typename... Columns>
void ROOT::RDF::RDisplay::AddRow ( Columns &...  columns)
inlineprivate

Adds a row of events to the table.

Definition at line 279 of file RDisplay.hxx.

◆ AddToRow()

void ROOT::RDF::RDisplay::AddToRow ( const std::string &  stringEle)
private

Adds a single element to the next slot in the table.

Definition at line 116 of file RDFDisplay.cxx.

◆ AsString()

std::string ROOT::RDF::RDisplay::AsString ( const RPrintOptions options = {EPrintFormat::kMarkdown}) const

Returns the representation as a string.

Definition at line 227 of file RDFDisplay.cxx.

◆ AsStringHtml()

std::string ROOT::RDF::RDisplay::AsStringHtml ( ) const
private

Definition at line 242 of file RDFDisplay.cxx.

◆ AsStringInternal()

std::string ROOT::RDF::RDisplay::AsStringInternal ( bool  considerDots,
const RPrintOptions options = {EPrintFormat::kMarkdown} 
) const
private

Definition at line 232 of file RDFDisplay.cxx.

◆ AsStringMarkdown()

std::string ROOT::RDF::RDisplay::AsStringMarkdown ( bool  considerDots) const
private

Definition at line 280 of file RDFDisplay.cxx.

◆ DashesBetweenLines()

std::string ROOT::RDF::RDisplay::DashesBetweenLines ( size_t  lastColToPrint,
bool  allColumnsFit 
) const
private

Generate dashes between entries in Print() and AsString() Methods.

Definition at line 207 of file RDFDisplay.cxx.

◆ EnsureCurrentColumnWidth()

void ROOT::RDF::RDisplay::EnsureCurrentColumnWidth ( size_t  w)
private

Definition at line 105 of file RDFDisplay.cxx.

◆ GetNColumnsToShorten()

size_t ROOT::RDF::RDisplay::GetNColumnsToShorten ( ) const
private

Get the number of columns that do NOT fit in the characters limit.

Definition at line 191 of file RDFDisplay.cxx.

◆ MovePosition()

void ROOT::RDF::RDisplay::MovePosition ( )
private

Moves to the next cell.

Moves to the next cell, and if the row is full moves to the next row.

Definition at line 166 of file RDFDisplay.cxx.

◆ Print()

void ROOT::RDF::RDisplay::Print ( const RPrintOptions options = {EPrintFormat::kMarkdown}) const

Prints the representation to the standard output.

Collections are shortened to the first and last element. The overall width is shortened to a fixed number of columns that should fit the screen width.

Definition at line 221 of file RDFDisplay.cxx.

Friends And Related Symbol Documentation

◆ ROOT::Internal::RDF::DisplayHelper

template<typename T >
friend class ROOT::Internal::RDF::DisplayHelper
friend

Definition at line 67 of file RDisplay.hxx.

Member Data Documentation

◆ fCollectionsRepresentations

std::vector<VecStr_t> ROOT::RDF::RDisplay::fCollectionsRepresentations
private

Used by the JITted code to store the string representation of the data in case of collection.

Each row corresponds to a column, each column to a value of the collection.

Definition at line 92 of file RDisplay.hxx.

◆ fCurrentColumn

size_t ROOT::RDF::RDisplay::fCurrentColumn = 0
private

Column that is being filled.

Definition at line 100 of file RDisplay.hxx.

◆ fCurrentRow

size_t ROOT::RDF::RDisplay::fCurrentRow = 0
private

Row that is being filled.

Definition at line 98 of file RDisplay.hxx.

◆ fgMaxWidth

constexpr unsigned ROOT::RDF::RDisplay::fgMaxWidth = 100
staticconstexprprivate

Maximum width of the table that Print() displays.

Definition at line 83 of file RDisplay.hxx.

◆ fgSeparator

constexpr char ROOT::RDF::RDisplay::fgSeparator = ' '
staticconstexprprivate

Spacing used to align the table entries.

Definition at line 82 of file RDisplay.hxx.

◆ fIsCollection

std::vector<bool> ROOT::RDF::RDisplay::fIsCollection
private

True if the column contains a collection.

Collections are treated differently during the printing.

Definition at line 86 of file RDisplay.hxx.

◆ fNColumns

size_t ROOT::RDF::RDisplay::fNColumns
private

Number of columns to be printed.

Definition at line 96 of file RDisplay.hxx.

◆ fNextRow

size_t ROOT::RDF::RDisplay::fNextRow = 1
private

Next row to be filled.

Definition at line 99 of file RDisplay.hxx.

◆ fNMaxCollectionElements

size_t ROOT::RDF::RDisplay::fNMaxCollectionElements = 10
private

Definition at line 102 of file RDisplay.hxx.

◆ fRepresentations

VecStr_t ROOT::RDF::RDisplay::fRepresentations
private

Used by the JITted code to store the string representation of the data.

Definition at line 91 of file RDisplay.hxx.

◆ fTable

std::vector<std::vector<DElement_t> > ROOT::RDF::RDisplay::fTable
private

String representation of the data to be printed.

Definition at line 88 of file RDisplay.hxx.

◆ fTypes

VecStr_t ROOT::RDF::RDisplay::fTypes
private

This attribute stores the type of each column. It is needed by the interpreter to print it.

Definition at line 85 of file RDisplay.hxx.

◆ fWidths

std::vector<unsigned short> ROOT::RDF::RDisplay::fWidths
private

Tracks the maximum width of each column, based on the largest element.

Definition at line 89 of file RDisplay.hxx.

Libraries for ROOT::RDF::RDisplay:

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