From 4dcf271f6838c98e1b8f95d52f5d77b5f659e29b Mon Sep 17 00:00:00 2001 From: Jakob Blomer Date: Wed, 13 Sep 2023 00:25:57 +0200 Subject: [PATCH] [ntuple] minor code improvement --- tree/ntuple/v7/src/RNTupleDescriptorFmt.cxx | 10 +-- tree/ntuple/v7/test/ntuple_print.cxx | 84 ++++++++++----------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/tree/ntuple/v7/src/RNTupleDescriptorFmt.cxx b/tree/ntuple/v7/src/RNTupleDescriptorFmt.cxx index 102b984ac90d4..a086037d6b40f 100644 --- a/tree/ntuple/v7/src/RNTupleDescriptorFmt.cxx +++ b/tree/ntuple/v7/src/RNTupleDescriptorFmt.cxx @@ -98,6 +98,11 @@ void ROOT::Experimental::RNTupleDescriptor::PrintInfo(std::ostream &output) cons std::uint64_t nPages = 0; int compression = -1; for (const auto &column : fColumnDescriptors) { + // Alias columns (columns of projected fields) don't contribute to the storage consumption. Count them + // but don't add the the page sizes to the overall volume. + if (column.second.IsAliasColumn()) + continue; + // We generate the default memory representation for the given column type in order // to report the size _in memory_ of column elements auto elementSize = Detail::RColumnElementBase::Generate(column.second.GetModel().GetType())->GetSize(); @@ -110,11 +115,6 @@ void ROOT::Experimental::RNTupleDescriptor::PrintInfo(std::ostream &output) cons info.fElementSize = elementSize; info.fType = column.second.GetModel().GetType(); - // Alias columns (columns of projected fields) don't contribute to the storage consumption. Count them - // but don't add the the page sizes to the overall volume. - if (column.second.IsAliasColumn()) - continue; - for (const auto &cluster : fClusterDescriptors) { auto columnRange = cluster.second.GetColumnRange(column.second.GetPhysicalId()); info.fNElements += columnRange.fNElements; diff --git a/tree/ntuple/v7/test/ntuple_print.cxx b/tree/ntuple/v7/test/ntuple_print.cxx index 844f83d23686b..ea749aefdd4b5 100644 --- a/tree/ntuple/v7/test/ntuple_print.cxx +++ b/tree/ntuple/v7/test/ntuple_print.cxx @@ -32,48 +32,48 @@ TEST(RNtuplePrint, FullString) std::ostringstream osDetails; reader->PrintInfo(ROOT::Experimental::ENTupleInfo::kStorageDetails, osDetails); - reference = std::string("") - + "============================================================\n" - + "NTUPLE: ntpl\n" - + "Compression: 0\n" - + "------------------------------------------------------------\n" - + " # Entries: 1\n" - + " # Fields: 4\n" - + " # Columns: 2\n" - + " # Alias Columns: 1\n" - + " # Pages: 2\n" - + " # Clusters: 1\n" - + " Size on storage: 8 B\n" - + " Compression rate: 1.00\n" - + " Header size: .* B\n" - + " Footer size: .* B\n" - + " Meta-data / data: .*\n" - + "------------------------------------------------------------\n" - + "CLUSTER DETAILS\n" - + "------------------------------------------------------------\n" - + " # 0 Entry range: .0..0. -- 1\n" - + " # Pages: 2\n" - + " Size on storage: 8 B\n" - + " Compression: 1.00\n" - + "------------------------------------------------------------\n" - + "COLUMN DETAILS\n" - + "------------------------------------------------------------\n" - + " px .#0. -- Real32 .id:0.\n" - + " # Elements: 1\n" - + " # Pages: 1\n" - + " Avg elements / page: 1\n" - + " Avg page size: 4 B\n" - + " Size on storage: 4 B\n" - + " Compression: 1.00\n" - + "............................................................\n" - + " py .#0. -- Real32 .id:1.\n" - + " # Elements: 1\n" - + " # Pages: 1\n" - + " Avg elements / page: 1\n" - + " Avg page size: 4 B\n" - + " Size on storage: 4 B\n" - + " Compression: 1.00\n" - + "............................................................\n"; + reference = + "============================================================\n" + "NTUPLE: ntpl\n" + "Compression: 0\n" + "------------------------------------------------------------\n" + " # Entries: 1\n" + " # Fields: 4\n" + " # Columns: 2\n" + " # Alias Columns: 1\n" + " # Pages: 2\n" + " # Clusters: 1\n" + " Size on storage: 8 B\n" + " Compression rate: 1.00\n" + " Header size: .* B\n" + " Footer size: .* B\n" + " Meta-data / data: .*\n" + "------------------------------------------------------------\n" + "CLUSTER DETAILS\n" + "------------------------------------------------------------\n" + " # 0 Entry range: .0..0. -- 1\n" + " # Pages: 2\n" + " Size on storage: 8 B\n" + " Compression: 1.00\n" + "------------------------------------------------------------\n" + "COLUMN DETAILS\n" + "------------------------------------------------------------\n" + " px .#0. -- Real32 .id:0.\n" + " # Elements: 1\n" + " # Pages: 1\n" + " Avg elements / page: 1\n" + " Avg page size: 4 B\n" + " Size on storage: 4 B\n" + " Compression: 1.00\n" + "............................................................\n" + " py .#0. -- Real32 .id:1.\n" + " # Elements: 1\n" + " # Pages: 1\n" + " Avg elements / page: 1\n" + " Avg page size: 4 B\n" + " Size on storage: 4 B\n" + " Compression: 1.00\n" + "............................................................\n"; EXPECT_THAT(osDetails.str(), testing::MatchesRegex(reference)); }