Skip to content

Commit

Permalink
Add a new command to nimble_dump: stripe_groups_metadata (#133)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #133

`stripe_groups_metadata` dumps the stripes metadata information as referenced by the footer: https://www.internalfb.com/code/fbsource/[3a9c4e4b1b7b7e7b22668f54ddc12f0ccfc904b4]/fbcode/dwio/nimble/tablet/Footer.fbs?lines=52

Reviewed By: helfman

Differential Revision: D68035171

fbshipit-source-id: 388428157144ab03e3f2af15a158b65ad9f00b2b
  • Loading branch information
Chongfeng Hu authored and facebook-github-bot committed Jan 13, 2025
1 parent 2859f82 commit 16ee199
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dwio/nimble/tools/NimbleDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,31 @@ int main(int argc, char* argv[]) {
);
// clang-format on

app.addCommand(
"stripe_groups_metadata",
"<file>",
"Print stripe groups metadata information",
"Prints stripe groups information as referenced by the footer.",
[](const po::variables_map& options,
const std::vector<std::string>& /*args*/) {
nimble::tools::NimbleDumpLib{
std::cout, options["file"].as<std::string>()}
.emitStripeGroupsMetadata(options["no_header"].as<bool>());
},
positionalArgs)
// clang-format off
.add_options()
(
"file",
po::value<std::string>()->required(),
"Nimble file path. Can be a local path or a Warm Storage path."
)(
"no_header,n",
po::bool_switch()->default_value(false),
"Don't print column names. Default is to include column names."
);
// clang-format on

app.addAlias("i", "info");
app.addAlias("b", "binary");
app.addAlias("c", "content");
Expand Down
23 changes: 23 additions & 0 deletions dwio/nimble/tools/NimbleDumpLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,4 +886,27 @@ void NimbleDumpLib::emitStripesMetadata(bool noHeader) {
});
}

void NimbleDumpLib::emitStripeGroupsMetadata(bool noHeader) {
TabletReader tabletReader{*pool_, file_.get()};
TableFormatter formatter(
ostream_,
{
{"Group Id", 10, Alignment::Left},
{"Offset", 15, Alignment::Left},
{"Size", 15, Alignment::Left},
{"Compression Type", 18, Alignment::Left},
},
noHeader);
auto stripeGroupsMetadata = tabletReader.stripeGroupsMetadata();
for (auto i = 0; i < stripeGroupsMetadata.size(); ++i) {
const auto& metadata = stripeGroupsMetadata[i];
formatter.writeRow({
commaSeparated(i),
commaSeparated(metadata.offset()),
commaSeparated(metadata.size()),
toString(metadata.compressionType()),
});
}
}

} // namespace facebook::nimble::tools
1 change: 1 addition & 0 deletions dwio/nimble/tools/NimbleDumpLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class NimbleDumpLib {
uint32_t stripeId);
void emitLayout(bool noHeader, bool compressed);
void emitStripesMetadata(bool noHeader);
void emitStripeGroupsMetadata(bool noHeader);

private:
std::shared_ptr<velox::memory::MemoryPool> pool_;
Expand Down

0 comments on commit 16ee199

Please sign in to comment.