Skip to content

Commit

Permalink
Update nimble_dump info to Include Raw File Size (#79)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #79

Updating nimble_dump to display raw file size by reading from footer.

Reviewed By: sdruzkin, helfman

Differential Revision: D61890960
  • Loading branch information
phoenixawe authored and facebook-github-bot committed Sep 20, 2024
1 parent a561285 commit e2853be
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion dwio/nimble/tools/NimbleDumpLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -220,7 +222,10 @@ NimbleDumpLib::NimbleDumpLib(std::ostream& ostream, const std::string& file)
ostream_{ostream} {}

void NimbleDumpLib::emitInfo() {
auto tablet = std::make_shared<TabletReader>(*pool_, file_.get());
std::vector<std::string> preloadedOptionalSections = {
std::string(kStatsSection)};
auto tablet = std::make_shared<TabletReader>(
*pool_, file_.get(), preloadedOptionalSections);
ostream_ << CYAN << "Nimble File " << RESET_COLOR << "Version "
<< tablet->majorVersion() << "." << tablet->minorVersion()
<< std::endl;
Expand All @@ -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<nimble::serialization::Stats>(
statsSection->content().data())
->raw_size();
ostream_ << rawSize << std::endl;
} else {
ostream_ << "N/A" << std::endl;
}

auto& metadata = reader.metadata();
if (!metadata.empty()) {
ostream_ << "Metadata:";
Expand Down

0 comments on commit e2853be

Please sign in to comment.