diff options
| author | kungurtsev <[email protected]> | 2024-03-19 10:27:56 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-19 10:27:56 +0100 |
| commit | 83da64db07f41f06097b0e58c9dfd43c45bd7ce8 (patch) | |
| tree | b6b49700253673fa1ad0bb351884eb7e0b10cea4 | |
| parent | bb516b43eb3c73662d43edbb9594d07e26caced7 (diff) | |
EnableLocalDBFlatIndex setting (#2674)
| -rw-r--r-- | ydb/core/protos/feature_flags.proto | 1 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_executor.cpp | 1 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_executor_ut.cpp | 87 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_page_conf.h | 1 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_part_btree_index_iter.h | 4 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_part_charge_btree_index.h | 10 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_part_charge_create.cpp | 2 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_part_dump.cpp | 8 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_part_index_iter.h | 2 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_part_index_iter_create.cpp | 2 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_part_loader.cpp | 64 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_part_loader.h | 9 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_part_writer.h | 71 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/flat_table_part.h | 25 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/ut/ut_charge.cpp | 66 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/ut/ut_part.cpp | 2 | ||||
| -rw-r--r-- | ydb/core/tablet_flat/ut_large/ut_btree_index_large.cpp | 12 |
17 files changed, 239 insertions, 128 deletions
diff --git a/ydb/core/protos/feature_flags.proto b/ydb/core/protos/feature_flags.proto index bae93242a30..4e722d1acc8 100644 --- a/ydb/core/protos/feature_flags.proto +++ b/ydb/core/protos/feature_flags.proto @@ -131,4 +131,5 @@ message TFeatureFlags { optional bool EnableReplaceIfExistsForExternalEntities = 116 [ default = false]; optional bool EnableCMSRequestPriorities = 117 [default = false]; optional bool EnableKeyvalueLogBatching = 118 [default = false]; + optional bool EnableLocalDBFlatIndex = 119 [default = true]; } diff --git a/ydb/core/tablet_flat/flat_executor.cpp b/ydb/core/tablet_flat/flat_executor.cpp index 0a9e407ed71..e7d4d4e9e8c 100644 --- a/ydb/core/tablet_flat/flat_executor.cpp +++ b/ydb/core/tablet_flat/flat_executor.cpp @@ -4315,6 +4315,7 @@ ui64 TExecutor::BeginCompaction(THolder<NTable::TCompactionParams> params) comp->Epoch = snapshot->Subset->Epoch(); /* narrows requested to actual */ comp->Layout.Final = comp->Params->IsFinal; comp->Layout.WriteBTreeIndex = AppData()->FeatureFlags.GetEnableLocalDBBtreeIndex(); + comp->Layout.WriteFlatIndex = AppData()->FeatureFlags.GetEnableLocalDBFlatIndex(); comp->Writer.StickyFlatIndex = !comp->Layout.WriteBTreeIndex; comp->Layout.MaxRows = snapshot->Subset->MaxRows(); comp->Layout.ByKeyFilter = tableInfo->ByKeyFilter; diff --git a/ydb/core/tablet_flat/flat_executor_ut.cpp b/ydb/core/tablet_flat/flat_executor_ut.cpp index 18d8399728b..c9aba45a86a 100644 --- a/ydb/core/tablet_flat/flat_executor_ut.cpp +++ b/ydb/core/tablet_flat/flat_executor_ut.cpp @@ -5453,12 +5453,13 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) { } }; - Y_UNIT_TEST(UseBtreeIndex_Default) { + Y_UNIT_TEST(EnableLocalDBBtreeIndex_Default) { // uses flat index TMyEnvBase env; TRowsModel rows; auto &appData = env->GetAppData(); UNIT_ASSERT_VALUES_EQUAL(appData.FeatureFlags.HasEnableLocalDBBtreeIndex(), false); + UNIT_ASSERT_VALUES_EQUAL(appData.FeatureFlags.HasEnableLocalDBFlatIndex(), false); auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters()); int readRows = 0, failedAttempts = 0; @@ -5491,7 +5492,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) { UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 288); } - Y_UNIT_TEST(UseBtreeIndex_True) { + Y_UNIT_TEST(EnableLocalDBBtreeIndex_True) { // uses b-tree index TMyEnvBase env; TRowsModel rows; @@ -5529,7 +5530,85 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) { UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 332); } - Y_UNIT_TEST(UseBtreeIndex_True_TurnOff) { + Y_UNIT_TEST(EnableLocalDBBtreeIndex_True_EnableLocalDBFlatIndex_False) { // uses b-tree index + TMyEnvBase env; + TRowsModel rows; + + auto &appData = env->GetAppData(); + appData.FeatureFlags.SetEnableLocalDBBtreeIndex(true); + appData.FeatureFlags.SetEnableLocalDBFlatIndex(false); + auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters()); + int readRows = 0, failedAttempts = 0; + + env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); + + auto policy = MakeIntrusive<TCompactionPolicy>(); + policy->MinBTreeIndexNodeSize = 128; + env.SendSync(rows.MakeScheme(std::move(policy))); + + env.SendSync(rows.VersionTo(TRowVersion(1, 10)).RowTo(0).MakeRows(1000, 950)); + env.SendSync(rows.VersionTo(TRowVersion(2, 20)).RowTo(0).MakeRows(1000, 950)); + + env.SendSync(new NFake::TEvCompact(TRowsModel::TableId)); + env.WaitFor<NFake::TEvCompacted>(); + + // all pages are always kept in shared cache + UNIT_ASSERT_VALUES_EQUAL(counters->ActivePages->Val(), 334); + + env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) }); + UNIT_ASSERT_VALUES_EQUAL(readRows, 1000); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 0); + + // restart tablet + env.SendSync(new TEvents::TEvPoison, false, true); + env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); + + // after restart we have no pages in private cache + env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) }, true); + UNIT_ASSERT_VALUES_EQUAL(readRows, 1000); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 332); + } + + Y_UNIT_TEST(EnableLocalDBBtreeIndex_False_EnableLocalDBFlatIndex_False) { // uses flat index + TMyEnvBase env; + TRowsModel rows; + + auto &appData = env->GetAppData(); + appData.FeatureFlags.SetEnableLocalDBBtreeIndex(false); + appData.FeatureFlags.SetEnableLocalDBFlatIndex(false); + auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters()); + int readRows = 0, failedAttempts = 0; + + env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); + + auto policy = MakeIntrusive<TCompactionPolicy>(); + policy->MinBTreeIndexNodeSize = 128; + env.SendSync(rows.MakeScheme(std::move(policy))); + + env.SendSync(rows.VersionTo(TRowVersion(1, 10)).RowTo(0).MakeRows(1000, 950)); + env.SendSync(rows.VersionTo(TRowVersion(2, 20)).RowTo(0).MakeRows(1000, 950)); + + env.SendSync(new NFake::TEvCompact(TRowsModel::TableId)); + env.WaitFor<NFake::TEvCompacted>(); + + // all pages are always kept in shared cache + UNIT_ASSERT_VALUES_EQUAL(counters->ActivePages->Val(), 290); + + env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) }); + UNIT_ASSERT_VALUES_EQUAL(readRows, 1000); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 0); + + // restart tablet + env.SendSync(new TEvents::TEvPoison, false, true); + env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); + + // after restart we have no pages in private cache + env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) }, true); + UNIT_ASSERT_VALUES_EQUAL(readRows, 1000); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 288); + } + + Y_UNIT_TEST(EnableLocalDBBtreeIndex_True_TurnOff) { // uses b-tree index at first TMyEnvBase env; TRowsModel rows; @@ -5569,7 +5648,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) { UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 288); } - Y_UNIT_TEST(UseBtreeIndex_True_Generations) { + Y_UNIT_TEST(EnableLocalDBBtreeIndex_True_Generations) { // uses b-tree index TMyEnvBase env; TRowsModel rows; diff --git a/ydb/core/tablet_flat/flat_page_conf.h b/ydb/core/tablet_flat/flat_page_conf.h index eb03ae558f7..3b37d2ab8ff 100644 --- a/ydb/core/tablet_flat/flat_page_conf.h +++ b/ydb/core/tablet_flat/flat_page_conf.h @@ -84,6 +84,7 @@ namespace NPage { bool Final = true; bool CutIndexKeys = true; bool WriteBTreeIndex = false; + bool WriteFlatIndex = true; ui32 MaxLargeBlob = 8 * 1024 * 1024 - 8; /* Maximum large blob size */ ui32 LargeEdge = Max<ui32>(); /* External blob edge size */ ui32 SmallEdge = Max<ui32>(); /* Outer blobs edge bytes limit */ diff --git a/ydb/core/tablet_flat/flat_part_btree_index_iter.h b/ydb/core/tablet_flat/flat_part_btree_index_iter.h index 656c06d2960..40bb92aa206 100644 --- a/ydb/core/tablet_flat/flat_part_btree_index_iter.h +++ b/ydb/core/tablet_flat/flat_part_btree_index_iter.h @@ -113,8 +113,8 @@ public: : Part(part) , Env(env) , GroupId(groupId) - , GroupInfo(part->Scheme->GetLayout(groupId)) - , Meta(groupId.IsHistoric() ? part->IndexPages.BTreeHistoric[groupId.Index] : part->IndexPages.BTreeGroups[groupId.Index]) + , GroupInfo(Part->Scheme->GetLayout(GroupId)) + , Meta(Part->IndexPages.GetBTree(GroupId)) , State(Reserve(Meta.LevelCount + 1)) { const static TCellsIterable EmptyKey(static_cast<const char*>(nullptr), TColumns()); diff --git a/ydb/core/tablet_flat/flat_part_charge_btree_index.h b/ydb/core/tablet_flat/flat_part_charge_btree_index.h index 4207f85f69f..fb9356c53ff 100644 --- a/ydb/core/tablet_flat/flat_part_charge_btree_index.h +++ b/ydb/core/tablet_flat/flat_part_charge_btree_index.h @@ -71,7 +71,7 @@ public: bool ready = true, overshot = true, hasValidRowsRange = Groups || IncludeHistory; const TRowId sliceBeginRowId = beginRowId, sliceEndRowId = endRowId; - const auto& meta = Part->IndexPages.BTreeGroups[0]; + const auto& meta = Part->IndexPages.GetBTree({}); Y_ABORT_UNLESS(beginRowId < endRowId); Y_ABORT_UNLESS(endRowId <= meta.RowCount); @@ -221,7 +221,7 @@ public: bool ready = true, overshot = true, hasValidRowsRange = Groups || IncludeHistory; const TRowId sliceBeginRowId = beginRowId, sliceEndRowId = endRowId; - const auto& meta = Part->IndexPages.BTreeGroups[0]; + const auto& meta = Part->IndexPages.GetBTree({}); Y_ABORT_UNLESS(beginRowId < endRowId); Y_ABORT_UNLESS(endRowId <= meta.RowCount); @@ -444,7 +444,7 @@ private: private: bool DoGroup(TGroupId groupId, TRowId beginRowId, TRowId endRowId, TRowId firstChildBeginRowId, ui64 bytesLimit) const noexcept { bool ready = true; - const auto& meta = groupId.IsHistoric() ? Part->IndexPages.BTreeHistoric[groupId.Index] : Part->IndexPages.BTreeGroups[groupId.Index]; + const auto& meta = Part->IndexPages.GetBTree(groupId); TVector<TNodeState> level, nextLevel(::Reserve(3)); ui64 firstChildPrevBytes = bytesLimit ? GetPrevBytes(meta, firstChildBeginRowId) : 0; @@ -500,7 +500,7 @@ private: bool DoGroupReverse(TGroupId groupId, TRowId beginRowId, TRowId endRowId, TRowId lastChildEndRowId, ui64 bytesLimit) const noexcept { bool ready = true; - const auto& meta = groupId.IsHistoric() ? Part->IndexPages.BTreeHistoric[groupId.Index] : Part->IndexPages.BTreeGroups[groupId.Index]; + const auto& meta = Part->IndexPages.GetBTree(groupId); // level's nodes is in reverse order TVector<TNodeState> level, nextLevel(::Reserve(3)); @@ -584,7 +584,7 @@ private: const TKeyCellDefaults* keyDefaults = Part->Scheme->HistoryKeys.Get(); const TGroupId groupId(0, true); - const auto& meta = Part->IndexPages.BTreeHistoric[0]; + const auto& meta = Part->IndexPages.GetBTree(TGroupId{0, true}); TRowId beginRowId = 0, endRowId = meta.RowCount; TVector<TNodeState> level, nextLevel(::Reserve(3)); diff --git a/ydb/core/tablet_flat/flat_part_charge_create.cpp b/ydb/core/tablet_flat/flat_part_charge_create.cpp index 30b9a525475..f10010deb62 100644 --- a/ydb/core/tablet_flat/flat_part_charge_create.cpp +++ b/ydb/core/tablet_flat/flat_part_charge_create.cpp @@ -5,7 +5,7 @@ namespace NKikimr::NTable { THolder<ICharge> CreateCharge(IPages *env, const TPart &part, TTagsRef tags, bool includeHistory) { - if (part.IndexPages.BTreeGroups) { + if (part.IndexPages.HasBTree()) { return MakeHolder<TChargeBTreeIndex>(env, part, tags, includeHistory); } else { return MakeHolder<TCharge>(env, part, tags, includeHistory); diff --git a/ydb/core/tablet_flat/flat_part_dump.cpp b/ydb/core/tablet_flat/flat_part_dump.cpp index f338d251f91..619e17526f9 100644 --- a/ydb/core/tablet_flat/flat_part_dump.cpp +++ b/ydb/core/tablet_flat/flat_part_dump.cpp @@ -99,13 +99,13 @@ namespace { void TDump::Index(const TPart &part, ui32 depth) noexcept { - if (!part.IndexPages.Groups) { + if (!part.IndexPages.HasFlat()) { return; } TVector<TCell> key(Reserve(part.Scheme->Groups[0].KeyTypes.size())); - auto indexPageId = part.IndexPages.Groups[0]; + auto indexPageId = part.IndexPages.GetFlat({}); auto indexPage = Env->TryGetPage(&part, indexPageId); if (!indexPage) { @@ -172,8 +172,8 @@ namespace { void TDump::BTreeIndex(const TPart &part) noexcept { - if (part.IndexPages.BTreeGroups) { - auto meta = part.IndexPages.BTreeGroups.front(); + if (part.IndexPages.HasBTree()) { + auto meta = part.IndexPages.GetBTree({}); if (meta.LevelCount) { BTreeIndexNode(part, meta); } else { diff --git a/ydb/core/tablet_flat/flat_part_index_iter.h b/ydb/core/tablet_flat/flat_part_index_iter.h index e2d43a5419e..2cf880e262d 100644 --- a/ydb/core/tablet_flat/flat_part_index_iter.h +++ b/ydb/core/tablet_flat/flat_part_index_iter.h @@ -171,7 +171,7 @@ private: if (Index) { return &*Index; } - auto pageId = GroupId.IsHistoric() ? Part->IndexPages.Historic[GroupId.Index] : Part->IndexPages.Groups[GroupId.Index]; + auto pageId = Part->IndexPages.GetFlat(GroupId); auto page = Env->TryGetPage(Part, pageId); if (page) { Index = TIndex(*page); diff --git a/ydb/core/tablet_flat/flat_part_index_iter_create.cpp b/ydb/core/tablet_flat/flat_part_index_iter_create.cpp index 65a19e10666..a0f73299d51 100644 --- a/ydb/core/tablet_flat/flat_part_index_iter_create.cpp +++ b/ydb/core/tablet_flat/flat_part_index_iter_create.cpp @@ -5,7 +5,7 @@ namespace NKikimr::NTable { THolder<IIndexIter> CreateIndexIter(const TPart* part, IPages* env, NPage::TGroupId groupId) { - if (groupId.Index < (groupId.IsHistoric() ? part->IndexPages.BTreeHistoric : part->IndexPages.BTreeGroups).size()) { + if (part->IndexPages.HasBTree()) { return MakeHolder<TPartBtreeIndexIt>(part, env, groupId); } else { return MakeHolder<TPartIndexIt>(part, env, groupId); diff --git a/ydb/core/tablet_flat/flat_part_loader.cpp b/ydb/core/tablet_flat/flat_part_loader.cpp index 294e2be3151..dca805a4a70 100644 --- a/ydb/core/tablet_flat/flat_part_loader.cpp +++ b/ydb/core/tablet_flat/flat_part_loader.cpp @@ -58,7 +58,6 @@ void TLoader::StageParseMeta() noexcept const auto &layout = Root.GetLayout(); SchemeId = layout.HasScheme() ? layout.GetScheme() : SchemeId; - IndexId = layout.HasIndex() ? layout.GetIndex() : IndexId; GlobsId = layout.HasGlobs() ? layout.GetGlobs() : GlobsId; LargeId = layout.HasLarge() ? layout.GetLarge() : LargeId; SmallId = layout.HasSmall() ? layout.GetSmall() : SmallId; @@ -66,33 +65,42 @@ void TLoader::StageParseMeta() noexcept GarbageStatsId = layout.HasGarbageStats() ? layout.GetGarbageStats() : GarbageStatsId; TxIdStatsId = layout.HasTxIdStats() ? layout.GetTxIdStats() : TxIdStatsId; - GroupIndexesIds.clear(); + FlatGroupIndexes.clear(); + FlatHistoricIndexes.clear(); + if (layout.HasIndex() && layout.GetIndex() != Max<TPageId>()) { + FlatGroupIndexes.push_back(layout.GetIndex()); + } for (ui32 id : layout.GetGroupIndexes()) { - GroupIndexesIds.push_back(id); + FlatGroupIndexes.push_back(id); } - - HistoricIndexesIds.clear(); for (ui32 id : layout.GetHistoricIndexes()) { - HistoricIndexesIds.push_back(id); + FlatHistoricIndexes.push_back(id); } BTreeGroupIndexes.clear(); BTreeHistoricIndexes.clear(); - if (AppData()->FeatureFlags.GetEnableLocalDBBtreeIndex()) { - for (bool history : {false, true}) { - for (const auto &meta : history ? layout.GetBTreeHistoricIndexes() : layout.GetBTreeGroupIndexes()) { - NPage::TBtreeIndexMeta converted{{ - meta.GetRootPageId(), - meta.GetRowCount(), - meta.GetDataSize(), - meta.GetErasedRowCount()}, - meta.GetLevelCount(), - meta.GetIndexSize()}; - (history ? BTreeHistoricIndexes : BTreeGroupIndexes).push_back(converted); - } + for (bool history : {false, true}) { + for (const auto &meta : history ? layout.GetBTreeHistoricIndexes() : layout.GetBTreeGroupIndexes()) { + NPage::TBtreeIndexMeta converted{{ + meta.GetRootPageId(), + meta.GetRowCount(), + meta.GetDataSize(), + meta.GetErasedRowCount()}, + meta.GetLevelCount(), + meta.GetIndexSize()}; + (history ? BTreeHistoricIndexes : BTreeGroupIndexes).push_back(converted); } } + if (!AppData()->FeatureFlags.GetEnableLocalDBBtreeIndex() && FlatGroupIndexes) { + BTreeGroupIndexes.clear(); + BTreeHistoricIndexes.clear(); + } + if (!AppData()->FeatureFlags.GetEnableLocalDBFlatIndex() && BTreeGroupIndexes) { + FlatGroupIndexes.clear(); + FlatHistoricIndexes.clear(); + } + } else { /* legacy page collection w/o layout data, (Evolution < 14) */ do { pageId--; @@ -100,7 +108,7 @@ void TLoader::StageParseMeta() noexcept switch (type) { case EPage::Scheme: SchemeId = pageId; break; - case EPage::Index: IndexId = pageId; break; + case EPage::Index: FlatGroupIndexes = {pageId}; break; /* All special pages have to be placed after the index page, hack is required for legacy page collections without topology data in metablob. @@ -122,12 +130,14 @@ void TLoader::StageParseMeta() noexcept if (!HasBasics() || (Rooted && SchemeId != meta.TotalPages() - 1) || (LargeId == Max<TPageId>()) != (GlobsId == Max<TPageId>()) - || (1 + GroupIndexesIds.size() + (SmallId == Max<TPageId>() ? 0 : 1)) != Packs.size()) + || (Max(BTreeGroupIndexes.size(), FlatGroupIndexes.size()) + (SmallId == Max<TPageId>() ? 0 : 1)) != Packs.size()) { Y_Fail("Part " << Packs[0]->PageCollection->Label() << " has" << " invalid layout : " << (Rooted ? "rooted" : "legacy") << " " << Packs.size() << "s " << meta.TotalPages() << "pg" - << ", Scheme " << SchemeId << ", Index " << IndexId + << ", Scheme " << SchemeId + << ", FlatIndex " << (FlatGroupIndexes.size() ? FlatGroupIndexes[0] : Max<TPageId>()) + << ", BTreeIndex " << (BTreeGroupIndexes.size() ? BTreeGroupIndexes[0].PageId : Max<TPageId>()) << ", Blobs " << GlobsId << ", Small " << SmallId << ", Large " << LargeId << ", ByKey " << ByKeyId << ", Garbage " << GarbageStatsId @@ -164,7 +174,7 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept Y_ABORT("Scheme page is not loaded"); } else if (ByKeyId != Max<TPageId>() && !byKey) { Y_ABORT("Filter page must be loaded if it exists"); - } else if (small && Packs.size() != (1 + GroupIndexesIds.size() + 1)) { + } else if (small && Packs.size() != (1 + Max(BTreeGroupIndexes.size(), FlatGroupIndexes.size()))) { Y_Fail("TPart has small blobs, " << Packs.size() << " page collections"); } @@ -175,12 +185,6 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept // Use epoch from metadata unless it has been provided to loader externally TEpoch epoch = Epoch != TEpoch::Max() ? Epoch : TEpoch(Root.GetEpoch()); - TVector<TPageId> groupIndexesIds(Reserve(GroupIndexesIds.size() + 1)); - groupIndexesIds.push_back(IndexId); - for (auto pageId : GroupIndexesIds) { - groupIndexesIds.push_back(pageId); - } - // TODO: put index size to stat? // TODO: include history indexes bytes size_t indexesRawSize = 0; @@ -190,7 +194,7 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept } // Note: although we also have flat index, it shouldn't be loaded; so let's not count it here } else { - for (auto indexPage : groupIndexesIds) { + for (auto indexPage : FlatGroupIndexes) { indexesRawSize += GetPageSize(indexPage); } } @@ -200,7 +204,7 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept { epoch, TPartScheme::Parse(*scheme, Rooted), - { std::move(groupIndexesIds), HistoricIndexesIds, BTreeGroupIndexes, BTreeHistoricIndexes }, + { FlatGroupIndexes, FlatHistoricIndexes, BTreeGroupIndexes, BTreeHistoricIndexes }, blobs ? new NPage::TExtBlobs(*blobs, extra) : nullptr, byKey ? new NPage::TBloom(*byKey) : nullptr, large ? new NPage::TFrames(*large) : nullptr, diff --git a/ydb/core/tablet_flat/flat_part_loader.h b/ydb/core/tablet_flat/flat_part_loader.h index 8eef08d3c98..5f549fcf31c 100644 --- a/ydb/core/tablet_flat/flat_part_loader.h +++ b/ydb/core/tablet_flat/flat_part_loader.h @@ -4,7 +4,6 @@ #include "flat_sausagecache.h" #include "shared_cache_events.h" #include "util_fmt_abort.h" -#include "util_basics.h" #include <ydb/core/tablet_flat/protos/flat_table_part.pb.h> #include <ydb/core/util/pb.h> #include <util/generic/hash.h> @@ -137,7 +136,8 @@ namespace NTable { private: bool HasBasics() const noexcept { - return SchemeId != Max<TPageId>() && IndexId != Max<TPageId>(); + return SchemeId != Max<TPageId>() && + (FlatGroupIndexes || BTreeGroupIndexes); } const TSharedData* GetPage(TPageId page) noexcept @@ -172,15 +172,14 @@ namespace NTable { EStage Stage = EStage::Meta; bool Rooted = false; /* Has full topology metablob */ TPageId SchemeId = Max<TPageId>(); - TPageId IndexId = Max<TPageId>(); TPageId GlobsId = Max<TPageId>(); TPageId LargeId = Max<TPageId>(); TPageId SmallId = Max<TPageId>(); TPageId ByKeyId = Max<TPageId>(); TPageId GarbageStatsId = Max<TPageId>(); TPageId TxIdStatsId = Max<TPageId>(); - TVector<TPageId> GroupIndexesIds; - TVector<TPageId> HistoricIndexesIds; + TVector<TPageId> FlatGroupIndexes; + TVector<TPageId> FlatHistoricIndexes; TVector<NPage::TBtreeIndexMeta> BTreeGroupIndexes; TVector<NPage::TBtreeIndexMeta> BTreeHistoricIndexes; TRowVersion MinRowVersion; diff --git a/ydb/core/tablet_flat/flat_part_writer.h b/ydb/core/tablet_flat/flat_part_writer.h index 572f1e8d54f..4c7b9e22683 100644 --- a/ydb/core/tablet_flat/flat_part_writer.h +++ b/ydb/core/tablet_flat/flat_part_writer.h @@ -5,18 +5,15 @@ #include "flat_page_conf.h" #include "flat_page_gstat.h" #include "flat_page_txidstat.h" -#include "flat_page_txstatus.h" #include "flat_page_writer.h" #include "flat_page_other.h" #include "flat_part_iface.h" #include "flat_part_overlay.h" -#include "flat_part_screen.h" #include "flat_part_slice.h" #include "flat_part_laid.h" #include "flat_row_state.h" #include "flat_bloom_writer.h" #include "util_fmt_abort.h" -#include "util_deref.h" #include <ydb/core/tablet_flat/protos/flat_table_part.pb.h> #include <ydb/core/util/intrusive_heap.h> @@ -43,6 +40,7 @@ namespace NTable { : Final(conf.Final) , CutIndexKeys(conf.CutIndexKeys) , WriteBTreeIndex(conf.WriteBTreeIndex) + , WriteFlatIndex(conf.WriteFlatIndex || !conf.WriteBTreeIndex) , SmallEdge(conf.SmallEdge) , LargeEdge(conf.LargeEdge) , MaxLargeBlob(conf.MaxLargeBlob) @@ -189,7 +187,7 @@ namespace NTable { // N.B. non-main groups have no key TCellsRef groupKey = groupIdx == 0 ? KeyState.Key : TCellsRef{ }; g.NextDataSize = g.Data.CalcSize(groupKey, row, KeyState.Final, TRowVersion::Min(), TRowVersion::Max(), txId); - g.NextIndexSize = g.Index.CalcSize(groupKey); + g.NextIndexSize = WriteFlatIndex ? g.Index.CalcSize(groupKey) : 0; g.NextBTreeIndexSize = WriteBTreeIndex ? g.BTreeIndex.CalcSize(groupKey) : 0; overheadBytes += ( g.NextDataSize.DataPageSize + @@ -255,7 +253,7 @@ namespace NTable { // N.B. non-main groups have no key TCellsRef groupKey = groupIdx == 0 ? KeyState.Key : TCellsRef{ }; g.NextDataSize = g.Data.CalcSize(groupKey, row, KeyState.Final, minVersion, maxVersion, /* txId */ 0); - g.NextIndexSize = g.Index.CalcSize(groupKey); + g.NextIndexSize = WriteFlatIndex ? g.Index.CalcSize(groupKey) : 0; g.NextBTreeIndexSize = WriteBTreeIndex ? g.BTreeIndex.CalcSize(groupKey) : 0; // FIXME: not each row produces index row so overhead bytes shouldn't add index size @@ -368,7 +366,7 @@ namespace NTable { // N.B. non-main groups have no key TCellsRef groupKey = groupIdx == 0 ? syntheticKey : TCellsRef{ }; g.NextDataSize = g.Data.CalcSize(groupKey, row, KeyState.Final, TRowVersion::Min(), maxVersion, /* txId */ 0); - g.NextIndexSize = g.Index.CalcSize(groupKey); + g.NextIndexSize = WriteFlatIndex ? g.Index.CalcSize(groupKey) : 0; g.NextBTreeIndexSize = WriteBTreeIndex ? g.BTreeIndex.CalcSize(groupKey) : 0; // FIXME: not each row produces index row so overhead bytes shouldn't add index size @@ -442,7 +440,9 @@ namespace NTable { ui32 smallRefs = 0; ui32 largeRefs = 0; for (auto& g : Groups) { - indexSize += g.Index.BytesUsed() + g.FirstKeyIndexSize; + if (WriteFlatIndex) { + indexSize += g.Index.BytesUsed() + g.FirstKeyIndexSize; + } if (WriteBTreeIndex) { indexSize += g.BTreeIndex.EstimateBytesUsed() + g.FirstKeyBTreeIndexSize; } @@ -506,24 +506,27 @@ namespace NTable { WriteStats.HiddenRows += Current.HiddenRows; WriteStats.HiddenDrops += Current.HiddenDrops; - if (Current.HistoryWritten > 0) { - Current.HistoricIndexes.clear(); - Current.HistoricIndexes.reserve(Histories.size()); - for (auto& g : Histories) { - Current.HistoricIndexes.push_back(WritePage(g.Index.Flush(), EPage::Index)); + Current.HistoricIndexes.clear(); + Current.GroupIndexes.clear(); + Current.Index = Max<TPageId>(); + if (WriteFlatIndex) { + if (Current.HistoryWritten > 0) { + Current.HistoricIndexes.reserve(Histories.size()); + for (auto& g : Histories) { + Current.HistoricIndexes.push_back(WritePage(g.Index.Flush(), EPage::Index)); + } } - } - if (Groups.size() > 1) { - Current.GroupIndexes.clear(); - Current.GroupIndexes.reserve(Groups.size() - 1); - for (ui32 group : xrange(ui32(1), ui32(Groups.size()))) { - Current.GroupIndexes.push_back(WritePage(Groups[group].Index.Flush(), EPage::Index)); + if (Groups.size() > 1) { + Current.GroupIndexes.reserve(Groups.size() - 1); + for (ui32 group : xrange(ui32(1), ui32(Groups.size()))) { + Current.GroupIndexes.push_back(WritePage(Groups[group].Index.Flush(), EPage::Index)); + } } - } - - Current.Index = WritePage(Groups[0].Index.Flush(), EPage::Index); + Current.Index = WritePage(Groups[0].Index.Flush(), EPage::Index); + } + Current.BTreeGroupIndexes.clear(); Current.BTreeHistoricIndexes.clear(); if (WriteBTreeIndex) { @@ -618,7 +621,7 @@ namespace NTable { if (!last || WriteStats.Parts > 0) head = Max(head, ui32(20) /* Multiple part outputs */); - if (!Current.GroupIndexes.empty()) + if (!Current.GroupIndexes.empty() || Current.BTreeGroupIndexes.size() > 1) head = Max(head, ui32(26) /* Multiple column groups */); if (Current.Versioned) @@ -644,8 +647,9 @@ namespace NTable { if (auto *lay = proto.MutableLayout()) { lay->SetScheme(Current.Scheme); - lay->SetIndex(Current.Index); + if (Current.Index != Max<TPageId>()) + lay->SetIndex(Current.Index); if (Current.Globs != Max<TPageId>()) lay->SetGlobs(Current.Globs); if (Current.Large != Max<TPageId>()) @@ -751,7 +755,7 @@ namespace NTable { */ Y_ABORT_UNLESS(dataPage->Count, "Invalid EPage::DataPage blob"); - TPgSize keySize = g.FirstKeyIndexSize; + TPgSize flatKeyIndexSize = g.FirstKeyIndexSize; if (groupId.IsMain()) { Y_DEBUG_ABORT_UNLESS(NextSliceFirstRowId != Max<TRowId>()); @@ -760,7 +764,7 @@ namespace NTable { if (CutIndexKeys) { CutKey(groupId); - keySize = g.Index.CalcSize(Key); + flatKeyIndexSize = WriteFlatIndex ? g.Index.CalcSize(Key) : 0; } } else if (groupId.Index == 0) { InitKey(Key, dataPage->Record(0), groupId); @@ -777,7 +781,7 @@ namespace NTable { Current.Bytes += raw.size(); /* before encoding */ if (g.Codec == NPage::ECodec::Plain) { - /* Ecoding was not enabled, keep as is */ + /* Encoding was not enabled, keep as is */ } else if (keep = Encode(raw, g.Codec, g.ForceCompression)) { std::swap(raw, keep); } @@ -786,10 +790,12 @@ namespace NTable { auto page = WritePage(raw, EPage::DataPage, groupId.Index); - // N.B. non-main groups have no key - Y_DEBUG_ABORT_UNLESS(g.Index.CalcSize(Key) == keySize); + if (WriteFlatIndex) { + // N.B. non-main groups have no key + Y_DEBUG_ABORT_UNLESS(g.Index.CalcSize(Key) == flatKeyIndexSize); - g.Index.Add(keySize, Key, dataPage.BaseRow(), page); + g.Index.Add(flatKeyIndexSize, Key, dataPage.BaseRow(), page); + } if (WriteBTreeIndex) { if (dataPage.BaseRow()) { @@ -815,8 +821,10 @@ namespace NTable { SaveSlice(lastRowId, TSerializedCellVec(Key)); if (Phase == 1) { - Y_DEBUG_ABORT_UNLESS(g.Index.CalcSize(Key) == g.LastKeyIndexSize); - g.Index.Add(g.LastKeyIndexSize, Key, lastRowId, page); + if (WriteFlatIndex) { + Y_DEBUG_ABORT_UNLESS(g.Index.CalcSize(Key) == g.LastKeyIndexSize); + g.Index.Add(g.LastKeyIndexSize, Key, lastRowId, page); + } Y_ABORT_UNLESS(std::exchange(Phase, 2) == 1); PrevPageLastKey.clear(); // new index will be started PrevPageData = { }; @@ -1024,6 +1032,7 @@ namespace NTable { const bool Final = false; const bool CutIndexKeys; const bool WriteBTreeIndex; + const bool WriteFlatIndex; const ui32 SmallEdge; const ui32 LargeEdge; const ui32 MaxLargeBlob; diff --git a/ydb/core/tablet_flat/flat_table_part.h b/ydb/core/tablet_flat/flat_table_part.h index 6ba390d99af..770f8d47177 100644 --- a/ydb/core/tablet_flat/flat_table_part.h +++ b/ydb/core/tablet_flat/flat_table_part.h @@ -49,11 +49,28 @@ namespace NTable { struct TIndexPages { using TPageId = NPage::TPageId; + using TGroupId = NPage::TGroupId; using TBtreeIndexMeta = NPage::TBtreeIndexMeta; - const TVector<TPageId> Groups; - const TVector<TPageId> Historic; + const TVector<TPageId> FlatGroups; + const TVector<TPageId> FlatHistoric; const TVector<TBtreeIndexMeta> BTreeGroups; const TVector<TBtreeIndexMeta> BTreeHistoric; + + bool HasBTree() const noexcept { + return !BTreeGroups.empty(); + } + + bool HasFlat() const noexcept { + return !FlatGroups.empty(); + } + + const TBtreeIndexMeta& GetBTree(TGroupId groupId) const noexcept { + return groupId.IsHistoric() ? BTreeHistoric[groupId.Index] : BTreeGroups[groupId.Index]; + } + + TPageId GetFlat(TGroupId groupId) const noexcept { + return groupId.IsHistoric() ? FlatHistoric[groupId.Index] : FlatGroups[groupId.Index]; + } }; struct TParams { @@ -92,8 +109,8 @@ namespace NTable { , GarbageStats(std::move(params.GarbageStats)) , TxIdStats(std::move(params.TxIdStats)) , Stat(stat) - , GroupsCount(IndexPages.Groups.size()) - , HistoricGroupsCount(IndexPages.Historic.size()) + , GroupsCount(Max(IndexPages.FlatGroups.size(), IndexPages.BTreeGroups.size())) + , HistoricGroupsCount(Max(IndexPages.FlatHistoric.size(), IndexPages.BTreeHistoric.size())) , IndexesRawSize(params.IndexesRawSize) , MinRowVersion(params.MinRowVersion) , MaxRowVersion(params.MaxRowVersion) diff --git a/ydb/core/tablet_flat/ut/ut_charge.cpp b/ydb/core/tablet_flat/ut/ut_charge.cpp index 76f9ccf1648..28d1648d8c1 100644 --- a/ydb/core/tablet_flat/ut/ut_charge.cpp +++ b/ydb/core/tablet_flat/ut/ut_charge.cpp @@ -322,10 +322,10 @@ namespace { auto &pages = Eggs.Lone()->IndexPages; TGroupId mainGroupId{}; - for (auto x : pages.Groups) { + for (auto x : pages.FlatGroups) { result.insert({mainGroupId, x}); } - for (auto x : pages.Historic) { + for (auto x : pages.FlatHistoric) { result.insert({mainGroupId, x}); } @@ -988,17 +988,17 @@ Y_UNIT_TEST_SUITE(Charge) { // no index => touch index me.To(100).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {pages.Groups[0]}}, + {TGroupId{0}, {pages.FlatGroups[0]}}, }, TSet<TPageId> { }); // index => touch pages + index me.To(101).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0]}} + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0]}} }, TSet<TPageId> { - pages.Groups[0] + pages.FlatGroups[0] }); } @@ -1008,7 +1008,7 @@ Y_UNIT_TEST_SUITE(Charge) { // no index => touch index me.To(200).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {pages.Groups[0]}}, + {TGroupId{0}, {pages.FlatGroups[0]}}, {TGroupId{0, true}, {}} }, TSet<TPageId> { @@ -1016,20 +1016,20 @@ Y_UNIT_TEST_SUITE(Charge) { // no history index => touch main pages + index + history index me.To(201).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], pages.Historic[0]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], pages.FlatHistoric[0]}}, {TGroupId{0, true}, {}} }, TSet<TPageId> { - pages.Groups[0] + pages.FlatGroups[0] }); // history index => touch main pages + history pages + index + history index me.To(202).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], pages.Historic[0]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], pages.FlatHistoric[0]}}, {TGroupId{0, true}, {1, 2, 3, 4}} }, TSet<TPageId> { - pages.Groups[0], pages.Historic[0] + pages.FlatGroups[0], pages.FlatHistoric[0] }); } @@ -1039,7 +1039,7 @@ Y_UNIT_TEST_SUITE(Charge) { // no index => touch index me.To(300).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {pages.Groups[0]}}, + {TGroupId{0}, {pages.FlatGroups[0]}}, {TGroupId{1}, {}} }, TSet<TPageId> { @@ -1047,20 +1047,20 @@ Y_UNIT_TEST_SUITE(Charge) { // no groups index => touch main pages + index + all groups indexes me.To(301).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], pages.Groups[1], pages.Groups[2], pages.Groups[3]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], pages.FlatGroups[1], pages.FlatGroups[2], pages.FlatGroups[3]}}, {TGroupId{1}, {}} }, TSet<TPageId> { - pages.Groups[0] + pages.FlatGroups[0] }); // groups index => touch all pages + index + all groups indexes me.To(302).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], pages.Groups[1], pages.Groups[2], pages.Groups[3]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], pages.FlatGroups[1], pages.FlatGroups[2], pages.FlatGroups[3]}}, {TGroupId{1}, {3, 4, 5, 6, 7}} }, TSet<TPageId> { - pages.Groups[0], pages.Groups[1] + pages.FlatGroups[0], pages.FlatGroups[1] }); } @@ -1070,7 +1070,7 @@ Y_UNIT_TEST_SUITE(Charge) { // no index => touch index me.To(400).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {pages.Groups[0]}}, + {TGroupId{0}, {pages.FlatGroups[0]}}, {TGroupId{0, true}, {}}, {TGroupId{1}, {}}, {TGroupId{1, true}, {}}, @@ -1082,7 +1082,7 @@ Y_UNIT_TEST_SUITE(Charge) { // only index => touch main pages + index + all groups indexes + history index me.To(401).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], pages.Historic[0], pages.Groups[1], pages.Groups[2], pages.Groups[3]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], pages.FlatHistoric[0], pages.FlatGroups[1], pages.FlatGroups[2], pages.FlatGroups[3]}}, {TGroupId{0, true}, {}}, {TGroupId{1}, {}}, {TGroupId{1, true}, {}}, @@ -1090,13 +1090,13 @@ Y_UNIT_TEST_SUITE(Charge) { {TGroupId{2, true}, {}} }, TSet<TPageId> { - pages.Groups[0] + pages.FlatGroups[0] }); // history index => touch main pages + index + all groups indexes + main history pages me.To(402).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], - pages.Historic[0], pages.Historic[1], pages.Historic[2], pages.Historic[3], pages.Groups[1], pages.Groups[2], pages.Groups[3]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], + pages.FlatHistoric[0], pages.FlatHistoric[1], pages.FlatHistoric[2], pages.FlatHistoric[3], pages.FlatGroups[1], pages.FlatGroups[2], pages.FlatGroups[3]}}, {TGroupId{0, true}, {1, 2, 3, 4}}, {TGroupId{1}, {}}, {TGroupId{1, true}, {}}, @@ -1104,13 +1104,13 @@ Y_UNIT_TEST_SUITE(Charge) { {TGroupId{2, true}, {}} }, TSet<TPageId> { - pages.Groups[0], pages.Historic[0] + pages.FlatGroups[0], pages.FlatHistoric[0] }); // main history and history => touch main pages + index + all groups indexes + history pages + history groups pages me.To(403).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], - pages.Historic[0], pages.Historic[1], pages.Historic[2], pages.Historic[3], pages.Groups[1], pages.Groups[2], pages.Groups[3]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], + pages.FlatHistoric[0], pages.FlatHistoric[1], pages.FlatHistoric[2], pages.FlatHistoric[3], pages.FlatGroups[1], pages.FlatGroups[2], pages.FlatGroups[3]}}, {TGroupId{0, true}, {1, 2, 3, 4}}, {TGroupId{1}, {}}, {TGroupId{1, true}, {3, 4, 5}}, @@ -1118,13 +1118,13 @@ Y_UNIT_TEST_SUITE(Charge) { {TGroupId{2, true}, {}} }, TSet<TPageId> { - pages.Groups[0], pages.Historic[0], pages.Historic[1] + pages.FlatGroups[0], pages.FlatHistoric[0], pages.FlatHistoric[1] }); // groups index => touch main pages + index + history index + all groups indexes + groups pages me.To(404).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], - pages.Historic[0], pages.Groups[1], pages.Groups[2], pages.Groups[3]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], + pages.FlatHistoric[0], pages.FlatGroups[1], pages.FlatGroups[2], pages.FlatGroups[3]}}, {TGroupId{0, true}, {}}, {TGroupId{1}, {3, 4, 5, 6, 7}}, {TGroupId{1, true}, {}}, @@ -1132,13 +1132,13 @@ Y_UNIT_TEST_SUITE(Charge) { {TGroupId{2, true}, {}} }, TSet<TPageId> { - pages.Groups[0], pages.Groups[1] + pages.FlatGroups[0], pages.FlatGroups[1] }); // main history and groups => touch main pages + index + all groups indexes + groups pages + history main pages me.To(405).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], - pages.Historic[0], pages.Historic[1], pages.Historic[2], pages.Historic[3], pages.Groups[1], pages.Groups[2], pages.Groups[3]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], + pages.FlatHistoric[0], pages.FlatHistoric[1], pages.FlatHistoric[2], pages.FlatHistoric[3], pages.FlatGroups[1], pages.FlatGroups[2], pages.FlatGroups[3]}}, {TGroupId{0, true}, {1, 2, 3, 4}}, {TGroupId{1}, {3, 4, 5, 6, 7}}, {TGroupId{1, true}, {}}, @@ -1146,13 +1146,13 @@ Y_UNIT_TEST_SUITE(Charge) { {TGroupId{2, true}, {}} }, TSet<TPageId> { - pages.Groups[0], pages.Historic[0], pages.Groups[1] + pages.FlatGroups[0], pages.FlatHistoric[0], pages.FlatGroups[1] }); // all indexes me.To(406).CheckIndex(6, 22, 0, TMap<TGroupId, TArr>{ - {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.Groups[0], - pages.Historic[0], pages.Historic[1], pages.Historic[2], pages.Historic[3], pages.Groups[1], pages.Groups[2], pages.Groups[3]}}, + {TGroupId{0}, {1, 2, 3, 4, 5, 6, pages.FlatGroups[0], + pages.FlatHistoric[0], pages.FlatHistoric[1], pages.FlatHistoric[2], pages.FlatHistoric[3], pages.FlatGroups[1], pages.FlatGroups[2], pages.FlatGroups[3]}}, {TGroupId{0, true}, {1, 2, 3, 4}}, {TGroupId{1}, {3, 4, 5, 6, 7}}, {TGroupId{1, true}, {3, 4, 5}}, @@ -1160,7 +1160,7 @@ Y_UNIT_TEST_SUITE(Charge) { {TGroupId{2, true}, {}} }, TSet<TPageId> { - pages.Groups[0], pages.Historic[0], pages.Historic[1], pages.Groups[1] + pages.FlatGroups[0], pages.FlatHistoric[0], pages.FlatHistoric[1], pages.FlatGroups[1] }); } } diff --git a/ydb/core/tablet_flat/ut/ut_part.cpp b/ydb/core/tablet_flat/ut/ut_part.cpp index 51203cb2b0f..e62df79fc9e 100644 --- a/ydb/core/tablet_flat/ut/ut_part.cpp +++ b/ydb/core/tablet_flat/ut/ut_part.cpp @@ -402,7 +402,7 @@ Y_UNIT_TEST_SUITE(TPart) { /*_ Ensure that produced part has enough pages for code coverage and index grow algorithm in data pages writer has been triggered. */ - UNIT_ASSERT(pages > 100 && part.GetPageSize(part.IndexPages.Groups[0], { }) >= minIndex); + UNIT_ASSERT(pages > 100 && part.GetPageSize(part.IndexPages.GetFlat({}), { }) >= minIndex); { /*_ Ensure that part has some external blobs written to room 1 */ auto one = Eggs0().Lone()->Blobs->Total(); diff --git a/ydb/core/tablet_flat/ut_large/ut_btree_index_large.cpp b/ydb/core/tablet_flat/ut_large/ut_btree_index_large.cpp index 3af2bfb805a..c38cb94fe3d 100644 --- a/ydb/core/tablet_flat/ut_large/ut_btree_index_large.cpp +++ b/ydb/core/tablet_flat/ut_large/ut_btree_index_large.cpp @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPartLarge) { const auto part = eggs.Lone(); Cerr << "DataBytes = " << part->Stat.Bytes << " DataPages = " << IndexTools::CountMainPages(*part) << Endl; - Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.Groups[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[0].IndexSize << Endl; + Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.FlatGroups[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[0].IndexSize << Endl; UNIT_ASSERT_GE(part->Stat.Bytes, 1ull*1024*1024*1024); UNIT_ASSERT_LE(part->Stat.Bytes, 1ull*1024*1024*1024 + 100*1024*1024); @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPartLarge) { const auto part = eggs.Lone(); Cerr << "DataBytes = " << part->Stat.Bytes << " DataPages = " << IndexTools::CountMainPages(*part) << Endl; - Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.Groups[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[0].IndexSize << Endl; + Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.FlatGroups[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[0].IndexSize << Endl; UNIT_ASSERT_GE(part->Stat.Bytes, 1ull*1024*1024*1024); UNIT_ASSERT_LE(part->Stat.Bytes, 1ull*1024*1024*1024 + 100*1024*1024); @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPartLarge) { const auto part = eggs.Lone(); Cerr << "DataBytes = " << part->Stat.Bytes << " DataPages = " << IndexTools::CountMainPages(*part) << Endl; - Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.Groups[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[0].IndexSize << Endl; + Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.FlatGroups[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[0].IndexSize << Endl; UNIT_ASSERT_GE(part->Stat.Bytes, 1ull*1024*1024*1024); UNIT_ASSERT_LE(part->Stat.Bytes, 1ull*1024*1024*1024 + 100*1024*1024); @@ -126,7 +126,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPartLarge) { const auto part = eggs.Lone(); Cerr << "DataBytes = " << part->Stat.Bytes << " DataPages = " << IndexTools::CountMainPages(*part) << Endl; - Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.Groups[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[0].IndexSize << Endl; + Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.FlatGroups[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[0].IndexSize << Endl; UNIT_ASSERT_GE(part->Stat.Bytes, 1ull*1024*1024*1024); UNIT_ASSERT_LE(part->Stat.Bytes, 1ull*1024*1024*1024 + 100*1024*1024); @@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPartLarge) { const auto part = eggs.Lone(); Cerr << "DataBytes = " << part->Stat.Bytes << " DataPages = " << IndexTools::CountMainPages(*part) << Endl; - Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.Groups[1], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[1].IndexSize << Endl; + Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.FlatGroups[1], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[1].IndexSize << Endl; UNIT_ASSERT_GE(part->Stat.Bytes, 1ull*1024*1024*1024); UNIT_ASSERT_LE(part->Stat.Bytes, 1ull*1024*1024*1024 + 100*1024*1024); @@ -188,7 +188,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPartLarge) { const auto part = eggs.Lone(); Cerr << "DataBytes = " << part->Stat.Bytes << " DataPages = " << IndexTools::CountMainPages(*part) << Endl; - Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.Historic[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeHistoric[0].IndexSize << Endl; + Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.FlatHistoric[0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeHistoric[0].IndexSize << Endl; UNIT_ASSERT_GE(part->Stat.Bytes, 1ull*1024*1024*1024); UNIT_ASSERT_LE(part->Stat.Bytes, 1ull*1024*1024*1024 + 100*1024*1024); |
