Skip to content

Commit

Permalink
KIKIMR-19139 Get index page type from Store
Browse files Browse the repository at this point in the history
  • Loading branch information
kunga committed Sep 25, 2023
1 parent f7f3847 commit 10fe953
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/flat_fwd_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace NFwd {
ui16 room = (groupId.Historic ? part->Groups + 2 : 0) + groupId.Index;
TSlot slot = GetQueueSlot(part, room);

if (part->IndexPages.Has(groupId, ref)) {
if (part->GetPageType(ref, groupId) == EPage::Index) {
return TryGetIndexPage(slot, ref);
}

Expand Down
6 changes: 6 additions & 0 deletions ydb/core/tablet_flat/flat_part_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class TPartStore : public TPart, public IBundle {
return PageCollections[groupId.Index]->PageCollection->Page(id).Size;
}

NPage::EPage GetPageType(NPage::TPageId id, NPage::TGroupId groupId) const override
{
Y_VERIFY(groupId.Index < PageCollections.size());
return EPage(PageCollections[groupId.Index]->PageCollection->Page(id).Type);
}

ui8 GetPageChannel(NPage::TPageId id, NPage::TGroupId groupId) const override
{
Y_UNUSED(id);
Expand Down
26 changes: 2 additions & 24 deletions ydb/core/tablet_flat/flat_table_part.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,10 @@ namespace NTable {
Trace = 2, /* how many last data pages to keep while seq scans */
};

class TIndexPages {
public:
struct TIndexPages {
using TPageId = NPage::TPageId;
using TGroupId = NPage::TGroupId;

TIndexPages(TVector<TPageId> groups, TVector<TPageId> historic)
: Groups(std::move(groups))
, Historic(std::move(historic))
, All(Groups.size() + Historic.size())
{
for (auto p : Groups) {
All.insert(p);
}
for (auto p : Historic) {
All.insert(p);
}
}

const TVector<TPageId> Groups;
const TVector<TPageId> Historic;

bool Has(NPage::TGroupId groupId, TPageId pageId) const {
return groupId.IsMain() && All.contains(pageId);
}

private:
THashSet<TPageId> All;
};

struct TParams {
Expand Down Expand Up @@ -155,6 +132,7 @@ namespace NTable {
virtual ui64 DataSize() const = 0;
virtual ui64 BackingSize() const = 0;
virtual ui64 GetPageSize(NPage::TPageId id, NPage::TGroupId groupId = { }) const = 0;
virtual NPage::EPage GetPageType(NPage::TPageId id, NPage::TGroupId groupId = { }) const = 0;
virtual ui8 GetPageChannel(NPage::TPageId id, NPage::TGroupId groupId = { }) const = 0;
virtual ui8 GetPageChannel(ELargeObj lob, ui64 ref) const = 0;

Expand Down
4 changes: 2 additions & 2 deletions ydb/core/tablet_flat/test/libs/table/test_envs.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace NTest {

const TSharedData* TryGetPage(const TPart* part, TPageId ref, TGroupId groupId) override
{
auto pass = ShouldPass((const void*)part, ref | (ui64(groupId.Raw()) << 32), part->IndexPages.Has(groupId, ref));
auto pass = ShouldPass((const void*)part, ref | (ui64(groupId.Raw()) << 32), part->GetPageType(ref, groupId) == EPage::Index);

return pass ? TTestEnv::TryGetPage(part, ref, groupId) : nullptr;
}
Expand Down Expand Up @@ -255,7 +255,7 @@ namespace NTest {

Y_VERIFY(groupId.Index < partStore->Store->GetGroupCount());

if (part->IndexPages.Has(groupId, pageId)) {
if (part->GetPageType(pageId, groupId) == EPage::Index) {
return partStore->Store->GetPage(groupId.Index, pageId);
} else {
ui32 room = (groupId.Historic ? partStore->Store->GetRoomCount() : 0) + groupId.Index;
Expand Down
5 changes: 5 additions & 0 deletions ydb/core/tablet_flat/test/libs/table/test_part.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ namespace NTest {
return Store->GetPage(groupId.Index, id)->size();
}

NPage::EPage GetPageType(NPage::TPageId id, NPage::TGroupId groupId) const override
{
return Store->GetPageType(groupId.Index, id);
}

ui8 GetPageChannel(NPage::TPageId id, NPage::TGroupId groupId) const override
{
Y_UNUSED(id);
Expand Down
10 changes: 10 additions & 0 deletions ydb/core/tablet_flat/test/libs/table/test_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ namespace NTest {
return &PageCollections.at(room).at(page);
}

NPage::EPage GetPageType(ui32 room, ui32 page) const noexcept
{
Y_VERIFY(room < PageCollections.size(), "Room is out of bounds");

return PageTypes.at(room).at(page);
}

TArrayRef<const TSharedData> PageCollectionArray(ui32 room) const noexcept
{
Y_VERIFY(room < PageCollections.size(), "Only regular rooms can be used as arr");
Expand Down Expand Up @@ -208,6 +215,7 @@ namespace NTest {

TPageId id = PageCollections[group].size();
PageCollections[group].push_back(std::move(page));
PageTypes[group].push_back(type);

if (group == 0) {
switch (type) {
Expand Down Expand Up @@ -264,6 +272,7 @@ namespace NTest {
: Groups(groups)
, GlobOffset(globOffset)
, PageCollections(groups + 2)
, PageTypes(groups + 2)
{ }

ui32 NextGlobOffset() const {
Expand All @@ -275,6 +284,7 @@ namespace NTest {
const size_t Groups;
const ui32 GlobOffset;
TVector<TVector<TSharedData>> PageCollections;
TVector<TVector<EPage>> PageTypes;

/*_ Sometimes will be replaced just with one root TPageId */

Expand Down

0 comments on commit 10fe953

Please sign in to comment.