diff --git a/dwio/nimble/tools/NimbleDump.cpp b/dwio/nimble/tools/NimbleDump.cpp index 798b2b4..44914c0 100644 --- a/dwio/nimble/tools/NimbleDump.cpp +++ b/dwio/nimble/tools/NimbleDump.cpp @@ -136,6 +136,7 @@ int main(int argc, char* argv[]) { options["no_header"].as(), options["labels"].as(), options["raw_size"].as(), + options["inmap_stream"].as(), getOptional(options["stripe"])); }, positionalArgs) @@ -163,6 +164,10 @@ int main(int argc, char* argv[]) { po::bool_switch()->default_value(false), "Include stream labels. Lables provide a readable path from the " "root node to the stream, as they appear in the schema tree." + )( + "inmap_stream,i", + po::bool_switch()->default_value(false), + "Include InMap stream indicator." ); // clang-format on diff --git a/dwio/nimble/tools/NimbleDumpLib.cpp b/dwio/nimble/tools/NimbleDumpLib.cpp index fa24381..c412e6f 100644 --- a/dwio/nimble/tools/NimbleDumpLib.cpp +++ b/dwio/nimble/tools/NimbleDumpLib.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "common/strings/Zstd.h" @@ -444,6 +445,7 @@ void NimbleDumpLib::emitStreams( bool noHeader, bool showStreamLabels, bool showStreamRawSize, + bool showInMapStream, std::optional stripeId) { auto tabletReader = std::make_shared(*pool_, file_.get()); @@ -459,15 +461,31 @@ void NimbleDumpLib::emitStreams( if (showStreamLabels) { fields.push_back({"Stream Label", 16, Alignment::Left}); } + if (showInMapStream) { + fields.push_back({"InMap Stream", 16, Alignment::Left}); + } fields.push_back({"Type", 30, Alignment::Left}); - TableFormatter formatter(ostream_, fields, noHeader); + TableFormatter formatter(ostream_, std::move(fields), noHeader); std::optional labels{}; if (showStreamLabels) { VeloxReader reader{*pool_, tabletReader}; labels.emplace(reader.schema()); } + std::unordered_set inMapStreams; + if (showInMapStream) { + VeloxReader reader{*pool_, tabletReader}; + SchemaReader::traverseSchema( + reader.schema(), [&](auto /*level*/, const Type& type, auto /*info*/) { + if (type.kind() == Kind::FlatMap) { + auto& map = type.asFlatMap(); + for (size_t i = 0; i < map.childrenCount(); ++i) { + inMapStreams.insert(map.inMapDescriptorAt(i).offset()); + } + } + }); + } traverseTablet( *pool_, @@ -500,7 +518,10 @@ void NimbleDumpLib::emitStreams( } values.push_back(folly::to(itemCount)); if (showStreamLabels) { - auto it = values.emplace_back(labels->streamLabel(streamId)); + values.emplace_back(labels->streamLabel(streamId)); + } + if (showInMapStream) { + values.emplace_back(inMapStreams.contains(streamId) ? "T" : "F"); } values.push_back(getStreamInputLabel(stream)); formatter.writeRow(values); diff --git a/dwio/nimble/tools/NimbleDumpLib.h b/dwio/nimble/tools/NimbleDumpLib.h index 3553ade..18ff610 100644 --- a/dwio/nimble/tools/NimbleDumpLib.h +++ b/dwio/nimble/tools/NimbleDumpLib.h @@ -33,6 +33,7 @@ class NimbleDumpLib { bool noHeader, bool flatmapKeys, bool rawSize, + bool showInMapStream, std::optional stripeId); void emitHistogram(bool topLevel, bool noHeader, std::optional stripeId);