Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ydb/core/tablet_flat/flat_fwd_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ namespace NFwd {
TDeque<TPageEx> Pages;
ui32 PagesBeginOffset = 0, PagesPendingOffset = 0;
TDeque<TNodeState> Queue;
TPageId BeginPageId = Max<TPageId>(), EndPageId = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are needed just for clear error message

};

public:
Expand All @@ -300,6 +301,8 @@ namespace NFwd {
auto& meta = Part->IndexPages.GetBTree(groupId);
Levels.resize(meta.LevelCount + 1);
Levels[0].Queue.push_back({meta.GetPageId(), meta.GetDataSize()});
Levels[0].BeginPageId = 0;
Levels[0].EndPageId = meta.GetPageId() + 1;
if (meta.LevelCount) {
IndexPageLocator.Add(meta.GetPageId(), GroupId, 0);
}
Expand All @@ -318,6 +321,9 @@ namespace NFwd {
return {page, false, true};
}

Y_ENSURE(level.BeginPageId <= pageId && pageId < level.EndPageId, "Requested page " << pageId << " is out of loaded slice "
<< BeginRowId << " " << EndRowId << " " << level.BeginPageId << " " << level.EndPageId << " with index " << Part->IndexPages.GetBTree(GroupId).ToString());

DropPagesBefore(level, pageId);
ShrinkPages(level);

Expand Down Expand Up @@ -429,8 +435,13 @@ namespace NFwd {
if (child.GetRowCount() <= BeginRowId) {
continue;
}
Y_ENSURE(!Levels[levelId + 1].Queue || Levels[levelId + 1].Queue.back().PageId < child.GetPageId());
Levels[levelId + 1].Queue.push_back({child.GetPageId(), child.GetDataSize()});
auto& nextLevel = Levels[levelId + 1];
Y_ENSURE(!nextLevel.Queue || nextLevel.Queue.back().PageId < child.GetPageId());
nextLevel.Queue.push_back({child.GetPageId(), child.GetDataSize()});
if (nextLevel.BeginPageId == Max<TPageId>()) {
nextLevel.BeginPageId = child.GetPageId();
}
nextLevel.EndPageId = child.GetPageId() + 1;
if (child.GetRowCount() >= EndRowId) {
break;
}
Expand Down
6 changes: 5 additions & 1 deletion ydb/core/tablet_flat/flat_page_btree_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ namespace NKikimr::NTable::NPage {
TRowId RowCount_;
ui64 DataSize_;

auto operator<=>(const TShortChild&) const = default;

inline TPageId GetPageId() const noexcept {
return PageId_;
}
Expand All @@ -102,7 +104,9 @@ namespace NKikimr::NTable::NPage {
return DataSize_;
}

auto operator<=>(const TShortChild&) const = default;
TString ToString() const {
return TStringBuilder() << "PageId: " << GetPageId() << " RowCount: " << GetRowCount() << " DataSize: " << GetDataSize();
}
} Y_PACKED;

static_assert(sizeof(TShortChild) == 20, "Invalid TBtreeIndexNode TShortChild size");
Expand Down
5 changes: 5 additions & 0 deletions ydb/core/tablet_flat/flat_part_iter.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ namespace NTable {
return EReady::Data;
}

if (Page.BaseRow() + Page->Count >= EndRowId) {
// Row is outside of bounds
return Exhausted();
}

if (seek != ESeek::Exact) {
// The row we seek is on the next page

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/test/libs/table/test_envs.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ namespace NTest {
for (ui32 room : xrange(partStore->Store->GetRoomCount())) {
if (room < partStore->Store->GetGroupCount()) {
NPage::TGroupId groupId(room);
partGroupQueues.push_back(Settle(partStore, room, NFwd::CreateCache(part, PartIndexPageLocator[part], groupId)));
partGroupQueues.push_back(Settle(partStore, room, NFwd::CreateCache(part, PartIndexPageLocator[part], groupId, partStore->Slices)));
} else if (room == partStore->Store->GetOuterRoom()) {
partGroupQueues.push_back(Settle(partStore, room, MakeOuter(partStore)));
} else if (room == partStore->Store->GetExternRoom()) {
Expand Down
Loading
Loading