From e2853bea2b5b202d608a782cf2778308b147240a Mon Sep 17 00:00:00 2001 From: Stephanie Han Date: Fri, 20 Sep 2024 12:16:55 -0700 Subject: [PATCH] Update nimble_dump info to Include Raw File Size (#79) Summary: Pull Request resolved: https://github.com/facebookincubator/nimble/pull/79 Updating nimble_dump to display raw file size by reading from footer. Reviewed By: sdruzkin, helfman Differential Revision: D61890960 --- dwio/nimble/tools/NimbleDumpLib.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dwio/nimble/tools/NimbleDumpLib.cpp b/dwio/nimble/tools/NimbleDumpLib.cpp index c8e1dae..c0f4729 100644 --- a/dwio/nimble/tools/NimbleDumpLib.cpp +++ b/dwio/nimble/tools/NimbleDumpLib.cpp @@ -28,9 +28,11 @@ #include "dwio/nimble/common/Types.h" #include "dwio/nimble/encodings/EncodingFactory.h" #include "dwio/nimble/encodings/EncodingLayout.h" +#include "dwio/nimble/tablet/Constants.h" #include "dwio/nimble/tools/EncodingUtilities.h" #include "dwio/nimble/tools/NimbleDumpLib.h" #include "dwio/nimble/velox/EncodingLayoutTree.h" +#include "dwio/nimble/velox/StatsGenerated.h" #include "dwio/nimble/velox/VeloxReader.h" #include "folly/cli/NestedCommandLineApp.h" @@ -220,7 +222,10 @@ NimbleDumpLib::NimbleDumpLib(std::ostream& ostream, const std::string& file) ostream_{ostream} {} void NimbleDumpLib::emitInfo() { - auto tablet = std::make_shared(*pool_, file_.get()); + std::vector preloadedOptionalSections = { + std::string(kStatsSection)}; + auto tablet = std::make_shared( + *pool_, file_.get(), preloadedOptionalSections); ostream_ << CYAN << "Nimble File " << RESET_COLOR << "Version " << tablet->majorVersion() << "." << tablet->minorVersion() << std::endl; @@ -237,6 +242,19 @@ void NimbleDumpLib::emitInfo() { << std::endl; VeloxReader reader{*pool_, tablet}; + + auto statsSection = + tablet.get()->loadOptionalSection(preloadedOptionalSections[0]); + ostream_ << "Raw Data Size: "; + if (statsSection.has_value()) { + auto rawSize = flatbuffers::GetRoot( + statsSection->content().data()) + ->raw_size(); + ostream_ << rawSize << std::endl; + } else { + ostream_ << "N/A" << std::endl; + } + auto& metadata = reader.metadata(); if (!metadata.empty()) { ostream_ << "Metadata:";