35 : fPageSource(std::move(pageSource))
39 auto descriptorGuard =
fPageSource->GetSharedDescriptorGuard();
52 fUncompressedSize = 0;
54 std::vector<DescriptorId_t> clusterIds;
55 for (
const auto &cgDesc : fDescriptor.GetClusterGroupIterable()) {
57 clusterIds.insert(clusterIds.end(), cgDesc.GetClusterIds().begin(), cgDesc.GetClusterIds().end());
60 for (
const auto &colDesc : fDescriptor.GetColumnIterable()) {
61 if (colDesc.IsAliasColumn())
64 auto colId = colDesc.GetPhysicalId();
69 std::uint64_t nElems = 0;
70 std::vector<std::uint64_t> compressedPageSizes{};
72 for (
auto cid : clusterIds) {
73 const auto &clusterDescriptor = fDescriptor.GetClusterDescriptor(cid);
74 if (!clusterDescriptor.ContainsColumn(colId)) {
78 auto columnRange = clusterDescriptor.GetColumnRange(colId);
79 if (columnRange.IsSuppressed())
82 nElems += columnRange.GetNElements();
84 if (!fCompressionSettings && columnRange.GetCompressionSettings()) {
85 fCompressionSettings = columnRange.GetCompressionSettings();
86 }
else if (fCompressionSettings && columnRange.GetCompressionSettings() &&
87 (*fCompressionSettings != *columnRange.GetCompressionSettings())) {
92 std::to_string(*fCompressionSettings) +
" vs " +
93 std::to_string(*columnRange.GetCompressionSettings()) +
94 ") for column with physical ID " + std::to_string(colId)));
97 const auto &pageRange = clusterDescriptor.GetPageRange(colId);
99 for (
const auto &page : pageRange.GetPageInfos()) {
100 compressedPageSizes.emplace_back(page.GetLocator().GetNBytesOnStorage());
101 fUncompressedSize += page.GetNElements() * elemSize;
106 std::accumulate(compressedPageSizes.begin(), compressedPageSizes.end(),
static_cast<std::uint64_t
>(0));
107 fColumnInfo.emplace(colId,
RColumnInspector(colDesc, compressedPageSizes, elemSize, nElems));
114 std::uint64_t compressedSize = 0;
115 std::uint64_t uncompressedSize = 0;
117 for (
const auto &colDescriptor : fDescriptor.GetColumnIterable(fieldId)) {
118 auto colInfo = GetColumnInspector(colDescriptor.GetPhysicalId());
119 compressedSize += colInfo.GetCompressedSize();
120 uncompressedSize += colInfo.GetUncompressedSize();
123 for (
const auto &subFieldDescriptor : fDescriptor.GetFieldIterable(fieldId)) {
124 auto subFieldId = subFieldDescriptor.GetId();
126 auto subFieldInfo = CollectFieldTreeInfo(subFieldId);
128 compressedSize += subFieldInfo.GetCompressedSize();
129 uncompressedSize += subFieldInfo.GetUncompressedSize();
132 auto fieldInfo =
RFieldTreeInspector(fDescriptor.GetFieldDescriptor(fieldId), compressedSize, uncompressedSize);
133 fFieldTreeInfo.emplace(fieldId, fieldInfo);
137std::vector<ROOT::DescriptorId_t>
140 std::vector<ROOT::DescriptorId_t> colIds;
141 std::deque<ROOT::DescriptorId_t> fieldIdQueue{fieldId};
143 while (!fieldIdQueue.empty()) {
144 auto currId = fieldIdQueue.front();
145 fieldIdQueue.pop_front();
147 for (
const auto &col : fDescriptor.GetColumnIterable(currId)) {
148 if (col.IsAliasColumn()) {
152 colIds.emplace_back(col.GetPhysicalId());
155 for (
const auto &fld : fDescriptor.GetFieldIterable(currId)) {
156 fieldIdQueue.push_back(fld.GetId());
163std::unique_ptr<ROOT::Experimental::RNTupleInspector>
167 return std::unique_ptr<RNTupleInspector>(
new RNTupleInspector(std::move(pageSource)));
170std::unique_ptr<ROOT::Experimental::RNTupleInspector>
174 return std::unique_ptr<RNTupleInspector>(
new RNTupleInspector(std::move(pageSource)));
179 if (!fCompressionSettings)
182 int algorithm = *fCompressionSettings / 100;
183 int level = *fCompressionSettings - (algorithm * 100);
186 " (level " + std::to_string(level) +
")";
194 if (physicalColumnId > fDescriptor.GetNPhysicalColumns()) {
195 throw RException(
R__FAIL(
"No column with physical ID " + std::to_string(physicalColumnId) +
" present"));
198 return fColumnInfo.at(physicalColumnId);
203 size_t typeCount = 0;
205 for (
auto &[colId, colInfo] : fColumnInfo) {
206 if (colInfo.GetType() == colType) {
214std::vector<ROOT::DescriptorId_t>
217 std::vector<ROOT::DescriptorId_t> colIds;
219 for (
const auto &[colId, colInfo] : fColumnInfo) {
220 if (colInfo.GetType() == colType)
221 colIds.emplace_back(colId);
229 std::set<ROOT::ENTupleColumnType> colTypes;
231 for (
const auto &[colId, colInfo] : fColumnInfo) {
232 colTypes.emplace(colInfo.GetType());
235 return std::vector(colTypes.begin(), colTypes.end());
240 struct ColumnTypeInfo {
241 std::uint64_t nElems = 0;
242 std::uint64_t compressedSize = 0;
243 std::uint64_t uncompressedSize = 0;
244 std::uint64_t nPages = 0;
245 std::uint32_t count = 0;
257 float GetCompressionFactor()
const
259 if (compressedSize == 0)
261 return static_cast<float>(uncompressedSize) /
static_cast<float>(compressedSize);
265 std::map<ENTupleColumnType, ColumnTypeInfo> colTypeInfo;
268 for (
const auto &[colId, colInfo] : fColumnInfo) {
269 colTypeInfo[colInfo.GetType()] += colInfo;
274 output <<
" column type | count | # elements | compressed bytes | uncompressed bytes | compression ratio | "
276 <<
"----------------|---------|-------------|------------------|--------------------|-------------------|-"
278 for (
const auto &[colType, typeInfo] : colTypeInfo)
280 << typeInfo.count <<
" |" << std::setw(12) << typeInfo.nElems <<
" |" << std::setw(17)
281 << typeInfo.compressedSize <<
" |" << std::setw(19) << typeInfo.uncompressedSize <<
" |" << std::fixed
282 << std::setprecision(3) << std::setw(18) << typeInfo.GetCompressionFactor() <<
" |" << std::setw(6)
283 << typeInfo.nPages <<
" \n";
286 output <<
"columnType,count,nElements,compressedSize,uncompressedSize,compressionFactor,nPages\n";
287 for (
const auto &[colType, typeInfo] : colTypeInfo) {
289 <<
"," << typeInfo.compressedSize <<
"," << typeInfo.uncompressedSize <<
"," << std::fixed
290 << std::setprecision(3) << typeInfo.GetCompressionFactor() <<
"," << typeInfo.nPages <<
'\n';
293 default:
R__ASSERT(
false &&
"Invalid print format");
299 std::string_view histName, std::string_view histTitle)
301 if (histName.empty()) {
311 if (histTitle.empty()) {
321 auto hist = std::make_unique<TH1D>(std::string(histName).c_str(), std::string(histTitle).c_str(), 1, 0, 1);
324 for (
const auto &[colId, colInfo] : fColumnInfo) {
341 std::string histName, std::string histTitle,
size_t nBins)
343 if (histTitle.empty())
344 histTitle =
"Page size distribution for column with ID " + std::to_string(physicalColumnId);
346 return GetPageSizeDistribution({physicalColumnId}, histName, histTitle, nBins);
350 std::string histName,
351 std::string histTitle,
size_t nBins)
353 if (histName.empty())
355 if (histTitle.empty())
359 auto perTypeHist = GetPageSizeDistribution({colType}, histName, histTitle, nBins);
361 if (perTypeHist->GetNhists() < 1)
362 return std::make_unique<TH1D>(histName.c_str(), histTitle.c_str(), 64, 0, 0);
364 auto hist = std::unique_ptr<TH1D>(
dynamic_cast<TH1D *
>(perTypeHist->GetHists()->First()));
366 hist->SetName(histName.c_str());
367 hist->SetTitle(histTitle.c_str());
368 hist->SetXTitle(
"Page size (B)");
369 hist->SetYTitle(
"N_{pages}");
375 std::string histName, std::string histTitle,
size_t nBins)
377 auto hist = std::make_unique<TH1D>();
379 if (histName.empty())
380 histName =
"pageSizeHist";
381 hist->SetName(histName.c_str());
382 if (histTitle.empty())
383 histTitle =
"Page size distribution";
384 hist->SetTitle(histTitle.c_str());
385 hist->SetXTitle(
"Page size (B)");
386 hist->SetYTitle(
"N_{pages}");
388 std::vector<std::uint64_t> pageSizes;
389 std::for_each(colIds.begin(), colIds.end(), [
this, &pageSizes](
const auto colId) {
390 auto colInfo = GetColumnInspector(colId);
391 pageSizes.insert(pageSizes.end(), colInfo.GetCompressedPageSizes().begin(),
392 colInfo.GetCompressedPageSizes().end());
395 if (!pageSizes.empty()) {
396 auto histMinMax = std::minmax_element(pageSizes.begin(), pageSizes.end());
397 hist->SetBins(nBins, *histMinMax.first,
398 *histMinMax.second + ((*histMinMax.second - *histMinMax.first) /
static_cast<double>(nBins)));
400 for (
const auto pageSize : pageSizes) {
401 hist->Fill(pageSize);
408std::unique_ptr<THStack>
410 std::string histName, std::string histTitle,
size_t nBins)
412 if (histName.empty())
413 histName =
"pageSizeHist";
414 if (histTitle.empty())
415 histTitle =
"Per-column type page size distribution";
417 auto stackedHist = std::make_unique<THStack>(histName.c_str(), histTitle.c_str());
419 double histMin = std::numeric_limits<double>::max();
421 std::map<ROOT::ENTupleColumnType, std::vector<std::uint64_t>> pageSizes;
423 std::vector<ROOT::ENTupleColumnType> colTypeVec = colTypes;
424 if (std::empty(colTypes)) {
425 colTypeVec = GetColumnTypes();
428 for (
const auto colType : colTypeVec) {
429 auto colIds = GetColumnsByType(colType);
434 std::vector<std::uint64_t> pageSizesForColType;
435 std::for_each(colIds.cbegin(), colIds.cend(), [
this, &pageSizesForColType](
const auto colId) {
436 auto colInfo = GetColumnInspector(colId);
437 pageSizesForColType.insert(pageSizesForColType.end(), colInfo.GetCompressedPageSizes().begin(),
438 colInfo.GetCompressedPageSizes().end());
440 if (pageSizesForColType.empty())
443 pageSizes.emplace(colType, pageSizesForColType);
445 auto histMinMax = std::minmax_element(pageSizesForColType.begin(), pageSizesForColType.end());
446 histMin = std::min(histMin,
static_cast<double>(*histMinMax.first));
447 histMax = std::max(histMax,
static_cast<double>(*histMinMax.second));
450 for (
const auto &[colType, pageSizesForColType] : pageSizes) {
451 auto hist = std::make_unique<TH1D>(
454 histMax + ((histMax - histMin) /
static_cast<double>(nBins)));
456 for (
const auto pageSize : pageSizesForColType) {
457 hist->Fill(pageSize);
460 stackedHist->Add(hist.release());
467 std::initializer_list<ROOT::ENTupleColumnType> colTypes, std::string_view histName, std::string_view histTitle,
470 if (histName.empty())
471 histName =
"pagesPerClusterHist";
472 if (histTitle.empty())
473 histTitle =
"#pages per cluster";
475 auto stackedHist = std::make_unique<THStack>(std::string(histName).c_str(), std::string(histTitle).c_str());
477 std::vector<std::unordered_map<ENTupleColumnType, std::uint64_t>> pagesPerClusterPerColumnType;
479 std::vector<ROOT::ENTupleColumnType> colTypeVec = colTypes;
480 if (std::empty(colTypes)) {
481 colTypeVec = GetColumnTypes();
484 R__ASSERT(fDescriptor.GetNClusters() == fDescriptor.GetNActiveClusters());
485 for (
const auto &clDesc : fDescriptor.GetActiveClusterIterable()) {
486 auto &pagesPerColumnTypeInThisCluster = pagesPerClusterPerColumnType.emplace_back();
487 for (
const auto &colRange : clDesc.GetColumnRangeIterable()) {
488 const auto colId = colRange.GetPhysicalColumnId();
489 const auto &colDesc = fDescriptor.GetColumnDescriptor(colId);
490 const auto nPages = clDesc.GetPageRange(colId).GetPageInfos().size();
491 auto &nPagesForThisType = pagesPerColumnTypeInThisCluster[colDesc.GetType()];
492 nPagesForThisType += nPages;
496 double histMin = std::numeric_limits<double>::max();
498 for (
const auto &pagesPerType : pagesPerClusterPerColumnType) {
499 auto [min, max] = std::minmax_element(pagesPerType.begin(), pagesPerType.end(),
500 [](
const auto &
a,
const auto &
b) { return a.second < b.second; });
501 histMin = std::min<double>(histMin, min->second);
502 histMax = std::max<double>(histMax, max->second);
506 for (
const auto &pagesPerType : pagesPerClusterPerColumnType) {
507 for (
const auto &[colType, nPages] : pagesPerType) {
508 auto &hist = histsPerType[
static_cast<std::size_t
>(colType)];
512 histMin, histMax + ((histMax - histMin) /
static_cast<double>(nBins)));
518 for (
auto &hist : histsPerType) {
520 stackedHist->Add(hist.release());
532 if (fieldId >= fDescriptor.GetNFields()) {
533 throw RException(
R__FAIL(
"No field with ID " + std::to_string(fieldId) +
" present"));
536 return fFieldTreeInfo.at(fieldId);
542 auto fieldId = fDescriptor.FindFieldId(fieldName);
545 throw RException(
R__FAIL(
"Could not find field `" + std::string(fieldName) +
"`"));
548 return GetFieldTreeInspector(fieldId);
552 bool includeSubfields)
const
554 size_t typeCount = 0;
556 for (
auto &[fldId, fldInfo] : fFieldTreeInfo) {
557 if (!includeSubfields && fldInfo.GetDescriptor().GetParentId() != fDescriptor.GetFieldZeroId()) {
561 if (std::regex_match(fldInfo.GetDescriptor().GetTypeName(), typeNamePattern)) {
569std::vector<ROOT::DescriptorId_t>
572 std::vector<ROOT::DescriptorId_t> fieldIds;
574 for (
auto &[fldId, fldInfo] : fFieldTreeInfo) {
576 if (!searchInSubfields && fldInfo.GetDescriptor().GetParentId() != fDescriptor.GetFieldZeroId()) {
580 if (std::regex_match(fldInfo.GetDescriptor().GetFieldName(), fieldNamePattern)) {
581 fieldIds.emplace_back(fldId);
589 std::ostream &output)
const
591 const auto &tupleDescriptor = GetDescriptor();
594 output <<
"digraph D {\n";
595 output <<
"node[shape=box]\n";
597 const std::string &nodeId = (isZeroField) ?
"0" : std::to_string(fieldDescriptor.
GetId() + 1);
601 auto htmlEscape = [&](
const std::string &in) -> std::string {
603 out.reserve(in.size());
604 for (
const char &
c : in) {
606 case '&': out +=
"&";
break;
607 case '<': out +=
"<";
break;
608 case '>': out +=
">";
break;
609 case '\"': out +=
""";
break;
610 case '\'': out +=
"'";
break;
611 default: out +=
c;
break;
617 output << nodeId <<
"[label=<";
619 output <<
"<b>Name: </b>" << htmlEscape(fieldDescriptor.
GetFieldName()) <<
"<br></br>";
620 output <<
"<b>Type: </b>" << htmlEscape(fieldDescriptor.
GetTypeName()) <<
"<br></br>";
621 output <<
"<b>ID: </b>" << std::to_string(fieldDescriptor.
GetId()) <<
"<br></br>";
622 if (description !=
"")
623 output <<
"<b>Description: </b>" << htmlEscape(description) <<
"<br></br>";
625 output <<
"<b>Version: </b>" << version <<
"<br></br>";
627 output <<
"<b>RFieldZero</b>";
629 for (
const auto &childFieldId : fieldDescriptor.
GetLinkIds()) {
630 const auto &childFieldDescriptor = tupleDescriptor.GetFieldDescriptor(childFieldId);
631 output << nodeId +
"->" + std::to_string(childFieldDescriptor.GetId() + 1) +
"\n";
632 PrintFieldTreeAsDot(childFieldDescriptor, output);
640struct SpeedscopeFrame {
642 std::uint64_t fOpeningPosition = 0;
643 std::uint64_t fClosingPosition = 0;
646static void PrintSpeedscopeFrames(
const std::vector<SpeedscopeFrame> &frames, std::ostream &output)
649 output <<
" \"$schema\":\"https://www.speedscope.app/file-format-schema.json\",\n";
650 output <<
" \"shared\":{\n";
651 output <<
" \"frames\":[\n";
653 for (std::size_t i = 0; i < frames.size(); ++i) {
654 output <<
" { \"name\":\"" << frames[i].fString <<
"\" }" << (i + 1 < frames.size() ?
",\n" :
"\n");
659 output <<
" \"profiles\":[\n";
661 output <<
" \"type\":\"evented\",\n";
662 output <<
" \"name\":\"Flattened Timeline\",\n";
663 output <<
" \"unit\":\"bytes\",\n";
664 output <<
" \"startValue\":0,\n";
665 output <<
" \"endValue\":" << frames.back().fClosingPosition <<
",\n";
666 output <<
" \"events\":[\n";
675 std::function<std::size_t(std::size_t, std::uint32_t)> processRecursive = [&](std::size_t nextIdxToProcess,
676 std::uint32_t limit) -> std::size_t {
677 while (nextIdxToProcess < frames.size() && frames[nextIdxToProcess].fOpeningPosition < limit) {
678 const std::size_t currentIdx = nextIdxToProcess;
683 output <<
" {\"type\":\"O\",\"frame\":" << currentIdx
684 <<
",\"at\":" << frames[currentIdx].fOpeningPosition <<
"}";
687 nextIdxToProcess = processRecursive(nextIdxToProcess + 1, frames[currentIdx].fClosingPosition);
689 output <<
",\n {\"type\":\"C\",\"frame\":" << currentIdx
690 <<
",\"at\":" << frames[currentIdx].fClosingPosition <<
"}";
692 return nextIdxToProcess;
695 processRecursive(0, frames.back().fClosingPosition);
710 const auto &tupleDescriptor = GetDescriptor();
712 const auto &rootFieldDescriptor = tupleDescriptor.GetFieldDescriptor(rootId);
714 std::vector<SpeedscopeFrame> frames;
715 std::uint64_t positionCursor = 0;
718 auto visitFieldsRecursive = [&](
auto &self,
const ROOT::RFieldDescriptor &fieldDescriptor) -> std::size_t {
719 SpeedscopeFrame fieldSpeedscopeFrame;
720 fieldSpeedscopeFrame.fString =
721 tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId()) +
" (" + fieldDescriptor.GetTypeName() +
")";
722 fieldSpeedscopeFrame.fOpeningPosition = positionCursor;
723 frames.push_back(fieldSpeedscopeFrame);
725 std::size_t fieldSpeedscopeFrameIndex = frames.size() - 1;
727 std::size_t subTreeSize = 0;
728 const auto &childIds = fieldDescriptor.GetLinkIds();
730 for (
const auto &childFieldId : childIds) {
731 const auto &childFieldDescriptor = tupleDescriptor.GetFieldDescriptor(childFieldId);
732 subTreeSize += self(self, childFieldDescriptor);
735 for (
const auto &columnDescriptor : tupleDescriptor.GetColumnIterable(fieldDescriptor.GetId())) {
736 const auto &columnInfo = GetColumnInspector(columnDescriptor.GetPhysicalId());
737 std::size_t columnSize = columnInfo.GetCompressedSize();
739 SpeedscopeFrame columnSpeedscopeFrame;
740 columnSpeedscopeFrame.fString =
741 "[col#" + std::to_string(columnDescriptor.GetPhysicalId()) +
"] " +
742 tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId()) +
" (" +
744 columnSpeedscopeFrame.fOpeningPosition = positionCursor;
745 positionCursor += columnSize;
746 columnSpeedscopeFrame.fClosingPosition = positionCursor;
747 frames.push_back(columnSpeedscopeFrame);
748 subTreeSize += columnSize;
751 frames[fieldSpeedscopeFrameIndex].fClosingPosition = positionCursor;
756 const auto &topLevelIds = rootFieldDescriptor.GetLinkIds();
757 for (
const auto &childId : topLevelIds) {
758 const auto &childFieldDescriptor = tupleDescriptor.GetFieldDescriptor(childId);
759 visitFieldsRecursive(visitFieldsRecursive, childFieldDescriptor);
762 PrintSpeedscopeFrames(frames, output);
774 throw RException(
R__FAIL(
"Disk profile is only supported for file-based page sources"));
779 const auto &descriptor = GetDescriptor();
781 struct RDiskPageLeaf {
782 std::uint64_t fPosition = 0;
783 std::uint64_t
fSize = 0;
785 std::array<DescriptorId_t, 3> fAncestors;
787 static constexpr std::array<const char *, 3> kAncestorsNames = {
"cluster group",
"cluster",
"column range"};
788 std::vector<RDiskPageLeaf> pageLeaves;
791 for (
const auto &clusterGroupDescriptor : descriptor.GetClusterGroupIterable()) {
792 const auto groupId = clusterGroupDescriptor.GetId();
794 for (
const auto clusterId : clusterGroupDescriptor.GetClusterIds()) {
795 const auto &clusterDescriptor = descriptor.GetClusterDescriptor(clusterId);
797 for (
const auto &columnRange : clusterDescriptor.GetColumnRangeIterable()) {
798 const auto columnId = columnRange.GetPhysicalColumnId();
800 const auto &pageRange = clusterDescriptor.GetPageRange(columnId);
801 for (
const auto &pageInfo : pageRange.GetPageInfos()) {
802 const auto &locator = pageInfo.GetLocator();
804 RDiskPageLeaf pageLeaf;
805 pageLeaf.fPosition = locator.GetPosition<std::uint64_t>();
806 pageLeaf.fSize = locator.GetNBytesOnStorage() +
808 pageLeaf.fName =
"[page @" + std::to_string(pageLeaf.fPosition) +
"]";
809 pageLeaf.fAncestors = {groupId, clusterId, columnId};
810 pageLeaves.push_back(pageLeaf);
817 std::sort(pageLeaves.begin(), pageLeaves.end(),
818 [](
const RDiskPageLeaf &
a,
const RDiskPageLeaf &
b) { return a.fPosition < b.fPosition; });
822 std::unique(pageLeaves.begin(), pageLeaves.end(),
823 [](
const RDiskPageLeaf &
a,
const RDiskPageLeaf &
b) { return a.fPosition == b.fPosition; }),
826 std::vector<SpeedscopeFrame> frames;
830 SpeedscopeFrame headerFrame;
831 headerFrame.fString =
"ntuple header";
832 headerFrame.fOpeningPosition = anchor->GetSeekHeader();
833 headerFrame.fClosingPosition = anchor->GetSeekHeader() + anchor->GetNBytesHeader();
834 frames.push_back(headerFrame);
839 std::size_t fIndex = 0;
841 std::vector<ROpenFrame> openFrames;
842 std::uint64_t previouspageLeafEnd = 0;
845 for (
const auto &pageLeaf : pageLeaves) {
846 std::size_t sharedDepth = 0;
849 while (sharedDepth < openFrames.size() && sharedDepth < pageLeaf.fAncestors.size() &&
850 openFrames[sharedDepth].fId == pageLeaf.fAncestors[sharedDepth]) {
855 while (openFrames.size() > sharedDepth) {
856 frames[openFrames.back().fIndex].fClosingPosition = previouspageLeafEnd;
857 openFrames.pop_back();
861 for (std::size_t depth = sharedDepth; depth < pageLeaf.fAncestors.size(); ++depth) {
862 SpeedscopeFrame ancestorFrame;
863 ancestorFrame.fString =
864 "[" + std::string(kAncestorsNames[depth]) +
" " + std::to_string(pageLeaf.fAncestors[depth]) +
"]";
865 ancestorFrame.fOpeningPosition = pageLeaf.fPosition;
866 frames.push_back(ancestorFrame);
868 ROpenFrame openFrame;
869 openFrame.fId = pageLeaf.fAncestors[depth];
870 openFrame.fIndex = frames.size() - 1;
871 openFrames.push_back(openFrame);
875 SpeedscopeFrame pageLeafFrame;
876 pageLeafFrame.fString = pageLeaf.fName;
877 pageLeafFrame.fOpeningPosition = pageLeaf.fPosition;
878 pageLeafFrame.fClosingPosition = pageLeaf.fPosition + pageLeaf.fSize;
879 frames.push_back(pageLeafFrame);
881 previouspageLeafEnd = pageLeaf.fPosition + pageLeaf.fSize;
885 while (!openFrames.empty()) {
886 frames[openFrames.back().fIndex].fClosingPosition = previouspageLeafEnd;
887 openFrames.pop_back();
891 for (
const auto &clusterGroupDescriptor : descriptor.GetClusterGroupIterable()) {
892 const auto locator = clusterGroupDescriptor.GetPageListLocator();
894 SpeedscopeFrame pageListFrame;
895 pageListFrame.fString =
"[page list " + std::to_string(clusterGroupDescriptor.GetId()) +
"]";
896 pageListFrame.fOpeningPosition = locator.GetPosition<std::uint64_t>();
897 pageListFrame.fClosingPosition = locator.GetPosition<std::uint64_t>() + locator.GetNBytesOnStorage();
898 frames.push_back(pageListFrame);
903 SpeedscopeFrame footerFrame;
904 footerFrame.fString =
"ntuple footer";
905 footerFrame.fOpeningPosition = anchor->GetSeekFooter();
906 footerFrame.fClosingPosition = anchor->GetSeekFooter() + anchor->GetNBytesFooter();
907 frames.push_back(footerFrame);
910 PrintSpeedscopeFrames(frames, output);
#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(...)
#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.
std::uint64_t GetCompressedSize() const
std::uint64_t GetUncompressedSize() const
std::uint64_t GetNPages() const
std::uint64_t GetNElements() const
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.
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
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::DescriptorId_t GetId() const
std::uint32_t GetFieldVersion() const
const std::vector< ROOT::DescriptorId_t > & GetLinkIds() const
ROOT::DescriptorId_t GetParentId() const
const std::string & GetFieldDescription() const
const std::string & GetFieldName() const
const std::string & GetTypeName() const
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.
RNTupleDescriptor Clone() const
Representation of an RNTuple data set in a ROOT file.
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)