Skip to content

Commit

Permalink
[ntuple] minor code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
jblomer committed Oct 12, 2023
1 parent e07e7a8 commit 4dcf271
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
10 changes: 5 additions & 5 deletions tree/ntuple/v7/src/RNTupleDescriptorFmt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
84 changes: 42 additions & 42 deletions tree/ntuple/v7/test/ntuple_print.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 4dcf271

Please sign in to comment.