summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ydb/core/tablet_flat/flat_page_btree_index.h15
-rw-r--r--ydb/core/tablet_flat/flat_page_btree_index_writer.h18
-rw-r--r--ydb/core/tablet_flat/flat_part_loader.cpp3
-rw-r--r--ydb/core/tablet_flat/flat_part_writer.h23
-rw-r--r--ydb/core/tablet_flat/protos/flat_table_part.proto3
-rw-r--r--ydb/core/tablet_flat/test/libs/table/test_part.h17
-rw-r--r--ydb/core/tablet_flat/test/libs/table/test_writer.h7
-rw-r--r--ydb/core/tablet_flat/ut/ut_btree_index_nodes.cpp104
-rw-r--r--ydb/core/tablet_flat/ut/ut_stat.cpp32
-rw-r--r--ydb/core/tablet_flat/ut_large/ut_btree_index_large.cpp2
10 files changed, 164 insertions, 60 deletions
diff --git a/ydb/core/tablet_flat/flat_page_btree_index.h b/ydb/core/tablet_flat/flat_page_btree_index.h
index 70f2681a3aa..8b674e89725 100644
--- a/ydb/core/tablet_flat/flat_page_btree_index.h
+++ b/ydb/core/tablet_flat/flat_page_btree_index.h
@@ -97,6 +97,7 @@ namespace NKikimr::NTable::NPage {
TPageId PageId;
TRowId RowCount;
ui64 DataSize;
+ ui64 GroupDataSize;
TRowId ErasedRowCount;
auto operator<=>(const TChild&) const = default;
@@ -106,11 +107,17 @@ namespace NKikimr::NTable::NPage {
}
TString ToString() const noexcept {
- return TStringBuilder() << "PageId: " << PageId << " RowCount: " << RowCount << " DataSize: " << DataSize << " ErasedRowCount: " << ErasedRowCount;
+ TStringBuilder result;
+ result << "PageId: " << PageId << " RowCount: " << RowCount << " DataSize: " << DataSize;
+ if (GroupDataSize) {
+ result << " GroupDataSize: " << GroupDataSize;
+ }
+ result << " ErasedRowCount: " << ErasedRowCount;
+ return result;
}
} Y_PACKED;
- static_assert(sizeof(TChild) == 28, "Invalid TBtreeIndexNode TChild size");
+ static_assert(sizeof(TChild) == 36, "Invalid TBtreeIndexNode TChild size");
static_assert(offsetof(TChild, PageId) == offsetof(TShortChild, PageId));
static_assert(offsetof(TChild, RowCount) == offsetof(TShortChild, RowCount));
@@ -245,7 +252,9 @@ namespace NKikimr::NTable::NPage {
: Raw(std::move(raw))
{
const auto data = NPage::TLabelWrapper().Read(Raw, EPage::BTreeIndex);
- Y_ABORT_UNLESS(data == ECodec::Plain && data.Version == 0);
+
+ // Version = 0 didn't have GroupDataSize field
+ Y_ABORT_UNLESS(data == ECodec::Plain && data.Version == 1);
Header = TDeref<const THeader>::At(data.Page.data());
size_t offset = sizeof(THeader);
diff --git a/ydb/core/tablet_flat/flat_page_btree_index_writer.h b/ydb/core/tablet_flat/flat_page_btree_index_writer.h
index 345c0b9eb4a..b718b06afee 100644
--- a/ydb/core/tablet_flat/flat_page_btree_index_writer.h
+++ b/ydb/core/tablet_flat/flat_page_btree_index_writer.h
@@ -97,7 +97,7 @@ namespace NKikimr::NTable::NPage {
Ptr = buf.mutable_begin();
End = buf.end();
- WriteUnaligned<TLabel>(Advance(sizeof(TLabel)), TLabel::Encode(EPage::BTreeIndex, 0, pageSize));
+ WriteUnaligned<TLabel>(Advance(sizeof(TLabel)), TLabel::Encode(EPage::BTreeIndex, 1, pageSize));
auto &header = Place<THeader>();
header.KeysCount = Keys.size();
@@ -249,6 +249,8 @@ namespace NKikimr::NTable::NPage {
void PlaceChild(const TChild& child) noexcept
{
if (IsShortChildFormat()) {
+ Y_DEBUG_ABORT_UNLESS(child.GroupDataSize == 0);
+ Y_DEBUG_ABORT_UNLESS(child.ErasedRowCount == 0);
Place<TShortChild>() = TShortChild{child.PageId, child.RowCount, child.DataSize};
} else {
Place<TChild>() = child;
@@ -375,13 +377,14 @@ namespace NKikimr::NTable::NPage {
}
void AddShortChild(TShortChild child) {
- AddChild(TChild{child.PageId, child.RowCount, child.DataSize, 0});
+ AddChild(TChild{child.PageId, child.RowCount, child.DataSize, 0, 0});
}
void AddChild(TChild child) {
// aggregate in order to perform search by row id from any leaf node
child.RowCount = (ChildRowCount += child.RowCount);
- child.DataSize = (ChildSize += child.DataSize);
+ child.DataSize = (ChildDataSize += child.DataSize);
+ child.GroupDataSize = (ChildGroupDataSize += child.GroupDataSize);
child.ErasedRowCount = (ChildErasedRowCount += child.ErasedRowCount);
Levels[0].PushChild(child);
@@ -423,7 +426,8 @@ namespace NKikimr::NTable::NPage {
Levels = { TLevel() };
ChildRowCount = 0;
ChildErasedRowCount = 0;
- ChildSize = 0;
+ ChildDataSize = 0;
+ ChildGroupDataSize = 0;
}
private:
@@ -474,7 +478,8 @@ namespace NKikimr::NTable::NPage {
Levels.emplace_back();
Y_ABORT_UNLESS(Levels.size() < Max<ui32>(), "Levels size is out of bounds");
}
- Levels[levelIndex + 1].PushChild(TChild{pageId, lastChild.RowCount, lastChild.DataSize, lastChild.ErasedRowCount});
+ lastChild.PageId = pageId;
+ Levels[levelIndex + 1].PushChild(lastChild);
if (!last) {
Levels[levelIndex + 1].PushKey(Levels[levelIndex].PopKey());
}
@@ -509,7 +514,8 @@ namespace NKikimr::NTable::NPage {
TRowId ChildRowCount = 0;
TRowId ChildErasedRowCount = 0;
- ui64 ChildSize = 0;
+ ui64 ChildDataSize = 0;
+ ui64 ChildGroupDataSize = 0;
};
}
diff --git a/ydb/core/tablet_flat/flat_part_loader.cpp b/ydb/core/tablet_flat/flat_part_loader.cpp
index dca805a4a70..85f16bc62a5 100644
--- a/ydb/core/tablet_flat/flat_part_loader.cpp
+++ b/ydb/core/tablet_flat/flat_part_loader.cpp
@@ -84,7 +84,8 @@ void TLoader::StageParseMeta() noexcept
NPage::TBtreeIndexMeta converted{{
meta.GetRootPageId(),
meta.GetRowCount(),
- meta.GetDataSize(),
+ meta.GetDataSize(),
+ meta.GetGroupDataSize(),
meta.GetErasedRowCount()},
meta.GetLevelCount(),
meta.GetIndexSize()};
diff --git a/ydb/core/tablet_flat/flat_part_writer.h b/ydb/core/tablet_flat/flat_part_writer.h
index b5d97fb3303..19abfe90058 100644
--- a/ydb/core/tablet_flat/flat_part_writer.h
+++ b/ydb/core/tablet_flat/flat_part_writer.h
@@ -339,7 +339,7 @@ namespace NTable {
}
if (erased) {
- Current.BTreeIndexErased++;
+ Current.BTreeIndexErasedRowCount++;
}
}
@@ -488,13 +488,14 @@ namespace NTable {
// The first group must write the last key
Y_ABORT_UNLESS(std::exchange(Phase, 1) == 0, "Called twice");
- for (auto& g : Groups) {
- g.Data.Flush(*this);
+ for (size_t i : xrange<size_t>(1, Groups.size())) {
+ Groups[i].Data.Flush(*this);
}
-
for (auto& g : Histories) {
g.Data.Flush(*this);
}
+ // Main index should have correct groups data size
+ Groups[0].Data.Flush(*this);
if (Current.Rows > 0) {
Y_ABORT_UNLESS(Phase == 2, "Missed the last Save call");
@@ -673,6 +674,7 @@ namespace NTable {
m->SetLevelCount(meta.LevelCount);
m->SetIndexSize(meta.IndexSize);
m->SetDataSize(meta.DataSize);
+ m->SetGroupDataSize(meta.GroupDataSize);
m->SetRowCount(meta.RowCount);
m->SetErasedRowCount(meta.ErasedRowCount);
}
@@ -802,10 +804,13 @@ namespace NTable {
g.BTreeIndex.AddKey(Key);
}
if (groupId.IsMain()) {
- g.BTreeIndex.AddChild({page, dataPage->Count, raw.size(), Current.BTreeIndexErased});
- Current.BTreeIndexErased = 0;
+ g.BTreeIndex.AddChild({page, dataPage->Count, raw.size(), Current.BTreeGroupDataSize, Current.BTreeIndexErasedRowCount});
+ Current.BTreeGroupDataSize = 0;
+ Current.BTreeIndexErasedRowCount = 0;
} else {
g.BTreeIndex.AddShortChild({page, dataPage->Count, raw.size()});
+ // Note: group data size is approximate, includes only finished pages
+ Current.BTreeGroupDataSize += raw.size();
}
g.BTreeIndex.Flush(Pager);
}
@@ -848,6 +853,8 @@ namespace NTable {
auto blob = NPage::TLabelWrapper::WrapString(plain, EPage::Opaque, 0);
ui64 ref = Globs.Size(); /* is the current blob index */
+ Current.BTreeGroupDataSize += blob.size();
+
return Register(row, tag, Pager.WriteLarge(std::move(blob), ref));
} else if (plain.size() >= SmallEdge) {
@@ -858,6 +865,7 @@ namespace NTable {
FrameS.Put(row, tag, blob.size());
Current.SmallWritten += blob.size();
+ Current.BTreeGroupDataSize += blob.size();
return { ELargeObj::Outer, Pager.WriteOuter(std::move(blob)) };
@@ -1114,7 +1122,8 @@ namespace NTable {
ui64 Coded = 0;
ui64 HiddenRows = 0;
ui64 HiddenDrops = 0;
- ui64 BTreeIndexErased = 0;
+ ui64 BTreeIndexErasedRowCount = 0;
+ ui64 BTreeGroupDataSize = 0;
// doesn't include written B-Tree index bytes
ui64 MainWritten = 0;
diff --git a/ydb/core/tablet_flat/protos/flat_table_part.proto b/ydb/core/tablet_flat/protos/flat_table_part.proto
index 00efe95b59f..b53415a18bb 100644
--- a/ydb/core/tablet_flat/protos/flat_table_part.proto
+++ b/ydb/core/tablet_flat/protos/flat_table_part.proto
@@ -27,9 +27,10 @@ message TBTreeIndexMeta {
optional uint32 RootPageId = 1;
optional uint32 LevelCount = 2;
optional uint64 IndexSize = 3;
- optional uint64 DataSize = 4;
+ optional uint64 DataSize = 4; // Main pages data size
optional uint64 RowCount = 5; // Total number of data rows
optional uint64 ErasedRowCount = 6; // Total number of erased data rows
+ optional uint64 GroupDataSize = 7; // Group pages data size (includes history and external blobs)
}
message TLayout {
diff --git a/ydb/core/tablet_flat/test/libs/table/test_part.h b/ydb/core/tablet_flat/test/libs/table/test_part.h
index 13eaba6c166..8320adfb96a 100644
--- a/ydb/core/tablet_flat/test/libs/table/test_part.h
+++ b/ydb/core/tablet_flat/test/libs/table/test_part.h
@@ -184,6 +184,23 @@ namespace NTest {
return result;
}
+ inline ui64 CountDataSize(const TPart& part, TGroupId groupId) {
+ size_t result = 0;
+
+ TTestEnv env;
+ auto index = CreateIndexIter(&part, &env, groupId);
+ for (size_t i = 0; ; i++) {
+ auto ready = i == 0 ? index->Seek(0) : index->Next();
+ if (ready != EReady::Data) {
+ Y_ABORT_UNLESS(ready != EReady::Page, "Unexpected page fault");
+ break;
+ }
+ result += part.GetPageSize(index->GetPageId(), groupId);
+ }
+
+ return result;
+ }
+
inline TRowId GetEndRowId(const TPart& part) {
TTestEnv env;
auto index = CreateIndexIter(&part, &env, { });
diff --git a/ydb/core/tablet_flat/test/libs/table/test_writer.h b/ydb/core/tablet_flat/test/libs/table/test_writer.h
index 40a69544a21..70e916d7b65 100644
--- a/ydb/core/tablet_flat/test/libs/table/test_writer.h
+++ b/ydb/core/tablet_flat/test/libs/table/test_writer.h
@@ -133,9 +133,10 @@ namespace NTest {
for (bool history : {false, true}) {
for (const auto &meta : history ? lay.GetBTreeHistoricIndexes() : lay.GetBTreeGroupIndexes()) {
NPage::TBtreeIndexMeta converted{{
- meta.GetRootPageId(),
- meta.GetRowCount(),
- meta.GetDataSize(),
+ meta.GetRootPageId(),
+ meta.GetRowCount(),
+ meta.GetDataSize(),
+ meta.GetGroupDataSize(),
meta.GetErasedRowCount()},
meta.GetLevelCount(),
meta.GetIndexSize()};
diff --git a/ydb/core/tablet_flat/ut/ut_btree_index_nodes.cpp b/ydb/core/tablet_flat/ut/ut_btree_index_nodes.cpp
index b1cd089d43d..08abeb57893 100644
--- a/ydb/core/tablet_flat/ut/ut_btree_index_nodes.cpp
+++ b/ydb/core/tablet_flat/ut/ut_btree_index_nodes.cpp
@@ -1,7 +1,6 @@
#include "flat_page_btree_index.h"
#include "flat_page_btree_index_writer.h"
#include "test/libs/table/test_writer.h"
-#include "ydb/core/tx/datashard/datashard.h"
#include <ydb/core/tablet_flat/test/libs/rows/layout.h>
#include <library/cpp/testing/unittest/registar.h>
@@ -56,7 +55,7 @@ namespace {
}
TChild MakeChild(ui32 index) {
- return {index + 10000, index + 100, index + 1000, index + 30};
+ return {index + 10000, index + 100, index + 1000, index + 2000, index + 30};
}
TShortChild MakeShortChild(ui32 index) {
@@ -74,7 +73,7 @@ namespace {
TChild child;
if (node.IsShortChildFormat()) {
auto shortChild = node.GetShortChild(pos);
- child = {shortChild.PageId, shortChild.RowCount, shortChild.DataSize, 0};
+ child = {shortChild.PageId, shortChild.RowCount, shortChild.DataSize, 0, 0};
} else {
child = node.GetChild(pos);
}
@@ -122,7 +121,7 @@ namespace {
void Dump(TSharedData node, const TPartScheme::TGroupInfo& groupInfo) {
TWriterBundle pager(1, TLogoBlobID());
auto pageId = ((IPageWriter*)&pager)->Write(node, EPage::BTreeIndex, 0);
- TChild page{pageId, 0, 0, 0};
+ TChild page{pageId, 0, 0, 0, 0};
Dump(page, groupInfo, pager.Back());
}
@@ -300,7 +299,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexNode) {
writer.AddKey(deserialized.GetCells());
}
for (auto &c : children) {
- writer.AddChild({c.PageId, c.RowCount, c.DataSize, 0});
+ writer.AddChild({c.PageId, c.RowCount, c.DataSize, 0, 0});
}
auto serialized = writer.Finish();
@@ -344,7 +343,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexNode) {
writer.AddKey(deserialized.GetCells());
}
for (auto &c : children) {
- writer.AddChild({c.PageId, c.RowCount, c.DataSize, 0});
+ writer.AddChild({c.PageId, c.RowCount, c.DataSize, 0, 0});
}
auto serialized = writer.Finish();
@@ -540,7 +539,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexBuilder) {
Dump(result, builder.GroupInfo, pager.Back());
- TBtreeIndexMeta expected{{0, 1155, 11055, 385}, 1, 595};
+ TBtreeIndexMeta expected{{0, 1155, 11055, 22055, 385}, 1, 683};
UNIT_ASSERT_EQUAL_C(result, expected, "Got " + result.ToString());
CheckKeys(result.PageId, keys, builder.GroupInfo, pager.Back());
@@ -575,10 +574,11 @@ Y_UNIT_TEST_SUITE(TBtreeIndexBuilder) {
Dump(result, builder.GroupInfo, pager.Back());
- TBtreeIndexMeta expected{{9, 0, 0, 0}, 3, 1550};
+ TBtreeIndexMeta expected{{9, 0, 0, 0, 0}, 3, 1790};
for (auto c : children) {
expected.RowCount += c.RowCount;
expected.DataSize += c.DataSize;
+ expected.GroupDataSize += c.GroupDataSize;
expected.ErasedRowCount += c.ErasedRowCount;
}
UNIT_ASSERT_EQUAL_C(result, expected, "Got " + result.ToString());
@@ -634,7 +634,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexBuilder) {
TLayoutCook lay = MakeLayout();
TIntrusivePtr<TPartScheme> scheme = new TPartScheme(lay.RowScheme()->Cols);
- TBtreeIndexBuilder builder(scheme, { }, 600, 1, Max<ui32>());
+ TBtreeIndexBuilder builder(scheme, { }, 650, 1, Max<ui32>());
TVector<TString> keys;
for (ui32 i : xrange(100)) {
@@ -659,7 +659,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexBuilder) {
Dump(result, builder.GroupInfo, pager.Back());
- TBtreeIndexMeta expected{{15, 15150, 106050, 8080}, 3, 10270};
+ TBtreeIndexMeta expected{{15, 15150, 106050, 207050, 8080}, 3, 11198};
UNIT_ASSERT_EQUAL_C(result, expected, "Got " + result.ToString());
}
@@ -701,7 +701,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPart) {
auto pages = IndexTools::CountMainPages(*part);
UNIT_ASSERT_VALUES_EQUAL(pages, 1);
- TBtreeIndexMeta expected{{0 /*Data page*/, 5, 5240, 0}, 0, 0};
+ TBtreeIndexMeta expected{{0 /*Data page*/, 5, 5240, 0, 0}, 0, 0};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[0], expected, "Got " + part->IndexPages.BTreeGroups[0].ToString());
}
@@ -731,7 +731,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPart) {
auto pages = IndexTools::CountMainPages(*part);
UNIT_ASSERT_VALUES_EQUAL(pages, 2);
- TBtreeIndexMeta expected{{part->IndexPages.BTreeGroups[0].PageId, 10, 10480, 0}, 1, 1115};
+ TBtreeIndexMeta expected{{part->IndexPages.BTreeGroups[0].PageId, 10, 10480, 0, 0}, 1, 1131};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[0], expected, "Got " + part->IndexPages.BTreeGroups[0].ToString());
}
@@ -764,7 +764,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPart) {
auto pages = IndexTools::CountMainPages(*part);
UNIT_ASSERT_VALUES_EQUAL(pages, 117);
- TBtreeIndexMeta expected{{part->IndexPages.BTreeGroups[0].PageId, 700, 733140, 0}, 3, 86036};
+ TBtreeIndexMeta expected{{part->IndexPages.BTreeGroups[0].PageId, 700, 733140, 0, 0}, 3, 87172};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[0], expected, "Got " + part->IndexPages.BTreeGroups[0].ToString());
}
@@ -798,7 +798,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPart) {
auto pages = IndexTools::CountMainPages(*part);
UNIT_ASSERT_VALUES_EQUAL(pages, 31);
- TBtreeIndexMeta expected{{part->IndexPages.BTreeGroups[0].PageId, 1000, 22098, 143}, 2, 1380};
+ TBtreeIndexMeta expected{{part->IndexPages.BTreeGroups[0].PageId, 1000, 22098, 0, 143}, 2, 1668};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[0], expected, "Got " + part->IndexPages.BTreeGroups[0].ToString());
}
@@ -832,10 +832,10 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPart) {
auto pages = IndexTools::CountMainPages(*part);
UNIT_ASSERT_VALUES_EQUAL(pages, 334);
- TBtreeIndexMeta expected0{{part->IndexPages.BTreeGroups[0].PageId, 1000, 16680, 0}, 3, 15246};
+ TBtreeIndexMeta expected0{{part->IndexPages.BTreeGroups[0].PageId, 1000, 16680, 21890, 0}, 3, 18430};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[0], expected0, "Got " + part->IndexPages.BTreeGroups[0].ToString());
- TBtreeIndexMeta expected1{{part->IndexPages.BTreeGroups[1].PageId, 1000, 21890, 0}, 3, 6497};
+ TBtreeIndexMeta expected1{{part->IndexPages.BTreeGroups[1].PageId, 1000, 21890, 0, 0}, 3, 6497};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[1], expected1, "Got " + part->IndexPages.BTreeGroups[1].ToString());
}
@@ -844,7 +844,8 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPart) {
lay
.Col(0, 0, NScheme::NTypeIds::Uint32)
- .Col(1, 1, NScheme::NTypeIds::String)
+ .Col(0, 1, NScheme::NTypeIds::String)
+ .Col(1, 2, NScheme::NTypeIds::String)
.Key({0});
NPage::TConf conf{ true, 7 * 1024 };
@@ -858,7 +859,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPart) {
for (ui32 i : xrange(1000)) {
for (ui32 j : xrange(i % 5 + 1)) {
- cook.Ver({0, 10 - j}).Add(*TSchemedCookRow(*lay).Col(i, ToString(i * 10 + j)));
+ cook.Ver({0, 10 - j}).Add(*TSchemedCookRow(*lay).Col(i, TString(i * 2 + j, 'x'), TString(i * 3 + j, 'x')));
}
}
@@ -871,16 +872,75 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPart) {
auto pages = IndexTools::CountMainPages(*part);
UNIT_ASSERT_VALUES_EQUAL(pages, 334);
- TBtreeIndexMeta expected0{{part->IndexPages.BTreeGroups[0].PageId, 1000, 32680, 0}, 3, 15246};
+ ui64 dataSize0 = IndexTools::CountDataSize(*part, TGroupId{0, 0});
+ ui64 dataSize1 = IndexTools::CountDataSize(*part, TGroupId{1, 0});
+ ui64 dataSizeHist0 = IndexTools::CountDataSize(*part, TGroupId{0, 1});
+ ui64 dataSizeHist1 = IndexTools::CountDataSize(*part, TGroupId{1, 1});
+
+ TBtreeIndexMeta expected0{{part->IndexPages.BTreeGroups[0].PageId, 1000, dataSize0, dataSize1+dataSizeHist0+dataSizeHist1, 0}, 3, 18430};
+ UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[0], expected0, "Got " + part->IndexPages.BTreeGroups[0].ToString());
+
+ TBtreeIndexMeta expected1{{part->IndexPages.BTreeGroups[1].PageId, 1000, dataSize1, 0, 0}, 3, 8284};
+ UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[1], expected1, "Got " + part->IndexPages.BTreeGroups[1].ToString());
+
+ TBtreeIndexMeta expectedHist0{{part->IndexPages.BTreeHistoric[0].PageId, 2000, dataSizeHist0, 0, 0}, 4, 34225};
+ UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeHistoric[0], expectedHist0, "Got " + part->IndexPages.BTreeHistoric[0].ToString());
+
+ TBtreeIndexMeta expectedHist1{{part->IndexPages.BTreeHistoric[1].PageId, 2000, dataSizeHist1, 0, 0}, 3, 16645};
+ UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeHistoric[1], expectedHist1, "Got " + part->IndexPages.BTreeHistoric[1].ToString());
+ }
+
+ Y_UNIT_TEST(External) {
+ TLayoutCook lay;
+
+ lay
+ .Col(0, 0, NScheme::NTypeIds::Uint32)
+ .Col(0, 1, NScheme::NTypeIds::String)
+ .Col(1, 2, NScheme::NTypeIds::String)
+ .Key({0});
+
+ NPage::TConf conf{ true, 7 * 1024 };
+ conf.WriteBTreeIndex = true;
+ conf.SmallEdge = 133;
+ conf.LargeEdge = 333;
+ conf.Group(0).PageRows = 3;
+ conf.Group(1).PageRows = 4;
+ conf.Group(0).BTreeIndexNodeKeysMin = conf.Group(0).BTreeIndexNodeKeysMax = 5;
+ conf.Group(1).BTreeIndexNodeKeysMin = conf.Group(1).BTreeIndexNodeKeysMax = 6;
+
+ TPartCook cook(lay, conf);
+
+ for (ui32 i : xrange(1000)) {
+ for (ui32 j : xrange(i % 5 + 1)) {
+ cook.Ver({0, 10 - j}).Add(*TSchemedCookRow(*lay).Col(i, TString(i * 2 + j, 'x'), TString(i * 3 + j, 'x')));
+ }
+ }
+
+ TPartEggs eggs = cook.Finish();
+
+ const auto part = eggs.Lone();
+
+ Cerr << DumpPart(*part, 2) << Endl;
+
+ auto pages = IndexTools::CountMainPages(*part);
+ UNIT_ASSERT_VALUES_EQUAL(pages, 334);
+
+ ui64 dataSize0 = IndexTools::CountDataSize(*part, TGroupId{0, 0});
+ ui64 dataSize1 = IndexTools::CountDataSize(*part, TGroupId{1, 0});
+ ui64 dataSizeHist0 = IndexTools::CountDataSize(*part, TGroupId{0, 1});
+ ui64 dataSizeHist1 = IndexTools::CountDataSize(*part, TGroupId{1, 1});
+ ui64 groupDataSize = dataSize1+dataSizeHist0+dataSizeHist1 + 120463 + 7413329;
+
+ TBtreeIndexMeta expected0{{part->IndexPages.BTreeGroups[0].PageId, 1000, dataSize0, groupDataSize, 0}, 3, 18430};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[0], expected0, "Got " + part->IndexPages.BTreeGroups[0].ToString());
- TBtreeIndexMeta expected1{{part->IndexPages.BTreeGroups[1].PageId, 1000, 22889, 0}, 3, 6497};
+ TBtreeIndexMeta expected1{{part->IndexPages.BTreeGroups[1].PageId, 1000, dataSize1, 0, 0}, 3, 6497};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeGroups[1], expected1, "Got " + part->IndexPages.BTreeGroups[1].ToString());
- TBtreeIndexMeta expectedHist0{{part->IndexPages.BTreeHistoric[0].PageId, 2000, 77340, 0}, 4, 34225};
+ TBtreeIndexMeta expectedHist0{{part->IndexPages.BTreeHistoric[0].PageId, 2000, dataSizeHist0, 0, 0}, 4, 34225};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeHistoric[0], expectedHist0, "Got " + part->IndexPages.BTreeHistoric[0].ToString());
- TBtreeIndexMeta expectedHist1{{part->IndexPages.BTreeHistoric[1].PageId, 2000, 45780, 0}, 3, 13014};
+ TBtreeIndexMeta expectedHist1{{part->IndexPages.BTreeHistoric[1].PageId, 2000, dataSizeHist1, 0, 0}, 3, 13014};
UNIT_ASSERT_EQUAL_C(part->IndexPages.BTreeHistoric[1], expectedHist1, "Got " + part->IndexPages.BTreeHistoric[1].ToString());
}
}
diff --git a/ydb/core/tablet_flat/ut/ut_stat.cpp b/ydb/core/tablet_flat/ut/ut_stat.cpp
index a84217f24e3..7410609b426 100644
--- a/ydb/core/tablet_flat/ut/ut_stat.cpp
+++ b/ydb/core/tablet_flat/ut/ut_stat.cpp
@@ -183,65 +183,65 @@ Y_UNIT_TEST_SUITE(BuildStats) {
Y_UNIT_TEST(Single_BTreeIndex)
{
auto subset = TMake(Mass0, PageConf(Mass0.Model->Scheme->Families.size(), true)).Mixed(0, 1, TMixerOne{ });
- Check(*subset, 24000, 2106439, 41220);
+ Check(*subset, 24000, 2106439, 49449);
}
Y_UNIT_TEST(Single_Slices_BTreeIndex)
{
auto subset = TMake(Mass0, PageConf(Mass0.Model->Scheme->Families.size(), true)).Mixed(0, 1, TMixerOne{ }, 0, 13);
subset->Flatten.begin()->Slices->Describe(Cerr); Cerr << Endl;
- Check(*subset, 12816, 1121048, 41220);
+ Check(*subset, 12816, 1121048, 49449);
}
Y_UNIT_TEST(Single_Groups_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true)).Mixed(0, 1, TMixerOne{ });
- Check(*subset, 24000, 2460139, 20485);
+ Check(*subset, 24000, 2460139, 23760);
}
Y_UNIT_TEST(Single_Groups_Slices_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true)).Mixed(0, 1, TMixerOne{ }, 0, 13);
subset->Flatten.begin()->Slices->Describe(Cerr); Cerr << Endl;
- Check(*subset, 10440, 1060798, 20485);
+ Check(*subset, 10440, 1060798, 23760);
}
Y_UNIT_TEST(Single_Groups_History_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true)).Mixed(0, 1, TMixerOne{ }, 0.3);
- Check(*subset, 24000, 4054050, 29710);
+ Check(*subset, 24000, 4054050, 34837);
}
Y_UNIT_TEST(Single_Groups_History_Slices_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true)).Mixed(0, 1, TMixerOne{ }, 0.3, 13);
subset->Flatten.begin()->Slices->Describe(Cerr); Cerr << Endl;
- Check(*subset, 13570, 2277890, 29710);
+ Check(*subset, 13570, 2277890, 34837);
}
Y_UNIT_TEST(Mixed_BTreeIndex)
{
auto subset = TMake(Mass0, PageConf(Mass0.Model->Scheme->Families.size(), true)).Mixed(0, 4, TMixerRnd(4));
- Check(*subset, 24000, 2106459, 40950);
+ Check(*subset, 24000, 2106459, 49449);
}
Y_UNIT_TEST(Mixed_Groups_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true)).Mixed(0, 4, TMixerRnd(4));
- Check(*subset, 24000, 2460219, 20394);
+ Check(*subset, 24000, 2460219, 23555);
}
Y_UNIT_TEST(Mixed_Groups_History_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true)).Mixed(0, 4, TMixerRnd(4), 0.3);
- Check(*subset, 24000, 4054270, 29619);
+ Check(*subset, 24000, 4054270, 34579);
}
Y_UNIT_TEST(Serial_BTreeIndex)
{
TMixerSeq mixer(4, Mass0.Saved.Size());
auto subset = TMake(Mass0, PageConf(Mass0.Model->Scheme->Families.size(), true)).Mixed(0, 4, mixer);
- Check(*subset, 24000, 2106459, 40950);
+ Check(*subset, 24000, 2106459, 49502);
}
Y_UNIT_TEST(Serial_Groups_BTreeIndex)
@@ -261,40 +261,40 @@ Y_UNIT_TEST_SUITE(BuildStats) {
Y_UNIT_TEST(Single_LowResolution_BTreeIndex)
{
auto subset = TMake(Mass0, PageConf(Mass0.Model->Scheme->Families.size(), true, true)).Mixed(0, 1, TMixerOne{ });
- Check(*subset, 24000, 2106439, 56610, 5310, 531050);
+ Check(*subset, 24000, 2106439, 66674, 5310, 531050);
}
Y_UNIT_TEST(Single_Slices_LowResolution_BTreeIndex)
{
auto subset = TMake(Mass0, PageConf(Mass0.Model->Scheme->Families.size(), true, true)).Mixed(0, 1, TMixerOne{ }, 0, 13);
subset->Flatten.begin()->Slices->Describe(Cerr); Cerr << Endl;
- Check(*subset, 12816, 1121048, 56610, 5310, 531050);
+ Check(*subset, 12816, 1121048, 66674, 5310, 531050);
}
Y_UNIT_TEST(Single_Groups_LowResolution_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true, true)).Mixed(0, 1, TMixerOne{ });
- Check(*subset, 24000, 2460139, 29557, 5310, 531050);
+ Check(*subset, 24000, 2460139, 33541, 5310, 531050);
}
Y_UNIT_TEST(Single_Groups_Slices_LowResolution_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true, true)).Mixed(0, 1, TMixerOne{ }, 0, 13);
subset->Flatten.begin()->Slices->Describe(Cerr); Cerr << Endl;
- Check(*subset, 10440, 1060798, 29557, 5310, 531050);
+ Check(*subset, 10440, 1060798, 33541, 5310, 531050);
}
Y_UNIT_TEST(Single_Groups_History_LowResolution_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true, true)).Mixed(0, 1, TMixerOne{ }, 0.3);
- Check(*subset, 24000, 4054050, 42292, 5310, 531050);
+ Check(*subset, 24000, 4054050, 48540, 5310, 531050);
}
Y_UNIT_TEST(Single_Groups_History_Slices_LowResolution_BTreeIndex)
{
auto subset = TMake(Mass1, PageConf(Mass1.Model->Scheme->Families.size(), true, true)).Mixed(0, 1, TMixerOne{ }, 0.3, 13);
subset->Flatten.begin()->Slices->Describe(Cerr); Cerr << Endl;
- Check(*subset, 13570, 2114857 /* ~2277890 */, 42292, 5310, 531050);
+ Check(*subset, 13570, 2114857 /* ~2277890 */, 48540, 5310, 531050);
}
}
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 b9f4a59b457..c811ce0f246 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
@@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TBtreeIndexTPartLarge) {
TPartCook cook(lay, conf);
for (ui32 i = 0; cook.GetDataBytes(0) < 1ull*1024*1024*1024; i++) {
- cook.Add(*TSchemedCookRow(*lay).Col(0u, TString(120, 'x') + std::to_string(i)));
+ cook.Add(*TSchemedCookRow(*lay).Col(0u, TString(110, 'x') + std::to_string(i)));
}
TPartEggs eggs = cook.Finish();