Skip to content

Commit

Permalink
Add new Tablet API to expose optionalSections metadata
Browse files Browse the repository at this point in the history
Summary: This new API will unlock use cases such as enumerating all optional sections in the Nimble file. It will also empower `nimble_dump` to be able to provide relevant information about the optional sections.

Differential Revision: D67949242
  • Loading branch information
Chongfeng Hu authored and facebook-github-bot committed Jan 8, 2025
1 parent fae485b commit ab40fe6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dwio/nimble/tablet/TabletReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ class TabletReader {
const StripeIdentifier& stripe,
std::span<const uint32_t> streamIdentifiers) const;

std::unordered_map<
std::string,
std::tuple<uint64_t, uint32_t, CompressionType>>
optionalSections() const {
return optionalSections_;
}

std::optional<Section> loadOptionalSection(
const std::string& name,
bool keepCache = false) const;
Expand Down
7 changes: 7 additions & 0 deletions dwio/nimble/tablet/tests/TabletTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,11 @@ TEST(TabletTests, OptionalSections) {
file, useChaniedBuffers);
nimble::TabletReader tablet{*pool, &readFile};

ASSERT_EQ(tablet.optionalSections().size(), 3);
ASSERT_TRUE(tablet.optionalSections().contains("section1"));
ASSERT_TRUE(tablet.optionalSections().contains("section2"));
ASSERT_TRUE(tablet.optionalSections().contains("section3"));

auto check1 = [&]() {
auto section = tablet.loadOptionalSection("section1");
ASSERT_TRUE(section.has_value());
Expand Down Expand Up @@ -607,6 +612,8 @@ TEST(TabletTests, OptionalSectionsEmpty) {
file, useChaniedBuffers);
nimble::TabletReader tablet{*pool, &readFile};

ASSERT_TRUE(tablet.optionalSections().empty());

auto section = tablet.loadOptionalSection("section1");
ASSERT_FALSE(section.has_value());
}
Expand Down

0 comments on commit ab40fe6

Please sign in to comment.