51 fUncompressedSize = 0;
54 for (
const auto &
cgDesc : fDescriptor.GetClusterGroupIterable()) {
59 for (
const auto &
colDesc : fDescriptor.GetColumnIterable()) {
83 if (!fCompressionSettings &&
columnRange.GetCompressionSettings()) {
84 fCompressionSettings =
columnRange.GetCompressionSettings();
85 }
else if (fCompressionSettings &&
columnRange.GetCompressionSettings() &&
86 (*fCompressionSettings != *
columnRange.GetCompressionSettings())) {
91 std::to_string(*fCompressionSettings) +
" vs " +
92 std::to_string(*
columnRange.GetCompressionSettings()) +
93 ") for column with physical ID " + std::to_string(
colId)));
136std::vector<ROOT::DescriptorId_t>
139 std::vector<ROOT::DescriptorId_t>
colIds;
146 for (
const auto &
col : fDescriptor.GetColumnIterable(
currId)) {
147 if (
col.IsAliasColumn()) {
151 colIds.emplace_back(
col.GetPhysicalId());
154 for (
const auto &
fld : fDescriptor.GetFieldIterable(
currId)) {
162std::unique_ptr<ROOT::Experimental::RNTupleInspector>
169std::unique_ptr<ROOT::Experimental::RNTupleInspector>
178 if (!fCompressionSettings)
181 int algorithm = *fCompressionSettings / 100;
182 int level = *fCompressionSettings - (
algorithm * 100);
185 " (level " + std::to_string(level) +
")";
213std::vector<ROOT::DescriptorId_t>
216 std::vector<ROOT::DescriptorId_t>
colIds;
228 std::set<ROOT::ENTupleColumnType>
colTypes;
244 std::uint32_t count = 0;
249 this->nElems +=
colInfo.GetNElements();
250 this->compressedSize +=
colInfo.GetCompressedSize();
251 this->uncompressedSize +=
colInfo.GetUncompressedSize();
252 this->nPages +=
colInfo.GetNPages();
256 float GetCompressionFactor()
const
264 std::map<ENTupleColumnType, ColumnTypeInfo>
colTypeInfo;
273 output <<
" column type | count | # elements | compressed bytes | uncompressed bytes | compression ratio | "
275 <<
"----------------|---------|-------------|------------------|--------------------|-------------------|-"
279 <<
typeInfo.count <<
" |" << std::setw(12) <<
typeInfo.nElems <<
" |" << std::setw(17)
280 <<
typeInfo.compressedSize <<
" |" << std::setw(19) <<
typeInfo.uncompressedSize <<
" |" << std::fixed
281 << std::setprecision(3) << std::setw(18) <<
typeInfo.GetCompressionFactor() <<
" |" << std::setw(6)
285 output <<
"columnType,count,nElements,compressedSize,uncompressedSize,compressionFactor,nPages\n";
288 <<
"," <<
typeInfo.compressedSize <<
"," <<
typeInfo.uncompressedSize <<
"," << std::fixed
289 << std::setprecision(3) <<
typeInfo.GetCompressionFactor() <<
"," <<
typeInfo.nPages <<
'\n';
292 default:
R__ASSERT(
false &&
"Invalid print format");
298 std::string_view histName, std::string_view
histTitle)
300 if (histName.empty()) {
320 auto hist = std::make_unique<TH1D>(std::string(histName).c_str(), std::string(
histTitle).c_str(), 1, 0, 1);
340 std::string histName, std::string
histTitle,
size_t nBins)
349 std::string histName,
352 if (histName.empty())
361 return std::make_unique<TH1D>(histName.c_str(),
histTitle.c_str(), 64, 0, 0);
363 auto hist = std::unique_ptr<TH1D>(
dynamic_cast<TH1D *
>(
perTypeHist->GetHists()->First()));
365 hist->SetName(histName.c_str());
367 hist->SetXTitle(
"Page size (B)");
368 hist->SetYTitle(
"N_{pages}");
374 std::string histName, std::string
histTitle,
size_t nBins)
376 auto hist = std::make_unique<TH1D>();
378 if (histName.empty())
379 histName =
"pageSizeHist";
380 hist->SetName(histName.c_str());
384 hist->SetXTitle(
"Page size (B)");
385 hist->SetYTitle(
"N_{pages}");
389 auto colInfo = GetColumnInspector(colId);
390 pageSizes.insert(pageSizes.end(), colInfo.GetCompressedPageSizes().begin(),
391 colInfo.GetCompressedPageSizes().end());
407std::unique_ptr<THStack>
409 std::string histName, std::string
histTitle,
size_t nBins)
411 if (histName.empty())
412 histName =
"pageSizeHist";
414 histTitle =
"Per-column type page size distribution";
418 double histMin = std::numeric_limits<double>::max();
420 std::map<ROOT::ENTupleColumnType, std::vector<std::uint64_t>>
pageSizes;
435 auto colInfo = GetColumnInspector(colId);
436 pageSizesForColType.insert(pageSizesForColType.end(), colInfo.GetCompressedPageSizes().begin(),
437 colInfo.GetCompressedPageSizes().end());
450 auto hist = std::make_unique<TH1D>(
470 if (
fieldId >= fDescriptor.GetNFields()) {
474 return fFieldTreeInfo.at(
fieldId);
486 return GetFieldTreeInspector(
fieldId);
507std::vector<ROOT::DescriptorId_t>
510 std::vector<ROOT::DescriptorId_t>
fieldIds;
527 std::ostream &output)
const
532 output <<
"digraph D {\n";
533 output <<
"node[shape=box]\n";
539 auto htmlEscape = [&](
const std::string &in) -> std::string {
541 out.reserve(in.size());
542 for (
const char &
c : in) {
544 case '&': out +=
"&";
break;
545 case '<': out +=
"<";
break;
546 case '>': out +=
">";
break;
547 case '\"': out +=
""";
break;
548 case '\'': out +=
"'";
break;
549 default: out +=
c;
break;
555 output << nodeId <<
"[label=<";
559 output <<
"<b>ID: </b>" << std::to_string(
fieldDescriptor.GetId()) <<
"<br></br>";
563 output <<
"<b>Version: </b>" <<
version <<
"<br></br>";
565 output <<
"<b>RFieldZero</b>";
578struct SpeedscopeFrame {
580 std::uint64_t fOpeningPosition = 0;
581 std::uint64_t fClosingPosition = 0;
587 output <<
" \"$schema\":\"https://www.speedscope.app/file-format-schema.json\",\n";
588 output <<
" \"shared\":{\n";
589 output <<
" \"frames\":[\n";
591 for (std::size_t i = 0; i <
frames.size(); ++i) {
592 output <<
" { \"name\":\"" <<
frames[i].fString <<
"\" }" << (i + 1 <
frames.size() ?
",\n" :
"\n");
597 output <<
" \"profiles\":[\n";
599 output <<
" \"type\":\"evented\",\n";
600 output <<
" \"name\":\"Flattened Timeline\",\n";
601 output <<
" \"unit\":\"bytes\",\n";
602 output <<
" \"startValue\":0,\n";
603 output <<
" \"endValue\":" <<
frames.back().fClosingPosition <<
",\n";
604 output <<
" \"events\":[\n";
614 std::uint32_t limit) -> std::size_t {
621 output <<
" {\"type\":\"O\",\"frame\":" <<
currentIdx
627 output <<
",\n {\"type\":\"C\",\"frame\":" <<
currentIdx
652 std::vector<SpeedscopeFrame>
frames;
712 throw RException(
R__FAIL(
"Disk profile is only supported for file-based page sources"));
717 const auto &descriptor = GetDescriptor();
720 std::uint64_t fPosition = 0;
721 std::uint64_t
fSize = 0;
725 static constexpr std::array<const char *, 3>
kAncestorsNames = {
"cluster group",
"cluster",
"column range"};
764 std::vector<SpeedscopeFrame>
frames;
777 std::size_t fIndex = 0;
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__LOG_WARNING(...)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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
std::string & operator+=(std::string &left, const TString &right)
The available trivial, native content types of a column.
Provides column-level storage information.
Provides field-level storage information.
Inspect on-disk and storage-related information of an RNTuple.
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.
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.
size_t GetColumnCountByType(ROOT::ENTupleColumnType colType) const
Get the number of columns of a given type present in the RNTuple.
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)
void PrintColumnTypeInfo(ENTupleInspectorPrintFormat format=ENTupleInspectorPrintFormat::kTable, std::ostream &output=std::cout)
Print storage information per column type.
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
static std::unique_ptr< RNTupleInspector > Create(const RNTuple &sourceNTuple)
Create a new RNTupleInspector.
void CollectColumnInfo()
Gather column-level and RNTuple-level information.
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 > 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,.
ROOT::RNTupleDescriptor fDescriptor
A column element encapsulates the translation between basic C++ types and their column representation...
static const char * GetColumnTypeName(ROOT::ENTupleColumnType type)
static std::unique_ptr< RColumnElementBase > Generate(ROOT::ENTupleColumnType type)
If CppT == void, use the default C++ type for the given column type.
Storage provider that reads ntuple pages from a file.
static std::unique_ptr< RPageSourceFile > CreateFromAnchor(const RNTuple &anchor, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Used from the RNTuple class to build a datasource if the anchor is already available.
static std::unique_ptr< RPageSource > Create(std::string_view ntupleName, std::string_view location, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Guess the concrete derived page source from the file name (location)
static constexpr std::size_t kNBytesPageChecksum
The page checksum is a 64bit xxhash3.
Base class for all ROOT issued exceptions.
Metadata stored for every field of an RNTuple.
ROOT::NTupleSize_t R__DEPRECATED(6, 46, "This function is ill-conceived in the descriptor " "as not all cluster descriptors may be present. This interface is no longer publicly exposed.") GetNElements(ROOT ROOT::DescriptorId_t GetFieldZeroId() const
Returns the logical parent of all top-level RNTuple data fields.
Representation of an RNTuple data set in a ROOT file.
const_iterator begin() const
const_iterator end() const
1-D histogram with a double per channel (see TH1 documentation)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
@ kSpeedscopeJSON
https://www.speedscope.app/file-format-schema.json
ENTupleInspectorPrintFormat
ROOT::RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
const ROOT::RNTuple * GetAnchorFromFile(const RPageSourceFile &source)
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr DescriptorId_t kInvalidDescriptorId
EValues
Note: this is only temporarily a struct and will become a enum class hence the name convention used.
static std::string AlgorithmToString(EAlgorithm::EValues algorithm)