Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tree/ntupleutil/inc/ROOT/RNTupleInspector.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public:
: fColumnDescriptor(colDesc),
fCompressedPageSizes(compressedPageSizes),
fElementSize(elemSize),
fNElements(nElems){};
fNElements(nElems)
{
}
~RColumnInspector() = default;

const ROOT::RColumnDescriptor &GetDescriptor() const { return fColumnDescriptor; }
Expand Down Expand Up @@ -136,7 +138,9 @@ public:

public:
RFieldTreeInspector(const ROOT::RFieldDescriptor &fieldDesc, std::uint64_t onDiskSize, std::uint64_t inMemSize)
: fRootFieldDescriptor(fieldDesc), fCompressedSize(onDiskSize), fUncompressedSize(inMemSize){};
: fRootFieldDescriptor(fieldDesc), fCompressedSize(onDiskSize), fUncompressedSize(inMemSize)
{
}
~RFieldTreeInspector() = default;

const ROOT::RFieldDescriptor &GetDescriptor() const { return fRootFieldDescriptor; }
Expand Down Expand Up @@ -426,6 +430,10 @@ public:
std::string histName = "", std::string histTitle = "",
size_t nBins = 64);

std::unique_ptr<THStack> GetPagesPerClusterDistribution(std::initializer_list<ROOT::ENTupleColumnType> colTypes = {},
std::string histName = "", std::string histTitle = "",
size_t nBins = 32);

/////////////////////////////////////////////////////////////////////////////
/// \brief Get storage information for a given (sub)field by ID.
///
Expand Down
52 changes: 52 additions & 0 deletions tree/ntupleutil/src/RNTupleInspector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,58 @@
return stackedHist;
}

std::unique_ptr<THStack> ROOT::Experimental::RNTupleInspector::GetPagesPerClusterDistribution(
std::initializer_list<ROOT::ENTupleColumnType> colTypes, std::string histName, std::string histTitle, size_t nBins)
{
if (histName.empty())
histName = "pagesPerClusterHist";
if (histTitle.empty())
histTitle = "Per-column #pages per cluster distribution";

auto stackedHist =
std::make_unique<THStack>(histName.c_str(), TString::Format("%s;#pages per cluster", histTitle.c_str()));

double histMin = std::numeric_limits<double>::max();
double histMax = 0;
// Each element of the vector is a map { columnId => nPagesInThisCluster }
std::vector<std::unordered_map<DescriptorId_t, std::uint64_t>> pagesPerCluster;
std::set<std::pair<DescriptorId_t, DescriptorId_t>> allFieldAndColumnIds;

std::vector<ROOT::ENTupleColumnType> colTypeVec = colTypes;
if (std::empty(colTypes)) {
colTypeVec = GetColumnTypes();
}

for (const auto &clDesc : fDescriptor.GetClusterIterable()) {
auto &pagesInThisCluster = pagesPerCluster.emplace_back();
for (const auto &colRange : clDesc.GetColumnRangeIterable()) {
const auto colId = colRange.GetPhysicalColumnId();
const auto nPages = clDesc.GetPageRange(colId).GetPageInfos().size();
auto &pagesForThisColumn = pagesInThisCluster[colId];
pagesForThisColumn += nPages;
histMin = std::min(histMin, static_cast<double>(pagesForThisColumn));
histMax = std::max(histMax, static_cast<double>(pagesForThisColumn));
const auto &colDesc = fDescriptor.GetColumnDescriptor(colId);
allFieldAndColumnIds.emplace(colDesc.GetFieldId(), colId);
}
}

for (const auto [fieldId, colId] : allFieldAndColumnIds) {

Check failure on line 494 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / debian13 dev=ON, CMAKE_CXX_FLAGS=-Wsuggest-override

loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<long unsigned int, long unsigned int>’ [-Werror=range-loop-construct]

Check warning on line 494 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / alma9 modules_off CMAKE_CXX_STANDARD=20

loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<long unsigned int, long unsigned int>’ [-Wrange-loop-construct]

Check warning on line 494 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / rawhide Fedora pydebug no GIL CMAKE_CXX_STANDARD=23

loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<long unsigned int, long unsigned int>’ [-Wrange-loop-construct]

Check warning on line 494 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / ubuntu2604

loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<long unsigned int, long unsigned int>’ [-Wrange-loop-construct]

Check warning on line 494 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / fedora43

loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<long unsigned int, long unsigned int>’ [-Wrange-loop-construct]

Check warning on line 494 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / fedora44

loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<long unsigned int, long unsigned int>’ [-Wrange-loop-construct]

Check warning on line 494 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / alma9 CMAKE_BUILD_TYPE=Debug

loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<long unsigned int, long unsigned int>’ [-Wrange-loop-construct]

Check warning on line 494 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / ubuntu22 imt=Off, CMAKE_BUILD_TYPE=Debug

loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<long unsigned int, long unsigned int>’ [-Wrange-loop-construct]

Check warning on line 494 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / ubuntu2404 CMAKE_BUILD_TYPE=Debug

loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<long unsigned int, long unsigned int>’ [-Wrange-loop-construct]
auto fieldName = fDescriptor.GetQualifiedFieldName(fieldId);
auto hist =
std::make_unique<TH1D>(TString::Format("%s_%lu", fieldName.c_str(), colId), std::to_string(colId).c_str(),

Check warning on line 497 in tree/ntupleutil/src/RNTupleInspector.cxx

View workflow job for this annotation

GitHub Actions / mac-beta ARM64

format specifies type 'unsigned long' but the argument has type 'typename tuple_element<1UL, std::pair<unsigned long long, unsigned long long>>::type' (aka 'unsigned long long') [-Wformat]
nBins, histMin, histMax + ((histMax - histMin) / static_cast<double>(nBins)));
for (const auto &pagesInCluster : pagesPerCluster) {
auto it = pagesInCluster.find(colId);
hist->Fill(it == pagesInCluster.end() ? 0u : it->second);
}

stackedHist->Add(hist.release());
}

return stackedHist;
}

//------------------------------------------------------------------------------

const ROOT::Experimental::RNTupleInspector::RFieldTreeInspector &
Expand Down
Loading