From 6953ce49d787f2c9bc95dc992be3d043835e2eb8 Mon Sep 17 00:00:00 2001 From: Chongfeng Hu Date: Thu, 9 Jan 2025 17:39:27 -0800 Subject: [PATCH] Augment nimble_dump info subcommand by listing all metadata sections by size (#129) Summary: This change augments `nimble_dump`'s `info` subcommand. With this change, we will list all metadata sections in the Nimble file, along with their respective sizes. Differential Revision: D67958989 --- dwio/nimble/tools/NimbleDumpLib.cpp | 34 +++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/dwio/nimble/tools/NimbleDumpLib.cpp b/dwio/nimble/tools/NimbleDumpLib.cpp index 5f8dfae..fa24381 100644 --- a/dwio/nimble/tools/NimbleDumpLib.cpp +++ b/dwio/nimble/tools/NimbleDumpLib.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ #include +#include #include #include #include @@ -263,9 +264,38 @@ void NimbleDumpLib::emitInfo() { ostream_ << "File Size: " << commaSeparated(tablet->fileSize()) << std::endl; ostream_ << "Checksum: " << tablet->checksum() << " [" << nimble::toString(tablet->checksumType()) << "]" << std::endl; - ostream_ << "Footer Compression: " << tablet->footerCompressionType() + ostream_ << "Postscript Size: " << commaSeparated(kPostscriptSize) << std::endl; - ostream_ << "Footer Size: " << commaSeparated(tablet->footerSize()) + ostream_ << "Footer Size: " << commaSeparated(tablet->footerSize()) << " (" + << tablet->footerCompressionType() << ")" << std::endl; + ostream_ << "Stripes Metadata Size: "; + auto stripesMetadata = tablet->stripesMetadata(); + if (!stripesMetadata) { + ostream_ << "0" << std::endl; + } else { + ostream_ << commaSeparated(stripesMetadata.value().size()) << " (" + << stripesMetadata.value().compressionType() << ")" << std::endl; + } + auto stripeGroupsMetadata = tablet->stripeGroupsMetadata(); + ostream_ << "Stripe Groups Metadata Size: " + << commaSeparated(std::transform_reduce( + stripeGroupsMetadata.begin(), + stripeGroupsMetadata.end(), + 0, + std::plus{}, + [](const MetadataSection& metadataSection) { + return metadataSection.size(); + })) + << std::endl; + ostream_ << "Optional Sections Size: " + << commaSeparated(std::transform_reduce( + tablet->optionalSections().begin(), + tablet->optionalSections().end(), + 0, + std::plus{}, + [](const std::pair& entry) { + return entry.second.size(); + })) << std::endl; ostream_ << "Stripe Count: " << commaSeparated(tablet->stripeCount()) << std::endl;