Skip to content

Commit

Permalink
cr: don't count b-tree index either
Browse files Browse the repository at this point in the history
  • Loading branch information
kunga committed May 22, 2024
1 parent 0616fc1 commit d7b7f5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
23 changes: 12 additions & 11 deletions ydb/core/tablet_flat/flat_dbase_sz_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace NTable {
{
auto *partStore = CheckedCast<const NTable::TPartStore*>(part);

Touch(partStore->Locate(lob, ref), ref);
AddPageSize(partStore->Locate(lob, ref), ref);

return { true, nullptr };
}
Expand All @@ -37,24 +37,25 @@ namespace NTable {
auto info = partStore->PageCollections.at(groupId.Index).Get();
auto type = EPage(info->PageCollection->Page(pageId).Type);

if (type != EPage::FlatIndex) { // do not count flat index pages
Touch(partStore->PageCollections.at(groupId.Index).Get(), pageId);
switch (type) {
case EPage::FlatIndex:
case EPage::BTreeIndex:
// need index pages to continue counting
// do not count index
// if these pages are not in memory, data won't be counted in precharge
return Env->TryGetPage(part, pageId, groupId);
default:
AddPageSize(partStore->PageCollections.at(groupId.Index).Get(), pageId);
return nullptr;
}

if (type == EPage::FlatIndex || type == EPage::BTreeIndex) {
// need page data to continue counting
return Env->TryGetPage(part, pageId, groupId);
}

return nullptr;
}

ui64 GetSize() const {
return Bytes;
}

private:
void Touch(TInfo *info, TPageId page) noexcept
void AddPageSize(TInfo *info, TPageId page) noexcept
{
if (Touched[info].insert(page).second) {
Pages++;
Expand Down
6 changes: 3 additions & 3 deletions ydb/core/tablet_flat/flat_executor_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5153,13 +5153,13 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorIndexLoading) {
TVector<ui64> sizes;

env.SendSync(new NFake::TEvExecute{ new TTxCalculateReadSize(sizes, 0, 1) });
UNIT_ASSERT_VALUES_EQUAL(sizes, (TVector<ui64>{102, 1090, 1784, 2478, 23044, 23044}));
UNIT_ASSERT_VALUES_EQUAL(sizes, (TVector<ui64>{0, 0, 0, 0, 20566, 20566}));

env.SendSync(new NFake::TEvExecute{ new TTxCalculateReadSize(sizes, 100, 200) });
UNIT_ASSERT_VALUES_EQUAL(sizes, (TVector<ui64>{102, 1090, 2478, 8030, 1056896, 1056896}));
UNIT_ASSERT_VALUES_EQUAL(sizes, (TVector<ui64>{0, 0, 0, 0, 1048866, 1048866}));

env.SendSync(new NFake::TEvExecute{ new TTxCalculateReadSize(sizes, 300, 700) });
UNIT_ASSERT_VALUES_EQUAL(sizes, (TVector<ui64>{102, 1090, 4560, 25033, 4158799, 4158799}));
UNIT_ASSERT_VALUES_EQUAL(sizes, (TVector<ui64>{0, 0, 0, 0, 4133766, 4133766}));
}

Y_UNIT_TEST(PrechargeAndSeek_FlatIndex) {
Expand Down

0 comments on commit d7b7f5b

Please sign in to comment.